Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions wcfsetup/install/files/lib/system/session/SessionHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,25 @@ public function getPermission(string $permission): mixed
return $this->groupData[$permission];
}

/**
* Returns true if the active user has the given permission.
* Only works for boolean permisions.
*
* @throws \BadMethodCallException
* @since 6.3
*/
public function hasPermission(string $permission): bool
{
$result = $this->getPermission($permission);
if ($result === true || $result === 1 || $result === '1') {
return true;
} else if ($result === false || $result === 0 || $result === '0') {
return false;
}

throw new \BadMethodCallException("'{$permission}' is not a boolean permission");
}

/**
* Returns true if a permission was set to 'Never'. This is required to preserve
* compatibility, while preventing ACLs from overruling a 'Never' setting.
Expand Down
Loading