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


PHP RoleModel::GetAssignable方法代码示例

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


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

示例1: add

 /**
  * Create a user.
  *
  * @since 2.0.0
  * @access public
  */
 public function add()
 {
     $this->permission('Garden.Users.Add');
     // Page setup
     $this->addJsFile('user.js');
     $this->title(t('Add User'));
     $this->addSideMenu('dashboard/user');
     $RoleModel = new RoleModel();
     $AllRoles = $RoleModel->getArray();
     $RoleData = $RoleModel->GetAssignable();
     // By default, people with access here can freely assign all roles
     $this->RoleData = $RoleData;
     $UserModel = new UserModel();
     $this->User = false;
     // Set the model on the form.
     $this->Form->setModel($UserModel);
     try {
         // These are all the 'effective' roles for this add action. This list can
         // be trimmed down from the real list to allow subsets of roles to be edited.
         $this->EventArguments['RoleData'] =& $this->RoleData;
         $this->fireEvent("BeforeUserAdd");
         if ($this->Form->authenticatedPostBack()) {
             // These are the new roles the creating user wishes to apply to the target
             // user, adjusted for his ability to affect those roles
             $RequestedRoles = $this->Form->getFormValue('RoleID');
             if (!is_array($RequestedRoles)) {
                 $RequestedRoles = array();
             }
             $RequestedRoles = array_flip($RequestedRoles);
             $UserNewRoles = array_intersect_key($this->RoleData, $RequestedRoles);
             // Put the data back into the forum object as if the user had submitted
             // this themselves
             $this->Form->setFormValue('RoleID', array_keys($UserNewRoles));
             $NewUserID = $this->Form->save(array('SaveRoles' => true, 'NoConfirmEmail' => true));
             if ($NewUserID !== false) {
                 $Password = $this->Form->getValue('Password', '');
                 $UserModel->sendWelcomeEmail($NewUserID, $Password, 'Add');
                 $this->informMessage(t('The user has been created successfully'));
                 $this->RedirectUrl = url('dashboard/user');
             }
             $this->UserRoleData = $UserNewRoles;
         } else {
             // Set the default roles.
             $this->UserRoleData = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
         }
     } catch (Exception $Ex) {
         $this->Form->addError($Ex);
     }
     $this->render();
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:56,代码来源:class.usercontroller.php


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