Ob der User, der den Request ausgeloest hat, Inhaber der angegebenen Rolle(n) ist.

@param  string $roles - Rollenbezeichner

@return bool
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);
    }
377223
public static function hasRole($roles)
    {
        $user = wp_get_current_user();

        if (is_string($roles)) {
            $roles = array($roles);
        }

        if (!array_intersect($roles, $user->roles)) {
            return false;
        }

        return true;
    }
231319
public function hasRole($role = ''){

        $session = $this->getSession();
        $cookie = $this->getCookie();


        if ($cookie->has(self::USER_SESSION)) {
            $login = $cookie->get(self::USER_SESSION);
        }elseif (false !== $session->has(self::USER_SESSION)) {
            $login = $session->get(self::USER_SESSION);
        }else{
            return false;
        }

        $roleLogin = $login['role'];

        if (is_string($role)) {
            return $roleLogin === $role;
        }elseif(is_array($role)){
            return array_search($roleLogin, $role);
        }

        return false;
    }
1067503
public function checkCurrentUserAccess($roles)
    {
        if ($this->getCurrentUser() === null) {
            return;
        }
        if ($roles instanceof core_kernel_classes_Resource) {
            $roles = [$roles->getUri()];
        }

        if (is_array($roles)) {
            $roles = array_map(function($role) {
                return $role instanceof core_kernel_classes_Resource ? $role->getUri() : $role;
            }, $roles);
        }

        if (in_array(TaoRoles::SYSTEM_ADMINISTRATOR, $roles)
            && !$this->userHasRoles($this->getCurrentUser(), TaoRoles::SYSTEM_ADMINISTRATOR)
        ) {
            throw new common_exception_Error('Permission denied');
        }

        if (in_array(TaoRoles::GLOBAL_MANAGER, $roles)
            && !$this->userHasRoles($this->getCurrentUser(), [TaoRoles::SYSTEM_ADMINISTRATOR, TaoRoles::GLOBAL_MANAGER])
        ) {
            throw new common_exception_Error('Permission denied');
        }
    }
529590
public function hasRole($role) {
        $roles = (array) $this->Session->read('Acl.roles');

        if (is_numeric($role)) {
            return isset($roles[$role]);
        }

        return in_array($role, $roles);
    }
606803
public function isAll($role)
    {
        foreach ($this->getArrayFrom($role) as $role) {
            if (!$this->hasRole($role)) {
                return false;
            }
        }

        return true;
    }
1320013
public function roles($roles)
    {
        $this->sync(
            Models::role()->getRoleKeys($roles),
            $this->authority->roles()
        );
    }
380719
protected function _checkRoles($requestedRole, $roles) {
		if (is_string($roles)) {
			$roles = [$roles];
		}
		if (is_string($requestedRole)) {
			$requestedRole = [$requestedRole];
		}
		if (!is_array($requestedRole)) {
			throw new InvalidArgumentException('The requested role is not a string or an array!');
		}
		$result = array_intersect($roles, $requestedRole);

		return (count($result) > 0);
	}
938098
public function hasRole($role)
    {
        foreach ($this->roles as $roleObj) {
            if($role == $roleObj->getRole()){
                return true;
            }
        }
        return false;
    }
1294028
public function isAllowed(array $roles, $resource)
    {
        $allowed = false;
        foreach ($roles as $role) {
            if ($this->isRoleAllowed($role, $resource)) {
                $allowed = true;
                break;
            }
        }
        return $allowed;
    }
525191
public function getAccessibleRoles(array $roles)
    {
        $accessibleRoles = $roles;
        foreach ($roles as $role) {
            /**
             * @var $role Role
             */
            if (isset($this->map[$role->getRole()])) {
                foreach ($this->map[$role->getRole()] as $r) {
                    $accessibleRoles[] = new Role($r);
                }
            }
        }

        return $accessibleRoles;
    }
1285541
public function hasRole($role): bool
    {
        if (is_string($role)) {
            return $this->roles->contains('slug', $role);
        }

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

        return false;
    }
963210
protected function checkRoles(array $roles)
    {
        $checkedRoles = array();
        foreach ($roles as $role) {
            if (true === is_string($role) && false === in_array($role, $checkedRoles)) {
                $checkedRoles[] = (string)$role;
            }
        }
        return $checkedRoles;
    }
1150665
public function hasRole($role)
    {
        if (is_string($role)) {
            return $this->roles->contains('slug', $role);
        }

        if (is_array($role)) {
            $roles = $this->getRoleSlugs();

            $intersection      = array_intersect($roles, (array) $role);
            $intersectionCount = count($intersection);

            return ($intersectionCount > 0) ? true : false;
        }

        return ! ! $role->intersect($this->roles)->count();
    }
1318280
public function matchIdentityRoles(array $roles): bool
    {
        $identityRoles = $this->getIdentityRoles();
        // Too easy...
        if (empty($identityRoles)) {
            return false;
        }
        $roleNames = [];
        foreach ($roles as $role) {
            $roleNames[] = $role instanceof RoleInterface ? $role->getName() : (string)$role;
        }

        $identityRoleNames = [];
        foreach ($this->flattenRoles($identityRoles) as $role) {
            $identityRoleNames[] = $role->getName();
        }

        return count(array_intersect($roleNames, $identityRoleNames)) > 0;
    }
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;
    }
1271808
public function hasRole($roles): bool
    {
        if (is_string($roles) && false !== strpos($roles, '|')) {
            $roles = $this->convertPipeToArray($roles);
        }

        if (is_string($roles)) {
            return $this->roles->contains('name', $roles);
        }

        if ($roles instanceof Role) {
            return $this->roles->contains('id', $roles->id);
        }

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

            return false;
        }

        return $roles->intersect($this->roles)->isNotEmpty();
    }