本文整理汇总了PHP中Y::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Y::user方法的具体用法?PHP Y::user怎么用?PHP Y::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Y
的用法示例。
在下文中一共展示了Y::user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
// Иерархию ролей расположим в файле auth.php в директории config приложения
if($this->authFile===null){
$this->authFile=Yii::getPathOfAlias('application.config.auth').'.php';
}
parent::init();
// Для гостей у нас и так роль по умолчанию guest.
if(!Y::isGuest()){
// Связываем роль, заданную в БД с идентификатором пользователя,
// возвращаемым UserIdentity.getId().
$this->assign(Y::user()->role, Y::userId());
}
}
示例2: actionRegistration
/**
* Registration user
*/
public function actionRegistration()
{
if(Y::module()->isRegistrationClose) $this->redirect('close');
$model = new RegistrationForm;
$profile=new Profile;
$profile->regMode = true;
// ajax validator
if(isset($_POST['ajax']) && $_POST['ajax']==='registration-form')
Y::end(UActiveForm::validate(array($model,$profile)));
if (Y::userId()) {
$this->redirect(Y::module()->cabinetUrl);
} 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().$soucePassword);
$model->password=UserModule::encrypting($soucePassword);
$model->verifyPassword=UserModule::encrypting($model->verifyPassword);
$model->createtime=time();
$model->lastvisit=((Y::module()->loginNotActiv||(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false))&&Y::module()->autoLogin)?time():0;
$model->superuser=0;
$model->status=((Y::module()->activeAfterRegister)?User::STATUS_ACTIVE:User::STATUS_NOACTIVE);
if ($model->save()) {
$profile->user_id=$model->id;
$profile->save();
if (Y::module()->sendActivationMail) {
$activation_url = $this->createAbsoluteUrl('/user/activation',array("activkey" => $model->activkey, "email" => $model->email));
UserModule::sendMail($model->email,Users::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),Users::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url)));
}
if ((Y::module()->loginNotActiv||(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false))&&Y::module()->autoLogin) {
$identity=new UserIdentity($model->username,$soucePassword);
$identity->authenticate();
Y::user()->login($identity,0);
$this->redirect(Y::module()->returnUrl);
} else {
if (!Y::module()->activeAfterRegister&&!Y::module()->sendActivationMail) {
Y::flash('/user/registration',Users::t("Thank you for your registration. Contact Admin to activate your account."));
} elseif(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false) {
Y::flash('/user/registration',Users::t("Thank you for your registration. Please {{login}}.",array('{{login}}'=>CHtml::link(Users::t('Login'),Y::module()->loginUrl))));
} elseif(Y::module()->loginNotActiv) {
Y::flash('/user/registration',Users::t("Thank you for your registration. Please check your email or login."));
} else {
Y::flash('/user/registration',Users::t("Thank you for your registration. Please check your email."));
}
$this->refresh();
}
}
} else $profile->validate();
}
$this->render('/user/registration',array('model'=>$model,'profile'=>$profile,'lang'=>Yii::app()->language));
}
}