PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
/
forms
<?php class BLoginForm extends CFormModel { public $email; public $password; public $remember_me; private $_identity; public $module_id; public $invation_id; public $invation_code; protected $tokens; public function rules() { return array( array('email,password', 'required'), array('invation_id,invation_code', 'required','on' => 'acceptInvitation'), array('email', 'email'), array('invation_id', 'exist','className' => 'BContributor_Invites','attributeName' => 'id','criteria' => array('condition' => 'is_active=1'),'on' => 'acceptInvitation'), array('invation_code', 'exist','className' => 'BContributor_Invites','attributeName' => 'code','criteria' => array('condition' => 'is_active=1'),'on' => 'acceptInvitation'), array('email', 'exist', 'className' => 'User','criteria' => array('condition' => 'is_active=1')), array('password', 'PasswordValidator', 'className' => 'User', 'idAttribute' => 'email', 'skipOnError' => true), array('invation_id,invation_code,email, password, remember_me', 'safe'), ); } public function login() { if ($this->validate()) { $this->_identity = new BUserIdentity($this->email, $this->password); $this->_identity->authenticate(); if ($this->_identity->errorCode == UserIdentity::ERROR_NONE) { if ($this->remember_me == true) { $duration = 3600 * 24 * 30; } // 30 days else { $duration = 0; } Yii::app()->user->login($this->_identity, $duration); return true; } elseif ($this->_identity->errorCode == BUserIdentity::ERROR_USER_PERMISSION) { $this->addError('email', Yii::app()->lang->term('ERROR_USER_PERMISSION')); return false; } } return false; } public function getIdentity() { return $this->_identity; } public function acceptInvitation($invation_id, $invation_code) { $this->scenario = 'acceptInvitation'; $this->invation_id = $invation_id; $this->invation_code = $invation_code; if ($this->validate()) { $invite = BContributor_Invites::model()->findByPK($this->invation_id); $this->_identity = new BUserIdentity($this->email, $this->password); $this->_identity->authenticate(); if ($this->_identity->errorCode == UserIdentity::ERROR_NONE) { if ($this->remember_me == true) { $duration = 3600 * 24 * 30; } // 30 days else { $duration = 0; } Yii::app()->user->login($this->_identity, $duration); $invite->is_active = 0; $invite->save(); return true; } elseif ($this->_identity->errorCode == BUserIdentity::ERROR_USER_PERMISSION) { $c = new BContributor(); $c->setIsNewRecord(true); $c->user_id = $this->_identity->getId(); $c->role = $invite->permission; $c->save(); $this->_identity->authenticate(); $invite->is_active = 0; $invite->save(); if ($this->_identity->errorCode == UserIdentity::ERROR_NONE) { if ($this->remember_me == true) { $duration = 3600 * 24 * 30; } // 30 days else { $duration = 0; } Yii::app()->user->login($this->_identity, $duration); return true; } $this->addError('email', Yii::app()->lang->term('ERROR_USER_PERMISSION')); } } return false; } }
[+]
..
[-] ColorForm.php
[edit]
[-] ProfileResetPassForm.php
[edit]
[-] NewsCommentForm.php
[edit]
[-] SkinForm.php
[edit]
[-] PageForm.php
[edit]
[-] BLoginForm.php
[edit]
[-] UserResetPassForm.php
[edit]
[-] ModuleForm.php
[edit]
[-] NewsForm.php
[edit]
[-] ContributorForm.php
[edit]
[-] News_CategoriesForm.php
[edit]
[-] InviteForm.php
[edit]
[-] NewsTagForm.php
[edit]
[-] DomainForm.php
[edit]