Returns true if the access entity has access to
the given permission access level

@access public
@param string $accessLevel
@return boolean
420780
public function hasAccess($accessLevel)
    {
        foreach ($this->permissions as $permission) {
            /**
             * If the user has the \Globa\* access level he can
             * do everything
             */
            if ($permission == '\\Global\\*') {
                return true;
            }
            
            if ($permission == $accessLevel) {
                return true;
            }
            
            // If there is a star in the permission and everything before 
            // the star is equal with the access level, the user has access
            // to the given access level.
            $posStar = strpos($permission, '*');
            if ($posStar !== false) {
                $startPermission = substr($permission, 0, $posStar);
                $startAccessLevel = substr($accessLevel, 0, $posStar);
                
                if ($startPermission == $startAccessLevel) {
                    return true;
                }
            } 
        }
    
        return false;
    }
482439
private boolean hasPermission(IPerson person, String permission, String target) {
        EntityIdentifier ei = person.getEntityIdentifier();
        IAuthorizationPrincipal ap =
                AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
        return ap.hasPermission(IPermission.PORTAL_GROUPS, permission, target);
    }
721743
public function grantPermission($accessEntityUuid, $accessEntityClass, $accessLevel, $grantedBy)
    {
        return $this->permissionsDataSource->grantPermission($accessEntityUuid, $accessEntityClass, $accessLevel, $grantedBy);
    }
111634
protected function hasGroupLoop($accessLevel, $modifiedUuid)
    {
        $parts = explode('\\', $accessLevel);
        
        if (count($parts) < 3 || $parts[1] !== 'Group') {
            return false;
        }
        
        if ($parts[2] === $modifiedUuid) {
            return true;
        }
        
        if ($this->hasPermissionForModifiedGroup($modifiedUuid, $parts[2])) {
            return true;
        }
        
        return false;
    }
598305
protected function checkAccessControlRequestHeaders(array $accessControlRequestHeaders)
    {
        // Make sure all array elements are strings and not blank
        foreach ($accessControlRequestHeaders as $h) {
            if (!is_string($h) || $h === '') {
                return false;
            }
        }

        return true;
    }
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);
    }
1138200
public function hasAccess($checkPermissions, $cache = true): bool
    {
        if (! $cache || is_null($this->cachePermissions)) {
            $this->cachePermissions = $this->roles()
                ->pluck('permissions')
                ->prepend($this->permissions);
        }

        $permissions = $this->cachePermissions;

        foreach ($permissions as $permission) {
            if (isset($permission[$checkPermissions]) && $permission[$checkPermissions]) {
                return true;
            }
        }

        return false;
    }
1365349
public function hasAccess($accessKey, User $user = null)
    {
        if ($user === null) {
            $user = $this->currentUser();
        }

        if (is_array($accessKey)) {
            return $user->hasAnyAccess($accessKey);
        } else {
            return $user->hasAccess($accessKey);
        }
    }
555666
public function hasAccessRestrictions()
    {
        if (!is_array($this->accessRoles) || empty($this->accessRoles)) {
            return false;
        }
        if (count($this->accessRoles) === 1 && in_array('Neos.Flow:Everybody', $this->accessRoles)) {
            return false;
        }

        return true;
    }
545871
public function hasAccess(array $url, array $user): bool
    {
        $result = parent::hasAccess($url, $user);

        if (!$result) {
            return $result;
        }

        if (!empty($user['is_supervisor']) && $user['is_supervisor']) {
            $users = Utils::getReportToUsers($user['id']);

            foreach ($users as $userRecord) {
                $result = (new AccessFactory())->hasAccess($url, $userRecord->toArray());

                if ($result) {
                    return $result;
                }
            }
        }

        return false;
    }
47675
public function canDisplayIsSourced($access_level = null){
		if(!$this->gedcomrecord->canShow($access_level)) return false;
		if($access_level === null )
		    $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree());

		$global_facts = Globals::getGlobalFacts();
		if (isset($global_facts['SOUR'])) {
			return $global_facts['SOUR'] >= $access_level;
		}

		return true;
	}
1073060
public function has_access($condition, $driver = null, $user = null)
	{
		if (is_null($user))
		{
			$groups = $this->get_groups();
			$user = reset($groups);
		}
		return parent::has_access($condition, $driver, $user);
	}
597887
protected function checkAccessPolicy($access_policy_name, Reference $ref)
	{
		// Allow by default
		if (empty($access_policy_name)) {
			return true;
		}

		if (!isset($this->access_policies[$access_policy_name])) {
			throw new \InvalidArgumentException('Unknown policy: '.$access_policy_name);
		}
		$access_policy = $this->access_policies[$access_policy_name];

		//debug_dump($access_policy, 'POLICY: '.$access_policy_name.' @ '.get_class($this));

		if ($this->auth->isAllMighty()) {
			return true;
		}

		switch ($access_policy['type']) {

			// anyone: Completely open for anyone
			case 'anyone':
				return true;

			// nobody: Nobody is allowed, except all mighty users.
			case 'nobody':
				return false;

			// anonymous: Only anonymous users allowed (not logged in)
			case 'anonymous':
				$user_id = $this->auth->getUserId();
				return $user_id === null;

			// user: All logged-in users allowed
			case 'user':
				$user_id = $this->auth->getUserId();
				return $user_id !== null;

			// owner: Owner must match current user
			case 'owner':
				if ($ref->isNullRef()) {
					// Everyone owns nothing :)
					return true;
				}
				$properties = $ref->properties;
				$user_id = $this->auth->getUserId();
				$owner_property = $access_policy['owner_property'];
				if (isset($access_policy['session_state'])) {
					$session_machine = $this->auth->getSessionMachine();
					if (!$session_machine || $session_machine->state != $access_policy['session_state']) {
						return false;
					}
				}
				return $user_id !== null ? $user_id == $properties[$owner_property] : $properties[$owner_property] === null;

			// role: Current user must have specified role ($ref is ignored)
			case 'role':
				return $this->auth->hasUserRoles($access_policy['required_role']);

			// These are done by SQL select.
			case 'condition':
				if ($ref->isNullRef()) {
					// Nonexistent entity has nulls everywhere
					// FIXME: Are we sure?
					return false;
				}
				$properties = $ref->properties;
				return !empty($properties['_access_policy_'.$access_policy_name]);

			// These are done by SQL select.
			case 'user_relation':
				if ($ref->isNullRef()) {
					// No relation to nonexistent entity.
					return false;
				}
				$properties = $ref->properties;
				return !empty($properties['_access_policy_'.$access_policy_name]);

			// unknown policies are considered unsafe
			default:
				return false;
		}

		// This should not happen.
		throw new \RuntimeException('Policy '.$policy.' did not decide.');
	}
217651
public function addAccessLevel(AccessLevel $accessLevel)
    {
        // Add the access level
        $this->accessLevels[$accessLevel->getKey()] = $accessLevel;
        
        // Save the access levels
        $this->saveAccessLevels();
    }
942449
protected function _authorizeAccess($context)
    {
        if (is_person($this->_viewer) && $this->_viewer->admin()) {
            return true;
        }

        if ($this->_entity->isPrivatable()) {
            return $this->_entity->allows($this->_viewer, 'access');
        }
    }
237066
public function respectThreshold($wantedLevel) {
		// If not threshold is given, always display the rule
		if (is_null($wantedLevel)) {
			return true;
		}

		$currentValue = $this->getLevelNumericalValue($this->level);
		$wantedValue = $this->getLevelNumericalValue($wantedLevel);

		return  $currentValue >= $wantedValue;
	}
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;
    }