/** * 更新消息数 * Enter description here ... * @param int $uid * @param int $num */ public function editMessageNum($uid, $num) { Wind::import('WINDID:service.user.dm.WindidUserDm'); $dm = new WindidUserDm($uid); $dm->addMessages($num); $result = $this->_getUserDs()->editUser($dm); if ($result instanceof WindidError) { return $result->getCode(); } $this->_getNotifyClient()->send('editMessageNum', $uid); return (int) $result; }
public function setUser($username, $password, $email, $groupid = 3, $uid = 0) { if (!$email) { return new PwError('ADMIN:founder.edit.fail.email.empty'); } Wind::import('WSRV:user.dm.WindidUserDm'); $userDm = new WindidUserDm($uid); $userDm->setEmail($email); //$userDm->setGroupid($groupid); $password && $userDm->setPassword($password); if (!$uid) { $userDm->setUsername($username); return $this->loadUser()->addUser($userDm); } else { return $this->loadUser()->editUser($userDm); } }
/** * 用户注册 * Enter description here ... * @param string $username * @param string $email * @param string $password * @param string $question * @param string $answer * @param string $regip * @return int */ public function register($username, $email, $password, $question = '', $answer = '', $regip = '') { Wind::import('WINDID:service.user.dm.WindidUserDm'); $dm = new WindidUserDm(); $dm->setUsername($username)->setEmail($email)->setPassword($password)->setQuestion($question)->setAnswer($answer)->setRegip($regip); $result = $this->_getUserDs()->addUser($dm); if ($result instanceof WindidError) { return $result->getCode(); } $uid = (int) $result; $client = Windid::client(); if ($client->windid == 'local') { $srv = Windid::load('user.srv.WindidUserService'); $result = $srv->defaultAvatar($uid, 'face'); } else { $params = array('uid' => $uid, 'type' => 'face'); WindidApi::open('avatar/default', array(), $params); } $this->_getNotifyClient()->send('register', $uid); return $uid; }
public function getBaseUserDm($uid, $password, $editInfo) { Wind::import('WSRV:user.dm.WindidUserDm'); $allow = array('username', 'password', 'email', 'question', 'answer'); $dm = new WindidUserDm($uid); foreach ($editInfo as $key => $info) { if (!in_array($key, $allow)) { continue; } $fun = 'set' . ucfirst($key); $dm->{$fun}($info); } $password && $dm->setOldpwd($password); return $dm; }
/** * 用户注册 * * @param string $username * @param string $email * @param string $password * @param string $question * @param string $answer * @param string $regip * @return int */ public function register($username, $email, $password, $question = '', $answer = '', $regip = '') { Wind::import('WSRV:user.dm.WindidUserDm'); $dm = new WindidUserDm(); $dm->setUsername($username)->setEmail($email)->setPassword($password)->setQuestion($question)->setAnswer($answer)->setRegip($regip); return $this->addDmUser($dm); }
/** * 编辑用户信息操作 * * @return voido */ public function doEditAction() { $uid = (int) $this->getInput('uid', 'post'); if (!$uid) { $this->showError('WINDID:fail'); } Wind::import('WINDID:service.user.dm.WindidUserDm'); $dm = new WindidUserDm($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->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'); /* @var $srv PwAreaService */ $srv = Wekit::load('area.srv.PwAreaService'); $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->setEmail($this->getInput('email', 'post')); $dm->setAliww($this->getInput('aliww', 'post')); $dm->setQq($this->getInput('qq', 'post')); $dm->setMsn($this->getInput('msn', 'post')); $ds = Windid::load('user.WindidUser'); $result = $ds->editUser($dm); if ($result instanceof PwError) { $this->showError($result->getError()); } $srv = Windid::load('notify.srv.WindidNotifyClient'); $srv->send('202', $dm->getData(), true); $this->showMessage('WINDID:success', 'windid/user/edit?uid=' . $uid); }
public function editDmUser(WindidUserDm $dm) { /* if (($result = $dm->beforeUpdate()) instanceof WindidError) { return $result->getCode(); } */ $params = $dm->getData(); $params['uid'] = $dm->uid; if (isset($params['password'])) { $params['password'] = $dm->password; } unset($params['salt'], $params['safecv']); return WindidApi::open('user/editUser', array(), $params); }
/** * 更新用户信息 * * @param int $uid 用户ID * @param WindidUserDm $dm 用户资料 * @return int|bool 返回用户注册uid|失败时返回false */ public function editUser(WindidUserDm $dm) { if (($check = $dm->beforeUpdate()) !== true) { return $check; } return $this->_getDao(self::FETCH_ALL)->editUser($dm->uid, $dm->getData(), $dm->getIncreaseData()); }
protected function updateUser($uid, $unreads) { $uid = intval($uid); if ($uid < 1) { return false; } Wind::import('WINDID:service.user.dm.WindidUserDm'); $dm = new WindidUserDm($uid); $dm->setMessageCount($unreads); return $this->_getUserDs()->editUser($dm); }
/** * 修改用户信息 */ public function editUserAction() { list($uid, $username, $password, $old_password, $email, $question, $answer, $regip, $realname, $profile, $regdate, $gender, $byear, $bmonth, $bday, $hometown, $location, $homepage, $qq, $msn, $aliww, $mobile, $alipay, $addmessages, $messages) = $this->getInput(array('uid', 'username', 'password', 'old_password', 'email', 'question', 'answer', 'regip', 'realname', 'profile', 'regdate', 'gender', 'byear', 'bmonth', 'bday', 'hometown', 'location', 'homepage', 'qq', 'msn', 'aliww', 'mobile', 'alipay', 'addmessages', 'messages'), 'post'); Wind::import('WSRV:user.dm.WindidUserDm'); $dm = new WindidUserDm($uid); isset($username) && $dm->setUsername($username); isset($password) && $dm->setPassword($password); isset($old_password) && $dm->setOldpwd($old_password); isset($email) && $dm->setEmail($email); isset($question) && $dm->setQuestion($question); isset($answer) && $dm->setAnswer($answer); isset($regip) && $dm->setRegip($regip); isset($realname) && $dm->setRealname($realname); isset($profile) && $dm->setProfile($profile); isset($regdate) && $dm->setRegdate($regdate); isset($gender) && $dm->setGender($gender); isset($byear) && $dm->setByear($byear); isset($bmonth) && $dm->setBmonth($bmonth); isset($bday) && $dm->setBday($bday); isset($hometown) && $dm->setHometown($hometown); isset($location) && $dm->setLocation($location); isset($homepage) && $dm->setHomepage($homepage); isset($qq) && $dm->setQq($qq); isset($msn) && $dm->setMsn($msn); isset($aliww) && $dm->setAliww($aliww); isset($mobile) && $dm->setMobile($mobile); isset($alipay) && $dm->setAlipay($alipay); isset($addmessages) && $dm->addMessages($addmessages); isset($messages) && $dm->setMessageCount($messages); $result = $this->_getUserDs()->editUser($dm); if ($result instanceof WindidError) { $this->output($result->getCode()); } $this->_getNotifyService()->send('editUser', array('uid' => $uid, 'changepwd' => $dm->password ? 1 : 0), $this->appid); $this->output(WindidUtility::result(true)); }
public static function updateCheck(WindidUserDm $dm) { if (!($user = self::_getUserService()->getUserByUid($dm->uid))) { return new WindidError(WindidError::USER_NOT_EXISTS); } $data = $dm->getData(); if ($result = self::checkName($data['username'], $dm->uid) !== true) { return $result; } if ($result = self::checkEmail($data['email'], $dm->uid) !== true) { return $result; } if (WindidUtility::buildPassword($data['password'], $user['salt']) != $user['password']) { return new WindidError(WindidError::PASSWORD_ERROR); } return true; }
/** * 添加用户对象接口,使用前必须使用WidnidApi::getDm('user') 设置数据 * Enter description here ... * @param WindidUserDm $dm */ public function addDmUser($dm) { Wind::import('WINDID:service.user.dm.WindidUserDm'); if (!$dm instanceof WindidUserDm) { return WindidError::CLASS_ERROR; } $_baseInfo = $_extInfo = array(); $_data = $dm->getData(); $userBase = array('username', 'password', 'email', 'question', 'answer', 'regip', 'regdate'); foreach ($_data as $k => $v) { if (in_array($k, $userBase)) { $_baseInfo[$k] = $v; continue; } $_extInfo[$k] = $v; } if (!$_baseInfo) { return WindidError::FAIL; } $uid = WindidApi::open('user/register', array(), $_baseInfo); if ($uid < 1) { return $uid; } if ($_extInfo && $uid > 0) { $_extInfo['uid'] = $uid; $result = WindidApi::open('user/editInfo', array(), $_extInfo); if ($result < 1) { return $result; } } return $uid; }