本文整理汇总了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;
}
示例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;
}