Пример #1
0
 public function afterBan(PwUserBanInfoDm $dm)
 {
     //【禁止用户】禁止发言用户组
     $userDm = new PwUserInfoDm($dm->getField('uid'));
     $userDm->setGroupid(6)->setGroups(array());
     //用户禁止,设置用户的组为禁止发言组,删除用户拥有的其他附加组
     $result = $this->_getUserDs()->editUser($userDm, PwUser::FETCH_MAIN);
     if (!$result instanceof PwError) {
         $userinfo = $this->_getUserDs()->getUserByUid($dm->getField('uid'), PwUser::FETCH_MAIN);
         Wekit::load('SRV:forum.srv.PwForumMiscService')->updateDataByUser($userinfo['username']);
     }
     return 6;
 }
Пример #2
0
 /**
  * 禁止用户
  */
 public function dorunAction()
 {
     $this->getRequest()->isPost() || $this->showError('operate.fail');
     $key = $this->getInput('key', 'post');
     if (!in_array($key, array('1', '2'))) {
         $this->showError('USER:ban.error.data.format');
     }
     $array = array();
     list($end_time, $reason, $types) = $this->getInput(array('end_time', 'reason', 'type'), 'post');
     $userInfos = $this->_getUids(explode(',', $this->getInput('value', 'post')), intval($key));
     if (!$userInfos) {
         $this->showError('USER:ban.user.illegal');
     }
     //如果是创始人  则自动设置为system
     $_uid = $this->loginUser->uid;
     $_operator = $this->loginUser->username;
     if ($this->isFounder($_operator)) {
         $_operator = 'system';
         $_uid = 0;
     }
     if ($end_time > 0) {
         $end_time = Pw::str2time($end_time);
     }
     Wind::import('SRV:user.dm.PwUserBanInfoDm');
     $_notice = array();
     $rightTypes = array_keys($this->_getService()->getBanType());
     foreach ($types as $type) {
         if (!in_array($type, $rightTypes)) {
             continue;
         }
         foreach ($userInfos as $uid => $info) {
             $dm = new PwUserBanInfoDm();
             $dm->setUid($uid)->setEndTime(intval($end_time))->setTypeid($type)->setReason($reason)->setOperator($_operator)->setCreatedUid($_uid);
             $array[] = $dm;
             isset($_notice[$uid]) || ($_notice[$uid] = array());
             $_notice[$uid]['end_time'] = $end_time;
             $_notice[$uid]['reason'] = $reason;
             $_notice[$uid]['type'][] = $type;
             $_notice[$uid]['operator'] = $_operator;
         }
     }
     $r = $this->_getService()->banUser($array);
     if ($r instanceof PwError) {
         $this->showError($r->getError(), 'u/forbidden/run');
     }
     $this->_getService()->sendNotice($_notice, 1);
     $this->showMessage('USER:ban.success', 'u/forbidden/run');
 }
Пример #3
0
 public function afterBan(PwUserBanInfoDm $dm)
 {
     /* @var $userDs PwUser */
     $userDs = Wekit::load('SRV:user.PwUser');
     $info = $userDs->getUserByUid($dm->getField('uid'), PwUser::FETCH_MAIN);
     if (Pw::getstatus($info['status'], PwUser::STATUS_BAN_AVATAR)) {
         return $info['status'];
     }
     //已经禁止不需要再次更改
     $userDm = new PwUserInfoDm($dm->getField('uid'));
     $userDm->setBanAvatar(true);
     $userDs->editUser($userDm, PwUser::FETCH_MAIN);
     /* @var $userSrv PwUserService */
     $userSrv = Wekit::load('SRV:user.srv.PwUserService');
     $userSrv->restoreDefualtAvatar($dm->getField('uid'), 'ban');
     $p = 1 << PwUser::STATUS_BAN_AVATAR - 1;
     return intval($info['status'] + $p);
 }
