Exemple #1
0
 /**
  * 更新版块帖子统计数
  *
  * @param mixed $forum int 版块fid | object PwForumBo
  * @param int $topic 主题更新数
  * @param int $replies 回复更新数
  * @param int $tpost 今日发帖更新数
  * @param int $lastinfo 
  * @return void
  */
 public function updateStatistics($forum, $topic, $replies, $tpost = 0, $lastinfo = array())
 {
     if (!$forum instanceof PwForumBo) {
         $forum = new PwForumBo($forum);
     }
     if (!$forum->isForum()) {
         return false;
     }
     $article = $topic + $replies;
     $dm = new PwForumDm($forum->fid);
     $dm->addThreads($topic)->addPosts($replies)->addArticle($article)->addTodayPosts($tpost);
     if ($lastinfo) {
         !isset($lastinfo['time']) && ($lastinfo['time'] = Pw::getTime());
         $dm->setLastpostInfo($lastinfo['tid'], Pw::substrs($lastinfo['subject'], 26, 0, true), $lastinfo['username'], $lastinfo['time']);
     }
     $service = $this->_getForum();
     $service->updateForum($dm, PwForum::FETCH_STATISTICS);
     if ($fids = $forum->getParentFids()) {
         $dm = new PwForumDm(true);
         $dm->addArticle($article)->addSubThreads($topic)->addTodayPosts($tpost);
         if ($lastinfo && $forum->isOpen()) {
             $dm->setLastpostInfo($lastinfo['tid'], Pw::substrs($lastinfo['subject'], 26, 0, true), $lastinfo['username'], $lastinfo['time']);
         }
         $service->batchUpdateForum($fids, $dm, PwForum::FETCH_STATISTICS);
     }
     return true;
 }