Menu::hasPerms (method)

Last updated: Tue, Oct 31, 2023 1:44 pm
Return to Knowledgebase

Purpose

Location

users/classes/Menu.php

Parameters

# Parameter Data Type Required Description
1 $item object Yes Menu to check the permissions against

Returns

Data Type Description of Returned Data
bool "true" if the user has the necessary permissions to access them item; "false" otherwise

Example

hasPerms($menuItem)

Further Documentation:

Internal use for the class only. Not meant to be called by the user in development.

1. Decodes the permissions associated with the provided menu item using json_decode.
2. If the user is logged in, it removes the '0' permission from the item's permissions as it is considered irrelevant.
3. Checks if the '0' permission exists in the item's permissions and returns true if it does.
4. Finds the intersection between the item's permissions and the permissions of the current user.
5. Returns true if there is at least one common permission; otherwise, it returns false.