/**
  * 判断指定用户是否有访问指定版块的权限
  *
  * @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);
 }
Example #2
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));
 }
Example #4
0
 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);
 }
Example #5
0
 /**
  * 帖子列表页
  */
 public function run()
 {
     $tab = $this->getInput('tab');
     $fid = intval($this->getInput('fid'));
     $type = intval($this->getInput('type', 'get'));
     //主题分类ID
     $page = $this->getInput('page', 'get');
     $orderby = $this->getInput('orderby', 'get');
     $pwforum = new PwForumBo($fid, true);
     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' => $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('topped', 'digest', 'highlight', 'up', 'copy', 'type', 'move', 'lock', 'down', 'delete', 'ban'));
     }
     $this->_initTopictypes($fid, $type);
     $threadList = new PwThreadList();
     $this->runHook('c_thread_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);
     if ($tab == 'digest') {
         Wind::import('SRV:forum.srv.threadList.PwDigestThread');
         $dataSource = new PwDigestThread($pwforum->fid, $type, $orderby);
     } elseif ($type) {
         Wind::import('SRV:forum.srv.threadList.PwSearchThread');
         $dataSource = new PwSearchThread($pwforum);
         $dataSource->setOrderby($orderby);
         $dataSource->setType($type, $this->_getSubTopictype($type));
     } elseif ($orderby == 'postdate') {
         Wind::import('SRV:forum.srv.threadList.PwNewForumThread');
         $dataSource = new PwNewForumThread($pwforum);
     } else {
         Wind::import('SRV:forum.srv.threadList.PwCommonThread');
         $dataSource = new PwCommonThread($pwforum);
     }
     $orderby != $defaultOrderby && $dataSource->setUrlArg('orderby', $orderby);
     $threadList->execute($dataSource);
     $this->setOutput($threadList, 'threadList');
     $this->setOutput($threadList->getList(), 'threaddb');
     $this->setOutput($fid, 'fid');
     $this->setOutput($type ? $type : null, 'type');
     $this->setOutput($tab, 'tab');
     $this->setOutput($pwforum, 'pwforum');
     $this->setOutput($pwforum->headguide(), 'headguide');
     $this->setOutput($threadList->icon, 'icon');
     $this->setOutput($threadList->uploadIcon, 'uploadIcon');
     $this->setOutput($operateThread, 'operateThread');
     $this->setOutput($pwforum->forumset['numofthreadtitle'] ? $pwforum->forumset['numofthreadtitle'] : 26, 'numofthreadtitle');
     $this->setOutput(!$this->loginUser->uid && !$this->allowPost($pwforum) ? ' J_qlogin_trigger' : '', 'postNeedLogin');
     $this->setOutput($threadList->page, 'page');
     $this->setOutput($threadList->perpage, 'perpage');
     $this->setOutput($threadList->total, 'count');
     $this->setOutput($threadList->maxPage, 'totalpage');
     $this->setOutput($defaultOrderby, 'defaultOrderby');
     $this->setOutput($orderby, 'orderby');
     $this->setOutput($threadList->getUrlArgs(), 'urlargs');
     $this->setOutput($this->_formatTopictype($type), 'topictypes');
     //版块风格
     if ($pwforum->foruminfo['style']) {
         $this->setTheme('forum', $pwforum->foruminfo['style']);
         //$this->addCompileDir($pwforum->foruminfo['style']);
     }
     //seo设置
     Wind::import('SRV:seo.bo.PwSeoBo');
     $lang = Wind::getComponent('i18n');
     if ($threadList->page <= 1) {
         if ($type) {
             PwSeoBo::setDefaultSeo($lang->getMessage('SEO:bbs.thread.run.type.title'), '', $lang->getMessage('SEO:bbs.thread.run.type.description'));
         } else {
             PwSeoBo::setDefaultSeo($lang->getMessage('SEO:bbs.thread.run.title'), '', $lang->getMessage('SEO:bbs.thread.run.description'));
         }
     }
     PwSeoBo::init('bbs', 'thread', $fid);
     PwSeoBo::set(array('{forumname}' => $pwforum->foruminfo['name'], '{forumdescription}' => Pw::substrs($pwforum->foruminfo['descrip'], 100, 0, false), '{classification}' => $this->_getSubTopictypeName($type), '{page}' => $threadList->page));
     Pw::setCookie('visit_referer', 'fid_' . $fid . '_page_' . $threadList->page, 300);
 }
Example #6
0
 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;
 }
Example #7
0
 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));
         }
     }
 }