How to check for existence of a permission
I create a permission
$PermissionName in Vanilla 2.0 dynamically and now want to show "you do not have permission"
if (in_array($PermissionName, $PermissionArray) || !$Session->CheckPermission($PermissionName)).
$Session->CheckPermission($PermissionName) shows false if PermissionName does not exist and so I have to check for the existance of a permission called PermissionName.
My problem is that I have no $PermissionArray to check my PermissionName against. I've looked at the PermissionModel and found
public function GetPermissions($RoleID, $LimitToSuffix = '')
If the RoleID would be in $Session, I'd be happy, but it is not
So I'd either need a Vanilla function that replaces my
in_array($PermissionName, $PermissionArray) or I need a way to get $PermissionArray.
The only way I see by now would be:
1. get the user from $Session
2. get user roles with RoleModels GetByUserID
3. loop through roles, call GetPermissions from PermissionModel and concat the results to $PermissionArray
4. do my in_array($PermissionName, $PermissionArray) check
But that would be around ten lines of code for something that I assume is a function somewhere in the dashboard application.