/** * 编辑用户信息 */ 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'); } }
/** * 执行第三方授权登录后的注册动作 * */ public function doThirdRegistAction() { //第三方登录注册不校验验证码 /* if(Wekit::load("verify.srv.PwCheckVerifyService")->checkVerify($this->getInput('code')) != true){ $this->showError('USER:verifycode.error','index.php?m=u&c=login'); } */ //post参数中获取用户注册信息、第三方授权获取的信息通过hidden标签保存 $username = $this->getInput('username', 'post'); $password = $this->getInput('password', 'post'); $email = $this->getInput('email', 'post'); $gender = $this->getInput('gender', 'post'); $uid = $this->getInput('uid', 'post'); $type = $this->getInput('type', 'post'); $avatar = $this->getInput('avatar', 'post'); //执行注册 Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm(); $userDm->setUsername($username); $userDm->setPassword($password); $userDm->setEmail($email); $userDm->setGender($gender); $userDm->setRegdate(Pw::getTime()); $userDm->setLastvisit(Pw::getTime()); $userDm->setRegip(Wind::getComponent('request')->getClientIp()); $userDm->setStatus(0); Wind::import('SRV:user.srv.PwRegisterService'); $registerService = new PwRegisterService(); $registerService->setUserDm($userDm); // [u_regsiter]:插件扩展 $this->runHook('c_register', $registerService); if (($info = $registerService->register()) instanceof PwError) { $this->showError($info->getError()); } // 这里取了lastInsertId,但已经指定了主键的值,所以返回false表示成功。。 if ($this->_getUserOpenAccountDs()->addUser($info['uid'], $uid, $type) == false) { $this->downloadThirdPlatformAvatar($info['uid'], $avatar); } // 以便后面登录用到 $acctRelationData = array('uid' => $info['uid']); //继续登录 $login = new PwLoginService(); $this->runHook('c_login_dorun', $login); Wind::import('SRV:user.srv.PwRegisterService'); $registerService = new PwRegisterService(); $info = $registerService->sysUser($acctRelationData['uid']); if (!$info) { $this->showError('USER:user.syn.error'); } $identity = PwLoginService::createLoginIdentify($info); $identity = base64_encode($identity . '|' . $this->getInput('backurl') . '|' . '0'); $this->forwardRedirect(WindUrlHelper::createUrl('u/login/welcome', array('_statu' => $identity))); }
public function updateMyInfoAction() { $userid = $this->loginUser->uid; $txt_real_name = $this->getInput("Txt_petname"); $rd_sex = $this->getInput("Rd_sex_1"); $txt_blog = trim($this->getInput("Txt_blog")); $txt_introduce = trim($this->getInput("Txt_introduce")); //Txt_introduce $txt_qq = $this->getInput("Txt_qq"); //Txt_qq $txt_alipay = $this->getInput("Txt_alipay"); //Txt_alipay $byear = $this->getInput("byear"); $bmonth = $this->getInput("bmonth"); $bday = $this->getInput("bday"); $email = trim($this->getInput('Txt_email', 'post')); $userDm = new PwUserInfoDm($this->loginUser->uid); $userDm->setRealname($txt_real_name); $userDm->setByear($byear); $userDm->setBmonth($bmonth); $userDm->setBday($bday); $userDm->setGender($rd_sex); $userDm->setHomepage($txt_blog); $userDm->setProfile($txt_introduce); $userDm->setAliww($txt_alipay); $userDm->setQq($txt_qq); $userDm->setEmail($email); $returnData = array("success" => true, "data" => "更新成功"); if ($email) { $r = PwUserValidator::isEmailValid($email, $this->loginUser->username); if ($r instanceof PwError) { $code = $r->getError(); $message = "邮箱地址已经被占用, 请使用另外一个地址"; if ($code == 'USER:user.error.-7') { $message = "请输入有效的邮箱地址"; } $returnData['success'] = false; $returnData['data'] = $message; print_r(json_encode($returnData)); die; } } //更新成功, 页面将刷新 $userDs = Wekit::load('user.PwUser'); $result = $userDs->editUser($userDm, PwUser::FETCH_MAIN + PwUser::FETCH_INFO); if ($result instanceof PwError) { $code = $result->getError(); if ($code == "USER:error.profile.length") { $message = "您最多输入250个字的自我描述"; } else { if ($code == "USER:error.homepage") { $message = "博客地址不正确,需要以http开头"; } else { $message = "信息填写不完全" . $code; } } $returnData['success'] = false; $returnData['data'] = $message; // "请设置正确的博客链接"; print_r(json_encode($returnData)); die; } print_r(json_encode($returnData)); die; }
/** * 编辑用户信息操作 * * @return voido */ public function doEditAction() { $info = $this->checkUser(); Wind::import('SRC:service.user.dm.PwUserInfoDm'); $dm = new PwUserInfoDm($info['uid']); //用户信息 //$dm->setUsername($this->getInput('username', 'post')); list($password, $repassword) = $this->getInput(array('password', 'repassword'), 'post'); if ($password) { if ($password != $repassword) { $this->showError('USER:user.error.-20'); } $dm->setPassword($password); } $dm->setEmail($this->getInput('email', 'post')); list($question, $answer) = $this->getInput(array('question', 'answer'), 'post'); switch ($question) { case '-2': $dm->setQuestion('', ''); break; case '-1': default: break; } $dm->setRegdate(Pw::str2time($this->getInput('regdate', 'post'))); $dm->setRegip($this->getInput('regip', 'post')); $dm->setOnline(intval($this->getInput('online', 'post')) * 3600); //基本资料 $dm->setRealname($this->getInput('realname', 'post')); $dm->setGender($this->getInput('gender', 'post')); $birthday = $this->getInput('birthday', 'post'); if ($birthday) { $bir = explode('-', $birthday); isset($bir[0]) && $dm->setByear($bir[0]); isset($bir[1]) && $dm->setBmonth($bir[1]); isset($bir[2]) && $dm->setBday($bir[2]); } else { $dm->setBday('')->setByear('')->setBmonth(''); } list($hometown, $location) = $this->getInput(array('hometown', 'location'), 'post'); $srv = WindidApi::api('area'); $areas = $srv->fetchAreaInfo(array($hometown, $location)); $dm->setLocation($location, isset($areas[$location]) ? $areas[$location] : ''); $dm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : ''); $dm->setHomepage($this->getInput('homepage', 'post')); $dm->setProfile($this->getInput('profile', 'post')); //交易信息 $dm->setAlipay($this->getInput('alipay', 'post')); $dm->setMobile($this->getInput('mobile', 'post')); $dm->setTelphone($this->getInput('telphone', 'post')); $dm->setAddress($this->getInput('address', 'post')); $dm->setZipcode($this->getInput('zipcode', 'post')); //联系信息 $dm->setEmail($this->getInput('email', 'post')); $dm->setAliww($this->getInput('aliww', 'post')); $dm->setQq($this->getInput('qq', 'post')); $dm->setMsn($this->getInput('msn', 'post')); /* @var $pwUser PwUser */ $pwUser = Wekit::load('user.PwUser'); $result = $pwUser->editUser($dm); if ($result instanceof PwError) { $this->showError($result->getError()); } $isFounder = $this->isFounder($info['username']); $this->showMessage($isFounder ? 'USER:founder.update.success' : 'USER:update.success', 'u/manage/edit?uid=' . $info['uid']); }
/** * 修改性别 * @access public * @return void * @example <pre> /index.php?m=native&c=user&a=doSex <br> post: securityKey&gender </pre> */ public function doSexAction() { $this->checkUserSessionValid(); // $userDm = new PwUserInfoDm($this->uid); $userDm->setGender($this->getInput('gender', 'post')); /* @var $userDs PwUser */ $result = $this->_getUserDs()->editUser($userDm, PwUser::FETCH_MAIN + PwUser::FETCH_INFO); if ($result instanceof PwError) { $this->showError($result->getError()); } else { PwSimpleHook::getInstance('profile_editUser')->runDo($dm); $this->showMessage('USER:user.edit.profile.success'); } }