本文整理汇总了PHP中UserAccount::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAccount::save方法的具体用法?PHP UserAccount::save怎么用?PHP UserAccount::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserAccount
的用法示例。
在下文中一共展示了UserAccount::save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: veriflyAction
public function veriflyAction()
{
switch ($this->request->getPost('type')) {
case "login":
break;
case "register":
$this->tag->setTitle('注册中。。。');
$username = $this->request->getPost('username');
$email = $this->request->getPost("email");
if (CheckController::usernameCheck($username)) {
$errmsg .= "用户名已存在辣~";
}
if (CheckController::emailCheck($email)) {
$errmsg .= "邮箱已经被使用辣~";
}
if (!$errmsg) {
$token = md5($username . $username . $regtime);
//创建用于激活识别码
$token_exptime = time() + 60 * 60 * 24;
//过期时间为24小时后
$user = new UserAccount();
$user->username = $username;
//用户名
$user->email = $email;
//邮箱
$user->regtime = time();
//注册时间
$user->salt = rand(100000, 999999);
//随机生成salt值
$user->password = md5(md5('12345678') . $user->salt);
//默认密码12346
$user->token = $token;
//激活识别码
$user->token_exptime = $token_exptime;
//验证超时时间
if ($user->save() == true) {
$this->tag->setTitle('注册成功 | FiSkinAlcon');
$this->flash->success("注册成功!一封激活邮件已发往您的邮箱,请及时登录查看喵~");
} else {
$this->tag->setTitle('新用户注册 | FiSkinAlcon');
foreach ($user->getMessages() as $message) {
$errmsg .= getMessage() . "<br/>";
}
$this->flash->error($errmsg);
}
}
break;
}
}
示例2: processinviteAction
function processinviteAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(TRUE);
$formvalues = $this->_getAllParams();
$session = SessionWrapper::getInstance();
$id = decode($formvalues['id']);
$formvalues['id'] = $id;
// debugMessage($formvalues);
$formvalues['status'] = 1;
$formvalues['password'] = $formvalues['password'];
$formvalues['agreedtoterms'] = 1;
$formvalues['activationdate'] = DEFAULT_DATETIME;
$formvalues['hasacceptedinvite'] = 1;
$user = new UserAccount();
$user->populate($id);
$user->processPost($formvalues);
// debugMessage($user->toArray()); debugMessage("Error > ".$user->getErrorStackAsString()); exit();
$user->save();
// save notification to user's inbox
$user->sendActivationConfirmationNotification();
$url = $this->view->serverUrl($this->view->baseUrl('profile/view/id/' . encode($user->getID())));
$usecase = '1.16';
$module = '1';
$type = USER_ACTIVATE;
$details = "User Profile <a href='" . $url . "' class='blockanchor'>" . $user->getName() . "</a> activated";
$browser = new Browser();
$audit_values = $session->getVar('browseraudit');
$audit_values['module'] = $module;
$audit_values['usecase'] = $usecase;
$audit_values['transactiontype'] = $type;
$audit_values['userid'] = $session->getVar('userid');
$audit_values['url'] = $url;
$audit_values['transactiondetails'] = $details;
$audit_values['status'] = "Y";
// debugMessage($audit_values);
$this->notify(new sfEvent($this, $type, $audit_values));
$this->clearSession();
$session->setVar(SUCCESS_MESSAGE, "You can now login using your Username or Email and Password");
// $loginurl = $this->view->baseUrl("user/checklogin/email/".$user->getEmail().'/password/'.$formvalues['password']);
$loginurl = $this->view->baseUrl("user/login");
$this->_helper->redirector->gotoUrl($loginurl);
return false;
}
示例3: run
public function run()
{
$transaction = Yii::app()->db->beginTransaction();
try {
if ($this->data->validate()) {
$user = new UserAccount();
$user->setPassword($this->data->password);
$user->status = UserAccount::STATUS_NEED_ACTIVATION;
if (!$user->save()) {
throw new Exception("User registration failed. Cant save User row. Errors: " . var_export($user->getErrors(), true));
}
$identity = new Identity();
$identity->user_id = $user->id;
$identity->type = Identity::TYPE_EMAIL;
$identity->status = Identity::STATUS_NEED_CONFIRMATION;
$identity->identity = $this->data->email;
if (!$identity->save()) {
throw new Exception("User registration failed. Can't save Identity. Errors: " . var_export($identity->getErrors(), true));
}
$profile = new Profile();
$attributeNames = $profile->attributeNames();
$attributes = $this->data->getAttributes($attributeNames);
$profile->setAttributes($attributes, false);
$profile->user_id = $user->id;
if (!$profile->save()) {
throw new Exception("User registration failed. Can't save Profile. Errors: " . var_export($profile->getErrors(), true));
}
$this->afterRecordsCreated($user, $profile, $identity);
} else {
throw new Exception("Invalid registration data. Errors: " . var_export($this->data->getErrors(), true));
}
} catch (Exception $exc) {
$transaction->rollback();
throw $exc;
}
$transaction->commit();
return true;
}
示例4: signUpAction
public function signUpAction()
{
$signUp = $this->request->getPost('data');
$signUp['username'] = $signUp['phone'];
if (!$signUp['phone'] || !$signUp['code'] || !$signUp['password'] || !$signUp['repassword']) {
\ToolFlash::error('请填写完注册信息');
}
if (!\ToolValidator::isMobile($signUp['phone'])) {
\ToolFlash::error('请填写正确的手机号码');
}
//判断该用户是否存在
if (\BUser::instance()->phoneExists($signUp['phone'])) {
\ToolFlash::error('手机号已存在');
}
if ($signUp['password'] != $signUp['repassword']) {
\ToolFlash::error('两次输入密码不一致');
}
$smsInfo = $this->session->get('sms_info');
if ($signUp['code'] != $smsInfo['code']) {
\ToolFlash::error('请输入正确的手机验证码');
}
if (!\Captcha::install()->verify($this->session->get('captachaID'), $signUp['captcha'])) {
\ToolFlash::error("验证码不正确");
}
$userData = array('username' => $signUp['username'], 'phone' => $signUp['phone'], 'password' => $signUp['password']);
if (\BUser::instance()->saveUser($userData)) {
//注册成功保存session
$userInfo = \User::findFirst("username='" . $userData['phone'] . "'")->toArray();
\BUser::instance()->setLoginSession($userInfo);
//跳转到上个页面
$url = $this->session->get('referer');
$this->session->remove('referer');
$url = $url ? $url : $this->url->getBaseUri();
/******注册成功送5000测试账户余额 add by zhangyanan 20150504 start 正式上线后删除*****/
$UserAccount = new \UserAccount();
$UserAccountLog = new \UserAccountLog();
$UserAccount->save(array('uid' => $userInfo['id'], 'account' => 200000, 'income' => 200000, 'expense' => 0, 'ctime' => time()));
$UserAccountLog->save(array('uid' => $userInfo['id'], 'type' => 1, 'amount' => 200000, 'note' => '注册测试金额2000', 'ctime' => time()));
/******注册成功送5000测试账户余额 add by zhangyanan 20150504 end 正式上线后删除*****/
\ToolFlash::success('注册成功', $url);
} else {
\ToolFlash::error('注册失败,请重新注册');
}
}
示例5: resetPassword
/**
* Resets user's password and send it to email
* @param UserAccount $user
*/
public function resetPassword(UserAccount $user)
{
if ($user->status != UserAccount::STATUS_ACTIVE) {
if (!$this->allowActivationOnPasswordReset) {
throw new CException('Can\'t reset password for inactive users.');
} else {
$identity = Identity::model()->findByAttributes(array('user_id' => $user->id, 'type' => Identity::TYPE_EMAIL, 'status' => Identity::STATUS_NEED_CONFIRMATION));
$identity->userIdentityConfirmation->confirm();
}
}
$emailAddr = $user->getActiveEmail();
$newPassword = $this->randomPassword();
$user->setPassword($newPassword);
$user->save(false, array('password'));
$email = new YiiMailer('resetPassword', $data = array('newPassword' => $newPassword, 'description' => $description = 'Password reset'));
$email->setSubject($description);
$email->setTo($emailAddr);
$email->setFrom(Yii::app()->params['noreplyAddress'], Yii::app()->name, FALSE);
Yii::log('Sendign reset password mail to ' . $emailAddr);
if ($email->send()) {
Yii::log('Ok');
} else {
Yii::log('Failed');
throw new CException('Failed to send the email');
}
}
示例6: croppictureAction
function croppictureAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(TRUE);
$session = SessionWrapper::getInstance();
$formvalues = $this->_getAllParams();
$user = new UserAccount();
$user->populate(decode($formvalues['id']));
$userfolder = $user->getID();
// debugMessage($formvalues);
//debugMessage($user->toArray());
$oldfile = "large_" . $user->getProfilePhoto();
$base = BASE_PATH . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . "users" . DIRECTORY_SEPARATOR . 'user_' . $userfolder . '' . DIRECTORY_SEPARATOR . 'avatar' . DIRECTORY_SEPARATOR;
// debugMessage($user->toArray());
$src = $base . $oldfile;
$currenttime = time();
$currenttime_file = $currenttime . '.jpg';
$newlargefilename = $base . "large_" . $currenttime_file;
$newmediumfilename = $base . "medium_" . $currenttime_file;
// exit();
$image = WideImage::load($src);
$cropped1 = $image->crop($formvalues['x1'], $formvalues['y1'], $formvalues['w'], $formvalues['h']);
$resized_1 = $cropped1->resize(300, 300, 'fill');
$resized_1->saveToFile($newlargefilename);
//$image2 = WideImage::load($src);
$cropped2 = $image->crop($formvalues['x1'], $formvalues['y1'], $formvalues['w'], $formvalues['h']);
$resized_2 = $cropped2->resize(165, 165, 'fill');
$resized_2->saveToFile($newmediumfilename);
$user->setProfilePhoto($currenttime_file);
$user->save();
// check if UserAccount already has profile picture and archive it
$ftimestamp = current(explode('.', $user->getProfilePhoto()));
$allfiles = glob($base . DIRECTORY_SEPARATOR . '*.*');
$currentfiles = glob($base . DIRECTORY_SEPARATOR . '*' . $ftimestamp . '*.*');
// debugMessage($currentfiles);
$deletearray = array();
foreach ($allfiles as $value) {
if (!in_array($value, $currentfiles)) {
$deletearray[] = $value;
}
}
// debugMessage($deletearray);
if (count($deletearray) > 0) {
foreach ($deletearray as $afile) {
$afile_filename = basename($afile);
rename($afile, $base . DIRECTORY_SEPARATOR . 'archive' . DIRECTORY_SEPARATOR . $afile_filename);
}
}
$session->setVar(SUCCESS_MESSAGE, "Successfully updated profile picture");
$this->_helper->redirector->gotoUrl($this->view->baseUrl('profile/view/id/' . encode($user->getID())));
// exit();
}