Пример #1
0
 public function run()
 {
     $_tids = array();
     $_dms = array();
     $specialSort = $this->_getSpecialSort($this->topped);
     foreach ($this->tids as $fid => $tids) {
         $topicDm = new PwTopicDm(true);
         $topicDm->setTopped($this->topped);
         $topicDm->setSpecialsort($specialSort);
         if ($this->topped == 1) {
             $fids = array($fid);
         } elseif ($this->topped == 2) {
             $fids = $this->_getCateList($fid);
         } elseif ($this->topped == 3) {
             $fids = $this->fids ? $this->fids : array_keys(Wekit::load('forum.srv.PwForumService')->getForumList());
         } else {
             $fids = array();
         }
         foreach ($fids as $_fid) {
             foreach ($tids as $tid) {
                 $dm = new PwThreadSortDm();
                 $dm->setFid($_fid)->setTid($tid)->setType('topped')->setExtra($this->topped)->setEndtime($this->overtime)->setCreatedTime(Pw::getTime());
                 $_dms[] = $dm;
             }
         }
         $_tids = array_merge($_tids, $tids);
     }
     Wekit::load('forum.PwThread')->batchUpdateThread($_tids, $topicDm, PwThread::FETCH_MAIN);
     if ($this->overtime) {
         if ($this->overids) {
             $topicDm = new PwTopicDm(true);
             $topicDm->setOvertime($this->overtime);
             Wekit::load('forum.PwThread')->batchUpdateThread($this->overids, $topicDm, PwThread::FETCH_MAIN);
         }
         $this->_getOvertimeDs()->batchAdd($_tids, 'topped', $this->overtime);
     } else {
         $this->_getOvertimeDs()->batchDeleteByTidAndType($_tids, 'topped');
     }
     $sortDs = Wekit::load('forum.PwSpecialSort');
     $sortDs->batchDeleteSpecialSortByTid($_tids);
     $sortDs->batchAdd($_dms);
     $this->_addManageLog();
 }