当前位置: 首页>>代码示例>>PHP>>正文


PHP Rights::getAuthorizer方法代码示例

本文整理汇总了PHP中Rights::getAuthorizer方法的典型用法代码示例。如果您正苦于以下问题:PHP Rights::getAuthorizer方法的具体用法?PHP Rights::getAuthorizer怎么用?PHP Rights::getAuthorizer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rights的用法示例。


在下文中一共展示了Rights::getAuthorizer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nameIsAvailable

 /**
  * Makes sure that the name is available.
  * This is the 'nameIsAvailable' validator as declared in rules().
  */
 public function nameIsAvailable($attribute, $params)
 {
     // Make sure that an authorization item with the name does not already exist
     if (Rights::getAuthorizer()->authManager->getAuthItem($this->name) !== null) {
         $this->addError('name', Rights::t('core', 'An item with this name already exists.', array(':name' => $this->name)));
     }
 }
开发者ID:rusli-nasir,项目名称:smsempresayii,代码行数:11,代码来源:AuthItemForm.php

示例2: afterLogin

 /**
  * Actions to be taken after logging in.
  * Overloads the parent method in order to mark superusers.
  * @param boolean $fromCookie whether the login is based on cookie.
  */
 public function afterLogin($fromCookie)
 {
     parent::afterLogin($fromCookie);
     // Mark the user as a superuser if necessary.
     if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) {
         $this->isSuperuser = true;
     }
 }
开发者ID:fobihz,项目名称:cndiesel,代码行数:13,代码来源:RWebUser.php

示例3: init

 /**
  * Initializes the data provider.
  */
 public function init()
 {
     $this->_authorizer = Rights::getAuthorizer();
     // Set properties and generate the data
     $this->setRoles();
     $this->setItems();
     $this->setPermissions();
     $this->setParents();
     $this->generateData();
 }
开发者ID:sharmarakesh,项目名称:edusec-college-management-system,代码行数:13,代码来源:RPermissionDataProvider.php

示例4: fetchData

 /**
  * Fetches the data from the persistent data storage.
  * @return array list of data items
  */
 public function fetchData()
 {
     if ($this->sortable !== null) {
         $this->processSortable();
     }
     if ($this->items === null) {
         $this->items = Rights::getAuthorizer()->getAuthItems($this->type, $this->userId, $this->parent, true, $this->exclude);
     }
     $data = array();
     foreach ($this->items as $name => $item) {
         $data[] = $item;
     }
     return $data;
 }
开发者ID:PTZ2002,项目名称:decoram,代码行数:18,代码来源:RAuthItemDataProvider.php

示例5: getAssignments

 /**
  * Gets the users assignments.
  * @param boolean whether to display the authorization item type.
  * @return string the assignments markup.
  */
 public function getAssignments($displayType = false)
 {
     $authorizer = Rights::getAuthorizer();
     $assignments = $authorizer->authManager->getAuthAssignments($this->getId());
     $items = $authorizer->authManager->getAuthItemsByNames(array_keys($assignments));
     $items = $authorizer->attachAuthItemBehavior($items);
     $assignedItems = array();
     foreach ($items as $itemName => $item) {
         $itemMarkup = $item->getNameText();
         if ($displayType === true) {
             $itemMarkup .= ' (<span class="type-text">' . Rights::getAuthItemTypeName($item->type) . '</span>)';
         }
         $assignedItems[] = $itemMarkup;
     }
     return implode('<br />', $assignedItems);
 }
开发者ID:rusli-nasir,项目名称:smsempresayii,代码行数:21,代码来源:RightsUserBehavior.php

示例6: getAssignments

 /**
  * Returns the authorization items assigned to the user.
  * @return string the assignments markup.
  */
 public function getAssignments()
 {
     if ($this->_assignments !== null) {
         return $this->_assignments;
     } else {
         $authorizer = Rights::getAuthorizer();
         $authAssignments = $authorizer->authManager->getAuthAssignments($this->getId());
         $nestedItems = $authorizer->authManager->getAuthItemsByNames(array_keys($authAssignments), true);
         $assignments = array();
         foreach ($nestedItems as $type => $items) {
             $items = $authorizer->attachAuthItemBehavior($items);
             $assignments[$type] = array();
             foreach ($items as $itemName => $item) {
                 $assignments[$type][$itemName] = $item;
             }
         }
         return $this->_assignments = $assignments;
     }
 }
