/** * Implemented for {@see XenForo_DataWriter_DiscussionContainerInterface}. */ public function updateCountersAfterDiscussionDelete(XenForo_DataWriter_Discussion $discussionDw) { if ($discussionDw->get('discussion_type') == 'redirect') { // note: this assumes the discussion type will never change to/from this except at creation return; } if ($discussionDw->get('discussion_state') == 'visible') { $this->set('discussion_count', $this->get('discussion_count') - 1); $this->set('message_count', $this->get('message_count') - $discussionDw->get('reply_count') - 1); if ($discussionDw->get('last_post_id') == $this->get('last_post_id')) { $this->updateLastPost(); } } }
/** * Saves the discussion data writer if it exists and has changed. */ protected function _saveDiscussionDataWriter() { if ($this->_discussionDw && $this->_discussionDw->hasChanges()) { $this->_discussionDw->save(); } }
/** * Implemented for {@see XenForo_DataWriter_DiscussionContainerInterface}. */ public function updateCountersAfterDiscussionDelete(XenForo_DataWriter_Discussion $discussionDw) { if ($discussionDw->get('discussion_type') == 'redirect') { // note: this assumes the discussion type will never change to/from // this except at creation return; } if ($discussionDw->get('discussion_state') == 'visible') { $this->set('discussion_count', $this->get('discussion_count') - 1); $this->set('message_count', $this->get('message_count') - $discussionDw->get('reply_count') - 1); if ($discussionDw->get('last_post_id') == $this->get('last_post_id')) { $this->updateLastPost(); } } $categoryDw = $this->_getSocialCategoryDataWriter($this->get('node_id'), $this->_errorHandler); $categoryDw->updateCountersAfterDiscussionDelete($discussionDw); if ($categoryDw->hasChanges()) { $categoryDw->save(); } }
/** * @see XenForo_DataWriter::setExtraData */ public function setExtraData($name, $value) { if ($name == self::DATA_FORUM && is_array($value) && !empty($value['node_id'])) { self::setForumCacheItem($value); } return parent::setExtraData($name, $value); }
/** * Implemented for {@see XenForo_DataWriter_DiscussionContainerInterface}. */ public function updateCountersAfterDiscussionDelete(XenForo_DataWriter_Discussion $discussionDw) { if ($discussionDw->get('discussion_type') == 'redirect') { // note: this assumes the discussion type will never change to/from this except at creation return; } // need to check both of these -- there's a case where we approve a moderated thread // and move it simultaneously and this code gets triggered if ($discussionDw->get('discussion_state') == 'visible' && $discussionDw->getExisting('discussion_state') == 'visible') { $this->set('discussion_count', $this->get('discussion_count') - 1); $this->set('message_count', $this->get('message_count') - $discussionDw->get('reply_count') - 1); if ($discussionDw->get('last_post_id') == $this->get('last_post_id')) { $this->updateLastPost(); } } }