PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
<?php class BUserIdentity extends UserIdentity { const ERROR_USER_PERMISSION = 114; public $token; public $is_contributor = false; public function __construct($email, $password) { $this->_email = $email; $this->_password = $password; } public static function getUserFromToken($token) { $user_id = $token->id; $user = User::model()->findByPk($user_id); if ($user) { $userIdentity = new UserIdentity(1, 1); $userIdentity->_id = $user->id; $userIdentity->_email = $user->email; $userIdentity->_name = $user->name; $userIdentity->errorCode = self::ERROR_NONE; } return $userIdentity; } public function token_authenticate() { $login_session = User_Session::model()->find('token = :token', array(':token' => strtolower($this->token))); $user = User::model()->findByPk((int)$login_session->user_id); if ($user === null) { $this->errorMessage = 'ERROR_USERNAME_INVALID'; $this->errorCode = self::ERROR_USERNAME_INVALID; return; } elseif ($user->is_active == 0) { $this->errorCode = self::ERROR_USER_INACTIVE; return; }else { $this->_id = $user->id; $this->_email = $user->email; $this->_name = $user->name; $this->_is_admin = $user->is_admin == 1; $this->errorCode = self::ERROR_NONE; } $auth = Yii::app()->authManager; $is_has_right = false; if ($this->getId() != Yii::app()->site->model->owner_id) { $contributor = BContributor::model()->find('user_id=:user_id', array(':user_id' => $this->getId())); if (isset($contributor)) { $role = $contributor->role; $this->is_contributor = true; $this->errorCode = self::ERROR_NONE; if (!$auth->isAssigned($role, $this->_id)) { $auth->assign($role, $this->_id); } $is_has_right = true; } } if ($this->getId() == Yii::app()->site->model->owner_id || $this->getIsAdmin()) { $is_has_right = true; } if (!$is_has_right) { $this->errorMessage = 'ERROR_USER_PERMISSION'; $this->errorCode = self::ERROR_USER_PERMISSION; } } public function authenticate() { parent::authenticate(); if ($this->errorCode == self::ERROR_NONE) { $auth = Yii::app()->authManager; $is_has_right = false; if ($this->getId() != Yii::app()->site->model->owner_id) { $contributor = BContributor::model()->find('user_id=:user_id', array(':user_id' => $this->getId())); if (isset($contributor)) { $role = $contributor->role; $this->is_contributor = true; $this->errorCode = self::ERROR_NONE; if (!$auth->isAssigned($role, $this->_id)) { $auth->assign($role, $this->_id); } $is_has_right = true; } } if ($this->getId() == Yii::app()->site->model->owner_id || $this->getIsAdmin()) { $is_has_right = true; } if (!$is_has_right) { $this->errorMessage = 'ERROR_USER_PERMISSION'; $this->errorCode = self::ERROR_USER_PERMISSION; } } return $this->errorCode == self::ERROR_NONE; } }
[+]
..
[-] BTag.php
[edit]
[-] BActiveRecord.php
[edit]
[-] BModule.php
[edit]
[-] BPages.php
[edit]
[-] BComments.php
[edit]
[-] BNews_News_Category.php
[edit]
[-] BNewsModule.php
[edit]
[-] BAuthAssignment.php
[edit]
[-] BNewsCategory.php
[edit]
[-] BConfigurations.php
[edit]
[-] BPages_Elements.php
[edit]
[-] BNews_Comments.php
[edit]
[-] BNews_Categories.php
[edit]
[-] BUsers.php
[edit]
[-] BUserIdentity.php
[edit]
[-] BNews.php
[edit]
[-] BWebUser.php
[edit]
[+]
forms
[-] BColors.php
[edit]
[-] BSkins.php
[edit]
[-] BNews_Tag.php
[edit]
[-] BContributor_Invites.php
[edit]
[-] BContributor.php
[edit]