Checks whether the user or group is allowed access
@return bool
761792
public function check()
    {
    	$action = $this->request->param('action');
        $controller = $this->request->param('controller');
        $prefix = ($this->request->param('prefix') === false) ? '/' : $this->request->param('prefix');
        $plugin = ($this->request->param('plugin') === false) ? '' : $this->request->param('plugin');

        $plugin_prefix = (empty($plugin)) ? $prefix : $plugin . '.' . $prefix;
        if( isset($this->_authorized[$plugin_prefix][$controller]) &&
            in_array($action, $this->_authorized[$plugin_prefix][$controller]) ) return true;

        $user_id = $this->request->session()->read('Auth.User.id');
        $group_id = -1;
        if( isset($this->controllers['group']) ) {
            $User = TableRegistry::get($this->controllers['user']);
            $group_id = $User->get($user_id)->group_id;
        }

        $UserGroupPermission = TableRegistry::get('UserGroupPermission');
        $Permission = TableRegistry::get('Permission');

        $unique_string = $this->getUniqueString($controller, $action, $prefix, $plugin);
        $permission_id = $Permission->find()
            ->select(['id'])
            ->where(['unique_string' => $unique_string])->first();
        if( is_null($permission_id) ) return false;

        $allow = $UserGroupPermission->find()
            ->select(['allow'])
            ->where(
                [
                    'group_or_user'     => 'user',
                    'group_or_user_id'  => $user_id,

                ])
            ->orWhere(
                [
                    'group_or_user'     => 'group',
                    'group_or_user_id'  => $group_id
                ])->andWhere(['permission_id' => $permission_id->id])
            ->order(['allow'=>'DESC'])->first();
        if( is_null($allow) ) return false;

        return $allow->allow;
    }
1235176
public function hasGroupPermission(Group $group)
    {
        $definitions = (new Query())->select("nav_id")->from("cms_nav_permission")->where(['group_id' => $group->id])->all();
        
        // the group has no permission defined, this means he can access ALL cms pages
        if (count($definitions) == 0) {
            return true;
        }
        
        foreach ($definitions as $permission) {
            if ($this->id == $permission['nav_id']) {
                return true;
            }
        }
        
        return false;
    }
154606
private function __canAccessAlerts()
    {
        if ($this->Page instanceof AdministrationPage && self::isLoggedIn() && Symphony::Author()->isDeveloper()) {
            return true;
        }

        return false;
    }
376810
public function check_permissions() {
        $context = context_module::instance($this->cm->id);
        return has_capability('mod/glossary:exportentry', $context)
            || ($this->entry->userid == $this->user->id && has_capability('mod/glossary:exportownentry', $context));
    }
805223
public function AllowDiscountForNonUsers()
    {
        $bIsValid = true;
        $aExtranetGroup = $this->GetFieldDataExtranetGroupWithInverseEmptySelectionLogicIdList();
        if (null === $aExtranetGroup || count($aExtranetGroup) > 0) {
            $bIsValid = false;
        }

        if ($bIsValid) {
            $aExtranetUser = $this->GetFieldDataExtranetUserWithInverseEmptySelectionLogicIdList();
            if (null === $aExtranetUser || count($aExtranetUser) > 0) {
                $bIsValid = false;
            }
        }
        if ($bIsValid) {
            $aExtranetUserCountry = $this->GetMLTIdList('data_country_mlt');
            if (count($aExtranetUserCountry) > 0) {
                $bIsValid = false;
            }
        }

        return $bIsValid;
    }
376043
public function hasSuperUser()
    {

        $permissions = $this->getAllPermissions();

        foreach ($permissions as $permission)
            if ($permission === 'superuser') return true;

        return false;
    }
822398
public function allowedUserGroups( $privilege = self::PRIVILEGE_DEFAULT )
    {
        $result = array();

        if ( null === $this->userGroups )
        {
            $this->userGroups = $this->getMapper()
                                     ->findUserGroups();
        }

        foreach ( $this->userGroups as $id => $name )
        {
            if ( $this->isAllowed( 'user.group.' . $id, $privilege ) )
            {
                $result[$id] = $name;
            }
        }

        return $result;
    }
