Esempio n. 1
0
 public function save($object)
 {
     if ($object->name == '') {
         throw new ApplicationTableException('Invalid name');
     }
     return parent::save($object);
 }
Esempio n. 2
0
 public function save($object)
 {
     // auto update all comments of a joomla user, if name/email changed
     if ($object->user_id && ($row = $this->first(array('conditions' => array('user_id = ?', $object->user_id)))) && ($row->author != $object->author || $row->email != $object->email)) {
         // get database
         $db = $this->getDBO();
         $query = "UPDATE " . $this->getTableName() . " SET author = " . $db->quote($object->author) . ", email = " . $db->quote($object->email) . " WHERE user_id = " . $object->user_id;
         $db->query($query);
     }
     return parent::save($object);
 }
Esempio n. 3
0
 public function save($object)
 {
     if ($object->name == '') {
         throw new SubmissionTableException('Invalid name');
     }
     if ($object->alias == '' || preg_match('/[^\\x{00C0}-\\x{00D6}x{00D8}-\\x{00F6}x{00F8}-\\x{00FF}x{0370}-\\x{1FFF}a-z0-9\\-]/u', $object->alias)) {
         throw new SubmissionTableException('Invalid slug');
     }
     if (SubmissionHelper::checkAliasExists($object->alias, $object->id)) {
         throw new SubmissionTableException('Slug already exists, please choose a unique slug');
     }
     return parent::save($object);
 }
Esempio n. 4
0
 public function save($object)
 {
     if ($object->name == '') {
         throw new CategoryTableException('Invalid name');
     }
     if ($object->alias == '' || $object->alias != YString::sluggify($object->alias)) {
         throw new CategoryTableException('Invalid slug');
     }
     if (CategoryHelper::checkAliasExists($object->alias, $object->id)) {
         throw new CategoryTableException('Slug already exists, please choose a unique slug');
     }
     if (!is_numeric($object->parent)) {
         throw new CategoryTableException('Invalid parent id');
     }
     return parent::save($object);
 }
Esempio n. 5
0
 public function save($object)
 {
     if (!is_string($object->type) || empty($object->type)) {
         throw new ItemTableException('Invalid type id');
     }
     if ($object->name == '') {
         throw new ItemTableException('Invalid name');
     }
     if ($object->alias == '' || $object->alias != YString::sluggify($object->alias)) {
         throw new ItemTableException('Invalid slug');
     }
     if (ItemHelper::checkAliasExists($object->alias, $object->id)) {
         throw new ItemTableException('Alias already exists, please choose a unique alias');
     }
     // first save to get id
     if (empty($object->id)) {
         parent::save($object);
     }
     // init vars
     $db = $this->getDBO();
     $search_data = array();
     $element_data = array();
     foreach ($object->getElements() as $id => $element) {
         // get element data
         $element_data[] = $element->toXML();
         // get search data
         if ($data = $element->getSearchData()) {
             $search_data[] = "(" . $object->id . ", " . $db->quote($id) . ", " . $db->quote($data) . ")";
         }
     }
     // set element data
     $object->elements = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<elements>\n" . implode("\n", $element_data) . "\n</elements>";
     // delete old search data
     $query = "DELETE FROM " . ZOO_TABLE_SEARCH . " WHERE item_id = " . (int) $object->id;
     $db->query($query);
     // insert new search data
     if (count($search_data)) {
         $query = "INSERT INTO " . ZOO_TABLE_SEARCH . " VALUES " . implode(", ", $search_data);
         $db->query($query);
     }
     // save tags
     YTable::getInstance('tag')->save($object->id, $object->getTags());
     return parent::save($object);
 }