Returns the user's roles as an array of string values (needed for
Symfony security checks). The roles owned by groups the user is a
member are included by default.

@param boolean $areGroupsIncluded

@return array[string]
348030
public function getRoles($areGroupsIncluded = true)
    {
        $roleNames = parent::getRoles();

        if ($areGroupsIncluded) {
            foreach ($this->getGroups() as $group) {
                $roleNames = array_unique(array_merge($roleNames, $group->getRoles()));
            }
        }

        return $roleNames;
    }
424378
function roleIDList()
    {
        if ( eZINI::instance()->variable( 'RoleSettings', 'EnableCaching' ) === 'true' )
        {
            $userCache = $this->getUserCache();
            return $userCache['roles'];
        }

        $groups = $this->attribute( 'groups' );
        $groups[] = $this->attribute( 'contentobject_id' );
        return eZRole::fetchIDListByUser( $groups );
    }
489385
public function get_roles($group = null)
	{
		// When group is empty, attempt to get groups from a current login
		if ($group === null)
		{
			if ($login = \Auth::instance()
				and is_array($groups = $login->get_groups())
				and isset($groups[0][1]))
			{
				$group = $groups[0][1];
			}
		}

		// if it's a group id, find the corresponding object
		elseif (is_numeric($group) and isset(static::$_valid_groups[$group]))
		{
			$group = static::$_valid_groups[$group];
		}

		// if the group was found, return the roles
		if ($group instanceOf Model\Auth_Group)
		{
			return $group->roles;
		}
		else
		{
			// no group found, so no roles either
			return array();
		}
	}
1171062
public function getRoles()
    {
        global $wpdb;
        $capabilities = get_user_meta($this->ID, $wpdb->prefix . 'capabilities', true);

        return is_array($capabilities) ? array_keys($capabilities) : array(
            'non-user'
        );
    }
211403
public function getRoles()
    {
        $roles = array();

        if ($this->acl) {
            foreach ($this->acl->getRoles() as $role) {
                //Do not translate, only make first one uppercase
                $roles[$role] = ucfirst($role);
            }
        }
        asort($roles);

        return $roles;
    }
301675
public function whereHasRoleIn(array $roles)
    {
        $managerRoles = array();
        $otherRoles = array();

        foreach ($roles as $role) {
            $roleName = $role instanceof RoleInterface ? $role->getRole() : $role;

            if (preg_match('/^ROLE_WS_MANAGER_/', $roleName)) {
                $managerRoles[] = $roleName;
            } else {
                $otherRoles[] = $roleName;
            }
        }

        $eol = PHP_EOL;

        if (count($otherRoles) > 0 && count($managerRoles) === 0) {
            $this->leftJoinRights = true;
            $clause = "{$eol}({$eol}";
            $clause .= "rightRole.name IN (:roles){$eol}";
            $this->parameters[":roles"] = $otherRoles;
            $clause .= "AND{$eol}BIT_AND(rights.mask, 1) = 1{$eol})";
            $this->addWhereClause($clause);
        } elseif (count($otherRoles) === 0 && count($managerRoles) > 0) {
            $this->leftJoinRoles = true;
            $clause = "{$eol}({$eol}";
            $clause .= "role.name IN (:roles){$eol}";
            $this->parameters[":roles"] = $managerRoles;
            $this->addWhereClause($clause . ')');
        } elseif (count($otherRoles) > 0 && count($managerRoles) > 0) {
            $this->leftJoinRoles = true;
            $this->leftJoinRights = true;
            $clause = "{$eol}({$eol}({$eol}";
            $clause .= "rightRole.name IN (:otherroles){$eol}";
            $this->parameters[":otherroles"] = $otherRoles;
            $clause .= "AND{$eol}BIT_AND(rights.mask, 1) = 1{$eol}){$eol}";
            $clause .= "OR{$eol}";
            $clause .= "role.name IN (:managerroles){$eol}";
            $this->parameters[":managerroles"] = $managerRoles;
            $this->addWhereClause($clause . ")");
        }

        return $this;
    }
885436
public function getRoles()
    {
        if (count($this->rolesStringAsArray) > 0) {
            return $this->rolesStringAsArray;
        }

        $roleNames = array();

        foreach ($this->getEntityRoles(true) as $role) {
            $roleNames[] = $role->getName();
        }

        return $roleNames;
    }
853673
protected function getUserRoles(): Collection
    {
        if (! \is_null($this->userRoles)) {
            return $this->userRoles;
        } elseif (! $this->auth->guest()) {
            return $this->auth->roles();
        }

        return new Collection($this->roles->has('guest') ? ['guest'] : []);
    }
1193129
public function getRoleParents($role, $onlyParents = true) {
        $parents = array();
        if (Zend_Registry::isRegistered('Zend_Acl')) {
            $acl = Zend_Registry::get('Zend_Acl');
            $roles = $acl->getRoles();

            foreach ($roles as $potentialParent) {
                if ($acl->inheritsRole($role, $potentialParent, $onlyParents)) {
                    $parents[] = $potentialParent;
                }
            }
        }
        return $parents;
    }
