本文整理汇总了PHP中UserModule::sendMail方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModule::sendMail方法的具体用法?PHP UserModule::sendMail怎么用?PHP UserModule::sendMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModule
的用法示例。
在下文中一共展示了UserModule::sendMail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionRecovery
/**
* Recovery password
*/
public function actionRecovery () {
$form = new UserRecoveryForm;
if (Y::userId()) {
$this->redirect(Y::module()->returnUrl);
Y::end();
}
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email&&$activkey) { //get new pass
$find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
if(isset($find)&&$find->activkey==$activkey) {
$form2 = new UserChangePassword;
if(isset($_POST['UserChangePassword'])) {
$form2->attributes=$_POST['UserChangePassword'];
if($form2->validate()) {
$find->password = UserModule::encrypting($form2->password);
if ($find->status==0) {
$find->status = 1;
}
$find->save();
Y::flash('recoveryMessage',Users::t("New password is saved."));
$this->redirect(Y::module()->recoveryUrl);
}
}
$this->render('changepassword',array('form'=>$form2));
} else {
Y::flash('recoveryMessage',Users::t("Incorrect recovery link."));
$this->redirect(Y::module()->recoveryUrl);
}
} else { //send email
if(isset($_POST['UserRecoveryForm'])) {
$form->attributes=$_POST['UserRecoveryForm'];
if($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$user->activkey = Y::module()->encrypting(microtime().$user->password);
$user->save();
$activation_url = 'http://' . $_SERVER['HTTP_HOST'].$this->siteUrl('user/recovery',array("activkey" => $user->activkey, "email" => urldecode($user->email)));
$subject = Users::t("You have requested the password recovery site {site_name}",
array(
'{site_name}'=>Yii::app()->name,
));
$message = Users::t("You have requested the password recovery site {site_name}. To receive a new password, go to {activation_url}.",
array(
'{site_name}'=>Yii::app()->name,
'{activation_url}'=>$activation_url,
));
UserModule::sendMail($user->email,$subject,$message);
Y::flash('recoveryMessage',Users::t("Please check your email. An instructions was sent to your email address."));
$this->refresh();
}
}
$this->render('recovery',array('form'=>$form));
}
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new User();
$profile = new Profile();
$this->performAjaxValidation(array($model, $profile));
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$password = $_POST['User']['password'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
//send mail
UserModule::sendMail($model->email, UserModule::t("You are registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password)));
$profile->user_id = $model->id;
$profile->save();
}
$this->redirect(array('/rights/assignment/user', 'id' => $model->id));
} else {
$profile->validate();
}
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
示例3: actionRecovery
/**
* Recovery password
*/
public function actionRecovery()
{
$form = new UserRecoveryForm();
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email && $activkey) {
$form2 = new UserChangePassword();
$organ = Organ::model()->findByAttributes(array('Email' => $email));
$find = User::model()->findByAttributes(array('OrganID' => $organ->ID, 'IsMain' => '1'));
if (isset($find) && $find->ActiveKey == $activkey) {
if (isset($_POST['UserChangePassword'])) {
$form2->attributes = $_POST['UserChangePassword'];
if ($form2->validate()) {
$find->PassWord = Yii::app()->controller->module->encrypting($form2->password);
$find->ActiveKey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
User::model()->updateByPk($find->ID, array('PassWord' => $find->PassWord, 'ActiveKey' => $find->ActiveKey));
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
$this->redirect(array('recovery/finish'));
}
}
$this->render('changepassword', array('form' => $form2));
} else {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Incorrect recovery link."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if (isset($_POST['UserRecoveryForm'])) {
$status = 2;
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = User::model()->findByPk($form->user_id);
//激活码
if ($user->ActiveKey == null) {
$user->ActiveKey = $user->encrypting(microtime() . $user->PassWord);
$user->verifyPassword = $user->PassWord;
$user->save();
}
//获取邮箱
$organinfo = Organ::model()->findByPk($user->OrganID);
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->ActiveKey, "email" => $organinfo->Email));
$subject = UserModule::t("找回 {site_name}密码", array('{site_name}' => Yii::app()->name));
$message = UserModule::t("You have requested the password recovery site {site_name}. To receive a new password, go to {activation_url}.", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url . ' '));
$res = UserModule::sendMail($organinfo->Email, $subject, $message);
if ($res == 'ok') {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. An instructions was sent to your email address."));
} else {
$this->render('recovery', array('form' => $form, 'emailError' => $res));
exit;
}
$this->refresh();
}
}
$this->render('recovery', array('form' => $form));
}
}
}
示例4: actionRegistration
/**
* Registration user
*/
public function actionRegistration()
{
$model = new RegistrationForm();
$profile = new Profile();
$profile->regMode = true;
if (Yii::app()->getModule('user')->disableUsername) {
$model->username = time() + rand(0, 9999999);
}
// ajax validator
if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
echo UActiveForm::validate(array($model, $profile));
Yii::app()->end();
}
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->profileUrl);
} else {
if (isset($_POST['RegistrationForm'])) {
$model->attributes = $_POST['RegistrationForm'];
$profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
if ($model->validate() && $profile->validate()) {
$soucePassword = $model->password;
$model->activkey = UserModule::encrypting(microtime() . $model->password);
$model->password = UserModule::encrypting($model->password);
$model->verifyPassword = UserModule::encrypting($model->verifyPassword);
$model->superuser = 0;
$model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
if ($model->save()) {
$profile->user_id = $model->id;
$profile->save();
if (Yii::app()->controller->module->sendActivationMail) {
$activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url)));
}
if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
$identity = new UserIdentity($model->username, $soucePassword);
$identity->authenticate();
Yii::app()->user->login($identity, 0);
$this->redirect(Yii::app()->controller->module->getReturnUrl());
} else {
if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
} elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
} elseif (Yii::app()->controller->module->loginNotActiv) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email or login."));
} else {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
}
$this->refresh();
}
}
} else {
$profile->validate();
}
}
$this->render('/user/registration', array('model' => $model, 'profile' => $profile));
}
}
示例5: actionCreate
public function actionCreate()
{
$model = new Staff();
$profile = new Profile();
$this->performAjaxValidation(array($model, $profile), 'staff-form');
if (isset($_POST['Staff'])) {
$model->attributes = $_POST['Staff'];
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$realp = PasswordHelper::generateStrongPassword();
$model->password = $realp;
$model->activkey = PasswordHelper::hashPassword(microtime() . $model->password);
$model->password = PasswordHelper::hashPassword($model->password);
$model->status = 0;
if ($model->save()) {
$profile->user_id = $model->id;
$profile->save();
if (!empty($_POST['Profile']['group_id'])) {
foreach ($_POST['Profile']['group_id'] as $groupid) {
$userGroup = new UserGroup();
$userGroup->profile_id = $model->id;
$userGroup->group_id = $groupid;
$userGroup->save();
}
}
$passwordHistory = new PasswordHistory();
$passwordHistory->profile_id = $model->id;
$passwordHistory->password = $model->password;
$passwordHistory->save();
if (Yii::app()->getModule('user')->sendActivationMail) {
$activation_url = $this->createAbsoluteUrl('/user/activation', array("activkey" => $model->activkey, "email" => $model->email));
UserModule::sendMail($model->email, UserModule::t("Your {site_name} account has been created", array('{site_name}' => Yii::app()->name)), UserModule::t("To activate your account, go to <a href='{activation_url}'>{activation_url}</a>.<br/><br/>Username: " . $model->username . "<br/>Password: " . $realp . "<br/>", array('{activation_url}' => $activation_url)));
}
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
$this->renderPartial('_view', array('model' => $model, 'profile' => $profile), false, true);
Yii::app()->end();
}
$this->redirect(array('view', 'id' => $model->id));
} else {
Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, 'An error occured while trying to create new user, please try again.');
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
$this->renderPartial('_form', array('model' => $model, 'profile' => $profile), false, true);
Yii::app()->end();
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
} else {
$profile->validate();
}
}
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
$this->renderPartial('_form', array('model' => $model, 'profile' => $profile), false, true);
Yii::app()->end();
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
示例6: actionRecovery
/**
* Recovery password
*/
public function actionRecovery () {
$form = new UserRecoveryForm;
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = ((isset($_GET['email']))?$_GET['email']:'');
$activkey = ((isset($_GET['activkey']))?$_GET['activkey']:'');
if ($email&&$activkey) {
$form2 = new UserChangePassword;
$find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
if(isset($find)&&$find->activkey==$activkey) {
if(isset($_POST['UserChangePassword'])) {
$form2->attributes=$_POST['UserChangePassword'];
if($form2->validate()) {
$find->password = Yii::app()->controller->module->encrypting($form2->password);
$find->activkey=Yii::app()->controller->module->encrypting(microtime().$form2->password);
if ($find->status==0) {
$find->status = 1;
}
$find->save();
Yii::app()->user->setFlash('success',UserModule::t("New password is saved."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
}
$this->render('changepassword',array('model'=>$form2));
} else {
Yii::app()->user->setFlash('error',UserModule::t("Incorrect recovery link."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if(isset($_POST['UserRecoveryForm'])) {
$form->attributes=$_POST['UserRecoveryForm'];
if($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$activation_url = 'http://' . $_SERVER['HTTP_HOST'].$this->createUrl(implode(Yii::app()->controller->module->recoveryUrl),array("activkey" => $user->activkey, "email" => $user->email));
$subject = UserModule::t("You have requested a password recovery of {site_name}",
array(
'{site_name}'=>Yii::app()->name,
));
$message = UserModule::t("You have requested our password recovery services. To receive a new password, go to {activation_url}. Sincerely, Team of {site_name}",
array(
'{site_name}'=>Yii::app()->name,
'{activation_url}'=>$activation_url,
));
UserModule::sendMail($user->email,$subject,$message);
Yii::app()->user->setFlash('info',UserModule::t("Please check your email. Further instructions are sent to your email address."));
$this->refresh();
}
}
$this->render('recovery',array('model'=>$form));
}
}
}
示例7: actionSendEmail
public function actionSendEmail()
{
Yii::import('application.modules.user.UserModule');
$email = urldecode($_POST['email']);
$subject = urldecode($_POST['subject']);
$message = urldecode($_POST['message']);
if ($email) {
UserModule::sendMail($email, $subject, $message);
}
}
示例8: actionRegistration
/**
* Registration user
*/
public function actionRegistration()
{
$model = new RegistrationForm();
$profile = new Profile();
$profile->regMode = true;
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->profileUrl);
} else {
if (isset($_POST['RegistrationForm'])) {
$model->attributes = $_POST['RegistrationForm'];
$profile->attributes = $_POST['Profile'];
if ($model->validate() && $profile->validate()) {
$soucePassword = $model->password;
$model->activkey = UserModule::encrypting(microtime() . $model->password);
$model->password = UserModule::encrypting($model->password);
$model->verifyPassword = UserModule::encrypting($model->verifyPassword);
$model->createtime = time();
$model->lastvisit = (Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin ? time() : 0;
$model->superuser = 0;
$model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
if ($model->save()) {
$profile->user_id = $model->id;
$profile->save();
// assign user the 'Authenticated' role for Rights module
$authenticatedName = Rights::module()->authenticatedName;
Rights::assign($authenticatedName, $model->id);
// end of change
if (Yii::app()->controller->module->sendActivationMail) {
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
UserModule::sendMail($model->email, UserModule::t("You have registered at {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate your account. Go to {activation_url}", array('{activation_url}' => $activation_url)));
}
if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
$identity = new UserIdentity($model->username, $soucePassword);
$identity->authenticate();
Yii::app()->user->login($identity, 0);
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Contact Admin to activate your account."));
} elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
} elseif (Yii::app()->controller->module->loginNotActiv) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email or login."));
} else {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email."));
}
$this->refresh();
}
}
}
}
$this->render('/user/registration', array('form' => $model, 'profile' => $profile));
}
}
示例9: actionRecovery
/**
* Recovery password
*/
public function actionRecovery()
{
$form = new UserRecoveryForm();
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email && $activkey) {
$form2 = new UserChangePassword();
$find = User::model()->notsafe()->findByAttributes(array('email' => $email));
if (isset($find) && $find->activkey == $activkey) {
if (isset($_POST['UserChangePassword'])) {
$form2->attributes = $_POST['UserChangePassword'];
if ($form2->validate()) {
$find->password = Yii::app()->controller->module->encrypting($form2->password);
$find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
if ($find->status == 0) {
$find->status = 1;
}
$find->save();
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
}
$this->render('changepassword', array('form' => $form2));
} else {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Incorrect recovery link."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if (isset($_POST['UserRecoveryForm'])) {
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email));
$subject = UserModule::t("Bạn đã có yêu cầu phục hồi mật khẩu từ {site_name}", array('{site_name}' => Yii::app()->name));
$message = UserModule::t("Bạn đã có yêu cầu phục hồi mật khẩu từ {site_name}. Để nhận được mật khẩu mới bạn hãy vào link sau: {activation_url}.", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
if (Yii::app()->request->isAjaxRequest) {
jsonOut(array('error' => false, 'msg' => 'Xin vui lòng kiểm tra email. Một hướng dẫn đã chuyển đến email của bạn.'), false);
}
UserModule::sendMail($user->email, $subject, $message);
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. An instructions was sent to your email address."));
$this->refresh();
} else {
if (Yii::app()->request->isAjaxRequest) {
jsonOut(array('error' => true, 'msg' => CActiveForm::validate($form)));
}
}
}
$this->render('recovery', array('form' => $form));
}
}
}
示例10: actionRecovery
/**
* Recovery password
*/
public function actionRecovery()
{
$form = new UserRecoveryForm();
Yii::app()->theme = 'client';
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email && $activkey) {
$form2 = new UserChangePassword();
$find = User::model()->notsafe()->findByAttributes(array('email' => $email));
if (isset($find) && $find->activkey == $activkey) {
if (isset($_POST['UserChangePassword'])) {
$form2->attributes = $_POST['UserChangePassword'];
if ($form2->validate()) {
$find->password = Yii::app()->controller->module->encrypting($form2->password);
$find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
if ($find->status == 0) {
$find->status = 1;
}
$find->save();
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
}
$this->render('changepassword', array('form' => $form2));
} else {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Incorrect recovery link."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if (isset($_POST['UserRecoveryForm'])) {
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$user->activkey = UserModule::encrypting(microtime() . $user->password);
$user->save();
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email));
echo '<br>' . $activation_url;
echo '<br>' . Yii::app()->controller->module->recoveryUrl;
$this->createUrl(implode(Yii::app()->controller->module->recoveryUrl));
$subject = UserModule::t("You have requested the password recovery site {site_name}", array('{site_name}' => Yii::app()->name));
$message = UserModule::t("You have requested the password recovery site {site_name}. To receive a new password, go to <a href=\"{activation_url}\">{activation_url}</a>.", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
UserModule::sendMail($user->email, $subject, $message);
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. An instructions was sent to your email address."));
$this->refresh();
}
}
$this->render('recovery', array('form' => $form));
}
}
}
示例11: actionRegistration
/**
* Registration user
*/
public function actionRegistration()
{
$model = new RegistrationForm();
if (isset($_GET['role']) && $_GET['role'] == 'Customer') {
$role = 'Customer';
} elseif (isset($_GET['role']) && $_GET['role'] == 'Author') {
$role = 'Author';
} elseif (isset($_GET['role']) && $_GET['role'] == 'Manager') {
$role = 'Manager';
} else {
$role = 'Customer';
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'simple-registration-form') {
echo UActiveForm::validate($model);
Yii::app()->end();
}
if (Yii::app()->user->id && (!Yii::app()->user->hasFlash('reg_success') && !Yii::app()->user->hasFlash('reg_failed'))) {
$this->redirect(Yii::app()->controller->module->profileUrl);
} else {
if (isset($_POST['RegistrationForm'])) {
$model->attributes = $_POST['RegistrationForm'];
if ($model->validate()) {
$soucePassword = $this->generate_password(8);
$model->password = UserModule::encrypting($soucePassword);
$model->superuser = 0;
$model->status = 1;
$model->username = $model->email;
if ($model->save()) {
$AuthAssignment = new AuthAssignment();
$AuthAssignment->attributes = array('itemname' => $role, 'userid' => $model->id);
$AuthAssignment->save();
$login_url = '<a href="' . $this->createAbsoluteUrl('/user/login') . '">' . Yii::app()->name . '</a>';
UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("You have registred from {login_url}<br /><br />Your password: {pass}", array('{login_url}' => $login_url, '{pass}' => $soucePassword)));
$identity = new UserIdentity($model->username, $soucePassword);
$identity->authenticate();
Yii::app()->user->login($identity, 0);
//$this->redirect(Yii::app()->controller->module->returnUrl);
Yii::app()->user->setFlash('reg_success', UserModule::t("Thank you for your registration. Password has been sent to your e-mail. Please check your e-mail ({{login}}) before start.", ['{{login}}' => $model->email]));
$this->refresh();
} else {
Yii::app()->user->setFlash('reg_failed', UserModule::t("Sorry, something wrong... :("));
$this->refresh();
}
}
}
Yii::app()->theme = 'client';
$this->render('/user/registration', array('model' => $model, 'role' => $role));
}
}
示例12: actionRecovery
/**
* Recovery password
*/
public function actionRecovery()
{
$form = new UserRecoveryForm();
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email && $activkey) {
$form2 = new UserChangePassword();
$find = User::model()->notsafe()->findByAttributes(array('email' => $email));
if (isset($find) && $find->activkey == $activkey) {
if (isset($_POST['UserChangePassword'])) {
$form2->attributes = $_POST['UserChangePassword'];
if ($form2->validate()) {
$find->password = Yii::app()->controller->module->encrypting($form2->password);
$find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
if ($find->status == 0) {
$find->status = 1;
}
$find->save();
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
}
$this->render('changepassword', array('form' => $form2));
} else {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Incorrect recovery link."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if (isset($_POST['UserRecoveryForm'])) {
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email));
$subject = UserModule::t("You have requested the password recovery site {site_name}", array('{site_name}' => Yii::app()->name));
$message = UserModule::t('<p> You have requested to reset your {site_name}. password, No problem! Click the link below to create a new password </p> <a href="' . $activation_url . '">{activation_url}</a>.<br> If you did not request to change your password, let us know and we’ll make sure everything is okay with your account. You can email us at support@instanttop.com <p>Kind regards,<br>
Your' . Yii::app()->name . ' team </p>', array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
UserModule::sendMail($user->email, $subject, $message);
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. An instructions was sent to your email address."));
$this->refresh();
}
}
$this->render('recovery', array('form' => $form));
}
}
}
示例13: actionRecovery
/**
* Recovery password
*/
public function actionRecovery()
{
$form = new UserRecoveryForm();
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email && $activkey) {
$form2 = new UserChangePassword();
$find = AUserLogin::model()->scope_select_all()->findByAttributes(array('login_name' => $email));
if (isset($find) && $find->userLogin2userDetails->activkey == $activkey) {
if (isset($_POST['UserChangePassword'])) {
$form2->attributes = $_POST['UserChangePassword'];
if ($form2->validate()) {
$find->pwd = Yii::app()->controller->module->encrypting($form2->password);
$find->userLogin2userDetails->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
if ($find->userLogin2userDetails->is_active == 0) {
$find->userLogin2userDetails->is_active = 1;
}
$find->save();
$find->userLogin2userDetails->save();
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
}
$this->render('changepassword', array('form' => $form2));
} else {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Incorrect recovery link."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if (isset($_POST['UserRecoveryForm'])) {
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = AUserLogin::model()->scope_select_all()->findByAttributes(array('login_name' => $form->login_or_email));
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->userLogin2userDetails->activkey, "email" => $user->login_name));
$subject = UserModule::t("You have requested the password recovery for {site_name}", array('{site_name}' => Yii::app()->name));
$message = UserModule::t("Hi, \n You have requested the password recovery for {site_name}. To receive a new password, go to {activation_url}. \n Regards, \n tw.in team", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
UserModule::sendMail($user->login_name, $subject, $message);
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. Instructions has been sent to your email address."));
$this->refresh();
}
}
$this->render('recovery', array('form' => $form));
}
}
}
示例14: actionRecovery
/**
* Recovery password
*/
public function actionRecovery()
{
$form = new UserRecoveryForm();
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email && $activkey) {
$form2 = new UserChangePassword();
$find = User::model()->notsafe()->findByAttributes(array('email' => $email));
if (isset($find) && $find->activkey == $activkey) {
if (isset($_POST['UserChangePassword'])) {
$form2->attributes = $_POST['UserChangePassword'];
if ($form2->validate()) {
$find->password = Yii::app()->controller->module->encrypting($form2->password);
$find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
if ($find->status == 0) {
$find->status = 1;
}
$find->save();
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Новый пароль сохранен."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
}
$this->render('changepassword', array('model' => $form2));
} else {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Неверная ссылка."));
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if (isset($_POST['UserRecoveryForm'])) {
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email));
$subject = UserModule::t("Запрос на восстанвление пароля на сайте {site_name}", array('{site_name}' => Yii::app()->name));
$message = UserModule::t("Вы запросили восстановление пароля на сайте {site_name}. Для получения нового пароля, перейдите по ссылке <br> {activation_url}.", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
UserModule::sendMail($user->email, $subject, $message);
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Ссылка на восстановление пароля отправлена на вашу почту."));
$this->refresh();
}
}
$this->render('recovery', array('model' => $form));
}
}
}
示例15: actionRecovery
/**
* Recovery password
*/
public function actionRecovery()
{
$form = new UserRecoveryForm();
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email && $activkey) {
$form2 = new UserChangePassword();
$find = User::model()->notsafe()->findByAttributes(array('email' => $email));
if (isset($find) && $find->activkey == $activkey) {
if (isset($_POST['UserChangePassword'])) {
$form2->attributes = $_POST['UserChangePassword'];
if ($form2->validate()) {
$find->password = Yii::app()->controller->module->encrypting($form2->password);
$find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
if ($find->status == 0) {
$find->status = 1;
}
$find->save();
Yii::app()->user->setFlash('success', "New password is saved.");
$this->redirect(Yii::app()->controller->module->loginUrl);
}
}
$this->render('/recovery/changepassword', array('form' => $form2));
} else {
Yii::app()->user->setFlash('error', "Incorrect recovery link.");
$this->redirect(Yii::app()->controller->module->recoveryUrl);
}
} else {
if (isset($_POST['UserRecoveryForm'])) {
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email));
$subject = UserModule::t("[{site_name}] Password Recovery", array('{site_name}' => Yii::app()->params['system_name']));
$message = UserModule::t("recovery password can be done by following the link: <br>\n\t\t\t\t\t\t\t\t\t\t {activation_url}. <br><br><br>\n\t\t\t\t\t\t\t\t\t\t Best regard {site_name} :)<br>" . date("M d-m-Y | H:i") . " WIB", array('{site_name}' => Yii::app()->params['system_name'], '{activation_url}' => $activation_url));
UserModule::sendMail($user->email, $subject, $message);
Yii::app()->user->setFlash('info', "Please check your email. An instructions was sent to your email address.");
$this->refresh();
}
}
$this->render('/recovery/recovery', array('form' => $form));
}
}
}