Beispiel #1
0
 /**
  * Handle moving from a non-counting to a counting forum, or vice versa
  *
  * @param integer $sourceForumId
  * @param integer $destinationForumId
  */
 protected function _handleForumMove($sourceForumId, $destinationForumId)
 {
     // fetch the source and destination forum info
     if (!self::isForumCacheItem($sourceForumId) || !self::isForumCacheItem($destinationForumId)) {
         $forums = $this->getModelFromCache('XenForo_Model_Forum')->getForumsByIds(array($sourceForumId, $destinationForumId));
         foreach ($forums as $forum) {
             self::setForumCacheItem($forum);
         }
     }
     $sourceForum = self::getForumCacheItem($sourceForumId);
     $destinationForum = self::getForumCacheItem($destinationForumId);
     // do the 'count_messages' settings differ?
     if ($sourceForum && $destinationForum && $sourceForum['count_messages'] != $destinationForum['count_messages']) {
         $oldState = $this->getExisting('discussion_state');
         $newState = $this->get('discussion_state');
         if ($newState == 'visible' && ($oldState != 'visible' || $destinationForum['count_messages'])) {
             // moving to a counting forum from a non-counting forum
             parent::_updateUserMessageCount(false, 'add');
         } else {
             if ($oldState == 'visible' && ($newState != 'visible' || !$destinationForum['count_messages'])) {
                 // moving from a counting forum from a non-counting forum
                 parent::_updateUserMessageCount(false, 'subtract');
             }
         }
     }
 }