ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearningSequenceMembershipGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
33{
34 public function __construct(
36 protected ilObject $obj,
37 protected ilObjUserTracking $obj_user_tracking,
38 protected ilPrivacySettings $privacy_settings,
39 protected ilRbacReview $rbac_review,
40 protected ilSetting $settings,
41 protected ilToolbarGUI $toolbar,
42 protected ILIAS\HTTP\Wrapper\RequestWrapper $request_wrapper,
43 protected ArrayBasedRequestWrapper $post_wrapper,
44 protected ILIAS\Refinery\Factory $refinery,
45 protected ILIAS\UI\Factory $ui_factory
46 ) {
48 }
49
50 protected function members(): void
51 {
52 $may_manage_members = $this->checkRbacOrPositionAccessBool(
53 'manage_members',
54 'manage_members',
55 $this->getParentObject()->getRefId()
56 );
57
58 if ($may_manage_members) {
59 $this->participants();
60 } else {
61 $this->jump2UsersGallery();
62 }
63 }
64
65 protected function printMembers(): void
66 {
67 $this->checkPermission('read');
68 if ($this->checkRbacOrPositionAccessBool('manage_members', 'manage_members')) {
69 $back_cmd = 'participants';
70 } else {
71 $back_cmd = 'jump2UsersGallery';
72 }
73
74 global $DIC;
75 $ilTabs = $DIC['ilTabs'];
76 $ilTabs->clearTargets();
77 $ilTabs->setBackTarget(
78 $this->lng->txt('back'),
79 $this->ctrl->getLinkTarget($this, $back_cmd)
80 );
81
82 $list = $this->initAttendanceList();
83 $form = $list->initForm('printMembersOutput');
84 $this->tpl->setContent($form->getHTML());
85 }
86
87 protected function getDefaultCommand(): string
88 {
89 $r = $this->refinery;
90 return $this->request_wrapper->retrieve("back_cmd", $r->byTrying([$r->kindlyTo()->string(), $r->always("members")]));
91 }
92
98 public function filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids): array
99 {
100 return $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
101 'manage_members',
102 'manage_members',
103 $this->getParentObject()->getRefId(),
104 $a_user_ids
105 );
106 }
107
111 public function assignMembers(array $user_ids, string $type): bool
112 {
113 $object = $this->getParentObject();
114 $members = $this->getParentObject()->getLSParticipants();
115
116 if (count($user_ids) == 0) {
117 $this->lng->loadLanguageModule('search');
118 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('search_err_user_not_exist'), true);
119 return false;
120 }
121
122 $assigned = false;
123 foreach ($user_ids as $new_member) {
124 $new_member = (int) $new_member;
125
126 if ($members->isAssigned($new_member)) {
127 continue;
128 }
129
130 switch ($type) {
131 case $object->getDefaultAdminRole():
132 $members->add($new_member, ilParticipants::IL_LSO_ADMIN);
133 $members->sendNotification(
135 $new_member
136 );
137 $assigned = true;
138 break;
139 case $object->getDefaultMemberRole():
140 $members->add($new_member, ilParticipants::IL_LSO_MEMBER);
141 $members->sendNotification(
143 $new_member
144 );
145 $assigned = true;
146 break;
147 default:
148 if (in_array($type, $object->getLocalLearningSequenceRoles(true))) {
149 $members->add($new_member, ilParticipants::IL_LSO_MEMBER);
150 $members->updateRoleAssignments($new_member, array($type));
151 } else {
152 ilLoggerFactory::getLogger('lso')->notice(
153 'Can not find role with id .' . $type . ' to assign users.'
154 );
155 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("lso_cannot_find_role"), true);
156 return false;
157 }
158
159 $members->sendNotification(
161 $new_member
162 );
163 $assigned = true;
164 break;
165 }
166 }
167
168 if ($assigned) {
169 $this->tpl->setOnScreenMessage('success', $this->lng->txt("lso_msg_member_assigned"), true);
170 } else {
171 $this->tpl->setOnScreenMessage('success', $this->lng->txt('lso_users_already_assigned'), true);
172 }
173
174 $this->ctrl->redirect($this, 'participants');
175 return $assigned;
176 }
177
181 protected function updateParticipantsStatus(): void
182 {
183 $members = $this->getParentObject()->getLSParticipants();
184
185 $participants = $this->post_wrapper->retrieve(
186 "visible_member_ids",
187 $this->refinery->byTrying([
188 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
189 $this->refinery->always([])
190 ])
191 );
192
193
194
195
196 $notification = [];
197 if ($this->post_wrapper->has('notification')) {
198 $notification = $this->post_wrapper->retrieve(
199 "notification",
200 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
201 );
202 }
203
204 foreach ($participants as $participant) {
205 if ($members->isAdmin($participant)) {
206 $members->updateNotification($participant, in_array($participant, $notification));
207 continue;
208 }
209 $members->updateNotification($participant, false);
210 }
211
212 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
213 $this->ctrl->redirect($this, 'participants');
214 }
215
217 {
219 $this,
220 $this->getParentObject(),
221 $this->obj_user_tracking,
222 $this->privacy_settings,
223 $this->lng,
224 $this->access,
225 $this->rbac_review,
226 $this->settings,
227 $this->profile
228 );
229 }
230
232 {
233 $obj = parent::getParentObject();
234 if (!$obj instanceof ilObjLearningSequence) {
235 throw new Exception('Invalid class type ' . get_class($obj) . ". Expected ilObjLearningSequence.");
236 }
237 return $obj;
238 }
239
241 {
243 $this,
244 $this->getParentObject(),
245 $this->getParentObject()->getLSParticipants(),
246 $this->privacy_settings
247 );
248
249 $table->setTitle($this->lng->txt($this->getParentObject()->getType() . '_header_edit_members'));
250 $table->setData($this->readMemberData($participants));
251
252 return $table;
253 }
254
258 protected function initParticipantTemplate(): void
259 {
260 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lso_edit_members.html', 'components/ILIAS/LearningSequence');
261 }
262
266 public function getLocalTypeRole(bool $translation = false): array
267 {
268 return $this->getParentObject()->getLocalLearningSequenceRoles($translation);
269 }
270
276 public function readMemberData(array $usr_ids, ?array $columns = null): array
277 {
278 return $this->getParentObject()->readMemberData($usr_ids, $columns);
279 }
280
281
283 {
285 }
286
287 protected function getDefaultRole(): ?int
288 {
289 return $this->getParentObject()->getDefaultMemberRole();
290 }
291
295 public function getPrintMemberData(array $members): array
296 {
297 $member_data = $this->readMemberData($members, array());
298
299 return $this->getParentGUI()->addCustomData($member_data);
300 }
301
305 public function getAttendanceListUserData(int $user_id, array $filters = []): array
306 {
307 $data = array();
308
309 if ($this->filterUserIdsByRbacOrPositionOfCurrentUser([$user_id])) {
310 $data = $this->member_data[$user_id];
311 if (array_key_exists('access_time', $data)) {
312 $data['access'] = $data['access_time'];
313 }
314 $data['progress'] = $this->lng->txt($data['progress']);
315 }
316
317 return $data;
318 }
319
321 {
323 }
324
325 protected function setSubTabs(ilTabsGUI $tabs): void
326 {
328 'manage_members',
329 'manage_members',
330 $this->getParentObject()->getRefId()
331 );
332
333 if ($access) {
335 $this->getParentObject()->getType() . "_member_administration",
336 $this->ctrl->getLinkTarget($this, 'participants'),
337 "members",
338 get_class($this)
339 );
340
342 $this->getParentObject()->getType() . '_members_gallery',
343 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilUsersGalleryGUI')),
344 'view',
345 'ilUsersGalleryGUI'
346 );
347 } elseif ($this->getParentObject()->getShowMembers()) {
349 $this->getParentObject()->getType() . '_members_gallery',
350 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilUsersGalleryGUI')),
351 'view',
352 'ilUsersGalleryGUI'
353 );
354 }
355 }
356
357 protected function showParticipantsToolbar(): void
358 {
359 $toolbar_entries = [
360 'auto_complete_name' => $this->lng->txt('user'),
361 'user_type' => $this->getParentGUI()->getLocalRoles(),
362 'user_type_default' => $this->getDefaultRole(),
363 'submit_name' => $this->lng->txt('add'),
364 'add_search' => true
365 ];
366
367 $search_params = ['crs', 'grp'];
368 $parent_container = $this->obj->getParentObjectInfo(
369 $this->obj->getRefId(),
370 $search_params
371 );
372 if (!is_null($parent_container)) {
373 $container_id = $parent_container['ref_id'];
374 $toolbar_entries['add_from_container'] = $container_id;
375 }
376
378 $this,
379 $this->toolbar,
380 $toolbar_entries
381 );
382
383 $this->toolbar->addSeparator();
384
385 $this->toolbar->addComponent(
386 $this->ui_factory->button()->standard(
387 $this->lng->txt($this->getParentObject()->getType() . "_print_list"),
388 $this->ctrl->getLinkTarget($this, 'printMembers')
389 )
390 );
391
392 $this->showMailToMemberToolbarButton($this->toolbar, 'participants');
393 }
394}
return true
Class ilAbstractMailMemberRoles.
GUI class for learning sequence membership features.
__construct(ilObjectGUI $repository_gui, protected ilObject $obj, protected ilObjUserTracking $obj_user_tracking, protected ilPrivacySettings $privacy_settings, protected ilRbacReview $rbac_review, protected ilSetting $settings, protected ilToolbarGUI $toolbar, protected ILIAS\HTTP\Wrapper\RequestWrapper $request_wrapper, protected ArrayBasedRequestWrapper $post_wrapper, protected ILIAS\Refinery\Factory $refinery, protected ILIAS\UI\Factory $ui_factory)
readMemberData(array $usr_ids, ?array $columns=null)
filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids)
Filter user ids by access.
initParticipantTemplate()
Init participant view template.
getAttendanceListUserData(int $user_id, array $filters=[])
static getLogger(string $a_component_id)
Get component logger.
Base class for member tab content.
checkPermission(string $a_permission, string $a_cmd="")
Check permission If not granted redirect to parent gui.
ilParticipants $participants
participants()
Show participant table, subscriber table, wating list table;.
initAttendanceList(bool $a_for_members=false)
checkRbacOrPositionAccessBool(string $a_rbac_perm, string $a_pos_perm, int $a_ref_id=0)
showMailToMemberToolbarButton(ilToolbarGUI $toolbar, ?string $a_back_cmd=null, bool $a_separator=false)
Show mail to member toolbar button.
ilAccessHandler $access
Class ilObjectGUI Basic methods of all Output classes.
Class ilObject Basic functions for all objects.
updateNotification(int $a_usr_id, bool $a_notification)
Update notification status.
Singleton class that stores all privacy settings.
class ilRbacReview Contains Review functions of core Rbac.
static fillAutoCompleteToolbar(object $parent_object, ?ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt('user'), auto_complete_size = 15, user_type = array(ilCoursePar...
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addSubTabTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26