public function updateOvertime($tid) { $overtimes = $this->_getOvertimeDs()->getOvertimeByTid($tid); $deltop = 0; $dm = new PwTopicDm($tid); if ($overtimes) { $timestamp = Pw::getTime(); $newOvertime = 0; $ids = array(); foreach ($overtimes as $v) { if ($v['overtime'] > $timestamp) { (!$newOvertime || $newOvertime > $v['overtime']) && ($newOvertime = $v['overtime']); } else { switch ($v['m_type']) { case 'topped': $dm->setTopped(0); $deltop = 1; break; case 'highlight': $dm->setHighlight(''); break; } $ids[] = $v['id']; } } $ids && $this->_getOvertimeDs()->batchDelete($ids); $dm->setOvertime($newOvertime); } else { $dm->setOvertime(0); } $this->_getThreadDs()->updateThread($dm); if ($deltop) { Wekit::load('forum.PwSpecialSort')->deleteSpecialSortByTid($tid); } }
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(); }