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; }
/** * 喜欢增加策略 * Enter description here ... * @param PwUserBo $userBo * @param int $typeid * @param int $fromid */ public function addLike(PwUserBo $userBo, $typeid, $fromid = 0) { $uid = $userBo->uid; $likeDs = $this->_getLikeContentDs(); list($beLikeUid, $isspecial, $count, $fid, $extend) = $this->_getSourceInfo($typeid, $fromid); if ($beLikeUid == $uid) { return new PwError('BBS:like.fail.myself.post'); } $time = Pw::getTime(); //判断是否存在喜欢内容 $info = $likeDs->getInfoByTypeidFromid($typeid, $fromid); $likeid = isset($info['likeid']) ? (int) $info['likeid'] : 0; Wind::import('SRV:like.dm.PwLikeDm'); $dm = new PwLikeDm(); $dm->setTypeid($typeid)->setFromid($fromid)->setIsspecial($isspecial); if ($likeid < 1) { $likeid = $likeDs->addInfo($dm); } //判断是否喜欢过 $logInfo = $this->_getLikeLogDs()->getInfoByUidLikeid($uid, $likeid); if ($logInfo) { return new PwError('BBS:like.fail.already.liked'); } //写入喜欢记录 Wind::import('SRV:like.dm.PwLikeLogDm'); $logDm = new PwLikeLogDm(); $logDm->setUid($uid)->setLikeid($likeid)->setCreatedTime($time); $logid = $this->_getLikeLogDs()->addInfo($logDm); if ($logid < 1) { return new PwError('BBS:like.fail'); } //更新喜欢内容 $count++; $this->_updateLikeCount($typeid, $fromid, $count); $likeDs->updateUsers($likeid, $uid); //写入用户喜欢统计 Wind::import('SRV:user.dm.PwUserInfoDm'); $likeNumber = isset($userBo->info['likes']) ? intval($userBo->info['likes']) : 0; $likeNumber++; $infoDm = new PwUserInfoDm($uid); $infoDm->setLikes($likeNumber); $userDs = Wekit::load('user.PwUser'); $userDs->editUser($infoDm, PwUser::FETCH_DATA); //用户积分 Wind::import('SRV:forum.bo.PwForumBo'); $forumBo = new PwForumBo($fid); Wind::import('SRV:credit.bo.PwCreditBo'); $credit = PwCreditBo::getInstance(); $credit->operate('belike', new PwUserBo($beLikeUid), true, array('forumname' => $userBo->username), $forumBo->getCreditSet('belike')); $credit->execute(); //喜欢挂勾 $dm->setBeLikeUid($beLikeUid); //$this->_getHook()->runDo('addLike', $userBo, $dm); PwSimpleHook::getInstance('PwLikeService_addLike')->runDo($userBo, $dm); //喜欢后续操作 如果不需要排行,return true $this->setLikeBrand($likeid, $count, $typeid, $fromid); return array('likeCount' => $likeNumber, 'extend' => $extend); }
/** * 判断指定用户是否有访问指定版块的权限 * * @param int $uid * @param int $fid */ public function readForum($uid, $fid) { Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($fid); $user = new PwUserBo($uid); $result = $forum->allowVisit($user); if ($result instanceof PwError) { return $this->buildResponse(-1, $result->getError()); } return $this->buildResponse($result ? 500 : 0); }
public function run() { $fid = $this->getInput('fid'); $type = intval($this->getInput('type', 'get')); // 主题分类ID $page = intval($this->getInput('page', 'get')); $page < 1 && ($page = 1); $perpage = Wekit::C('bbs', 'thread.perpage'); $pwforum = new PwForumBo($fid, true); if (!$pwforum->isForum(true)) { $this->showError('BBS:forum.exists.not'); } if (($result = $pwforum->allowVisit($this->loginUser)) !== true) { $this->showError($result->getError()); } $totalJoin = Wekit::load('forum.PwForumUser')->countUserByFid($fid); $joinUser = Wekit::load('forum.PwForumUser')->getUserByFid($fid, 15); $activeUser = Wekit::load('forum.srv.PwForumUserService')->getActiveUser($fid, 7, 50); $uids = array_merge(array_keys($joinUser), array_keys($activeUser)); $users = Wekit::load('user.PwUser')->fetchUserByUid($uids); $guide = $pwforum->headguide(); $guide .= $this->buildBread('会员', 'bbs/user/run?fid=' . $fid); $this->setOutput($fid, 'fid'); $this->setOutput($pwforum, 'pwforum'); $this->setOutput($guide, 'headguide'); $this->setOutput($totalJoin, 'totalJoin'); $this->setOutput($joinUser, 'joinUser'); $this->setOutput($activeUser, 'activeUser'); $this->setOutput($users, 'users'); //版块风格 //版块风格 if ($pwforum->foruminfo['style']) { $this->setTheme('forum', $pwforum->foruminfo['style']); //$this->addCompileDir($pwforum->foruminfo['style']); } // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $seoBo->setCustomSeo($lang->getMessage('SEO:bbs.user.run.title', array($pwforum->foruminfo['name'])), '', $lang->getMessage('SEO:bbs.user.run.description', array($pwforum->foruminfo['name']))); Wekit::setV('seo', $seoBo); }
/** * 获取版块列表 * * @return array */ public function getAllForum() { $forumDs = $this->_getPwForum(); $forumResult = $forumDs->getForumList(PwForum::FETCH_MAIN | PwForum::FETCH_STATISTICS); if ($forumResult instanceof PwError) { return $this->buildResponse(-1, $forumResult->getError()); } $forumDomain = $this->_getDomainDs()->getByType('forum'); $key = Pw::collectByKey($forumDomain, 'id'); $forumDomain = array_combine($key, $forumDomain); $cates = $forums = $subForums = $secondSubForums = array(); $count = 0; foreach ($forumResult as $k => $v) { $v['domain'] = ''; if (isset($forumDomain[$k])) { $v['domain'] = $forumDomain[$k]['domain']; } if ($v['type'] == 'category') { $cates[$v['fid']] = array('fid' => $v['fid'], 'forumname' => strip_tags($v['name']), 'type' => $v['type'], 'todaypost' => '', 'domain' => $v['domain']); } elseif ($v['type'] == 'forum') { Wind::import('SRV:forum.bo.PwForumBo'); $pwforum = new PwForumBo($v['fid'], true); if ($pwforum->allowVisit(Wekit::getLoginUser()) !== true) { continue; } $forums[$v['parentid']][$v['fid']] = array('fid' => $v['fid'], 'forumname' => strip_tags($v['name']), 'type' => $v['type'], 'todaypost' => $v['todayposts'], 'domain' => $v['domain']); } elseif ($v['type'] == 'sub') { $subForums[$v['parentid']][$v['fid']] = array('fid' => $v['fid'], 'forumname' => strip_tags($v['name']), 'type' => $v['type'], 'todaypost' => $v['todayposts'], 'domain' => $v['domain']); } elseif ($v['type'] == 'sub2') { $secondSubForums[$v['parentid']][$v['fid']] = array('fid' => $v['fid'], 'forumname' => strip_tags($v['name']), 'type' => $v['type'], 'todaypost' => $v['todayposts'], 'domain' => $v['domain']); } $count++; } $result = array(); foreach ($cates as $k => $v) { $v['child'] = isset($forums[$k]) ? $this->_buildForums($forums[$k], $subForums, $secondSubForums) : array(); $result[] = $v; } return $this->buildResponse(0, array('count' => $count, 'forums' => $result)); }
/** * 退出版块 * @access public * @return string <pre> /index.php?m=native&c=forum&a=quit&_json=1 * post:fid=版块分类id response: html </pre> */ public function quitAction() { // $fid = $this->getInput('fid', 'post'); $fid = $this->getInput('fid'); if (!$fid) { $this->showError('operate.fail'); } Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($fid); if (!$forum->isForum()) { $this->showError('BBS:forum.exists.not'); } if (!$this->uid) { $this->showError('login.not'); } if (!Wekit::load('forum.PwForumUser')->get($this->uid, $fid)) { $this->showError('BBS:forum.join.not'); } Wekit::load('forum.PwForumUser')->quit($this->uid, $fid); $this->_removeJoionForum($this->loginUser->info, $fid); $this->showMessage('success'); }
/** * 发送推送消息 */ public function afterPush($pushid) { $extend = ''; $pushDs = Wekit::load('design.PwDesignPush'); $push = $pushDs->getPush($pushid); if (!$push) { return false; } $thread = Wekit::load('forum.PwThread')->getThread($push['push_from_id']); if (!$thread) { return false; } $info = unserialize($push['push_extend']); $standard = unserialize($push['push_standard']); $sTitle = $info[$standard['sTitle']]; $sUrl = $info[$standard['sUrl']]; $user = Wekit::load('SRV:user.PwUser')->getUserByUid($push['created_userid']); Wind::import('SRV:credit.bo.PwCreditBo'); Wind::import('SRV:forum.bo.PwForumBo'); $credit = PwCreditBo::getInstance(); $operation = 'push_thread'; $forum = new PwForumBo($thread['fid']); $credit->operate($operation, PwUserBo::getInstance($thread['created_userid']), true, array('forumname' => $forum->foruminfo['name']), $forum->getCreditSet($operation)); $credit->execute(); $strategy = $credit->getStrategy($operation); foreach ((array) $strategy['credit'] as $k => $v) { $v && ($extend .= $credit->cType[$k] . '+' . $v); } //$bo->sets($push['author_uid'], $credit['credit']); if ($push['neednotice']) { $content = '恭喜,您的帖子<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>被<a href="' . WindUrlHelper::createUrl('space/index/run', array('uid' => $push['created_userid']), '', 'pw') . '">' . $user['username'] . '</a>执行 推送 操作。'; $extend && ($content .= '获得' . $extend); $title = '帖子《<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>》被推送'; Wekit::load('SRV:message.srv.PwNoticeService')->sendDefaultNotice($push['author_uid'], $content, $title); $pushDs->updateNeedNotice($pushid, 0); } return true; }
public function check($permission) { if (!isset($permission['copy']) || !$permission['copy']) { return false; } if (isset($this->fid)) { Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($this->fid); if (!$forum->isForum()) { return new PwError('BBS:manage.error.copy.targetforum'); } if ($this->topictype && !$forum->forumset['topic_type']) { return new PwError('BBS:post.topictype.closed'); } if ($forum->forumset['topic_type'] && $forum->forumset['force_topic_type'] && !$this->topictype) { $topicTypes = Wekit::load('SRV:forum.PwTopicType')->getTypesByFid($forum->fid); if ($topicTypes) { return new PwError('BBS:post.topictype.empty'); } } } return true; }
private function _checkForumRight(PwForumBo $pwforum) { if (!$pwforum->isForum()) { $this->showError('BBS:forum.exists.not'); } if ($pwforum->allowVisit($this->loginUser) !== true) { $this->showError(array('BBS:forum.permissions.visit.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name')))); } if ($pwforum->forumset['jumpurl']) { $this->forwardRedirect($pwforum->forumset['jumpurl']); } if ($pwforum->foruminfo['password']) { if (!$this->loginUser->isExists()) { $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => $pwforum->fid)))); } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $pwforum->fid)) { $this->forwardAction('bbs/forum/password', array('fid' => $pwforum->fid)); } } }
/** * 积分操作 * * @param array $value 帖子 */ protected function _operateCredit($value) { Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($value['fid']); PwCreditBo::getInstance()->operate('delete_topic', PwUserBo::getInstance($value['created_userid']), true, array('operator' => $this->srv->user->username, 'title' => $value['subject']), $forum->getCreditSet('delete_topic')); }
/** * 验证版块密码 */ public function verifyAction() { $fid = $this->getInput('fid'); $password = $this->getInput('password', 'post'); Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($fid); if (!$forum->isForum(true)) { $this->showError('BBS:forum.exists.not'); } if (md5($password) != $forum->foruminfo['password']) { $this->showError('BBS:forum.password.error'); } Pw::setCookie('fp_' . $fid, Pw::getPwdCode(md5($password)), 86400); $this->showMessage('success'); }
public function checkForumGroup() { $fid = $this->info['fid']; if (!$fid) { return new PwError('BBS:forum.thread.exists.not'); } Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($fid); $user = Wekit::getLoginUser(); $forum->allowVisit($user); if (($result = $forum->allowVisit($user)) !== true) { return new PwError('BBS:forum.permissions.visit.allow', array('{grouptitle}' => $user->getGroupInfo('name'))); } if (($result = $forum->allowRead($user)) !== true) { return new PwError('BBS:forum.permissions.read.allow', array('{grouptitle}' => $user->getGroupInfo('name'))); } return true; }
/** * 删除板块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'); }
/** * 更新积分 */ protected function _operateCredit($operate, PwForumBo $forum) { Wind::import('SRV:credit.bo.PwCreditBo'); $credit = PwCreditBo::getInstance(); $user = Wekit::getLoginUser(); $credit->operate($operate, $user, true, array('forumname' => $forum->foruminfo['name']), $forum->getCreditSet($operate)); $credit->execute(); }
public function run() { $fid = intval($this->getInput('fid')); $pwforum = new PwForumBo($fid, true); if (!$pwforum->isForum(true)) { $this->showError('BBS:forum.exists.not'); } if ($pwforum->allowVisit($this->loginUser) !== true) { $this->showError(array('BBS:forum.permissions.visit.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name')))); } if ($pwforum->forumset['jumpurl']) { $this->forwardRedirect($pwforum->forumset['jumpurl']); } if ($pwforum->foruminfo['password']) { if (!$this->loginUser->isExists()) { $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => $fid)))); } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $fid)) { $this->forwardAction('bbs/forum/password', array('fid' => $fid)); } } $isBM = $pwforum->isBM($this->loginUser->username); if ($operateThread = $this->loginUser->getPermission('operate_thread', $isBM, array())) { $operateThread = Pw::subArray($operateThread, array('delete')); } $pwforum->foruminfo['threads'] = $pwforum->foruminfo['subthreads']; $this->setOutput($operateThread, 'operateThread'); $tab = $this->getInput('tab'); //tab标签 $page = intval($this->getInput('page', 'get')); $orderby = $this->getInput('orderby', 'get'); $threadList = new PwThreadList(); $this->runHook('c_cate_run', $threadList); $threadList->setPage($page)->setPerpage($pwforum->forumset['threadperpage'] ? $pwforum->forumset['threadperpage'] : Wekit::C('bbs', 'thread.perpage'))->setIconNew($pwforum->foruminfo['newtime']); $defaultOrderby = $pwforum->forumset['threadorderby'] ? 'postdate' : 'lastpost'; !$orderby && ($orderby = $defaultOrderby); $isCommon = 0; if ($tab == 'digest') { Wind::import('SRV:forum.srv.threadList.PwCateDigestThread'); $dataSource = new PwCateDigestThread($pwforum->fid, $orderby); } else { Wind::import('SRV:forum.srv.threadList.PwCateThread'); $srv = Wekit::load('forum.srv.PwForumService'); $forbidFids = $srv->getForbidVisitForum($this->loginUser, $srv->getForumsByLevel($fid, $srv->getForumMap()), true); $dataSource = new PwCateThread($pwforum, $forbidFids); $dataSource->setOrderby($orderby); $isCommon = 1; } $orderby != $defaultOrderby && $dataSource->setUrlArg('orderby', $orderby); $threadList->execute($dataSource); if ($isCommon && $threadList->total > 12000) { Wekit::load('forum.PwThreadCateIndex')->deleteOver($fid, $threadList->total - 10000); } $this->setOutput($threadList, 'threadList'); $this->setOutput($threadList->getList(), 'threaddb'); $this->setOutput($tab, 'tab'); $this->setOutput($defaultOrderby, 'defaultOrderby'); $this->setOutput($orderby, 'orderby'); $this->setOutput($pwforum->fid, 'fid'); $this->setOutput($pwforum, 'pwforum'); $this->setOutput($pwforum->headguide(), 'headguide'); $this->setOutput($threadList->icon, 'icon'); $this->setOutput($threadList->uploadIcon, 'uploadIcon'); $this->setOutput($pwforum->forumset['numofthreadtitle'] ? $pwforum->forumset['numofthreadtitle'] : 26, 'numofthreadtitle'); $this->setOutput($threadList->page, 'page'); $this->setOutput($threadList->perpage, 'perpage'); $this->setOutput($threadList->total, 'count'); $this->setOutput($threadList->maxPage, 'totalpage'); $this->setOutput($threadList->getUrlArgs(), 'urlargs'); //版块风格 if ($pwforum->foruminfo['style']) { $this->setTheme('forum', $pwforum->foruminfo['style']); //$this->addCompileDir($pwforum->foruminfo['style']); } //seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); if ($threadList->page <= 1) { $seoBo->setDefaultSeo($lang->getMessage('SEO:bbs.thread.run.title'), '', $lang->getMessage('SEO:bbs.thread.run.description')); } $seoBo->init('bbs', 'thread', $fid); $seoBo->set(array('{forumname}' => $pwforum->foruminfo['name'], '{forumdescription}' => Pw::substrs($pwforum->foruminfo['descrip'], 100, 0, false), '{classification}' => '', '{page}' => $threadList->page)); Wekit::setV('seo', $seoBo); }
private function allowPost(PwForumBo $forum) { return $forum->foruminfo['allow_post'] ? $forum->allowPost($this->loginUser) : $this->loginUser->getPermission('allow_post'); }
/** * 用户相关操作 */ private function _operateUser() { $operation = $this->digest == 1 ? 'digest_topic' : 'remove_digest'; $digestNum = $this->digest == 1 ? 1 : -1; Wind::import('SRV:credit.bo.PwCreditBo'); Wind::import('SRV:forum.bo.PwForumBo'); /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $credit = PwCreditBo::getInstance(); foreach ($this->threads as $thread) { //更新用户精华数 $userInfo = new PwUserInfoDm($thread['created_userid']); $userInfo->addDigest($digestNum); $userDs->editUser($userInfo, PwUser::FETCH_DATA); //更新用户积分 $forum = new PwForumBo($thread['fid']); $credit->operate($operation, PwUserBo::getInstance($thread['created_userid']), true, array('forumname' => $forum->foruminfo['name']), $forum->getCreditSet($operation)); $credit->execute(); } return true; }
/** * 更新版块帖子统计数 * * @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; }