1341200
public static function getUserRoles($incl_admin = true)
    {
        $wp_roles = new \WP_Roles();
        $wp_roles = $wp_roles->get_names();
        if (!$incl_admin) {
            unset($wp_roles['administrator']);
        }
        $roles = [];
        foreach ($wp_roles as $key => $value) {
            $roles[] = $key;
        }
        return $roles;
    }
854264
public function findAllPlatformRoles($includeRoleUser = true, $getBuilder = false)
    {
        $queryBuilder = $this
            ->createQueryBuilder('role')
            ->andWhere('role.type = :roleType')
            ->setParameter('roleType', Role::PLATFORM_ROLE);
        $queryBuilder->andWhere($queryBuilder->expr()->not($queryBuilder->expr()->eq('role.name', '?1')))
            ->setParameter(1, 'ROLE_ANONYMOUS');

        if (!$includeRoleUser) {
            $queryBuilder->andWhere($queryBuilder->expr()->not($queryBuilder->expr()->eq('role.name', '?2')))
                ->setParameter(2, 'ROLE_USER');
        }

        if ($getBuilder) {
            return $queryBuilder;
        }

        $query = $queryBuilder->getQuery();

        return $query->getResult();
    }
1084309
public function getRoles() {

		$roles = [];

		foreach($this -> permissions as $role => $permissions) {
			$roles[$role] = $this -> getRole($role);
		}

		return $roles;
	}
1231727
public static function get_user_role($user = null)
    {
        $wp_roles = \wp_roles();

        if ($user === null) {
            $user = \wp_get_current_user();
        }

        if (!($user instanceof WP_User)) {
            return false;
        }

        $roles = $user->roles;
        $role = \array_shift($roles);

        return isset($wp_roles->role_objects[ $role ]) ? $wp_roles->role_objects[ $role ] : false;
    }
1313142
public function getRolesReadOnly($domain = false)
    {
        $rolesReadOnly = [];

        if (!$this->tokenStorage->getToken()) {
            return $rolesReadOnly;
        }

        $this->iterateAdminRoles(function ($role, $isMaster) use ($domain, &$rolesReadOnly): void {
            if (!$isMaster && $this->authorizationChecker->isGranted($role)) {
                // although the user has no MASTER permission, allow the currently logged in user to view the role
                $rolesReadOnly[$role] = $this->translateRole($role, $domain);
            }
        });

        return $rolesReadOnly;
    }
699582
public function findUsersByRolesIncludingGroups(
        array $roles
    ) {
        //very slow otherwise. If we want to do it properly, the OR clause won't do it.
        //we must use UNION wich is not supported by Doctrine
        $dql = '
            SELECT u, r1, ws
            From Claroline\\CoreBundle\\Entity\\User u
            LEFT JOIN u.roles r1
            LEFT JOIN u.personalWorkspace ws
            WHERE r1 in (:roles)
            AND u.isRemoved = false
            ORDER BY u.lastName, u.firstName ASC
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('roles', $roles);

        $resA = $query->getResult();
        $resA = $resA ? $resA : [];

        $dql = '
            SELECT u, g, r2, ws
            From Claroline\\CoreBundle\\Entity\\User u
            LEFT JOIN u.personalWorkspace ws
            LEFT JOIN u.groups g
            LEFT JOIN g.roles r2
            WHERE r2 in (:roles)
            AND u.isRemoved = false
            ORDER BY u.lastName, u.firstName ASC
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('roles', $roles);

        $resB = $query->getResult();
        $resB = $resB ? $resB : [];

        return array_unique(array_merge($resA, $resB));
    }
134161
public function getGroupsDescription()
    {
        if (class_exists(Subsite::class)) {
            Subsite::disable_subsite_filter(true);
        }

        // Get the member's groups, if any
        $groups = $this->owner->Groups();
        if ($groups->Count()) {
            // Collect the group names
            $groupNames = array();
            foreach ($groups as $group) {
                /** @var Group $group */
                $groupNames[] = html_entity_decode($group->getTreeTitle());
            }
            // return a csv string of the group names, sans-markup
            $result = preg_replace("#</?[^>]>#", '', implode(', ', $groupNames));
        } else {
            // If no groups then return a status label
            $result = _t(__CLASS__ . '.NOGROUPS', 'Not in a Security Group');
        }

        if (class_exists(Subsite::class)) {
            Subsite::disable_subsite_filter(false);
        }
        return $result;
    }
781384
protected function convertRoles($roles)
    {
        if ($roles instanceof Traversable) {
            $roles = iterator_to_array($roles);
        }

        $collectedRoles = [];
        $toCollect      = [];

        foreach ((array) $roles as $role) {
            // If it's already a RoleInterface, nothing to do as a RoleInterface contains everything already
            if ($role instanceof RoleInterface) {
                $collectedRoles[] = $role;
                continue;
            }

            // Otherwise, it's a string and hence we need to collect it
            $toCollect[] = (string) $role;
        }

        // Nothing to collect, we don't even need to hit the (potentially) costly role provider
        if (empty($toCollect)) {
            return $collectedRoles;
        }

        return array_merge($collectedRoles, $this->roleProvider->getRoles($toCollect));
    }