/** * Method to save the KunenaForumTopic object to the database. * * @param bool $cascade * * @return bool True on success. * */ public function save($cascade = true) { $topicDelta = $this->delta(); $postDelta = $this->posts - $this->_posts; $isNew = !$this->exists(); if (!parent::save()) { return false; } $this->_posts = $this->posts; // Clear authentication cache $this->_authfcache = $this->_authccache = $this->_authcache = array(); if ($cascade) { $category = $this->getCategory(); if (!$category->update($this, $topicDelta, $postDelta)) { $this->setError($category->getError()); } } return true; }
/** * Method to save the KunenaForumMessage object to the database * * @return boolean True on success */ public function save() { $isNew = ! $this->_exists; if (!$this->thread) { // Create topic $topic = $this->getTopic(); if (!$topic->exists() && !$topic->save()) { $this->setError ( $topic->getError () ); return false; } $this->_thread = $this->thread = $topic->id; } // Create message if (! parent::save ()) { return false; } if ($isNew) { $this->_hold = 1; } // Update attachments and message text $update = $this->updateAttachments(); // Did we change anything? if ($update) { $table = $this->getTable (); $table->bind ( $this->getProperties () ); $table->exists(true); if (! $table->store ()) { $this->setError ( $table->getError () ); return false; } } // Cascade changes to other tables $this->update(); return true; }
/** * Method to save the KunenaForumMessage object to the database. * * @return boolean True on success */ public function save() { $isNew = !$this->_exists; $topic = $this->getTopic(); $newTopic = !$topic->exists(); if ($newTopic) { // Create topic, but do not cascade changes to category etc.. if (!$topic->save(false)) { $this->setError($topic->getError()); return false; } $this->_thread = $this->thread = $topic->id; } // Create message if (!parent::save()) { // If we created a new topic, remember to delete it too. if ($newTopic) { $topic->delete(); } return false; } if ($isNew) { $this->_hold = 1; } // Update attachments and message text $update = $this->updateAttachments(); // Did we change anything? if ($update) { if ($isNew && trim($this->message) == '') { // Oops, no attachments remain and the message becomes empty. // Let's delete the new message and fail on save. $this->delete(); // If we created a new topic, remember to delete it too. if ($newTopic) { $topic->delete(); } $this->setError(JText::_('COM_KUNENA_LIB_TABLE_MESSAGES_ERROR_NO_MESSAGE')); return false; } $table = $this->getTable(); $table->bind($this->getProperties()); $table->exists(true); if (!$table->store()) { $this->setError($table->getError()); return false; } } // Cascade changes to other tables $this->update($newTopic); return true; }
/** * Method to save the KunenaForumTopic object to the database * * @access public * @param boolean $updateOnly Save the object only if not a new topic * @return boolean True on success * @since 1.6 */ public function save($cascade = true) { $topicDelta = $this->delta(); $postDelta = $this->posts-$this->_posts; if (!parent::save()) { return false; } $this->_posts = $this->posts; if ($cascade) { $category = $this->getCategory(); if (! $category->update($this, $topicDelta, $postDelta)) { $this->setError ( $category->getError () ); } } return true; }