/** * function update * Updates an existing vocabulary in the vocabularies table */ public function update() { // Don't allow duplicate vocabularies if (isset($this->newfields['name']) && Vocabulary::exists($this->newfields['name'])) { return false; } // Let plugins disallow and act before we write to the database $allow = true; $allow = Plugins::filter('vocabulary_update_allow', $allow, $this); if (!$allow) { return; } Plugins::act('vocabulary_update_before', $this); if (isset($this->newfields['features'])) { $this->newfields['features'] = serialize($this->newfields['features']); } if (isset($this->fields['features'])) { $this->fields['features'] = serialize($this->fields['features']); } $result = parent::updateRecord('{vocabularies}', array('id' => $this->id)); $this->fields = array_merge($this->fields, $this->newfields); $this->newfields = array(); if (isset($this->fields['features'])) { $this->fields['features'] = unserialize($this->fields['features']); } // Let plugins act after we write to the database Plugins::act('vocabulary_update_after', $this); return $result; }