/**
  * 获取注册的信息
  *
  * @return PwUserInfoDm
  */
 private function _getUserDm()
 {
     list($username, $password, $repassword, $email, $aliww, $qq, $msn, $mobile, $mobileCode, $hometown, $location, $question, $answer, $regreason, $code) = $this->getInput(array('username', 'password', 'repassword', 'email', 'aliww', 'qq', 'msn', 'mobile', 'mobileCode', 'hometown', 'location', 'question', 'answer', 'regreason', 'code'), 'post');
     //	验证输入
     Wind::import('Wind:utility.WindValidator');
     $config = $this->_getRegistConfig();
     if (!$username) {
         $this->showError('USER:user.error.-1', 'u/register/run');
     }
     if (!$password) {
         $this->showError('USER:pwd.require', 'u/register/run');
     }
     if (!$email) {
         $this->showError('USER:user.error.-6', 'u/register/run');
     }
     if (!WindValidator::isEmail($email)) {
         $this->showError('USER:user.error.-7', 'u/register/run');
     }
     foreach ($config['active.field'] as $field) {
         if (!$this->getInput($field, 'post')) {
             $this->showError('USER:register.error.require.needField.' . $field, 'u/register/run');
         }
     }
     if ($config['active.check'] && !$regreason) {
         $this->showError('USER:register.error.require.regreason', 'u/register/run');
     }
     if ($config['active.phone']) {
         !PwUserValidator::isMobileValid($mobile) && $this->showError('USER:error.mobile', 'u/register/run');
         if (($mobileCheck = Wekit::load('mobile.srv.PwMobileService')->checkVerify($mobile, $mobileCode)) instanceof PwError) {
             $this->showError($mobileCheck->getError());
         }
     }
     if ($repassword != $password) {
         $this->showError('USER:user.error.-20', 'u/register/run');
     }
     if (in_array('register', (array) Wekit::C('verify', 'showverify'))) {
         $veryfy = Wekit::load("verify.srv.PwCheckVerifyService");
         if (false === $veryfy->checkVerify($code)) {
             $this->showError('USER:verifycode.error', 'u/register/run');
         }
     }
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm();
     $userDm->setUsername($username);
     $userDm->setPassword($password);
     $userDm->setEmail($email);
     $userDm->setRegdate(Pw::getTime());
     $userDm->setLastvisit(Pw::getTime());
     $userDm->setRegip(Wind::getComponent('request')->getClientIp());
     $userDm->setAliww($aliww);
     $userDm->setQq($qq);
     $userDm->setMsn($msn);
     $userDm->setMobile($mobile);
     $userDm->setMobileCode($mobileCode);
     $userDm->setQuestion($question, $answer);
     $userDm->setRegreason($regreason);
     $areaids = array($hometown, $location);
     if ($areaids) {
         $srv = WindidApi::api('area');
         $areas = $srv->fetchAreaInfo($areaids);
         $userDm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : '');
         $userDm->setLocation($location, isset($areas[$location]) ? $areas[$location] : '');
     }
     return $userDm;
 }
Esempio n. 2
0
 /**
 * 注册帐号
 * @access public
 * @return void
 * @example
 <pre>
 /index.php?m=native&c=user&a=doRegister&os=android <br>
 os可以是android或者ios <br>
 post: username&password&repassword&email&code
 response: {err:"",data:""}
 </pre>
 */
 public function doRegisterAction()
 {
     list($username, $password, $email, $code) = $this->getInput(array('username', 'password', 'email', 'code'));
     //  验证输入
     Wind::import('Wind:utility.WindValidator');
     $config = $this->_getRegistConfig();
     if (!$username) {
         $this->showError('USER:user.error.-1');
     }
     if (!$password) {
         $this->showError('USER:pwd.require');
     }
     if (!$email) {
         $this->showError('USER:user.error.-6');
     }
     if (!WindValidator::isEmail($email)) {
         $this->showError('USER:user.error.-7');
     }
     foreach ($config['active.field'] as $field) {
         if (!$this->getInput($field, 'post')) {
             $this->showError('USER:register.error.require.needField.' . $field);
         }
     }
     if ($config['active.check'] && !$regreason) {
         $this->showError('USER:register.error.require.regreason');
     }
     if ($this->_showVerify()) {
         $veryfy = $this->_getVerifyService();
         if ($veryfy->checkVerify($code) !== true) {
             $this->showError('USER:verifycode.error');
         }
     }
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm();
     $userDm->setUsername($username);
     $userDm->setPassword($password);
     $userDm->setEmail($email);
     $userDm->setRegdate(Pw::getTime());
     $userDm->setLastvisit(Pw::getTime());
     $userDm->setRegip(Wind::getComponent('request')->getClientIp());
     $userDm->setAliww($aliww);
     $userDm->setQq($qq);
     $userDm->setMsn($msn);
     $userDm->setMobile($mobile);
     $userDm->setMobileCode($mobileCode);
     $userDm->setQuestion($question, $answer);
     $userDm->setRegreason($regreason);
     $areaids = array($hometown, $location);
     if ($areaids) {
         $srv = WindidApi::api('area');
         $areas = $srv->fetchAreaInfo($areaids);
         $userDm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : '');
         $userDm->setLocation($location, isset($areas[$location]) ? $areas[$location] : '');
     }
     //
     $registerService = new PwRegisterService();
     $registerService->setUserDm($userDm);
     /*[u_regsiter]:插件扩展*/
     $this->runHook('c_register', $registerService);
     if (($info = $registerService->register()) instanceof PwError) {
         $this->showError($info->getError());
     } else {
         $laiwangOK = PwLaiWangSerivce::registerUser($info['uid'], $info['password'], $info['username'], '', 1);
         //
         if (1 == Wekit::C('register', 'active.mail')) {
             $this->showMessage('USER:active.sendemail.success');
         } else {
             $this->uid = $info['uid'];
             $this->setOutput($this->_getUserInfo($laiwangOK), 'data');
             $this->showMessage('USER:register.success');
         }
     }
 }