/**
  * 判断用户的管理组权限
  * @param int $uid
  */
 public function getPermissionsForUserGroup($uid)
 {
     Wind::import('SRV:user.bo.PwUserBo');
     $userBo = new PwUserBo($uid);
     $designPermission = $userBo->getPermission('design_allow_manage.push');
     return $designPermission ? $designPermission : -1;
 }
 public function beforeLogout(PwUserBo $bo)
 {
     if (!$bo->isExists()) {
         return true;
     }
     $srv = Wekit::load('online.srv.PwOnlineService');
     $srv->logoutOnline($bo->uid);
     return true;
 }
Example #3
0
 public function __construct($tid, $pids, PwUserBo $user, $isLazy = false)
 {
     $this->user = $user;
     $this->attachs = $this->_getData($tid, $pids);
     $this->isAdmin = $user->getPermission('operate_thread.deleteatt');
     $this->imgWidth = Wekit::C('bbs', 'ubb.img.width');
     $this->imgHeight = Wekit::C('bbs', 'ubb.img.height');
     $this->imgLazy = $isLazy;
     $this->_init();
 }
Example #4
0
 /**
  * 获取用户所有禁止访问的版块列表
  *
  * @param PwUserBo $user
  * @return array
  */
 protected function getForbidVisitForum(PwUserBo $user, $forums)
 {
     $fids = array();
     foreach ($forums as $key => $value) {
         if ($value['allow_visit'] && !$user->inGroup(explode(',', $value['allow_visit'])) || $value['allow_read'] && !$user->inGroup(explode(',', $value['allow_read']))) {
             $fids[] = $value['fid'];
         }
     }
     return $fids;
 }
Example #5
0
 /**
  * 获取用户所有禁止访问的版块列表
  *
  * @param PwUserBo $user
  * @return array
  */
 public function getForbidVisitForum(PwUserBo $user, $forums = null)
 {
     $forums === null && ($forums = $this->getForumList());
     $fids = array();
     foreach ($forums as $key => $value) {
         if ($value['allow_visit'] && !$user->inGroup(explode(',', $value['allow_visit']))) {
             $fids[] = $value['fid'];
         }
     }
     return $fids;
 }
 /**
  * 
  * 获取用户对应的对话框列表
  * 
  * @param int $uid
  * @param int $start
  * @param int $limit
  * @return array 
  */
 public function getMessageByUid($uid, $offset, $limit)
 {
     $user = new PwUserBo($uid);
     if (!$user->isExists()) {
         return $this->buildResponse(MESSAGE_UID_ERROR);
     }
     $result = $this->getPwMessageService()->getDialogs($uid, $offset, $limit);
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
Example #7
0
 public function synLogin($uid)
 {
     Wind::import('SRC:service.user.bo.PwUserBo');
     Wind::import('SRC:service.user.srv.PwLoginService');
     $userBo = new PwUserBo($uid);
     if ($userBo->isExists() && !Pw::getstatus($userBo->info['status'], PwUser::STATUS_UNACTIVE)) {
         $srv = new PwLoginService();
         $ip = Wind::getApp()->getRequest()->getClientIp();
         $srv->setLoginCookie($userBo, $ip, 1);
     }
     exit;
     //return true;
 }
Example #8
0
 protected function _getUser()
 {
     $authkey = 'winduser';
     $pre = Wekit::C('site', 'cookie.pre');
     $pre && ($authkey = $pre . '_' . $authkey);
     $winduser = $this->getInput($authkey, 'post');
     list($uid, $password) = explode("\t", Pw::decrypt(urldecode($winduser)));
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         return null;
     }
     unset($user->info['password']);
     return $user;
 }
 /**
  * Enter description here ...
  *
  * @param unknown_type $uid
  * @return Ambigous <multitype:unknown , multitype:unknown NULL >
  */
 public function isUserBanned($uid)
 {
     $user = new PwUserBo($uid);
     if (!$user->isExists()) {
         return $this->buildResponse(PERMISSIONS_USER_NOT_EXISTS);
     }
     // $result = $this->getUserBanService ()->getBanInfoByUid ( $uid, 1 );
     Wind::import('SRV:user.srv.PwBanBp');
     $banBp = new PwBanBp($uid);
     $result = $banBp->checkIfBanSpeak();
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse($result ? 500 : 0);
 }
