/** * 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(); } } }
/** * 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(); } }
/** * 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(); } } }