示例#1
0
 /**
  * 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();
         }
     }
 }
示例#2
0
 /**
  * Saves the discussion data writer if it exists and has changed.
  */
 protected function _saveDiscussionDataWriter()
 {
     if ($this->_discussionDw && $this->_discussionDw->hasChanges()) {
         $this->_discussionDw->save();
     }
 }
示例#3
0
 /**
  * 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();
     }
 }
示例#4
0
 /**
  * @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);
 }
示例#5
0
 /**
  * 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();
         }
     }
 }