Example #10
0
 protected function _setPreHook($m, $mc, $mca)
 {
     $prehook = Wekit::V('prehook');
     PwHook::preset($prehook['ALL']);
     PwHook::preset($prehook[$this->loginUser->isExists() ? 'LOGIN' : 'UNLOGIN']);
     if (isset($prehook[$m])) {
         PwHook::preset($prehook[$m]);
     }
     if (isset($prehook[$mc])) {
         PwHook::preset($prehook[$mc]);
     }
     if (isset($prehook[$mca])) {
         PwHook::preset($prehook[$mca]);
     }
 }
Example #11
0
 /**
  * 获得用户拥有的权限 //这个权限在读贴子详细内容时获取,此接口暂时不用
  * 
  * @access public
  * @return void
  * @example
  * <pre>
  * post: tid
  * </pre>
  */
 private function permissionAction()
 {
     $tid = $this->getInput('tid');
     $userBo = new PwUserBo($this->uid);
     Wind::import('SRV:forum.srv.PwThreadDisplay');
     $threadDisplay = new PwThreadDisplay($tid, $userBo);
     $this->runHook('c_read_run', $threadDisplay);
     if (($result = $threadDisplay->check()) !== true) {
         $this->showError($result->getError());
     }
     $_cache = Wekit::cache()->fetch(array('level', 'group_right'));
     $pwforum = $threadDisplay->getForum();
     $isBM = $pwforum->isBM($userBo->username);
     if ($threadPermission = $userBo->getPermission('operate_thread', $isBM, array())) {
         $operateThread = Pw::subArray($threadPermission, array('delete', 'ban'));
         $operateReply = Pw::subArray($threadPermission, array('delete', 'ban'));
     }
     /**
      * if ($hasFirstPart || $hasSecondPart || $hasThirdPart) //只要是版主都可以推荐
      * $operateThread['delete']
      * $operateReply['ban']
      */
     //        print_r($operateThread);
     //        print_r($operateReply);
 }
Example #12
0
 /**
  * 判断是否有权限
  * 删除全站或是本版帖子
  * 
  * @return int
  */
 public function getRight()
 {
     if ($this->right) {
         return $this->right;
     }
     $this->right = array('delCurrentThread' => 0, 'delForumThread' => 0, 'delSiteThread' => 0);
     $permission = $this->loginUser->getPermission('operate_thread', false, array());
     //如果是论坛斑竹,并且是操作的是自己的版块的帖子,则有删除选择,否则没有删除本版权限
     if (isset($permission['delete']) && 1 == $permission['delete']) {
         $this->right['delCurrentThread'] = 1;
         $this->right['delSiteThread'] = 1;
     } elseif (5 == $this->loginUser->gid && $this->srv->isBM($this->srv->getFids())) {
         $permission = $this->loginUser->getPermission('operate_thread', true, array());
         if (isset($permission['delete']) && $permission['delete'] == 1) {
             $this->right['delCurrentThread'] = 1;
             $this->right['delForumThread'] = 1;
         }
     }
     //如果所选用户不是全都是帖子发帖者,则删除当前帖子不可选
     if (1 == $this->right['delCurrentThread']) {
         $threadUids = array();
         foreach ($this->srv->getData() as $_item) {
             $threadUids[] = $_item['created_userid'];
         }
         if (array_diff(array_keys($this->getBanUsers()), $threadUids)) {
             $this->right['delCurrentThread'] = 0;
         }
     }
     return $this->right;
 }
 public function beforeLogout(PwUserBo $bo)
 {
     if (!$bo->isExists()) {
         return true;
     }
     $onlineTime = intval(Wekit::C('site', 'onlinetime'));
     if ($onlineTime <= 0) {
         return true;
     }
     $newLastVisit = $bo->info['lastvisit'] - $onlineTime * 60;
     Wind::import('SRV:user.dm.PwUserInfoDm');
     $dm = new PwUserInfoDm($bo->uid);
     $dm->setLastvisit($newLastVisit);
     /* @var $userDs PwUser */
     $userDs = Wekit::load('user.PwUser');
     $userDs->editUser($dm, PwUser::FETCH_DATA);
     return true;
 }
