本文整理汇总了PHP中UserHelper::generateActivationToken方法的典型用法代码示例。如果您正苦于以下问题:PHP UserHelper::generateActivationToken方法的具体用法?PHP UserHelper::generateActivationToken怎么用?PHP UserHelper::generateActivationToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserHelper
的用法示例。
在下文中一共展示了UserHelper::generateActivationToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
/**
*
* @param unknown $slug
*/
public function actionEdit($slug)
{
$user = User::model()->findbyAttributes(array('slug' => $slug, 'status' => User::STATUS_ACTIVE));
if (isset($user)) {
// save the current mail
$oldMail = $user->email;
// if there isn't an instance of UserPersonalInfo we have to create it.
if (!isset($user->personalInfo)) {
$user->personalInfo = new UserPersonalInfo();
}
if (isset($_POST['User']) && isset($_POST['UserPersonalInfo'])) {
$user->attributes = $_POST['User'];
// check if at least one of these field is setted
if (!empty($_POST['UserPersonalInfo']['first_name']) || !empty($_POST['UserPersonalInfo']['last_name']) || !empty($_POST['UserPersonalInfo']['gender']) || !empty($_POST['UserPersonalInfo']['birthdate'])) {
$user->personalInfo->attributes = $_POST['UserPersonalInfo'];
$user->personalInfo->user_id = $user->id;
}
// used to check if the user has already changed his own mail
if ($oldMail != $user->email) {
$user->setScenario('editProfile');
}
// validation of the models
$this->performAjaxValidationProfileForm($user);
//verify if the mail was changed
if ($oldMail != $user->email) {
$usersMetadata = new UserMetadata();
$usersMetadata->user_id = $user->id;
$usersMetadata->key = User::METADATA_KEY_EMAIL_CHANGE_NEW_ADDRESS;
$usersMetadata->value = $user->email;
$usersMetadata->save();
$usersMetadata2 = new UserMetadata();
$usersMetadata2->user_id = $user->id;
$usersMetadata2->key = User::METADATA_KEY_EMAIL_CHANGE_TOKEN;
$usersMetadata2->value = UserHelper::generateActivationToken();
$usersMetadata2->save();
//confirmation mail
$activation_link = Yii::app()->createAbsoluteUrl('profile/email?token=' . $usersMetadata2->value);
BasicNotifier::sendTemplatedEmail($oldMail, Yii::t('ProfileModule.edit', 'email.subject.changeEmail'), 'profile/change_email_confirmation', array('{CHANGE_EMAIL_ADDRESS}' => $user->email, '{CHANGE_EMAIL_CONFIRMATION_LINK}' => $activation_link), Yii::app()->session['lang']);
/* set flash messages */
Yii::app()->user->setFlash('pending', 'email');
//assign to as mail of the user his old mail. The new mail before to replace the old one have to be confirmed
$user->email = $oldMail;
}
/* save user and related models */
$user->withRelated->save(true, array('personalInfo'));
/* set flash messages */
Yii::app()->user->setFlash('success', true);
/* back to profile */
$this->redirect(Yii::app()->createUrl('profile'));
}
$this->render('edit', array('user' => $user, 'userPersonalInfo' => $user->personalInfo, 'slug' => $slug));
}
}