19 declare(strict_types=1);
50 $this->dataCache = $DIC[
'ilObjDataCache'];
51 $this->
access = $DIC->access();
53 $this->type = $this->objParticipants->
getType();
54 $this->
lng = $DIC[
'lng'];
56 $this->ref_id = $a_ref_id;
63 $participants = $this->objParticipants->getParticipants();
64 if ($this->type ===
'crs' || $this->type ===
'grp') {
65 $participants = $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
73 $preloadedRoleIds = [];
74 foreach ($participants as $user_id) {
80 if (!$user->getActive()) {
84 $login = $user->getLogin();
87 if (in_array($user->getPref(
'public_profile'), [
'g',
'y'])) {
88 $publicName = $user->getLastname() .
', ' . $user->getFirstname();
91 $this->data[$user_id][
'user_id'] = $user_id;
92 $this->data[$user_id][
'login'] = $login;
93 $this->data[$user_id][
'name'] = $publicName;
95 $assignedRoles = $this->objParticipants->getAssignedRoles($user_id);
96 $rolesToPreload = array_diff($assignedRoles, $preloadedRoleIds);
97 $this->dataCache->preloadObjectCache($rolesToPreload);
100 foreach ($assignedRoles as $roleId) {
101 $preloadedRoleIds[$roleId] = $roleId;
102 $title = $this->dataCache->lookupTitle((
int) $roleId);
103 $roleTitles[] = $title;
106 $roleTitles = $this->
sortRoles($roleTitles);
108 $roleTitles = array_map(
function (
string $roleTitle):
string {
112 $this->data[$user_id][
'role'] = implode(
', ', $roleTitles);
122 usort($roleTitles,
function (
string $a,
string $b):
int {
123 $leftPrefixTitle = substr($a, 0, 8);
124 $rightPrefixTitle = substr($b, 0, 8);
126 $leftRating = $this->roleSortWeightMap[$leftPrefixTitle] ?? 0;
127 $rightRating = $this->roleSortWeightMap[$rightPrefixTitle] ?? 0;
129 if ($leftRating > 0 || $rightRating > 0) {
130 if ($leftRating !== $rightRating) {
131 return $rightRating - $leftRating > 0 ? 1 : -1;
137 return strcmp($a, $b);
buildRoleTitle(string $role)
ilParticipants $objParticipants
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjectDataCache $dataCache
sortRoles(array $roleTitles)
static _getTranslation(string $a_role_title)
__construct(ilParticipants $objParticipants, int $a_ref_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Base class for course and group participants.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Class ilMailMemberSearchDataProvider.