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


PHP Rights::getValidChildTypes方法代码示例

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


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

示例1: actionUpdate

 /**
  * Updates an authorization item.
  */
 public function actionUpdate()
 {
     // Get the authorization item
     $model = $this->loadModel();
     $itemName = $model->getName();
     // Create the authorization item form
     $formModel = new AuthItemForm('update');
     if (isset($_POST['AuthItemForm']) === true) {
         $formModel->attributes = $_POST['AuthItemForm'];
         if ($formModel->validate() === true) {
             // Update the item and load it
             $this->_authorizer->updateAuthItem($itemName, $formModel->name, $formModel->description, $formModel->bizRule, $formModel->data);
             $item = $this->_authorizer->authManager->getAuthItem($formModel->name);
             $item = $this->_authorizer->attachAuthItemBehavior($item);
             // Set a flash message for updating the item
             Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', ':name updated.', array(':name' => $item->getNameText())));
             // Redirect to the correct destination
             $this->redirect(Yii::app()->user->getRightsReturnUrl(array('authItem/permissions')));
         }
     }
     $type = Rights::getValidChildTypes($model->type);
     $exclude = array($this->module->superuserName);
     $childSelectOptions = Rights::getParentAuthItemSelectOptions($model, $type, $exclude);
     if ($childSelectOptions !== array()) {
         $childFormModel = new AuthChildForm();
         // Child form is submitted and data is valid
         if (isset($_POST['AuthChildForm']) === true) {
             $childFormModel->attributes = $_POST['AuthChildForm'];
             if ($childFormModel->validate() === true) {
                 // Add the child and load it
                 $this->_authorizer->authManager->addItemChild($itemName, $childFormModel->itemname);
                 $child = $this->_authorizer->authManager->getAuthItem($childFormModel->itemname);
                 $child = $this->_authorizer->attachAuthItemBehavior($child);
                 // Set a flash message for adding the child
                 Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Child :name added.', array(':name' => $child->getNameText())));
                 // Reidrect to the same page
                 $this->redirect(array('authItem/update', 'name' => urlencode($itemName)));
             }
         }
     } else {
         $childFormModel = null;
     }
     // Set the values for the form fields
     $formModel->name = $model->name;
     $formModel->description = $model->description;
     $formModel->type = $model->type;
     $formModel->bizRule = $model->bizRule !== 'NULL' ? $model->bizRule : '';
     $formModel->data = $model->data !== null ? serialize($model->data) : '';
     $parentDataProvider = new RAuthItemParentDataProvider($model);
     $childDataProvider = new RAuthItemChildDataProvider($model);
     // Render the view
     $this->render('update', array('model' => $model, 'formModel' => $formModel, 'childFormModel' => $childFormModel, 'childSelectOptions' => $childSelectOptions, 'parentDataProvider' => $parentDataProvider, 'childDataProvider' => $childDataProvider));
 }
开发者ID:fobihz,项目名称:cndiesel,代码行数:56,代码来源:AuthItemController.php

示例2: actionUpdate

 /**
  * Updates an authorization item.
  */
 public function actionUpdate()
 {
     // Get the authorization item
     $model = $this->loadModel();
     // Create the authorization item form
     $form = new CForm('rights.views.authItem.authItemForm', new AuthItemForm('update'));
     // Form is submitted and data is valid
     if ($form->submitted() === true && $form->validate() === true) {
         // Update the item and load it
         $this->_authorizer->updateAuthItem($_GET['name'], $form->model->name, $form->model->description, $form->model->bizRule, $form->model->data);
         $item = $this->_authorizer->authManager->getAuthItem($form->model->name);
         $item = $this->_authorizer->attachAuthItemBehavior($item);
         // Set a flash message for updating the item
         Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', ':name updated.', array(':name' => $item->getNameText())));
         // Redirect to the correct destination
         $this->redirect(array(isset($_GET['redirect']) === true ? urldecode($_GET['redirect']) : 'authItem/permissions'));
     }
     // Create a form to add children to the authorization item
     $type = Rights::getValidChildTypes($model->type);
     $exclude = array($this->module->superuserName);
     $selectOptions = Rights::getParentAuthItemSelectOptions($model, $type, $exclude);
     if ($selectOptions !== array()) {
         // Create the child form
         $childForm = new CForm(array('elements' => array('name' => array('label' => false, 'type' => 'dropdownlist', 'items' => $selectOptions)), 'buttons' => array('submit' => array('type' => 'submit', 'label' => Rights::t('core', 'Add')))), new AuthChildForm());
         // Child form is submitted and data is valid
         if ($childForm->submitted() === true && $childForm->validate() === true) {
             // Add the child and load it
             $this->_authorizer->authManager->addItemChild($_GET['name'], $childForm->model->name);
             $child = $this->_authorizer->authManager->getAuthItem($childForm->model->name);
             $child = $this->_authorizer->attachAuthItemBehavior($child);
             // Set a flash message for adding the child
             Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Child :name added.', array(':name' => $child->getNameText())));
             // Reidrect to the same page
             $this->redirect(array('authItem/update', 'name' => $_GET['name']));
         }
     } else {
         $childForm = null;
     }
     // Set the values for the form fields
     $form->model->name = $model->name;
     $form->model->description = $model->description;
     $form->model->type = $model->type;
     $form->model->bizRule = $model->bizRule !== 'NULL' ? $model->bizRule : '';
     $form->model->data = $model->data !== null ? serialize($model->data) : '';
     $parentDataProvider = new AuthItemParentDataProvider($model);
     $childDataProvider = new AuthItemChildDataProvider($model);
     // Render the view
     $this->render('update', array('model' => $model, 'parentDataProvider' => $parentDataProvider, 'childDataProvider' => $childDataProvider, 'form' => $form, 'childForm' => $childForm));
 }
开发者ID:rusli-nasir,项目名称:smsempresayii,代码行数:52,代码来源:AuthItemController.php


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