Пример #1
0
 /** 
  * 编辑用户信息
  */
 public function dorunAction()
 {
     $userDm = new PwUserInfoDm($this->loginUser->uid);
     $userDm->setRealname($this->getInput('realname', 'post'));
     $userDm->setByear($this->getInput('byear', 'post'));
     $userDm->setBmonth($this->getInput('bmonth', 'post'));
     $userDm->setBday($this->getInput('bday', 'post'));
     $userDm->setGender($this->getInput('gender', 'post'));
     $userDm->setHomepage($this->getInput('homepage', 'post'));
     $userDm->setProfile($this->getInput('profile', 'post'));
     list($hometown, $location) = $this->getInput(array('hometown', 'location'), 'post');
     /* @var $srv PwAreaService */
     $srv = Wekit::load('area.srv.PwAreaService');
     $areas = $srv->fetchAreaInfo(array($hometown, $location));
     $userDm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : '');
     $userDm->setLocation($location, isset($areas[$location]) ? $areas[$location] : '');
     //没有禁止签名的时候方可编辑签名
     if ($this->loginUser->getPermission('allow_sign')) {
         $bbsSign = $this->getInput('bbs_sign', 'post');
         if (($len = $this->loginUser->getPermission('sign_max_length')) && Pw::strlen($bbsSign) > $len) {
             //仅在此限制签名字数
             $this->showError(array('USER:user.edit.sign.length.over', array('{max}' => $len)));
         }
         Wind::import('LIB:ubb.PwUbbCode');
         Wind::import('LIB:ubb.config.PwUbbCodeConvertConfig');
         $ubb = new PwUbbCodeConvertConfig();
         $ubb->isConverImg = $this->loginUser->getPermission('sign_ubb_img') ? true : false;
         $userDm->setBbsSign($bbsSign)->setSignUseubb($bbsSign != PwUbbCode::convert($bbsSign, $ubb) ? 1 : 0);
     }
     $result = $this->_editUser($userDm, PwUser::FETCH_MAIN + PwUser::FETCH_INFO);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     } else {
         $this->loginUser->info = array_merge($this->loginUser->info, $userDm->getData());
         $this->showMessage('USER:user.edit.profile.success');
     }
 }