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


PHP RoleModel::getPermissions方法代码示例

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


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

示例1: getSession

 /**
  *
  *
  * @param int $UserID
  * @param bool $Refresh
  * @return array|object|false
  */
 public function getSession($UserID, $Refresh = false)
 {
     // Ask for the user. This will check cache first.
     $User = $this->getID($UserID, DATASET_TYPE_OBJECT);
     if (!$User) {
         return false;
     }
     // If we require confirmation and user is not confirmed
     $ConfirmEmail = self::requireConfirmEmail();
     $Confirmed = val('Confirmed', $User);
     if ($ConfirmEmail && !$Confirmed) {
         // Replace permissions with those of the ConfirmEmailRole
         $ConfirmEmailRoleID = RoleModel::getDefaultRoles(RoleModel::TYPE_UNCONFIRMED);
         if (!is_array($ConfirmEmailRoleID) || count($ConfirmEmailRoleID) == 0) {
             throw new Exception(sprintf(t('No role configured with a type of "%s".'), RoleModel::TYPE_UNCONFIRMED), 400);
         }
         $RoleModel = new RoleModel();
         $permissionsModel = new Vanilla\Permissions();
         $RolePermissions = $RoleModel->getPermissions($ConfirmEmailRoleID);
         $permissionsModel->compileAndLoad($RolePermissions);
         $Permissions = $permissionsModel->getPermissions();
         // Ensure Confirm Email role can always sign in
         if (!$Permissions->has('Garden.SignIn.Allow')) {
             $Permissions->set('Garden.SignIn.Allow', true);
         }
         $User->Permissions = $Permissions->getPermissions();
         // Otherwise normal loadings!
     } else {
         if ($User && ($User->Permissions == '' || Gdn::cache()->activeEnabled())) {
             $userPermissions = $this->getPermissions($UserID);
             $User->Permissions = $userPermissions->getPermissions();
         }
     }
     // Remove secret info from session
     unset($User->Password, $User->HashMethod);
     return $User;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:44,代码来源:class.usermodel.php

示例2: getSession

 /**
  *
  *
  * @param $UserID
  * @param bool $Refresh
  * @return array|bool|null|object|type
  */
 public function getSession($UserID, $Refresh = false)
 {
     // Ask for the user. This will check cache first.
     $User = $this->getID($UserID, DATASET_TYPE_OBJECT);
     if (!$User) {
         return false;
     }
     // If we require confirmation and user is not confirmed
     $ConfirmEmail = self::requireConfirmEmail();
     $Confirmed = val('Confirmed', $User);
     if ($ConfirmEmail && !$Confirmed) {
         // Replace permissions with those of the ConfirmEmailRole
         $ConfirmEmailRoleID = RoleModel::getDefaultRoles(RoleModel::TYPE_UNCONFIRMED);
         $RoleModel = new RoleModel();
         $RolePermissions = $RoleModel->getPermissions($ConfirmEmailRoleID);
         $Permissions = UserModel::compilePermissions($RolePermissions);
         // Ensure Confirm Email role can always sign in
         if (!in_array('Garden.SignIn.Allow', $Permissions)) {
             $Permissions[] = 'Garden.SignIn.Allow';
         }
         $User->Permissions = $Permissions;
         // Otherwise normal loadings!
     } else {
         if ($User && ($User->Permissions == '' || Gdn::cache()->activeEnabled())) {
             $User->Permissions = $this->definePermissions($UserID);
         }
     }
     // Remove secret info from session
     unset($User->Password, $User->HashMethod);
     return $User;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:38,代码来源:class.usermodel.php


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