Esempio n. 1
0
 /** 
  * 批量激活用户
  *
  */
 public function doactiveAction()
 {
     $uids = $this->getInput('uid', 'post');
     if (!$uids) {
         $this->showError('operate.select');
     }
     /* @var $userDs PwUser */
     $userDs = Wekit::load('user.PwUser');
     $infos = $userDs->fetchUserByUid($uids, PwUser::FETCH_MAIN);
     /* @var $groupService PwUserGroupsService */
     $groupService = Wekit::load('usergroup.srv.PwUserGroupsService');
     $strategy = Wekit::C('site', 'upgradestrategy');
     $clearUid = array();
     foreach ($infos as $_temp) {
         $clearUid[] = $_temp['uid'];
         if (Pw::getstatus($_temp['status'], PwUser::STATUS_UNACTIVE)) {
             $userDm = new PwUserInfoDm($_temp['uid']);
             $userDm->setUnactive(false);
             if (!Pw::getstatus($_temp['status'], PwUser::STATUS_UNCHECK)) {
                 $userDm->setGroupid(0);
                 $_credit = $userDs->getUserByUid($_temp['uid'], PwUser::FETCH_DATA);
                 $credit = $groupService->calculateCredit($strategy, $_credit);
                 $memberid = $groupService->calculateLevel($credit, 'member');
                 $userDm->setMemberid($memberid);
             }
             $userDs->editUser($userDm, PwUser::FETCH_MAIN);
         }
     }
     $this->_getDs()->batchActiveUser($clearUid);
     $this->showMessage('operate.success');
 }
Esempio n. 2
0
 /**
  * 过滤用户DM同时设置用户的相关信息
  * 
  * @param PwUserInfoDm $userDm
  * @param array $hasCredit
  * @return PwUserInfoDm
  */
 protected function filterUserDm(PwUserInfoDm $userDm, $hasCredit = array())
 {
     //如果开启邮箱激活,则设置该状态为0,否则设置该状态为1
     $_uncheckGid = false;
     if ($this->config['active.mail']) {
         $userDm->setUnactive(true);
         $_uncheckGid = true;
     }
     //如果开启审核,则设置该状态为0,否则设置该状态为1
     if ($this->config['active.check']) {
         $userDm->setUncheck(true);
         $_uncheckGid = true;
     }
     //【用户注册】未验证用户组
     if ($_uncheckGid) {
         $userDm->setGroupid(7);
         $userDm->setGroups(array());
     }
     $_credit = $this->_getRegisterAddCredit($hasCredit);
     //【用户注册】计算memberid
     /* @var $groupService PwUserGroupsService */
     $groupService = Wekit::load('usergroup.srv.PwUserGroupsService');
     $credit = $groupService->calculateCredit(Wekit::C('site', 'upgradestrategy'), $_credit);
     $memberid = $groupService->calculateLevel($credit);
     $userDm->setMemberid($memberid);
     return $userDm;
 }
Esempio n. 3
0
 /** 
  * 激活email
  *
  * @param int $uid 用户ID
  * @param string $email 用户Email
  * @param string $code 激活码
  * @return boolean
  */
 public function activeEmail($uid, $email, $code)
 {
     /* @var $activeCodeDs PwUserActiveCode */
     $activeCodeDs = Wekit::load('user.PwUserActiveCode');
     $info = $activeCodeDs->getInfoByUid($uid);
     if (!$info || $info['email'] != $email || $info['code'] != $code) {
         return new PwError("USER:illegal.request");
     }
     if ($info['active_time'] > 0) {
         return new PwError('USER:active.email.dumplicate');
     }
     $validTime = $this->activeCodeValidTime * 3600;
     if ($info['send_time'] + $validTime < Pw::getTime()) {
         return new PwError('USER:active.email.overtime');
     }
     $activeCodeDs->activeCode($uid, Pw::getTime());
     $info = $this->_getUserDs()->getUserByUid($uid, PwUser::FETCH_MAIN);
     if (Pw::getstatus($info['status'], PwUser::STATUS_UNACTIVE)) {
         $userDm = new PwUserInfoDm($info['uid']);
         $userDm->setUnactive(false);
         !Pw::getstatus($info['status'], PwUser::STATUS_UNCHECK) && $userDm->setGroupid(0);
         $this->_getUserDs()->editUser($userDm, PwUser::FETCH_MAIN);
     }
     /* @var $registerCheckDs PwUserRegisterCheck */
     $registerCheckDs = Wekit::load('user.PwUserRegisterCheck');
     $registerCheckDs->activeUser($uid);
     return true;
 }