本文整理汇总了PHP中Y::module方法的典型用法代码示例。如果您正苦于以下问题:PHP Y::module方法的具体用法?PHP Y::module怎么用?PHP Y::module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Y
的用法示例。
在下文中一共展示了Y::module方法的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: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
if (strpos($this->username,"@")) {
$user=User::model()->notsafe()->findByAttributes(array('email'=>$this->username));
} else {
$user=User::model()->notsafe()->findByAttributes(array('username'=>$this->username));
}
if($user===null)
if (strpos($this->username,"@")) {
$this->errorCode=self::ERROR_EMAIL_INVALID;
} else {
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
else if(Y::module('users')->encrypting($this->password)!==$user->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else if($user->status==0&&Y::module('users')->loginNotActiv==false)
$this->errorCode=self::ERROR_STATUS_NOTACTIV;
else if($user->status==-1)
$this->errorCode=self::ERROR_STATUS_BAN;
else {
$this->_id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
}
示例3: curBaseUrl
public static function curBaseUrl()
{
$baseUrl = '/';
if (Y::module())
$baseUrl.=Y::module()->id.'/';
$baseUrl .= Y::controller()->id;
return $baseUrl;
}
示例4: relations
/**
* @return array relational rules.
*/
public function relations()
{
$relations = array(
'profile'=>array(self::HAS_ONE, 'Profile', 'user_id'),
);
if (isset(Y::module('users')->relations)) $relations = array_merge($relations,Y::module('users')->relations);
return $relations;
}
示例5: renderBlock
public function renderBlock($alias)
{
if (!isset($this->cat)) {
if (($module = Y::module()) != null) {
$this->cat = $module->category;
}
}
if (($block = $this->cat->getBlock($alias)) === null)
return '{{ ' . $alias . ' }}';
return $block->renderBlock($this->cat);
}
示例6: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('User', array(
'criteria'=>array(
'condition'=>'status>'.User::STATUS_BANED,
),
'pagination'=>array(
'pageSize'=>Y::module()->user_page_size,
),
));
$this->render('/user/index',array(
'dataProvider'=>$dataProvider,
));
}
示例7: getUpdateUrl
public function getUpdateUrl()
{
return Y::url(Y::module()->getId().'/records/update', array('pk' => $this->pk, 'catPk'=>$this->category->pk));
}
示例8:
<ul class="actions">
<?php
if(UserModule::isAdmin()) {
?>
<li><?php echo CHtml::link(Users::t('Manage User'),array('/user/admin')); ?></li>
<?php
}
?>
<li><?php echo CHtml::link(Users::t('Profile'),Y::module()->profileUrl); ?></li>
<li><?php echo CHtml::link(Users::t('Edit'),Y::module()->editProfileUrl); ?></li>
<li><?php echo CHtml::link(Users::t('Change password'),Y::module()->changePassUrl); ?></li>
<li><?php echo CHtml::link(Users::t('Logout'),Y::module()->logoutUrl); ?></li>
<li><?php echo CHtml::link(Yii::t('interface', 'CreatePost'), Users::url("posts/create",array('lang' => Yii::app()->language, 'add_type'=>'post'))); ?></li>
<li><?php echo CHtml::link(Yii::t('interface', 'CreateQuestion'),Users::url("posts/create",array('lang' => Yii::app()->language, 'add_type'=>'question'))); ?></li>
</ul>
示例9: 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));
}
}
示例10:
); ?>
<?php echo CHtml::errorSummary($model); ?>
<div class="row">
<?php echo $form->label($model,'username'); ?>
<?php echo $form->textField($model,'username') ?>
</div>
<div class="row">
<?php echo $form->label($model,'password'); ?>
<?php echo $form->passwordField($model,'password') ?>
</div>
<!--
<div class="row">
<p class="hint">
<?php echo CHtml::link(Users::t("Register"),$this->module->registrationUrl); ?> | <?php echo CHtml::link(Users::t("Lost Password?"),Y::module('users')->recoveryUrl); ?>
</p>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model,'rememberMe'); ?>
<?php echo $form->label($model,'rememberMe'); ?>
</div>
-->
<div class="row submit">
<?php echo CHtml::submitButton('Войти'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
示例11: actionLogout
/**
* Logout the current user and redirect to returnLogoutUrl.
*/
public function actionLogout()
{
Yii::app()->user->logout();
$this->redirect(Y::module()->returnLogoutUrl);
}
示例12: actionAdmin
/**
* Manages all models.
*/
public function actionAdmin()
{
$dataProvider=new CActiveDataProvider('ProfileField', array(
'pagination'=>array(
'pageSize'=>Y::module()->fields_page_size,
),
'sort'=>array(
'defaultOrder'=>'position',
),
));
$this->render('admin',array(
'dataProvider'=>$dataProvider,
));
}
示例13: attributeLabels
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
$labels = array(
'user_id' => Users::t('User ID'),
);
$model=$this->getFields();
foreach ($model as $field)
$labels[$field->varname] = ((Y::module('users')->fieldsMessage)?Users::t($field->title,array(),Y::module('users')->fieldsMessage):Users::t($field->title));
return $labels;
}
示例14: tableName
/**
* @return string the associated database table name
*/
public function tableName()
{
return Y::module('users')->tableProfileFields;
}
示例15: behaviors
public function behaviors(){
return Y::module('users')->getBehaviorsFor(get_class($this));
}