protected function run() { $forum = new PwForumBo($this->fid, true); if (!$forum->isForum(true)) { return new PwError('BBS:forum.unite.error.fid.exists.not'); } if ($forum->foruminfo['type'] == 'category') { return new PwError('BBS:forum.unite.error.fid.category'); } if ($forum->getSubForums()) { return new PwError('BBS:forum.unite.error.hassub'); } $toforum = new PwForumBo($this->tofid); if (!$toforum->isForum(true)) { return new PwError('BBS:forum.unite.error.tofid.exists.not'); } if ($toforum->foruminfo['type'] == 'category') { return new PwError('BBS:forum.unite.error.tofid.category'); } if ($this->fid == $this->tofid) { return new PwError('BBS:forum.unite.error.same'); } Wekit::load('forum.PwForum')->deleteForum($this->fid); Wind::import('SRV:forum.dm.PwForumDm'); $dm = new PwForumDm($this->tofid); $dm->addThreads($forum->foruminfo['threads'])->addPosts($forum->foruminfo['posts']); Wekit::load('forum.PwForum')->updateForum($dm, PwForum::FETCH_STATISTICS); Wekit::load('forum.srv.PwForumService')->updateForumStatistics($forum->foruminfo['parentid']); Wekit::load('forum.srv.PwForumService')->updateForumStatistics($this->tofid); return true; }
public function run($cronId) { $srv = Wekit::load('forum.PwForum'); $all = $srv->getForumList(PwForum::FETCH_MAIN | PwForum::FETCH_STATISTICS); $ypost = 0; foreach ($all as $value) { if ($value['type'] == 'category') { $ypost += $value['todayposts']; } } $bbsinfo = Wekit::load('site.PwBbsinfo')->getInfo(1); $dm = new PwBbsinfoDm(); $dm->setYposts($ypost); if ($ypost > $bbsinfo['hposts']) { $dm->setHposts($ypost); } Wekit::load('site.PwBbsinfo')->updateInfo($dm); $dm = new PwForumDm(true); $dm->setTodayPosts(0); $srv->batchUpdateForum(array_keys($all), $dm, PwForum::FETCH_STATISTICS); }
/** * 复制帖子 | 复制特殊帖、附件等待做。。。 * * @param int $topictype * @return int */ public function run() { foreach ($this->threads as $v) { $topicDm = new PwTopicDm($v['tid']); $topicDm->setLastpost($v['lastpost_userid'], $v['lastpost_username'], $v['lastpost_time'])->setSpecial($v['special'])->setDigest($v['digest'])->setTopped($v['topped'])->setSpecialsort($v['special_sort'])->setTopictype($this->topictype)->setTpcstatus($v['tpcstatus'])->setHighlight($v['highlight'])->setOvertime($v['overtime'])->addHits($v['hits'])->setTitle($v['subject'])->setContent($v['content'])->setFid($this->fid)->setAuthor($v['created_userid'], $v['created_username'], $v['created_ip'])->setModifyInfo($v['modified_userid'], $v['modified_username'], $v['modified_ip'], $v['modified_time'])->setCreatedTime($v['created_time'])->setDisabled($v['disabled'])->setAids($v['aids'])->setIfupload($v['ifupload'])->setReplyNotice($v['reply_notice'])->setLikeCount($v['like_count'])->setSellCount($v['sell_count'])->addReplies($v['replies'])->addSellCount($v['sell_count'])->setReminds($v['reminds'])->setWordVersion($v['word_version'])->setTags($v['tags']); $tid = $this->_getThreadDs()->addThread($topicDm); if ($tid) { PwSimpleHook::getInstance('PwThreadManageDoCopy')->runDo($topicDm, $tid); $forumDm = new PwForumDm($this->fid); $forumDm->addThreads(1); $forumDm->addArticle(1); Wekit::load('SRV:forum.PwForum')->updateForum($forumDm); } } //管理日志添加 Wekit::load('log.srv.PwLogService')->addThreadManageLog($this->srv->user, 'copy', $this->threads, $this->_reason, $this->fid . '|' . $this->topictype); }
/** * 删除板块icon */ public function deleteiconAction() { $fid = $this->getInput('fid'); Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($fid, true); if (!$forum->isForum(true)) { $this->showMessage('版块不存在', 'bbs/setforum/run', true); } Wind::import('SRV:forum.dm.PwForumDm'); $dm = new PwForumDm($fid); $dm->setIcon(''); $pwforum = Wekit::load('forum.PwForum'); $pwforum->updateForum($dm); Pw::deleteAttach($forum->foruminfo['icon']); $this->showMessage('success'); }
/** * 执行添加公共账号 * lyl */ public function doAddAction() { //判断公共账号所属的主分类是否存在 $configs = Wekit::C()->getValues('native'); $life_fid = isset($configs['forum.life_fid']) && $configs['forum.life_fid'] ? $configs['forum.life_fid'] : 0; Wind::import('SRV:forum.dm.PwForumDm'); $pwForum = Wekit::load('forum.PwForum'); $forumset = array('allowtype' => array('default'), 'typeorder' => array('default' => 0)); if (!$life_fid) { //尚未创建公共账号所属分类,自动创建 $dm = new PwForumDm(); $dm->setParentid(0)->setName('生活服务')->setVieworder(0)->setManager('')->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } else { // var_dump($result); $life_fid = $result; $config = new PwConfigSet('native'); $config->set('forum.life_fid', $life_fid)->flush(); // var_dump($life_fid); } } if ($_FILES['logo']['size'] > 300000) { $this->showError("图片大小不能超过300k", 'native/life/run/', true); } // exit; //添加公共服务版面 $dm_life = new PwForumDm(); list($forumname, $manager, $vieworder, $descrip, $isshow, $url, $address) = $this->getInput(array('forumname', 'manager', 'vieworder', 'descrip', 'isshow', 'url', 'address'), 'post'); if (!$forumname) { $this->showError("商家名称不能为空", 'native/life/run/', true); } if (Pw::strlen($address) > 100) { $this->showError("商家地址不能超过100个汉字", 'native/life/run/', true); } $dm_life->setParentid($life_fid)->setName($forumname)->setVieworder($vieworder)->setManager($manager)->setDescrip($descrip)->setIsshow($isshow)->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm_life)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } $fid = $result; //上传版块logo $dm_life = new PwForumDm($fid); $logo = $this->_uploadImage('logo', $fid); $dm_life->setlogo($logo['path']); if (($result = $pwForum->updateForum($dm_life)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } // Wekit::load('forum.srv.PwForumMiscService')->correctData(); $forumLifeDao = Wekit::loadDao('native.dao.PwForumLifeDao'); if (($result = $forumLifeDao->addForumLife(array('fid' => $fid, 'url' => $url, 'address' => $address))) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } $this->showMessage('success', 'native/life/run', true); }
public function doeditforumAction() { $forumid = $this->getInput('fid', 'post'); $forumid = $forumid ? explode(',', $forumid) : array(); $forum = (array) $this->_getFroumService()->getForumList(); $openForum = $noOpenForum = array(); foreach ($forum as $value) { if ($value['type'] == 'category') { continue; } if (in_array($value['fid'], $forumid)) { $openForum[] = $value['fid']; } else { $noOpenForum[] = $value['fid']; } } Wind::import('SRV:forum.dm.PwForumDm'); if ($openForum) { foreach ($openForum as $value) { $_forum = $this->_getForumDs()->getForum($value, 4); if (!$_forum) { continue; } $setting = unserialize($_forum['settings_basic']); $allowType = is_array($setting['allowtype']) ? $setting['allowtype'] : array(); if (in_array('poll', $allowType)) { continue; } $allowType[] = 'poll'; !isset($setting['typeorder']['poll']) && ($setting['typeorder']['poll'] = 0); $setting['allowtype'] = $allowType; $dm = new PwForumDm($value); $dm->setBasicSetting($setting); $this->_getForumDs()->updateForum($dm, 4); } } if ($noOpenForum) { foreach ($noOpenForum as $value) { $_forum = $this->_getForumDs()->getForum($value, 4); if (!$_forum) { continue; } $setting = unserialize($_forum['settings_basic']); $allowType = is_array($setting['allowtype']) ? $setting['allowtype'] : array(); if (!in_array('poll', $allowType)) { continue; } $allowType = array_diff($allowType, array('poll')); unset($setting['typeorder']['poll']); $setting['allowtype'] = $allowType; $dm = new PwForumDm($value); $dm->setBasicSetting($setting); $this->_getForumDs()->updateForum($dm, 4); } } $this->showMessage('ADMIN:success'); }
/** * 重新统计所有版块的帖子数 */ public function countAllForumStatistics() { $forums = $this->_getForum()->getForumOrderByType(false); $fids = array_keys($forums); Wind::import('SRV:forum.dm.PwForumDm'); $dm = new PwForumDm(true); $dm->setThreads(0)->setPosts(0)->setArticle(0)->setSubThreads(0); $this->_getForum()->batchUpdateForum($fids, $dm, PwForum::FETCH_STATISTICS); $threads = Wekit::load('forum.PwThreadExpand')->countThreadsByFid(); $posts = Wekit::load('forum.PwThreadExpand')->countPostsByFid(); foreach ($fids as $key => $value) { if (!isset($threads[$value]) && !isset($posts[$value])) { continue; } $dm = new PwForumDm($value); $dm->setThreads($threads[$value]['sum'])->setPosts($posts[$value]['sum']); $this->_getForum()->updateForum($dm, PwForum::FETCH_STATISTICS); } foreach ($fids as $key => $value) { $this->_getForum()->updateForumStatistics($value); } }
/** * 批量更新版块信息 * * @param array $fids 版块id序列 * @param object $dm 更新信息 * @param int $fetchmode 版块资料 <必然为FETCH_*的一种或者组合> * return bool */ public function batchUpdateForum($fids, PwForumDm $dm, $fetchmode = self::FETCH_ALL) { if (empty($fids)) { return false; } if (($result = $dm->beforeUpdate()) !== true) { return $result; } return $this->_getDao($fetchmode)->batchUpdateForum($fids, $dm->getData(), $dm->getIncreaseData()); }
/** * 更新版块帖子统计数 * * @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; }