Horde_Registry::hasPermission PHP Method

hasPermission() public method

Check permissions on an application.
public hasPermission ( string $app, integer $perms = Horde_Perms::READ, array $params = [] ) : boolean
$app string The name of the application
$perms integer The permission level to check for.
$params array Additional options: - notransparent: (boolean) Do not attempt transparent authentication. DEFAULT: false
return boolean Whether access is allowed.
    public function hasPermission($app, $perms = Horde_Perms::READ, array $params = array())
    {
        /* Always do isAuthenticated() check first. You can be an admin, but
         * application auth != Horde admin auth. And there can *never* be
         * non-SHOW access to an application that requires authentication. */
        if (!$this->isAuthenticated(array('app' => $app, 'notransparent' => !empty($params['notransparent']))) && $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create($app)->requireAuth() && $perms != Horde_Perms::SHOW) {
            return false;
        }
        /* Otherwise, allow access for admins, for apps that do not have any
         * explicit permissions, or for apps that allow the given permission. */
        return $this->isAdmin() || ($GLOBALS['injector']->getInstance('Horde_Perms')->exists($app) ? $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission($app, $this->getAuth(), $perms) : (bool) $this->getAuth());
    }