开发者ID:sundgaarden,项目名称:dashboard,代码行数:23,代码来源:RUserBehavior.php

示例7: afterLogin

 /**
  * Actions to be taken after logging in.
  * Overloads the parent method in order to mark superusers.
  * @param boolean $fromCookie whether the login is based on cookie.
  */
 public function afterLogin($fromCookie)
 {
     parent::afterLogin($fromCookie);
     $command = Yii::app()->db->createCommand();
     $command->select('username,user_url,display_name,email,fbuid,status,recent_login,avatar')->from('{{user}} u')->where('user_id=' . (int) $this->getId())->limit(1);
     $user = $command->queryRow();
     //Add only some neccessary field
     if ($user) {
         // Set User States here
         $this->setState('current_user', $user);
         // Set User Roles here
         $this->setState('current_roles', User::getArrayRoles($this->getId()));
         if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) {
             $this->isSuperuser = true;
         }
     } else {
         throw new CHttpException(503, t('cms', 'Error while Logging into your account. Please try again later.'));
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:24,代码来源:GxcUser.php

示例8: getItemChildren

 /**
  * Returns the children of the specified item.
  * Overloads the parent method to allow for caching.
  * @param mixed $names the parent item name. This can be either a string or an array.
  * The latter represents a list of item names (available since version 1.0.5).
  * @param boolean $allowCaching whether to accept cached data.
  * @return array all child items of the parent
  */
 public function getItemChildren($names, $allowCaching = true)
 {
     // Resolve the key for runtime caching.
     $key = $names === (array) $names ? implode('|', $names) : $names;
     // Get the children from cache if possible.
     if ($allowCaching && isset($this->_itemChildren[$key]) === true) {
         return $this->_itemChildren[$key];
     } else {
         // We only have one name.
         if (is_string($names)) {
             $condition = 'parent=' . $this->db->quoteValue($names);
         } else {
             if ($names === (array) $names && $names !== array()) {
                 foreach ($names as &$name) {
                     $name = $this->db->quoteValue($name);
                 }
                 $condition = 'parent IN (' . implode(', ', $names) . ')';
             } else {
                 $condition = '1';
             }
         }
         $sql = "SELECT name, type, description, bizrule, data\r\n\t\t\t\tFROM {$this->db->quoteTableName($this->itemTable)}, {$this->db->quoteTableName($this->itemChildTable)}\r\n\t\t\t\tWHERE {$condition} AND name=child";
         $children = array();
         foreach ($this->db->createCommand($sql)->queryAll() as $row) {
             if (($data = @unserialize($row['data'])) === false) {
                 $data = null;
             }
             $children[$row['name']] = new CAuthItem($this, $row['name'], $row['type'], $row['description'], $row['bizrule'], $data);
         }
         // Attach the authorization item behavior.
         $children = Rights::getAuthorizer()->attachAuthItemBehavior($children);
         // Cache the result.
         return $this->_itemChildren[$key] = $children;
     }
 }
开发者ID:ednjv,项目名称:SSBMVZLA,代码行数:43,代码来源:RDbAuthManager.php

示例9: fetchData

 /**
  * Fetches the data from the persistent data storage.
  * @return array list of data items
  */
 public function fetchData()
 {
     $this->items = Rights::getAuthorizer()->getAuthItemParents($this->parent->name, $this->type, null, true);
     return parent::fetchData();
 }
开发者ID:sharmarakesh,项目名称:edusec-college-management-system,代码行数:9,代码来源:RAuthItemParentDataProvider.php

示例10: afterLogin

 /**
  * Actions to be taken after logging in.
  * Overloads the parent method in order to mark superusers.
  * @param boolean $fromCookie whether the login is based on cookie.
  */
 public function afterLogin($fromCookie)
 {
     parent::afterLogin($fromCookie);
     // Mark the user as a superuser if necessary.
     //Get the user from the CActiveRecord
     $user = User::model()->findByPk($this->getId());
     Yii::app()->getSession()->remove('current_user');
     Yii::app()->getSession()->add('current_user', $user);
     if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) {
         $this->isSuperuser = true;
     }
 }
