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


PHP RoleModel::getByRoleID方法代码示例

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


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

示例1: edit

 /**
  * Edit a role.
  *
  * @since 2.0.0
  * @access public
  */
 public function edit($RoleID = false)
 {
     if (!$this->_permission($RoleID)) {
         return;
     }
     if ($this->title() == '') {
         $this->title(t('Edit Role'));
     }
     $this->setHighlightRoute('dashboard/role');
     $PermissionModel = Gdn::permissionModel();
     $this->Role = $this->RoleModel->getByRoleID($RoleID);
     // $this->EditablePermissions = is_object($this->Role) ? $this->Role->EditablePermissions : '1';
     $this->addJsFile('jquery.gardencheckboxgrid.js');
     // Set the model on the form.
     $this->Form->setModel($this->RoleModel);
     // Make sure the form knows which item we are editing.
     $this->Form->addHidden('RoleID', $RoleID);
     $LimitToSuffix = !$this->Role || $this->Role->CanSession == '1' ? '' : 'View';
     // If seeing the form for the first time...
     if ($this->Form->authenticatedPostBack() === false) {
         // Get the role data for the requested $RoleID and put it into the form.
         $Permissions = $PermissionModel->getPermissionsEdit($RoleID ? $RoleID : 0, $LimitToSuffix, $this->hideCategoryPermissions === false);
         // Remove permissions the user doesn't have access to.
         if (!Gdn::session()->checkPermission('Garden.Settings.Manage')) {
             foreach ($this->RoleModel->RankPermissions as $Permission) {
                 if (Gdn::session()->checkPermission($Permission)) {
                     continue;
                 }
                 list($Px, $Sx) = explode('.', $Permission, 2);
                 unset($Permissions['_' . $Px][$Sx]);
             }
         }
         $this->setData('PermissionData', $Permissions, true);
         $this->Form->setData($this->Role);
     } else {
         $this->removeRankPermissions();
         // Make sure the role's checkbox has a false value so that the role model can handle a sparse update of
         // column from other places.
         if (!$this->Form->getFormValue('PersonalInfo')) {
             $this->Form->setFormValue('PersonalInfo', false);
         }
         if ($this->hideCategoryPermissions) {
             $this->Form->setFormValue('IgnoreCategoryPermissions', true);
         }
         // If the form has been posted back...
         // 2. Save the data (validation occurs within):
         if ($RoleID = $this->Form->save()) {
             if ($this->deliveryType() === DELIVERY_TYPE_DATA) {
                 $this->index($RoleID);
                 return;
             }
             $this->informMessage(t('Your changes have been saved.'));
             $this->RedirectUrl = url('dashboard/role');
             // Reload the permission data.
             $this->setData('PermissionData', $PermissionModel->getPermissionsEdit($RoleID, $LimitToSuffix, $this->hideCategoryPermissions === false), true);
         }
     }
     $this->setData('_Types', $this->RoleModel->getDefaultTypes(true));
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:66,代码来源:class.rolecontroller.php


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