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


PHP Rights::getAuthItemSelectOptions方法代码示例

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


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

示例1: actionUser

 /**
  * Displays the authorization assignments for an user.
  */
 public function actionUser()
 {
     // Create the user model and attach the required behavior
     $userClass = $this->module->userClass;
     $model = CActiveRecord::model($userClass)->findByPk($_GET['id']);
     $model->attachBehavior('rights', new RightsUserBehavior());
     $assignedItems = $this->_authorizer->getAuthItems(null, $model->getId(), null, true);
     $assignments = array_keys($assignedItems);
     // Make sure we have items to be selected
     $selectOptions = Rights::getAuthItemSelectOptions(null, $assignments);
     if ($selectOptions !== array()) {
         // Create a from to add a child for the authorization item
         $form = new CForm(array('elements' => array('itemname' => array('label' => false, 'type' => 'dropdownlist', 'items' => $selectOptions)), 'buttons' => array('submit' => array('type' => 'submit', 'label' => Rights::t('core', 'Assign')))), new AssignmentForm());
         // Form is submitted and data is valid, redirect the user
         if ($form->submitted() === true && $form->validate() === true) {
             // Update and redirect
             $this->_authorizer->authManager->assign($form->model->itemname, $model->getId());
             $item = $this->_authorizer->authManager->getAuthItem($form->model->itemname);
             $item = $this->_authorizer->attachAuthItemBehavior($item);
             Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Permission :name assigned.', array(':name' => $item->getNameText())));
             $this->redirect(array('assignment/user', 'id' => $model->getId()));
         }
     } else {
         $form = null;
     }
     // Create a data provider for listing the assignments
     $dataProvider = new AuthItemDataProvider('assignments', array('userId' => $model->getId()));
     // Render the view
     $this->render('user', array('model' => $model, 'dataProvider' => $dataProvider, 'form' => $form));
 }
开发者ID:rusli-nasir,项目名称:smsempresayii,代码行数:33,代码来源:AssignmentController.php

示例2: actionUser

 /**
  * Displays the authorization assignments for an user.
  */
 public function actionUser()
 {
     // Create the user model and attach the required behavior
     $userClass = $this->module->userClass;
     $model = CActiveRecord::model($userClass)->findByPk($_GET['id']);
     $this->_authorizer->attachUserBehavior($model);
     $assignedItems = $this->_authorizer->getAuthItems(null, $model->getId());
     $assignments = array_keys($assignedItems);
     // Make sure we have items to be selected
     $assignSelectOptions = Rights::getAuthItemSelectOptions(null, $assignments);
     if ($assignSelectOptions !== array()) {
         $formModel = new AssignmentForm();
         // Form is submitted and data is valid, redirect the user
         if (isset($_POST['AssignmentForm']) === true) {
             $formModel->attributes = $_POST['AssignmentForm'];
             if ($formModel->validate() === true) {
                 // Update and redirect
                 $this->_authorizer->authManager->assign($formModel->itemname, $model->getId());
                 $item = $this->_authorizer->authManager->getAuthItem($formModel->itemname);
                 $item = $this->_authorizer->attachAuthItemBehavior($item);
                 Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Permission :name assigned.', array(':name' => $item->getNameText())));
                 $this->redirect(array('assignment/user', 'id' => $model->getId()));
             }
         }
     } else {
         $formModel = null;
     }
     // Create a data provider for listing the assignments
     $dataProvider = new RAuthItemDataProvider('assignments', array('userId' => $model->getId()));
     // Render the view
     $this->render('user', array('model' => $model, 'dataProvider' => $dataProvider, 'formModel' => $formModel, 'assignSelectOptions' => $assignSelectOptions));
 }
开发者ID:sharmarakesh,项目名称:edusec-college-management-system,代码行数:35,代码来源:AssignmentController.php

示例3: getAuthItemSelectOptions

 public function getAuthItemSelectOptions()
 {
     $authorizer = Yii::app()->getComponent('authorizer');
     return Rights::getAuthItemSelectOptions();
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:5,代码来源:UserAssignmentForm.php


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