开发者ID:ntquyen,项目名称:GXC-CMS,代码行数:17,代码来源:GxcUser.php

示例11: fetchData

 /**
  * Fetches the data from the persistent data storage.
  * @return array list of data items
  */
 public function fetchData()
 {
     $this->items = Rights::getAuthorizer()->getAuthItemChildren($this->parent->name, $this->type);
     return parent::fetchData();
 }
开发者ID:PTZ2002,项目名称:decoram,代码行数:9,代码来源:RAuthItemChildDataProvider.php

示例12: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  */
 public function actionUpdate()
 {
     $model = $this->loadModel();
     $profile = $model->profile;
     $this->performAjaxValidation(array($model, $profile));
     /* Get current user role. Added by Phihx. date 14/02/2014*/
     $assignedItems = Rights::getAuthorizer()->getAuthItems(null, $model->id);
     $userCurrenRole = array_keys($assignedItems);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $profile->attributes = $_POST['Profile'];
         if ($model->validate() && $profile->validate()) {
             /*$old_password = User::model()->notsafe()->findByPk($model->id);
             		if ($old_password->password!=$model->password) {
             			$model->password=Yii::app()->controller->module->encrypting($model->password);
             			$model->activkey=Yii::app()->controller->module->encrypting(microtime().$model->password);
             		}*/
             if (!empty($_POST['newPassword'])) {
                 $model->password = Yii::app()->controller->module->encrypting($_POST['newPassword']);
                 $model->activkey = Yii::app()->controller->module->encrypting(microtime() . $_POST['newPassword']);
             }
             $model->save();
             $profile->save();
             /*remove role for user. added by phihx. date 14/02/2014*/
             if (!empty($userCurrenRole)) {
                 foreach ($userCurrenRole as $role) {
                     Rights::revoke($role, $model->id);
                 }
             }
             /*Add role for user. added by phihx. date 14/02/2014*/
             if (!empty($_POST['user_role'])) {
                 //foreach($_POST['user_role'] as $role){
                 Rights::assign($_POST['user_role'], $model->id);
                 //}
             }
             Yii::app()->user->setFlash('success', translate('Chỉnh sửa người dùng thành công.'));
             $this->redirect(PIUrl::createUrl('/user'));
         } else {
             $profile->validate();
         }
     }
     /* Get All role. Added by Phihx. date 14/02/2014*/
     $allRoles = $this->getAllRoleUser();
     //$allClass = Classes::model()->findAll();
     $arrClass[''] = '---Chọn lớp---';
     Yii::app()->theme = 'flatlab';
     $this->render('update', array('model' => $model, 'profile' => $profile, 'allRoles' => $allRoles, 'userCurrenRole' => $userCurrenRole));
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:52,代码来源:AdminController.php

示例13: afterLogin

 /**
  * Actions to be taken after logging in.
  * Overloads the parent method in order to mark superusers.
  * @param boolean $fromCookie whether the login is based on cookie.
  */
 public function afterLogin($fromCookie)
 {
     parent::afterLogin($fromCookie);
     // Mark the user as a superuser if necessary.
     //Get the user from the CActiveRecord
     //$user=User::model()->findByPk($this->getId());
     $command = Yii::app()->db->createCommand();
     $command->select('username,user_url,display_name,email,fbuid,status,recent_login,avatar')->from('{{user}} u')->where('user_id=' . (int) $this->getId())->limit(1);
     $user = $command->queryRow();
     //Add only some neccessary field
     if ($user) {
         Yii::app()->getSession()->remove('current_user');
         Yii::app()->getSession()->add('current_user', $user);
         if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) {
             $this->isSuperuser = true;
         }
     } else {
         throw new CHttpException(503, t('Error while Logging into your account. Please try again later.'));
     }
 }
开发者ID:nganhtuan63,项目名称:gxc-cms,代码行数:25,代码来源:GxcUser.php


注:本文中的Rights::getAuthorizer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。