Example #14
0
 /**
  * 发送回复
  * @param int $tid
  * @param int $uid
  * @param string $title
  * @param string $content
  * return bool
  */
 public function sendPost($tid, $uid, $title, $content)
 {
     $userBo = new PwUserBo($uid);
     if (!$userBo->isExists()) {
         return $this->buildResponse(THREAD_USER_NOT_EXIST);
     }
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwReplyPost');
     $postAction = new PwReplyPost($tid);
     $pwPost = new PwPost($postAction);
     $info = $pwPost->getInfo();
     $title == 'Re:' . $info['subject'] && ($title = '');
     $postDm = $pwPost->getDm();
     $postDm->setTitle($title)->setContent($content)->setAuthor($uid, $userBo->username, $userBo->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
Example #15
0
 /** 
  * 获得登录用户信息
  *
  * @return PwUserBo
  */
 public function getLoginUser()
 {
     if ($this->_loginUser === null) {
         $user = $this->_getLoginUser();
         $user->ip = $this->clientIp;
         $this->_loginUser = $user->uid;
         PwUserBo::pushUser($user);
     }
     return PwUserBo::getInstance($this->_loginUser);
 }
 /**
  * 检查用户登录及应用马甲绑定的状况
  *
  * @return PwError|boolean
  */
 private function _check($ifCheck = true)
 {
     if (!Wekit::C('app_majia', 'isopen')) {
         return new PwError('马甲切换应用没有开启');
     }
     if (!$this->loginBo->isExists()) {
         return new PwError('用户没有登录');
     }
     if ($ifCheck && !in_array($this->loginBo->gid, Wekit::C('app_majia', 'band.allow.groups'))) {
         return new PwError('您所在的用户组不能使用马甲绑定功能');
     }
     return true;
 }
Example #17
0
 public function run()
 {
     $rmbrate = $this->_conf[$this->_order['buy']]['rate'];
     !$rmbrate && ($rmbrate = 10);
     $num = round($this->_order['price'] * $rmbrate);
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $creditBo PwCreditBo */
     $creditBo = PwCreditBo::getInstance();
     $creditBo->addLog('olpay_credit', array($this->_order['buy'] => $num), PwUserBo::getInstance($this->_order['created_userid']), array('number' => $this->_order['price']));
     $creditBo->set($this->_order['created_userid'], $this->_order['buy'], $num);
     //发送通知
     $params = array();
     $params['change_type'] = 'pay';
     $params['credit'] = $creditBo->cType[$this->_order['buy']];
     $params['num'] = $num;
     $params['unit'] = $creditBo->cUnit[$this->_order['buy']];
     $params['price'] = $this->_order['price'];
     /* @var $notice PwNoticeService */
     $notice = Wekit::load('SRV:message.srv.PwNoticeService');
     $notice->sendNotice($this->_order['created_userid'], 'credit', $this->_order['created_userid'], $params);
 }
 /**
  * 发送推送消息
  */
 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;
 }
 /**
  * 发表帖子
  * @param int $tid
  * @param int $fid
  * @param string $subject
  * @param string $content
  * return bool
  */
 public function postThread($uid, $fid, $subject, $content)
 {
     list($uid, $fid, $subject, $content) = array(intval($uid), intval($fid), trim($subject), trim($content));
     if ($uid < 1 || $fid < 1 || !$subject || !$content) {
         return $this->buildResponse(THREAD_INVALID_PARAMS, "参数错误");
     }
     $user = PwUserBo::getInstance($uid);
     if (!$user->isExists()) {
         return $this->buildResponse(USER_NOT_EXISTS, "用户不存在");
     }
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwTopicPost');
     $postAction = new PwTopicPost($fid);
     $pwPost = new PwPost($postAction);
     $postDm = $pwPost->getDm();
     $postDm->setFid($fid)->setTitle($subject)->setContent($content)->setAuthor($uid, $user->username, $user->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     $tid = $pwPost->getNewId();
     return $this->buildResponse(0, array('tid' => $tid));
 }
Example #20
0
 public function doDeletePostAction()
 {
     $pid = $this->getInput('pid');
     if (empty($pid)) {
         $this->showError('operate.select');
     }
     !is_array($pid) && ($pid = array($pid));
     Wind::import('SRV:forum.srv.operation.PwDeleteReply');
     Wind::import('SRV:forum.srv.dataSource.PwFetchReplyByPid');
     $deleteReply = new PwDeleteReply(new PwFetchReplyByPid($pid), PwUserBo::getInstance($this->loginUser->uid));
     $deleteReply->setIsDeductCredit(1)->execute();
     $this->showMessage('success');
 }
 private function _getUserBo()
 {
     Wind::import('SRV:user.bo.PwUserBo');
     return PwUserBo::getInstance($this->loginUser->uid);
 }
Example #22
0
 public function allowRead($forum, PwUserBo $user)
 {
     if (!$forum['allow_read']) {
         return true;
     }
     return $user->inGroup(explode(',', $forum['allow_read']));
 }
 /**
  * 获取对话消息列表
  *
  * @param int $dialogId
  * @param int $start
  * @param int $limit
  * @return array
  */
 public function getMessageAndReply($dialogId, $offset, $limit)
 {
     list($dialogId, $offset, $limit) = array(intval($dialogId), intval($offset), intval($limit));
     if ($dialogId < 1) {
         return $this->buildResponse(MESSAGE_INVALID_PARAMS);
     }
     list($count, $dialogResult) = $this->getPwMessageService()->getDialogMessageList($dialogId, $limit, $offset);
     if ($dialogResult instanceof PwError) {
         return $this->buildResponse(-1, $dialogResult->getError());
     }
     $result = array();
     $dialogResult = array_values($dialogResult);
     foreach ($dialogResult as $k => $v) {
         $result[$k]['messageid'] = $v['message_id'];
         $result[$k]['uid'] = $v['from_uid'];
         $result[$k]['username'] = PwUserBo::getInstance($v['uid'])->username;
         $result[$k]['icon'] = Pw::getAvatar($v['from_uid']);
         $result[$k]['postdate'] = $v['created_time'];
         $result[$k]['content'] = $v['content'];
         $result[$k]['id'] = $v['id'];
         //dialog和message的关系id
         $result[$k]['dialog_id'] = $dialogId;
         $result[$k]['is_read'] = $v['is_read'];
         $result[$k]['from_username'] = $v['from_username'];
     }
     return $this->buildResponse(0, array('count' => $count, 'dialog' => $result));
 }
 /**
  * 获取用户(A)在帖子(B)中的回复
  *
  * @param int $tid
  * @param int $uid
  * @param int $limit
  * @param int $offset
  * @return array
  */
 public function getPostByTidAndUid($tid, $uid, $offset, $limit)
 {
     list($uid, $tid, $offset, $limit) = array(intval($uid), intval($tid), intval($offset), intval($limit));
     $user = PwUserBo::getInstance($uid);
     if (!$user->username) {
         return $this->buildResponse(THREAD_USER_NOT_EXIST, "用户不存在");
     }
     $postResult = $this->_getThread()->getPostByTidAndUid($tid, $uid, $limit, $offset);
     if ($postResult instanceof PwError) {
         return $this->buildResponse(-1, $postResult->getError());
     }
     $postResult = array_values($postResult);
     $count = $this->_getThread()->countPostByTidAndUid($tid, $uid);
     $result = array();
     foreach ($postResult as $k => $v) {
         $result[$k]['pid'] = $v['pid'];
         $result[$k]['tid'] = $v['tid'];
         $result[$k]['author'] = $uid;
         $result[$k]['authorid'] = $user->username;
         $result[$k]['subject'] = $v['subject'];
         $result[$k]['postdate'] = $v['created_time'];
         $result[$k]['icon'] = Pw::getAvatar($uid);
         $result[$k]['content'] = $v['content'];
         $result[$k]['attachlist'] = '';
         $result[$k]['fid'] = $v['fid'];
     }
     return $this->buildResponse(0, array('count' => $count, 'posts' => $result));
 }
Example #25
0
 /**
  * 获取帖子类型
  *
  * @param PwUserBo $user
  * @return array
  */
 public function getThreadType(PwUserBo $user)
 {
     if (!is_array($this->forumset['typeorder'])) {
         return array();
     }
     asort($this->forumset['typeorder']);
     $array = array();
     $tType = Wekit::load('forum.srv.PwThreadType')->getTtype();
     foreach ($this->forumset['typeorder'] as $key => $value) {
         if (isset($tType[$key]) && in_array($key, $this->forumset['allowtype']) && ($tType[$key][2] === true || $user->getPermission($tType[$key][2]))) {
             $array[$key] = $tType[$key];
         }
     }
     return $array;
 }
Example #26
0
 /**
  * 检测今日发消息数量
  *
  * @param PwUserBo $user
  * @param int $countUser
  * @return PwError | bool
  */
 private function _checkTodayNum(PwUserBo $user, $touids)
 {
     !is_array($touids) && ($touids = array($touids));
     $behavior = $this->_getUserBehaviorDs()->getBehavior($user->uid, 'message_today');
     $dayMax = $user->getPermission('message_max_send');
     $countUser = count($touids);
     if ($behavior['number'] + $countUser > $dayMax) {
         $touids = array_slice($touids, 0, $dayMax - $behavior['number']);
     }
     return array($touids, $behavior['number'], $dayMax);
 }
Example #27
0
 /**
  * 获得大概年前登录用户对象
  *
  * @return PwUserBo
  */
 protected function _getLoginUser()
 {
     if (!($userCookie = Pw::getCookie('winduser'))) {
         $uid = $password = '';
     } else {
         list($uid, $password) = explode("\t", Pw::decrypt($userCookie));
     }
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         $user->reset();
     } else {
         unset($user->info['password']);
     }
     return $user;
 }
Example #28
0
 /**
  * 结果分析路由
  */
 public function routeAction()
 {
     $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName());
     $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession();
     $sessionData = $sessionInfo['sessiondata'];
     $refer = $sessionData['httpReferer'] ? $sessionData['httpReferer'] : $this->hostInfo;
     if (!$this->_getAccountTypeService()->checkType($sessionData['type'])) {
         $this->showError('登录类型错误,请重试');
     }
     if (!$sessionId || !$sessionInfo || !$sessionData['data']['user_id'] || !$sessionData['action']) {
         $this->showError('验证失败,请重试');
     }
     $url = $refer ? $refer : $this->hostInfo . Wind::getComponent('request')->getScriptUrl();
     $type_name = $this->_getAccountTypeService()->getTypeName($sessionData['type']);
     $msg_info = '使用' . $type_name . '账号认证通过(窗口将自动关闭)';
     if ($sessionData['action'] == 'bind') {
         //绑定流程
         $result = $this->_getAccountBindService()->bind($this->uid, $sessionData['data']['user_id'], $sessionData['type']);
         if ($result instanceof PwError) {
             $this->showError($result->getError());
         }
     } elseif ($sessionData['data']['isBound'] == 0 && $sessionData['action'] == 'login') {
         $sign = $sessionData['data']['sign'];
         //没有绑定社区账号 注册或者绑定
         $config = Wekit::C()->getValues('register');
         if ($config['type'] == 0) {
             //关闭注册,跳转到绑定设置页面
             $url = WindUrlHelper::createUrl('app/login/run', array('app' => 'account', 'sign' => $sign));
         } else {
             $url = WindUrlHelper::createUrl('app/register/run', array('app' => 'account', 'sign' => $sign));
         }
     } elseif ($sessionData['data']['isBound'] == 1 && $sessionData['action'] == 'login') {
         //进入登录 用户校验
         $uid = intval($sessionData['data']['bbs_uid']);
         Wind::import('SRV:user.bo.PwUserBo');
         $userBo = PwUserBo::getInstance($uid);
         if (!$userBo->isExists()) {
             //用户不存在
             $this->_getAccountBindDs()->deleteByUid($uid);
             $this->showError('绑定用户在站点已删除,请重试');
         }
         $pattern = '/m=u&c=login/i';
         if (preg_match($pattern, $url)) {
             $url = $this->_getCommonService()->getHost();
         }
         $userService = Wekit::load('user.srv.PwUserService');
         $userService->createIdentity($userBo->uid, $userBo->info['password']);
     }
     $this->setOutput($msg_info, 'msg_info');
     $this->setOutput($url, 'jumpurl');
     $this->setOutput(Wekit::app()->charset, 'charset');
     $this->setTemplate('login_notice');
 }
 public function doeditAction()
 {
     $designId = (int) $this->getInput('design_id', 'post');
     $designType = (int) $this->getInput('design_type', 'post');
     $new_permissions = $this->getInput('new_permissions', 'post');
     $new_username = $this->getInput('new_username', 'post');
     $ids = $this->getInput('ids', 'post');
     $permissions = $this->getInput('permissions', 'post');
     $fail = 0;
     $ds = $this->_getPermissionsDs();
     //添加新用户  前端已修改为单用户提交
     if ($new_username) {
         Wind::import('SRV:design.srv.vo.PwDesignPermissionsSo');
         Wind::import('SRV:user.bo.PwUserBo');
         $service = $this->_getPermissionsService();
         foreach ($new_username as $k => $name) {
             if (!$name) {
                 continue;
             }
             $user = Wekit::load('user.PwUser')->getUserByName($name);
             $new_uid = isset($user['uid']) ? $user['uid'] : 0;
             if ($new_uid < 1) {
                 $this->showError("DESIGN:user.name.error");
             }
             $vo = new PwDesignPermissionsSo();
             $vo->setDesignId($designId)->setDesignType($designType)->setUid($new_uid);
             $list = $ds->searchPermissions($vo);
             if ($list) {
                 $this->showError("DESIGN:user.already.permissions");
             }
             if ($service->getPermissionsForUserGroup($new_uid) < 0) {
                 $this->showError("DESIGN:user.group.error");
             }
             $userBo = new PwUserBo($new_uid);
             $designPermission = $userBo->getPermission('design_allow_manage.push');
             if ($designPermission < 1) {
                 $this->showError("DESIGN:user.group.error");
             }
             $resource = $ds->addInfo($designType, $designId, $new_uid, $new_permissions[$k]);
             if (!$resource) {
                 $fail++;
             }
         }
     }
     foreach ($ids as $k => $id) {
         $resource = $ds->updatePermissions($id, $permissions[$k]);
         if (!$resource) {
             $fail++;
         }
     }
     $this->showMessage("operate.success");
 }
 public function buyAction()
 {
     list($tid, $pid) = $this->getInput(array('tid', 'pid'));
     $submit = (int) $this->getInput('submit', 'get');
     if (!$this->loginUser->isExists()) {
         $this->showError('login.not');
     }
     if (!$tid) {
         $this->showError('data.error');
     }
     if ($pid) {
         $result = Wekit::load('forum.PwThread')->getPost($pid);
     } else {
         $pid = 0;
         $result = Wekit::load('forum.PwThread')->getThread($tid, PwThread::FETCH_ALL);
     }
     if (empty($result) || $result['tid'] != $tid) {
         $this->showError('data.error');
     }
     $start = strpos($result['content'], '[sell=');
     if ($start === false) {
         $this->showError('BBS:thread.buy.error.sell.not');
     }
     $start += 6;
     $end = strpos($result['content'], ']', $start);
     $cost = substr($result['content'], $start, $end - $start);
     list($creditvalue, $credittype) = explode(',', $cost);
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditBo = PwCreditBo::getInstance();
     isset($creditBo->cType[$credittype]) || ($credittype = key($creditBo->cType));
     $creditType = $creditBo->cType[$credittype];
     if ($result['created_userid'] == $this->loginUser->uid) {
         $this->showError('BBS:thread.buy.error.self');
     }
     if (Wekit::load('forum.PwThreadBuy')->get($tid, $pid, $this->loginUser->uid)) {
         $this->showError('BBS:thread.buy.error.already');
     }
     if (($myCredit = $this->loginUser->getCredit($credittype)) < $creditvalue) {
         $this->showError(array('BBS:thread.buy.error.credit.notenough', array('{myCredit}' => $myCredit . $creditType, '{count}' => $creditvalue . $creditType)));
     }
     !$submit && $this->showMessage(array('BBS:thread.buy.message.buy', array('{count}' => $myCredit . $creditType, '{buyCount}' => -$creditvalue . $creditType)));
     Wind::import('SRV:forum.dm.PwThreadBuyDm');
     $dm = new PwThreadBuyDm();
     $dm->setTid($tid)->setPid($pid)->setCreatedUserid($this->loginUser->uid)->setCreatedTime(Pw::getTime())->setCtype($credittype)->setCost($creditvalue);
     Wekit::load('forum.PwThreadBuy')->add($dm);
     $creditBo->addLog('buythread', array($credittype => -$creditvalue), $this->loginUser, array('title' => $result['subject'] ? $result['subject'] : Pw::substrs($result['content'], 20)));
     $creditBo->set($this->loginUser->uid, $credittype, -$creditvalue, true);
     $user = new PwUserBo($result['created_userid']);
     if (($max = $user->getPermission('sell_credit_range.maxincome')) && Wekit::load('forum.PwThreadBuy')->sumCost($tid, $pid) > $max) {
     } else {
         $creditBo->addLog('sellthread', array($credittype => $creditvalue), $user, array('title' => $result['subject'] ? $result['subject'] : Pw::substrs($result['content'], 20)));
         $creditBo->set($user->uid, $credittype, $creditvalue, true);
     }
     $creditBo->execute();
     if ($pid) {
         Wind::import('SRV:forum.dm.PwReplyDm');
         $dm = new PwReplyDm($pid);
         $dm->addSellCount(1);
         Wekit::load('forum.PwThread')->updatePost($dm);
     } else {
         Wind::import('SRV:forum.dm.PwTopicDm');
         $dm = new PwTopicDm($tid);
         $dm->addSellCount(1);
         Wekit::load('forum.PwThread')->updateThread($dm, PwThread::FETCH_CONTENT);
     }
     $this->showMessage('success', 'bbs/read/run/?tid=' . $tid . '&fid=' . $result['fid'], true);
 }