1261745
public function isUserAllowedAccess()
    {
        $requestedRoles = $this->getRequestedRoles();

        // we allow access if there are no requested roles that the user must have
        if (count($requestedRoles) < 1) {
            return true;
        }

        return $this->getAccessDecision($requestedRoles);
    }
716741
protected function canAccess()
    {
        if ($this->formRequest->user()->isAdmin() || $this->formRequest->user()->isUser()) {
            return true;
        }

        return $this->formRequest->user()->canDo('message.message.view');
    }
644176
public function is_user_access_restricted_by_capability() {
        $userid = $this->modinfo->get_user_id();
        if ($userid == -1) {
            return null;
        }
        $capability = 'mod/' . $this->modname . ':view';
        $capabilityinfo = get_capability_info($capability);
        if (!$capabilityinfo) {
            // Capability does not exist, no one is prevented from seeing the activity.
            return false;
        }

        // You are blocked if you don't have the capability.
        return !has_capability($capability, $this->get_context(), $userid);
    }
307807
public function isUserAllowedAccess()
    {
        if (!is_object($this->accessControl)) {
            $this->accessControl = new AccessControl($this->user, $this->config->get('AccessControl', false));
        }

        $isAccessAllowed = $this->accessControl->isUserAllowedAccess();
        if (!$isAccessAllowed) {
            $this->eventManager()->fire(SecurityEvent::ROLE_INVALID, new SecurityEvent($this->user));
        }

        return $isAccessAllowed;
    }
456605
public function hasPermissions() {
        return $this->action->usesPermissions()
            ? Auth::user()->hasPermissions($this->action->getPermissions())
            : true;
    }
1056873
public function isAccessible()
    {
        if ($this->hasAccessRestrictions() === false) {
            return true;
        }

        if ($this->securityContext->canBeInitialized() === false) {
            return true;
        }

        foreach ($this->accessRoles as $roleName) {
            if ($this->securityContext->hasRole($roleName)) {
                return true;
            }
        }

        return false;
    }
227991
public function inAllowedGroup()
    {
        if ($this->isCurrentUser() || (! $this->isStaff())) {
            // Always allow editing of non-staff user
            // for the time being
            return true;
        }

        $group  = $this->getGroupId();
        $groups = $this->util->getDbLookup()->getActiveStaffGroups();
        if (! isset($groups[$group])) {
            // Allow editing when the group does not exist or is no longer active.
            return true;
        }

        $allowedGroups = $this->userLoader->getCurrentUser()->getAllowedStaffGroups();
        if ($allowedGroups) {
            return (boolean) isset($allowedGroups[$group]);
        } else {
            return false;
        }
    }
1065641
public function canAdministrate()
    {
        $user = $this->getUser();
        if ($user->name == 'Guest' && $user->email == 'guest@example.com') {
            return false;
        }
        if (method_exists($user, 'isAdmin')) {
            return $user->isAdmin();
        }
        if (method_exists($user, 'can')) {
            return $user->can('administrate') || $user->can('admin');
        }
        // If no method of authorizing return false;
        return false;
    }
893989
public function checkAccess(array $permissions = [], bool $force = false): bool
    {
        // Guests are not allowed by default
        if ($this->isGuest()) {
            return false;
        }

        // Allow access to all users when permissions argument is empty
        if (empty($permissions)) {
            return true;
        }

        // Administrators are supermen :P
        if ($this->isAdmin()) {
            return true;
        }

        // User has the right to do this?
        if (count(array_intersect($permissions, $this->perissions)) > 0) {
            return true;
        }

        // You aren't allowed, by default.
        return false;
    }
1257898
public function canLoginHere()
    {
        if (! $this->_hasVar('can_login_here')) {
            $this->_setVar('can_login_here', true);
            if ($orgId = $this->userLoader->getOrganizationIdByUrl()) {
                if (! $this->isAllowedOrganization($orgId)) {
                    $this->_setVar('can_login_here', false);;
                }
            }
        }
        return $this->_getVar('can_login_here');
    }