ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Roles.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\User\Profile\Fields\NoOverrides;
28
29class Roles implements FieldDefinition
30{
31 use NoOverrides;
32
33 public function getIdentifier(): string
34 {
35 return 'roles';
36 }
37
38 public function getLabel(Language $lng): string
39 {
40 return $lng->txt($this->getIdentifier());
41 }
42
43 public function getSection(): AvailableSections
44 {
45 return AvailableSections::Access;
46 }
47
48 public function hiddenInLists(): bool
49 {
50 return true;
51 }
52
53 public function visibleInCoursesForcedTo(): ?bool
54 {
55 return true;
56 }
57
58 public function visibleInGroupsForcedTo(): ?bool
59 {
60 return true;
61 }
62
63 public function visibleInStudyProgrammesForcedTo(): ?bool
64 {
65 return false;
66 }
67
68 public function exportForcedTo(): ?bool
69 {
70 return false;
71 }
72
73 public function changeableByUserForcedTo(): ?bool
74 {
75 return false;
76 }
77
78 public function requiredForcedTo(): ?bool
79 {
80 return false;
81 }
82
83 public function searchableForcedTo(): ?bool
84 {
85 return false;
86 }
87
88 public function availableInCertificatesForcedTo(): ?bool
89 {
90 return false;
91 }
92
93 public function getLegacyInput(
96 ?\ilObjUser $user = null
98 $input = new \ilNonEditableValueGUI($this->getLabel($lng));
99 if ($user === null) {
100 return $input;
101 }
102 $input->setValue(
103 $this->retrieveValueFromUser($user)
104 );
105 return $input;
106 }
107
108 public function addValueToUserObject(
109 \ilObjUser $user,
110 mixed $input,
111 ?\ilPropertyFormGUI $form = null
112 ): \ilObjUser {
113 return $user;
114 }
115
116 public function retrieveValueFromUser(\ilObjUser $user): string
117 {
118 $rbac_review = new \ilRbacReview();
119 $assinged_roles = $rbac_review->assignedRoles($user->getId());
120 return substr(
121 array_reduce(
122 $rbac_review->getGlobalRolesArray(),
123 static fn(string $c, array $v) => in_array($v['obj_id'], $assinged_roles)
124 ? $c . \ilObjectFactory::getInstanceByObjId($v['obj_id'])->getTitle() . ', '
125 : $c,
126 ''
127 ),
128 0,
129 -2
130 );
131 }
132}
retrieveValueFromUser(\ilObjUser $user)
Definition: Roles.php:116
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: Roles.php:108
getLegacyInput(Language $lng, Context $context, ?\ilObjUser $user=null)
You don't need to add a post_var to the input as the User will handle this for you,...
Definition: Roles.php:93
This class represents a property in a property form.
This class represents a non editable value in a property form.
User class.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This class represents a property form user interface.
$c
Definition: deliver.php:25
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31
$context
Definition: webdav.php:31