Пример #4
0
 public function banUser($uid)
 {
     $this->user = new PwUserBo($uid);
     if (!$this->user->isExists()) {
         return $this->buildResponse(USER_NOT_EXISTS);
     }
     Wind::import('SRV:user.PwUserBan');
     Wind::import('SRV:user.dm.PwUserBanInfoDm');
     $rightType = array(PwUserBan::BAN_AVATAR, PwUserBan::BAN_SIGN, PwUserBan::BAN_SPEAK);
     $dmArray = array();
     foreach ($rightType as $k => $v) {
         $dm = new PwUserBanInfoDm();
         $dm->setUid($uid)->setTypeid($v)->setReason('App ban');
         $dmArray[] = $dm;
     }
     $result = $this->getUserBanService()->banUser($dmArray);
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
Пример #5
0
 public function afterBan(PwUserBanInfoDm $dm)
 {
     //禁止签名,用户的签名不清空还是保留 2012-10-25
     /* @var $userDs PwUser */
     $userDs = Wekit::load('SRV:user.PwUser');
     $info = $userDs->getUserByUid($dm->getField('uid'), PwUser::FETCH_MAIN);
     if (Pw::getstatus($info['status'], PwUser::STATUS_BAN_SIGN)) {
         return $info['status'];
     }
     //已经禁止不需要再次更改
     //$end_time = $dm->getField('end_time') > 0 ? Pw::time2str($dm->getField('end_time'), 'Y年m月d日 H:i') : '永久';
     //构建显示禁止签名的文本内容
     //	$newSign = sprintf('由于"%s"被%s禁止签名至%s', $dm->getField('reason'), $dm->getOperator(), $end_time);
     $userDm = new PwUserInfoDm($dm->getField('uid'));
     $userDm->setBanSign(true);
     //		->setBbsSign($newSign)
     /* @var $userDs PwUser */
     $userDs = Wekit::load('SRV:user.PwUser');
     $userDs->editUser($userDm, PwUser::FETCH_MAIN | PwUser::FETCH_INFO);
     $s = 1 << PwUser::STATUS_BAN_SIGN - 1;
     return intval($info['status'] + $s);
 }
Пример #6
0
 /** 
  * 添加禁言用户
  *
  * @param PwUserBanInfoDm $dm 用户禁止DM
  * @return boolean
  */
 public function addBanInfo(PwUserBanInfoDm $dm)
 {
     if (true != ($result = $dm->beforeAdd())) {
         return $result;
     }
     return $this->_getDao()->addBanInfo($dm->getData());
 }
Пример #7
0
 /**
  * 自动禁止用户
  * 
  * 用户积分有变动的时候执行
  * 在用户s_PwUserDataDao_update处作为hook执行
  *
  * @param int $uid
  * @param array $fields 
  * @param array $increaseFields 
  * @return array
  */
 public function autoBan($uid, $fields, $increaseFields)
 {
     //[如果自动禁止没有开启]
     $config = Wekit::C('site');
     if (0 == $config['autoForbidden.open'] || !$config['autoForbidden.type']) {
         return false;
     }
     //[自动禁止积分依据]如果更新的积分没有在禁止积分范围内
     $credit = $config['autoForbidden.condition']['credit'];
     $key = 'credit' . $credit;
     if (!in_array($key, array_keys($fields)) && !in_array($key, array_keys($increaseFields))) {
         return false;
     }
     //[禁止积分依据有没有到达禁止条件]
     $userBo = new PwUserBo($uid);
     if ($userBo->getCredit($credit) >= $config['autoForbidden.condition']['num']) {
         return false;
     }
     //执行禁止操作
     $dmList = array();
     $endTime = $config['autoForbidden.day'] > 0 ? $config['autoForbidden.day'] * 24 * 3600 + Pw::getTime() : 0;
     foreach ($config['autoForbidden.type'] as $type) {
         $banDm = new PwUserBanInfoDm();
         $banDm->setEndTime($endTime)->setTypeid($type)->setReason($config['autoForbidden.reason'])->setCreatedUid(0)->setUid($uid);
         $dmList[] = $banDm;
     }
     $this->banUser($dmList);
     //发送消息
     $_notice = array($uid => array('end_time' => $endTime, 'reason' => $config['autoForbidden.reason'], 'type' => $config['autoForbidden.type'], 'operator' => 'system'));
     $this->sendNotice($_notice, 1);
     return true;
 }
Пример #8
0
 /**
  * 构建禁止的对象
  * 
  * @return array
  */
 private function _buildBanDm()
 {
     Wind::import('SRV:user.dm.PwUserBanInfoDm');
     Wind::import('SRV:user.PwUserBan');
     $rightTypes = array(PwUserBan::BAN_AVATAR, PwUserBan::BAN_SIGN, PwUserBan::BAN_SPEAK);
     if ($this->banInfo->end_time > 0) {
         $this->banInfo->end_time = Pw::str2time($this->banInfo->end_time);
     }
     $data = $_notice = array();
     foreach ($this->banInfo->types as $type) {
         if (!in_array($type, $rightTypes)) {
             continue;
         }
         foreach ($this->selectBanUsers as $uid => $_item) {
             $dm = new PwUserBanInfoDm();
             $dm->setUid($uid)->setBanAllAccount($this->banInfo->ban_others)->setCreateTime(Pw::getTime())->setCreatedUid($this->loginUser->uid)->setOperator($this->loginUser->username)->setEndTime(intval($this->banInfo->end_time))->setTypeid($type)->setReason($this->banInfo->reason)->setFid(0);
             $data[] = $dm;
             isset($_notice[$uid]) || ($_notice[$uid] = array());
             $_notice[$uid]['end_time'] = $this->banInfo->end_time;
             $_notice[$uid]['reason'] = $this->banInfo->reason;
             $_notice[$uid]['type'][] = $type;
             $_notice[$uid]['operator'] = $this->loginUser->username;
         }
     }
     return array($data, $_notice);
 }