本文整理匯總了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();
}