19 declare(strict_types=1);
48 $this->dataCache = $DIC[
'ilObjDataCache'];
49 $this->
access = $DIC->access();
50 $this->type = $this->objParticipants->getType();
51 $this->
lng = $DIC[
'lng'];
58 $participants = $this->objParticipants->getParticipants();
59 if ($this->type ===
'crs' || $this->type ===
'grp') {
60 $participants = $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
68 $preloadedRoleIds = [];
69 foreach ($participants as
$user_id) {
75 if (!$user->getActive()) {
79 $login = $user->getLogin();
82 if (in_array($user->getPref(
'public_profile'), [
'g',
'y'])) {
83 $publicName = $user->getLastname() .
', ' . $user->getFirstname();
87 $this->data[
$user_id][
'login'] = $login;
88 $this->data[
$user_id][
'name'] = $publicName;
90 $assignedRoles = $this->objParticipants->getAssignedRoles($user_id);
91 $rolesToPreload = array_diff($assignedRoles, $preloadedRoleIds);
92 $this->dataCache->preloadObjectCache($rolesToPreload);
95 foreach ($assignedRoles as $roleId) {
96 $preloadedRoleIds[$roleId] = $roleId;
97 $title = $this->dataCache->lookupTitle((
int) $roleId);
98 $roleTitles[] = $title;
101 $roleTitles = $this->
sortRoles($roleTitles);
104 fn(
string $roleTitle):
string => $this->
buildRoleTitle($roleTitle),
108 $this->data[
$user_id][
'role'] = implode(
', ', $roleTitles);
118 usort($roleTitles,
function (
string $a,
string $b):
int {
119 $leftPrefixTitle = substr($a, 0, 8);
120 $rightPrefixTitle = substr($b, 0, 8);
122 $leftRating = $this->roleSortWeightMap[$leftPrefixTitle] ?? 0;
123 $rightRating = $this->roleSortWeightMap[$rightPrefixTitle] ?? 0;
125 if ($leftRating > 0 || $rightRating > 0) {
126 if ($leftRating !== $rightRating) {
127 return $rightRating - $leftRating > 0 ? 1 : -1;
133 return strcmp($a, $b);
buildRoleTitle(string $role)
__construct(protected ilParticipants $objParticipants, protected int $ref_id)
ilObjectDataCache $dataCache
sortRoles(array $roleTitles)
static _getTranslation(string $a_role_title)
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