本文整理汇总了PHP中YumUser::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP YumUser::validate方法的具体用法?PHP YumUser::validate怎么用?PHP YumUser::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YumUser
的用法示例。
在下文中一共展示了YumUser::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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,
));
}
示例2: 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));
}