Returns the roles owned by groups the user is a member.

@return Role[]
163823
public function getGroupRoles()
    {
        $roles = [];

        foreach ($this->groups as $group) {
            foreach ($group->getEntityRoles() as $role) {
                if (!in_array($role, $roles)) {
                    $roles[] = $role;
                }
            }
        }

        return $roles;
    }
856912
public function roles(): Collection
    {
        $user = $this->user();
        $userId = 0;

        // This is a simple check to detect if the user is actually logged-in,
        // otherwise it's just as the same as setting userId as 0.
        \is_null($user) || $userId = $user->getAuthIdentifier();

        $roles = ($this->userRoles ?: [])["{$userId}"] ?? new Collection();

        // This operation might be called more than once in a request, by
        // cached the event result we can avoid duplicate events being fired.
        if ($roles->isEmpty()) {
            $roles = $this->getUserRolesFromEventDispatcher($user, $roles);
        }

        $roles = new Collection($roles);

        $this->userRoles["{$userId}"] = $roles;

        return $roles;
    }
1000968
static public function getOrganizationRoleChoices()
    {
        return array(
            self::ORG_ROLE_AUTHOR =>                'Author',
            self::ORG_ROLE_CUSTODIAN =>             'Custodian',
            self::ORG_ROLE_DISTRIBUTOR =>           'Distributor',
            self::ORG_ROLE_ORIGINATOR =>            'Originator',
            self::ORG_ROLE_OWNER =>                 'Owner',
            self::ORG_ROLE_POINTOFCONTACT =>        'Point of Contact',
            self::ORG_ROLE_PRINCIPALINVESTIGATOR => 'Principal Investigator',
            self::ORG_ROLE_PROCESSOR =>             'Processor',
            self::ORG_ROLE_PUBLISHER =>             'Publisher',
            self::ORG_ROLE_RESOURCEPROVIDER =>      'Resource Provider',
            self::ORG_ROLE_USER =>                  'User'
        );
    }
401198
public function getAllowedRoles()
    {
        $returnValue = array();

        $role = new core_kernel_classes_Resource(GenerisRdf::INSTANCE_ROLE_GENERIS);
        $returnValue = array($role->getUri() => $role);

        return (array) $returnValue;
    }
523445
public function getPermissions() {
		$permissions = [];
		foreach ($this->role->sharedPermissionList as $permission) {
			$permissions[] = $permission->name;
		}

		return $permissions;
	}
970352
public static function getAllByParentGrouped()
    {
        $roles = false;
        if (method_exists(user(), 'roles') && method_exists(user(), 'getRolesList')) {
            $roles = true;
        }

        $builder = self::where('is_hidden', 0);

        // if roles are defined on user
        if ($roles) {
            $roles = user()->getRolesList();
            $builder->whereHas('roles', function ($query) use ($roles) {
                return $query->whereIn('roles.id', $roles);
            });
        }

        $items = $builder->orderBy('list_order')
            ->select('id', 'title', 'slug', 'url', 'icon', 'parent_id')
            ->get()
            ->groupBy('parent_id');

        if (count($items)) {
            $items['root'] = collect();
            if (isset($items[''])) {
                $items['root'] = $items[''];
                unset($items['']);
            }
            if (isset($items[0])) {
                $items['root'] = $items[0];
                unset($items[0]);
            }
        }

        return $items;
    }
1105231
public function getUserRoles() {
        $returnValue = $this->internalSession->getUserRoles();
        foreach (array_keys($returnValue) as $key) {
            $role = $returnValue[$key];
            if (!in_array($role, $this->filter)) {
                unset($returnValue[$key]);
            }
        }
        return $returnValue;
    }
1063211
public function getAssignedMembers()
    {
        $members = ArrayList::create($this->Users()->toArray());
        $groups  = $this->Groups();

        foreach ($groups as $group) {
            $members->merge($group->Members());
        }

        $members->removeDuplicates();
        return $members;
    }
1084309
public function getRoles() {

		$roles = [];

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

		return $roles;
	}
643267
public function getAuthorisedGroups()
	{
		if (is_null($this->authGroups))
		{
			$this->authGroups = array();
		}

		if (empty($this->authGroups))
		{
			$this->authGroups = Access::getGroupsByUser($this->get('id'));
		}

		return $this->authGroups;
	}
735991
public function getGroupsRoles(array $userGroups = []): array
    {
        $key = implode('.', $userGroups);

        if (!empty($this->_groupsRoles[$key])) {
            return $this->_groupsRoles[$key];
        }

        $result = [];

        if (!empty($userGroups)) {
            $query = $this->Roles->find('list', [
                'keyField' => 'id',
                'valueField' => 'name'
            ]);
            $query->matching('Groups', function ($q) use ($userGroups) {
                return $q->where(['Groups.id IN' => array_keys($userGroups)])->applyOptions(['accessCheck' => false]);
            });
            $result = $query->toArray();
        }

        $this->_groupsRoles[$key] = $result;

        return $this->_groupsRoles[$key];
    }
467425
public function getRoles(): ?array
    {
        $roles = $this->roles;
        $groupRoles = [[]];

        foreach ($this->getGroups() as $group) {
            $groupRoles[] = $group->getRoles();
        }
        $groupRoles = array_merge(...$groupRoles);

        return array_unique(array_merge($roles, $groupRoles));
    }
338233
public function rolesPermissions() {
    return [
      self::ROLE_USER => [
      ],
      self::ROLE_USER_MANAGER => [
        self::USER_VIEW,
        self::USER_CREATE,
        self::USER_UPDATE,
        self::USER_CHANGE_SECURITY_INFO,
        self::USER_CHANGE_PROFILE_INFO,
      ],
      self::ROLE_ADMIN => [
      ],
    ];
  }
868410
public function getGroups()
    {
        if (!is_array($this->fields['groups'])) {
            $this->fields['groups'] = [GROUP_ALL];
            if ($this->id == ADMIN_ID) $this->fields['groups'][] = GROUP_ADMIN;
            $r = self::getDbConnection()->fetchAll('SELECT group_id FROM users_groups_membership WHERE user_id='.$this->id);
            foreach ($r as $f) $this->fields['groups'][] = $f['group_id'];
        }
        return $this->fields['groups'];
    }
770117
public function getRoles()
    {
        $this_roles = \Cache::remember(
            'acl.getRolesById_'.$this->id,
            config('acl.cacheMinutes'),
            function () {
                return $this->roles;
            }
        );

        $slugs = method_exists($this_roles, 'pluck') ? $this_roles->pluck('slug','id') : $this_roles->lists('slug','id');
        return is_null($this_roles)
            ? []
            : $this->collectionAsArray($slugs);
    }
1157381
public function getRoles() {
		if ( $this->cacheEnabled() ) {
			if ( is_null( $this->getCachedRoles() ) ) {
				Cache::remember( 'roles.user_' . $this->id, config( 'roles.cache.expiry' ), function () {
					return $this->roles()->get();
				} );
			}

			return $this->getCachedRoles();
		} else {
			return $this->roles()->get();
		}
	}
878454
private function getRoleIds()
    {
        $assign_to_roles = $this->option('assign-to-roles');

        if ($assign_to_roles) {
            $role_ids = explode(',', $assign_to_roles);

            return array_map('intval', $role_ids);
        }

        return [];
    }