Back to AbstractMenu class

Method authorise

public bool
authorise
(mixed $id)
Method to check Menu object authorization against an access control object and optionally an access extension object
Parameters
  • int $id The menu id
Returns
  • bool
Since
  • 1.5
Class: AbstractMenu
Project: Joomla

Method authorise - Source code

/**
 * Method to check Menu object authorization against an access control object and optionally an access extension object
 *
 * @param   integer  $id  The menu id
 *
 * @return  boolean
 *
 * @since   1.5
 */
public function authorise($id)
{
    $menu = $this->getItem($id);
    if ($menu) {
        $access = (int) $menu->access;
        // If the access level is public we don't need to load the user session
        if ($access === 1) {
            return true;
        }
        return \in_array($access, $this->user->getAuthorisedViewLevels(), true);
    }
    return true;
}