/** * Store changes to this entry * * @param boolean $check Perform data validation check? * @return boolean False if error, True on success */ public function store($check = true) { $new = true; if ($this->get('id')) { $old = new self($this->get('id')); $new = false; } if (!$this->get('anonymous')) { $this->set('anonymous', 0); } if (!parent::store($check)) { return false; } if (!$new) { $fields = array(); // If this is a thread (first post), update the access levels // of all posts in this thread. if (!$this->get('parent') && $old->get('access') != $this->get('access')) { $fields['access'] = $this->get('access'); } // If the category has changed if ($old->get('category_id') != $this->get('category_id')) { $fields['category_id'] = $this->get('category_id'); } if (!empty($fields)) { $this->_tbl->updateReplies($fields, $this->get('id')); } } return true; }
/** * Store changes to this entry * * @param boolean $check Perform data validation check? * @return boolean False if error, True on success */ public function store($check = true) { // Get the entry before changes were made $old = new self($this->get('id')); // Store entry if (!parent::store($check)) { return false; } // If the section is marked as "deleted" and it wasn't already marked as such if ($this->get('state') == self::APP_STATE_DELETED && $old->get('state') != self::APP_STATE_DELETED) { // Collect a list of category IDs $cats = array(); foreach ($this->categories('list', array('state' => -1)) as $category) { $cats[] = $category->get('id'); } if (count($cats) > 0) { // Set all the threads/posts in all the categories to "deleted" $post = new Tables\Post($this->_db); if (!$post->setStateByCategory($cats, self::APP_STATE_DELETED)) { $this->setError($post->getError()); } // Set all the categories to "deleted" $cModel = new Tables\Category($this->_db); if (!$cModel->setStateBySection($this->get('id'), self::APP_STATE_DELETED)) { $this->setError($cModel->getError()); } } } return true; }