當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。