本文整理汇总了PHP中YumUser::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP YumUser::setPassword方法的具体用法?PHP YumUser::setPassword怎么用?PHP YumUser::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YumUser
的用法示例。
在下文中一共展示了YumUser::setPassword方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new User.
*/
public function actionCreate()
{
$user = new YumUser();
if (Yum::hasModule('profile')) {
$profile = new YumProfile();
}
$passwordform = new YumUserChangePassword();
// When opening a empty user creation mask, we most probably want to
// insert an _active_ user
if (!$user->status) {
$user->status = 1;
}
if (isset($_POST['YumUser'])) {
$user->attributes = $_POST['YumUser'];
if (isset($_POST['YumUserChangePassword'])) {
if ($_POST['YumUserChangePassword']['password'] == '') {
Yii::import('user.components.EPasswordGenerator');
$generatorOptions = Yum::module()->passwordGeneratorOptions;
$password = EPasswordGenerator::generate($generatorOptions['length'], $generatorOptions['capitals'], $generatorOptions['numerals'], $generatorOptions['symbols']);
$user->setPassword($password);
Yum::setFlash(Yum::t('The generated Password is {password}', array('{password}' => $password)));
} else {
$passwordform->attributes = $_POST['YumUserChangePassword'];
if ($passwordform->validate()) {
$user->setPassword($_POST['YumUserChangePassword']['password']);
}
}
}
$user->validate();
if (Yum::hasModule('profile') && isset($_POST['YumProfile'])) {
$profile->attributes = $_POST['YumProfile'];
}
if (!$user->hasErrors()) {
$user->activationKey = CPasswordHelper::hashPassword(microtime() . $user->password, Yum::module()->passwordHashCost);
if ($user->username == '' && isset($profile)) {
$user->username = $profile->email;
}
if (isset($profile)) {
$profile->validate();
}
if (!$user->hasErrors() && !$passwordform->hasErrors()) {
$user->save();
if (isset($_POST['YumUser']['roles'])) {
$user->syncRoles($_POST['YumUser']['roles']);
} else {
$user->syncRoles();
}
if (isset($profile)) {
$profile->user_id = $user->id;
$profile->save(array('user_id'), false);
}
$this->redirect(array('view', 'id' => $user->id));
}
}
}
$this->render('create', array('user' => $user, 'passwordform' => $passwordform, 'profile' => isset($profile) ? $profile : null));
}
示例2: actionCreate
/**
* Creates a new User.
*/
public function actionCreate() {
$model = new YumUser;
if(Yum::hasModule('profile'))
$profile = new YumProfile;
$passwordform = new YumUserChangePassword;
// When opening a empty user creation mask, we most probably want to
// insert an _active_ user
if(!isset($model->status))
$model->status = 1;
if(isset($_POST['YumUser'])) {
$model->attributes=$_POST['YumUser'];
if(Yum::hasModule('role'))
$model->roles = Relation::retrieveValues($_POST);
if(Yum::hasModule('profile') && isset($_POST['YumProfile']) )
$profile->attributes = $_POST['YumProfile'];
if(isset($_POST['YumUserChangePassword'])) {
if($_POST['YumUserChangePassword']['password'] == '') {
$password = YumUser::generatePassword();
$model->setPassword($password);
Yum::setFlash(Yum::t('The generated Password is {password}', array(
'{password}' => $password)));
} else {
$passwordform->attributes = $_POST['YumUserChangePassword'];
if($passwordform->validate())
$model->setPassword($_POST['YumUserChangePassword']['password']);
}
}
$model->activationKey = YumUser::encrypt(microtime() . $model->password);
if($model->username == '' && isset($profile))
$model->username = $profile->email;
$model->validate();
if(isset($profile))
$profile->validate();
if(!$model->hasErrors()
&& !$passwordform->hasErrors()) {
$model->save();
if(isset($profile)) {
$profile->user_id = $model->id;
$profile->save(array('user_id'), false);
}
Yii::import('application.modules.registration.controllers.YumRegistrationController');
YumRegistrationController::sendRegistrationEmail($model);
$this->redirect(array('view', 'id'=>$model->id));
}
}
$this->render('create',array(
'model' => $model,
'passwordform' => $passwordform,
'profile' => isset($profile) ? $profile : null,
));
}
示例3: generateDemoUser
public static function generateDemoUser($roles, $password, $status)
{
$firstnames = array('Kacie', 'Minh', 'Tammera', 'Rocco', 'Violet', 'Suzi', 'Lavone', 'Judie', 'Nathaniel', 'Lena', 'Garth', 'Maryjane', 'Nyla', 'Marisha', 'Karla', 'Virgina', 'Conception', 'Jillian', 'Chere', 'Orpha', 'Damaris', 'Freeda', 'Rosalyn', 'Dierdre', 'Rae', 'Joel', 'Willia', 'Megan', 'Ozell', 'Enola', 'Esteban', 'Farah', 'Trevor', 'Joslyn', 'Lydia', 'Latoyia', 'Doretha', 'Kristine', 'Loraine', 'In', 'Ebonie', 'Rhiannon', 'Chase', 'Yu', 'Pamula', 'Akilah', 'Teofila', 'Elnora', 'Mike', 'Florida');
$lastnames = array('Tosi', 'Bicknell', 'Deguzman', 'Elizalde', 'Gillock', 'Groff', 'Bradish', 'Hilario', 'Cashen', 'Peralez', 'Hyre', 'Leverich', 'Asher', 'Mcray', 'Pearson', 'Montana', 'Mattingly', 'Christofferse', 'Trybus', 'Danford', 'Pennel', 'Singletary', 'Cosme', 'Felt', 'Formby', 'Hurrell', 'Aguero', 'Arnold', 'Holmstrom', 'Watchman', 'Busch', 'Osbourn', 'Sine', 'Mcglinchey', 'Sherrick', 'Meyerhoff', 'Chaffins', 'Cranor', 'Macmillan', 'Killen', 'Gambill', 'Delosantos', 'Bevill', 'Giannini', 'Rhein', 'Sadberry', 'Baird');
$firstname = $firstnames[rand(0, count($firstnames) - 1)];
$lastname = $lastnames[rand(0, count($lastnames) - 1)];
$user = new YumUser();
$user->username = sprintf('%s_%s', $firstname, $lastname);
$user->roles = array($_POST['role']);
$user->setPassword($_POST['password']);
$user->status = $_POST['status'];
$user->createtime = time();
if ($user->save()) {
if (Yum::hasModule('profile')) {
$profile = new YumProfile();
$profile->user_id = $user->id;
$profile->firstname = $firstname;
$profile->lastname = $lastname;
$profile->email = sprintf('%s@%s.com', $firstname, $lastname);
$profile->save();
}
}
}