Determines if the current user has the necessary privileges for online translation.

@param array $roles The necessary roles for accessing the module.

@return bool
320145
private function _checkRoles($roles)
    {
        if (!$roles) {
            return true;
        }

        foreach ($roles as $role) {
            if (Yii::$app->user->can($role)) {
                return true;
            }
        }

        return false;
    }
1252024
public function isGranted(string $permission, array $roles): bool
    {
        foreach ($this->flattenRoles($roles) as $role) {
            if ($role->hasPermission($permission)) {
                return true;
            }
        }

        return false;
    }
1015011
public function hasRoleWithName(string $role): bool
    {
        $this->compileUserRoles();

        return in_array($role, $this->userRoles);
    }
6077
final public function isGranted(array $roles, array $resources, array $modules, array $accesses)
    {
        // Find a user which matches the required roles.
        $user = $this->checkRole($roles);

        if (null === $user) {
            return false;
        } else {
            return $this->isUserGranted($roles, $resources, $modules, $accesses, $user);
        }
    }
758347
private function hasRole($role) {

        if (substr($role, 0, 4) !== 'urn:')
        {
            $role = 'urn:lti:role:ims/lis/' . $role;
        }

        return in_array($role, $this->roles);

    }
357217
public function hasRoles($roles): bool
    {
        $userRoles = $this->getRoles()->all();

        // We should ensure that all given roles match the current user,
        // consider it as a AND condition instead of OR.
        foreach ((array) $roles as $role) {
            if (! \in_array($role, $userRoles)) {
                return false;
            }
        }

        return true;
    }
1022892
public function hasRole(Role $role)
    {
        $this->initializeRoles();
        return array_key_exists($role->getIdentifier(), $this->roles);
    }
641367
public function hasRole($role)
    {
        if (is_string($role)) {
            return $this->roles->contains('name', $role);
        }

        if (is_array($role)) {
            foreach ($role as $r) {
                if ($this->hasRole($r)) {
                    return true;
                }
            }

            return false;
        }

        return !!$role->intersect($this->roles)->count();
    }
874923
public function is($roles): bool
    {
        $userRoles = $this->roles()->all();

        // For a pre-caution, we should return false in events where user
        // roles not an array.
        if (! \is_array($userRoles)) {
            return false;
        }

        // We should ensure that all given roles match the current user,
        // consider it as a AND condition instead of OR.
        foreach ((array) $roles as $role) {
            if (! \in_array($role, $userRoles)) {
                return false;
            }
        }

        return true;
    }
241253
public function hasRole($role)
    {
        if ($this->instance instanceof \Phavour\Session\Storage) {
            $roles = $this->instance->get('roles');
            if (is_array($roles) && in_array($role, $roles)) {
                return true;
            }
        }

        return false;
    }
1287186
public function hasRole(string $role): bool
    {
        return (null !== $this->roles) ? \in_array($role, $this->roles) : false;
    }
967748
public function isUserInRole($roles) {
        if (!is_string($roles)) throw new IllegalTypeException('Illegal type of parameter $roles: '.gettype($roles));

        // Module holen
        $module = $this->getAttribute(MODULE_KEY);
        if (!$module) throw new RuntimeException('You can not call '.__METHOD__.'() in this context');

        // RoleProcessor holen ...
        $processor = $module->getRoleProcessor();
        if (!$processor) throw new RuntimeException('You can not call '.__METHOD__.'() without configuring a RoleProcessor');

        // ... und Aufruf weiterreichen
        return $processor->isUserInRole($this, $roles);
    }
303776
public function roleLoadPermissions($roles)
    {
        if (!$roles) {
            return false;
        }
        $multi = is_array($roles);
        if (!$multi) {
            $roles = [$roles];
        }
        $permissions_ids = [];

        foreach ($roles as $role) {
            if (!is_array($role->_permission_ids)) {
                $role->_permission_ids = explode(',', $role->_permission_ids);
            }
            $permissions_ids = array_merge($permissions_ids, $role->_permission_ids);
        }
        $perms = $this->permissionFetchById($permissions_ids);
        foreach ($perms as $perm) {
            foreach ($roles as $role) {
                if (in_array($perm->permission_id, $role->_permission_ids)) {
                    $role->addPermission($perm);
                    continue;
                }
            }
        }
        return true;
    }
653066
public function personalWorkspaceAllowed($roles)
    {
        $roles[] = $this->roleManager->getRoleByName('ROLE_USER');

        foreach ($roles as $role) {
            if ($role->isPersonalWorkspaceCreationEnabled()) {
                return true;
            }
        }

        return false;
    }
1290577
public function handle($roles)
    {
        if ($this->auth->check()) {
            return $this->auth->user()->hasRole($roles);
        }

        return false;
    }
243334
protected function userHasPermission(array $permissions)
    {
        if ( ! count($permissions)) {
            return true;
        }

        return (bool) count(
            array_filter($permissions, function ($permission) {
                return array_get($this->userPermissions, $permission);
            })
        );
    }
460109
public static function roleExists($role) : bool {
		if (empty($_SESSION['numbers']['user']['roles'])) return false;
		if (is_array($role)) {
			$temp = array_intersect($role, $_SESSION['numbers']['user']['roles']);
			return !empty($temp);
		} else {
			return in_array($role, $_SESSION['numbers']['user']['roles']);
		}
	}