ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilMembershipGUI.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
19 
22 
28 {
32  protected Factory $refinery;
33  protected ilLanguage $lng;
35  protected ilLogger $logger;
39  protected ilObjUser $user;
41  protected ilTabsGUI $tabs;
45  protected ilTree $tree;
46  protected array $member_data = [];
47 
48  public function __construct(ilObjectGUI $repository_gui, ilObject $repository_obj)
49  {
50  global $DIC;
51 
52  $this->repository_gui = $repository_gui;
53  $this->repository_object = $repository_obj;
54 
55  $this->lng = $DIC->language();
56  $this->lng->loadLanguageModule('crs');
57  $this->lng->loadLanguageModule($this->getParentObject()->getType());
58  $this->tpl = $DIC->ui()->mainTemplate();
59  $this->ctrl = $DIC->ctrl();
60  $this->lng->loadLanguageModule('trac');
61  $this->logger = $DIC->logger()->mmbr();
62  $this->access = $DIC->access();
63  $this->user = $DIC->user();
64  $this->error = $DIC['ilErr'];
65  $this->tabs = $DIC->tabs();
66  $this->toolbar = $DIC->toolbar();
67  $this->rbacsystem = $DIC->rbac()->system();
68  $this->rbacreview = $DIC->rbac()->review();
69  $this->tree = $DIC->repositoryTree();
70  $this->http = $DIC->http();
71  $this->refinery = $DIC->refinery();
72  }
73 
77  protected function initParticipantsFromPost(): array
78  {
79  if ($this->http->wrapper()->post()->has('participants')) {
80  return $this->http->wrapper()->post()->retrieve(
81  'participants',
82  $this->refinery->kindlyTo()->listOf(
83  $this->refinery->kindlyTo()->int()
84  )
85  );
86  }
87  return [];
88  }
89 
90  protected function initMemberIdFromGet(): int
91  {
92  if ($this->http->wrapper()->query()->has('member_id')) {
93  return $this->http->wrapper()->query()->retrieve(
94  'member_id',
95  $this->refinery->kindlyTo()->int()
96  );
97  }
98  return 0;
99  }
100 
101  protected function initSubscribersFromPost(): array
102  {
103  if ($this->http->wrapper()->post()->has('subscribers')) {
104  return $this->http->wrapper()->post()->retrieve(
105  'subscribers',
106  $this->refinery->kindlyTo()->listOf(
107  $this->refinery->kindlyTo()->int()
108  )
109  );
110  }
111  return [];
112  }
113 
114  protected function initWaitingListIdsFromPost(): array
115  {
116  if ($this->http->wrapper()->post()->has('waiting')) {
117  return $this->http->wrapper()->post()->retrieve(
118  'waiting',
119  $this->refinery->kindlyTo()->listOf(
120  $this->refinery->kindlyTo()->int()
121  )
122  );
123  }
124  return [];
125  }
126 
127  protected function getLanguage(): ilLanguage
128  {
129  return $this->lng;
130  }
131 
132  protected function getCtrl(): ilCtrlInterface
133  {
134  return $this->ctrl;
135  }
136 
137  protected function getLogger(): ilLogger
138  {
139  return $this->logger;
140  }
141 
142  public function getParentGUI(): ilObjectGUI
143  {
144  return $this->repository_gui;
145  }
146 
147  public function getParentObject(): ilObject
148  {
150  }
151 
152  public function getMembersObject(): ilParticipants
153  {
154  if ($this->participants instanceof ilParticipants) {
155  return $this->participants;
156  }
157  return $this->participants = ilParticipants::getInstance($this->getParentObject()->getRefId());
158  }
159 
161  {
162  return null;
163  }
164 
165  protected function checkPermissionBool(
166  string $a_permission,
167  string $a_cmd = '',
168  string $a_type = '',
169  int $a_ref_id = 0
170  ): bool {
171  if ($a_ref_id === 0) {
172  $a_ref_id = $this->getParentObject()->getRefId();
173  }
174  return $this->access->checkAccess($a_permission, $a_cmd, $a_ref_id);
175  }
176 
177  protected function checkRbacOrPositionAccessBool(
178  string $a_rbac_perm,
179  string $a_pos_perm,
180  int $a_ref_id = 0
181  ): bool {
182  if ($a_ref_id === 0) {
183  $a_ref_id = $this->getParentObject()->getRefId();
184  }
185  return $this->access->checkRbacOrPositionPermissionAccess($a_rbac_perm, $a_pos_perm, $a_ref_id);
186  }
187 
192  protected function checkPermission(string $a_permission, string $a_cmd = ""): void
193  {
194  if (!$this->checkPermissionBool($a_permission, $a_cmd)) {
195  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'), true);
196  $this->ctrl->redirect($this->getParentGUI());
197  }
198  }
199 
203  protected function checkRbacOrPermissionAccess(string $a_rbac_perm, string $a_pos_perm): void
204  {
205  if (!$this->checkRbacOrPositionAccessBool($a_rbac_perm, $a_pos_perm)) {
206  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'), true);
207  $this->ctrl->redirect($this->getParentGUI());
208  }
209  }
210 
214  protected function canAddOrSearchUsers(): bool
215  {
216  return $this->checkPermissionBool('manage_members');
217  }
218 
224  public function filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids): array
225  {
226  return $a_user_ids;
227  }
228 
229  public function executeCommand(): void
230  {
231  $cmd = $this->ctrl->getCmd('participants');
232  $next_class = $this->ctrl->getNextClass();
233 
234  switch ($next_class) {
235  case 'ilrepositorysearchgui':
236 
237  $this->checkPermission('manage_members');
238 
239  $rep_search = new ilRepositorySearchGUI();
240  $rep_search->addUserAccessFilterCallable([$this, 'filterUserIdsByRbacOrPositionOfCurrentUser']);
241 
242  $participants = $this->getMembersObject();
243  if (
244  $participants->isAdmin($this->user->getId()) ||
245  $this->access->checkAccess('manage_members', '', $this->getParentObject()->getRefId())
246  ) {
247  $rep_search->setCallback(
248  $this,
249  'assignMembers',
250  $this->getParentGUI()->getLocalRoles(),
251  (string) $this->getDefaultRole()
252  );
253  } else {
254  //#18445 excludes admin role
255  $rep_search->setCallback(
256  $this,
257  'assignMembers',
258  $this->getLocalRoles(),
259  (string) $this->getDefaultRole()
260  );
261  }
262 
263  // Set tabs
264  $this->ctrl->setReturn($this, 'participants');
265  $ret = $this->ctrl->forwardCommand($rep_search);
266  break;
267 
268  case 'ilmailmembersearchgui':
269  $this->tabs->clearTargets();
270  $this->tabs->setBackTarget(
271  $this->lng->txt('btn_back'),
272  $this->ctrl->getLinkTarget($this, $this->getDefaultCommand())
273  );
274 
275  $mail = new ilMail($this->user->getId());
276  if (!(
277  $this->getParentObject()->getMailToMembersType() === ilCourseConstants::MAIL_ALLOWED_ALL ||
278  $this->access->checkAccess('manage_members', "", $this->getParentObject()->getRefId())
279  ) ||
280  !$this->rbacsystem->checkAccess(
281  'internal_mail',
282  $mail->getMailObjectReferenceId()
283  )) {
284  $this->error->raiseError($this->lng->txt("msg_no_perm_read"), $this->error->MESSAGE);
285  }
286 
287  $mail_search = new ilMailMemberSearchGUI(
288  $this,
289  $this->getParentObject()->getRefId(),
290  $this->getMailMemberRoles()
291  );
292  $mail_search->setObjParticipants(
293  ilParticipants::getInstance($this->getParentObject()->getRefId())
294  );
295  $this->ctrl->forwardCommand($mail_search);
296  break;
297 
298  case 'ilusersgallerygui':
299 
300  $this->setSubTabs($this->tabs);
301  $this->tabs->setSubTabActive(
302  $this->getParentObject()->getType() . '_members_gallery'
303  );
304  $is_admin = $this->checkRbacOrPositionAccessBool('manage_members', 'manage_members');
305  $is_participant = ilParticipants::_isParticipant(
306  $this->getParentObject()->getRefId(),
307  $this->user->getId()
308  );
309  if (
310  !$is_admin &&
311  (
312  !$this->getParentObject()->getShowMembers() ||
313  !$is_participant
314  )
315  ) {
316  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
317  }
318 
319  $this->showMailToMemberToolbarButton($this->toolbar, 'jump2UsersGallery');
320  $this->showMemberExportToolbarButton($this->toolbar, 'jump2UsersGallery');
321 
323  $gallery_gui = new ilUsersGalleryGUI($provider);
324  $this->ctrl->forwardCommand($gallery_gui);
325  break;
326 
327  case 'ilcourseparticipantsgroupsgui':
328 
329  $this->setSubTabs($this->tabs);
330  $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
331 
332  $cmg_gui = new ilCourseParticipantsGroupsGUI($this->getParentObject()->getRefId());
333  if ($cmd === "show" || $cmd = "") {
334  $this->showMailToMemberToolbarButton($this->toolbar);
335  }
336  $this->ctrl->forwardCommand($cmg_gui);
337  break;
338 
339  case 'ilsessionoverviewgui':
340 
341  $this->setSubTabs($this->tabs);
342  $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
343 
344  $prt = ilParticipants::getInstance($this->getParentObject()->getRefId());
345 
346  $overview = new ilSessionOverviewGUI($this->getParentObject()->getRefId(), $prt);
347  $this->ctrl->forwardCommand($overview);
348  break;
349 
350  case 'ilmemberexportgui':
351 
352  $this->setSubTabs($this->tabs);
353  $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
354 
355  $export = new ilMemberExportGUI($this->getParentObject()->getRefId());
356  $this->ctrl->forwardCommand($export);
357  break;
358 
359  case 'ilobjectcustomuserfieldsgui':
360 
361  $this->setSubTabs($this->tabs);
362  $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
363  $this->activateSubTab($this->getParentObject()->getType() . "_member_administration");
364  $this->ctrl->setReturn($this, 'participants');
365  $cdf_gui = new ilObjectCustomUserFieldsGUI($this->getParentGUI()->getObject()->getId());
366  $this->ctrl->forwardCommand($cdf_gui);
367  break;
368 
369  default:
370  $this->setSubTabs($this->tabs);
371  //exclude mailMembersBtn cmd from this check
372  if (
373  $cmd === "mailMembersBtn" ||
374  $cmd === 'membersMap' ||
375  $cmd === 'printForMembersOutput' ||
376  $cmd === 'jump2UsersGallery'
377  ) {
378  $this->checkPermission('read');
379  } else {
380  $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
381  }
382  $this->$cmd();
383  break;
384  }
385  }
386 
390  protected function participants(): void
391  {
392  $this->initParticipantTemplate();
393  $this->showParticipantsToolbar();
394  $this->activateSubTab($this->getParentObject()->getType() . "_member_administration");
395 
396  // show waiting list table
397  $waiting = $this->parseWaitingListTable();
398  if ($waiting instanceof ilWaitingListTableGUI) {
399  $this->tpl->setVariable('TABLE_WAIT', $waiting->getHTML());
400  }
401 
402  // show subscriber table
403  $subscriber = $this->parseSubscriberTable();
404  if ($subscriber instanceof ilSubscriberTableGUI) {
405  $this->tpl->setVariable('TABLE_SUB', $subscriber->getHTML());
406  }
407 
408  // show member table
409  $table = $this->initParticipantTableGUI();
410  $table->setTitle($this->getParticipantTableTitle());
411  $table->setFormAction($this->ctrl->getFormAction($this));
412  $table->parse();
413 
414  // filter commands
415  $table->setFilterCommand('participantsApplyFilter');
416  $table->setResetCommand('participantsResetFilter');
417 
418  $this->tpl->setVariable('MEMBERS', $table->getHTML());
419  }
420 
421  protected function getParticipantTableTitle(): string
422  {
423  return $this->lng->txt($this->getParentObject()->getType() . '_mem_tbl_header');
424  }
425 
426  public function getAttendanceListUserData(int $user_id, array $filters = []): array
427  {
428  return [];
429  }
430 
434  protected function participantsApplyFilter(): void
435  {
436  $table = $this->initParticipantTableGUI();
437  $table->resetOffset();
438  $table->writeFilterToSession();
439 
440  $this->participants();
441  }
442 
446  protected function participantsResetFilter(): void
447  {
448  $table = $this->initParticipantTableGUI();
449  $table->resetOffset();
450  $table->resetFilter();
451 
452  $this->participants();
453  }
454 
458  protected function editMember(): void
459  {
460  $this->activateSubTab($this->getParentObject()->getType() . "_member_administration");
461  $this->editParticipants(array($this->initMemberIdFromGet()));
462  }
463 
468  protected function editParticipants(array $post_participants = array()): void
469  {
470  if (!$post_participants) {
471  $post_participants = $this->initParticipantsFromPost();
472  }
473 
474  $real_participants = $this->getMembersObject()->getParticipants();
475  $participants = array_intersect($post_participants, $real_participants);
476 
477  if (!count($participants)) {
478  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
479  $this->ctrl->redirect($this, 'participants');
480  }
481  $table = $this->initEditParticipantTableGUI($participants);
482  $this->tpl->setContent($table->getHTML());
483  }
484 
488  public function updateParticipants(): void
489  {
490  $participants = $this->initParticipantsFromPost();
491  if (!count($participants)) {
492  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
493  $this->ctrl->redirect($this, 'participants');
494  }
495  $notifications = $passed = $blocked = $contact = [];
496  if ($this->http->wrapper()->post()->has('notification')) {
497  $notifications = $this->http->wrapper()->post()->retrieve(
498  'notification',
499  $this->refinery->kindlyTo()->listOf(
500  $this->refinery->kindlyTo()->int()
501  )
502  );
503  }
504  if ($this->http->wrapper()->post()->has('passed')) {
505  $passed = $this->http->wrapper()->post()->retrieve(
506  'passed',
507  $this->refinery->kindlyTo()->listOf(
508  $this->refinery->kindlyTo()->int()
509  )
510  );
511  }
512  if ($this->http->wrapper()->post()->has('blocked')) {
513  $blocked = $this->http->wrapper()->post()->retrieve(
514  'blocked',
515  $this->refinery->kindlyTo()->listOf(
516  $this->refinery->kindlyTo()->int()
517  )
518  );
519  }
520  if ($this->http->wrapper()->post()->has('contact')) {
521  $contact = $this->http->wrapper()->post()->retrieve(
522  'contact',
523  $this->refinery->kindlyTo()->listOf(
524  $this->refinery->kindlyTo()->int()
525  )
526  );
527  }
528 
529  // Determine whether the user has the 'edit_permission' permission
530  $hasEditPermissionAccess =
531  (
532  $this->access->checkAccess('edit_permission', '', $this->getParentObject()->getRefId()) or
533  $this->getMembersObject()->isAdmin($this->user->getId())
534  );
535 
536  // Get all assignable local roles of the object, and
537  // determine the role id of the course administrator role.
538  $assignableLocalRoles = array();
539  $adminRoleId = $this->getParentObject()->getDefaultAdminRole();
540  foreach ($this->getLocalTypeRole(false) as $title => $role_id) {
541  $assignableLocalRoles[$role_id] = $title;
542  }
543 
544  $post_roles = [];
545  if ($this->http->wrapper()->post()->has('roles')) {
546  $post_roles = $this->http->wrapper()->post()->retrieve(
547  'roles',
548  $this->refinery->kindlyTo()->dictOf(
549  $this->refinery->kindlyTo()->dictOf(
550  $this->refinery->kindlyTo()->int()
551  )
552  )
553  );
554  }
555 
556  // Validate the user ids and role ids in the post data
557  foreach ($participants as $usr_id) {
558  $memberIsAdmin = $this->rbacreview->isAssigned($usr_id, (int) $adminRoleId);
559 
560  // If the current user doesn't have the 'edit_permission'
561  // permission, make sure he doesn't remove the course
562  // administrator role of members who are course administrator.
563  if (
564  !$hasEditPermissionAccess &&
565  $memberIsAdmin &&
566  (
567  !is_array($post_roles[$usr_id]) ||
568  !in_array($adminRoleId, $post_roles[$usr_id])
569  )
570  ) {
571  $post_roles[$usr_id][] = $adminRoleId;
572  }
573 
574  // Validate the role ids in the post data
575  foreach ((array) $post_roles[$usr_id] as $role_id) {
576  if (!array_key_exists($role_id, $assignableLocalRoles)) {
577  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_perm'), true);
578  $this->ctrl->redirect($this, 'participants');
579  }
580  if (!$hasEditPermissionAccess &&
581  $role_id == $adminRoleId &&
582  !$memberIsAdmin) {
583  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_perm'));
584  $this->ctrl->redirect($this, 'participants');
585  }
586  }
587  }
588 
589  $has_admin = false;
590  foreach ($this->getMembersObject()->getAdmins() as $admin_id) {
591  if (!isset($post_roles[$admin_id])) {
592  $has_admin = true;
593  break;
594  }
595  if (in_array($adminRoleId, (array) $post_roles[$admin_id])) {
596  $has_admin = true;
597  break;
598  }
599  }
600 
601  if (!$has_admin && is_array($post_roles)) {
602  // TODO PHP8 Review: Check change of SuperGlobals
603  foreach ($post_roles as $roleIdsToBeAssigned) {
604  if (in_array($adminRoleId, $roleIdsToBeAssigned)) {
605  $has_admin = true;
606  break;
607  }
608  }
609  }
610 
611  if (!$has_admin) {
612  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($this->getParentObject()->getType() . '_min_one_admin'), true);
613  $this->ctrl->redirect($this, 'participants');
614  }
615 
616  foreach ($participants as $usr_id) {
617  $this->getMembersObject()->updateRoleAssignments($usr_id, (array) $post_roles[$usr_id]);
618 
619  // Disable notification for all of them
620  $this->getMembersObject()->updateNotification($usr_id, false);
621  if (($this->getMembersObject()->isTutor($usr_id) || $this->getMembersObject()->isAdmin($usr_id)) && in_array(
622  $usr_id,
623  $notifications
624  )) {
625  $this->getMembersObject()->updateNotification($usr_id, true);
626  }
627 
628  $this->getMembersObject()->updateBlocked($usr_id, false);
629  if ((!$this->getMembersObject()->isAdmin($usr_id) && !$this->getMembersObject()->isTutor($usr_id)) && in_array(
630  $usr_id,
631  $blocked
632  )) {
633  $this->getMembersObject()->updateBlocked($usr_id, true);
634  }
635 
636  if ($this instanceof ilCourseMembershipGUI) {
637  $this->getMembersObject()->updatePassed($usr_id, in_array($usr_id, $passed), true);
638  $this->getMembersObject()->sendNotification(
640  $usr_id
641  );
642  }
643 
644  if (
645  ($this->getMembersObject()->isAdmin($usr_id) || $this->getMembersObject()->isTutor($usr_id)) &&
646  in_array($usr_id, $contact)
647  ) {
648  $this->getMembersObject()->updateContact($usr_id, true);
649  } else {
650  $this->getMembersObject()->updateContact($usr_id, false);
651  }
652 
653  $this->updateLPFromStatus($usr_id, in_array($usr_id, $passed));
654  }
655  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
656  $this->ctrl->redirect($this, "participants");
657  }
658 
659  protected function updateLPFromStatus(int $usr_id, bool $has_passed): void
660  {
661  }
662 
666  protected function confirmDeleteParticipants(): void
667  {
668  $participants = $this->initParticipantsFromPost();
669 
670  if (!count($participants)) {
671  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
672  $this->ctrl->redirect($this, 'participants');
673  }
674 
675  // Check last admin
676  if (!$this->getMembersObject()->checkLastAdmin($participants)) {
677  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($this->getParentObject()->getType() . '_at_least_one_admin'), true);
678  $this->ctrl->redirect($this, 'participants');
679  }
680 
681  // if only position access is granted, show additional info
682  if (!$this->checkPermissionBool('manage_members')) {
683  $this->lng->loadLanguageModule('rbac');
684  $this->tpl->setOnScreenMessage('info', $this->lng->txt('rbac_info_only_position_access'));
685  }
686 
687  // Access check for admin deletion
688  if (
689  !$this->access->checkAccess(
690  'edit_permission',
691  '',
692  $this->getParentObject()->getRefId()
693  ) &&
694  !$this->getMembersObject()->isAdmin($this->user->getId())
695  ) {
696  foreach ($participants as $usr_id) {
697  if ($this->getMembersObject()->isAdmin($usr_id)) {
698  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_perm_perm"), true);
699  $this->ctrl->redirect($this, 'participants');
700  }
701  }
702  }
703 
705  $this->repository_object->getRefId(),
707  )) {
708  $this->showDeleteParticipantsConfirmationWithLinkedCourses($participants);
709  return;
710  }
711 
712  $confirm = new ilConfirmationGUI();
713  $confirm->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteParticipants'));
714  $confirm->setHeaderText($this->lng->txt($this->getParentObject()->getType() . '_header_delete_members'));
715  $confirm->setConfirm($this->lng->txt('confirm'), 'deleteParticipants');
716  $confirm->setCancel($this->lng->txt('cancel'), 'participants');
717 
718  foreach ($participants as $usr_id) {
719  $name = ilObjUser::_lookupName($usr_id);
720 
721  $confirm->addItem(
722  'participants[]',
723  (string) $name['user_id'],
724  $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
725  ilUtil::getImagePath('standard/icon_usr.svg')
726  );
727  }
728  $this->tpl->setContent($confirm->getHTML());
729  }
730 
731  protected function deleteParticipants(): void
732  {
733  $participants = $this->initParticipantsFromPost();
734  if (!count($participants)) {
735  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
736  $this->ctrl->redirect($this, 'participants');
737  }
738 
739  // If the user doesn't have the edit_permission and is not administrator, he may not remove
740  // members who have the course administrator role
741  if (
742  !$this->access->checkAccess('edit_permission', '', $this->getParentObject()->getRefId()) &&
743  !$this->getMembersObject()->isAdmin($this->user->getId())
744  ) {
745  foreach ($participants as $part) {
746  if ($this->getMembersObject()->isAdmin($part)) {
747  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_perm'), true);
748  $this->ctrl->redirect($this, 'participants');
749  }
750  }
751  }
752 
753  if (!$this->getMembersObject()->deleteParticipants($participants)) {
754  $this->tpl->setOnScreenMessage('failure', 'Error deleting participants.', true);
755  $this->ctrl->redirect($this, 'participants');
756  } else {
757  foreach ($participants as $usr_id) {
758  $mail_type = 0;
759  // @todo more generic
760  switch ($this->getParentObject()->getType()) {
761  case 'crs':
763  break;
764  case 'grp':
766  break;
767  case 'lso':
769  break;
770  }
771  $this->getMembersObject()->sendNotification($mail_type, $usr_id);
772  }
773  }
774  $this->tpl->setOnScreenMessage('success', $this->lng->txt($this->getParentObject()->getType() . "_members_deleted"), true);
775  $this->ctrl->redirect($this, "participants");
776  }
777 
778  protected function sendMailToSelectedUsers(): void
779  {
780  $participants = [];
781  if ($this->http->wrapper()->post()->has('participants')) {
782  $participants = $this->initParticipantsFromPost();
783  } elseif ($this->http->wrapper()->post()->has('subscribers')) {
784  $participants = $this->initSubscribersFromPost();
785  } elseif ($this->http->wrapper()->post()->has('waiting')) {
786  $participants = $this->initWaitingListIdsFromPost();
787  } elseif ($this->http->wrapper()->query()->has('member_id')) {
788  $participants = [$this->initMemberIdFromGet()];
789  }
790  if (!count($participants)) {
791  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
792  $this->ctrl->redirect($this, 'participants');
793  }
794 
795  $rcps = [];
796  foreach ($participants as $usr_id) {
797  $rcps[] = ilObjUser::_lookupLogin($usr_id);
798  }
799  $context_options = $this->getMailContextOptions();
800 
804  $this,
805  'participants',
806  array(),
807  array(
808  'type' => 'new',
809  'sig' => $this->createMailSignature()
810  ),
811  $context_options
812  )
813  );
814  }
815 
816  protected function getMailContextOptions(): array
817  {
818  return [];
819  }
820 
824  protected function membersMap(): void
825  {
826  $this->activateSubTab($this->getParentObject()->getType() . "_members_map");
827  if (!ilMapUtil::isActivated() || !$this->getParentObject()->getEnableMap()) {
828  return;
829  }
830 
831  $map = ilMapUtil::getMapGUI();
832  $map->setMapId("course_map")
833  ->setWidth("700px")
834  ->setHeight("500px")
835  ->setLatitude($this->getParentObject()->getLatitude())
836  ->setLongitude($this->getParentObject()->getLongitude())
837  ->setZoom($this->getParentObject()->getLocationZoom())
838  ->setEnableTypeControl(true)
839  ->setEnableNavigationControl(true)
840  ->setEnableCentralMarker(true);
841 
842  $members = ilParticipants::getInstanceByObjId($this->getParentObject()->getId())->getParticipants();
843  foreach ($members as $user_id) {
844  $map->addUserMarker($user_id);
845  }
846 
847  $this->tpl->setContent($map->getHtml());
848  $this->tpl->setLeftContent($map->getUserListHtml());
849  }
850 
851  protected function mailMembersBtn(): void
852  {
853  $this->showMailToMemberToolbarButton($this->toolbar, 'mailMembersBtn');
854  }
855 
859  protected function showParticipantsToolbar(): void
860  {
861  if ($this->canAddOrSearchUsers()) {
863  $this,
864  $this->toolbar,
865  array(
866  'auto_complete_name' => $this->lng->txt('user'),
867  'user_type' => $this->getParentGUI()->getLocalRoles(),
868  'user_type_default' => $this->getDefaultRole(),
869  'submit_name' => $this->lng->txt('add')
870  )
871  );
872 
873  // spacer
874  $this->toolbar->addSeparator();
875 
876  // search button
877  $this->toolbar->addButton(
878  $this->lng->txt($this->getParentObject()->getType() . "_search_users"),
879  $this->ctrl->getLinkTargetByClass(
880  'ilRepositorySearchGUI',
881  'start'
882  )
883  );
884 
885  // separator
886  $this->toolbar->addSeparator();
887  }
888 
889  // print button
890  $this->toolbar->addButton(
891  $this->lng->txt($this->getParentObject()->getType() . "_print_list"),
892  $this->ctrl->getLinkTarget($this, 'printMembers')
893  );
894  $this->showMailToMemberToolbarButton($this->toolbar, 'participants', false);
895  }
896 
897  protected function showMemberExportToolbarButton(
898  ilToolbarGUI $toolbar,
899  ?string $a_back_cmd = null,
900  bool $a_separator = false
901  ): void {
902  if (
903  $this->getParentObject()->getType() === 'crs' &&
904  $this->getParentObject()->getShowMembersExport()) {
905  if ($a_separator) {
906  $toolbar->addSeparator();
907  }
908 
909  if ($a_back_cmd) {
910  $this->ctrl->setParameter($this, "back_cmd", $a_back_cmd);
911  }
912  $toolbar->addButton(
913  $this->lng->txt($this->getParentObject()->getType() . '_print_list'),
914  $this->ctrl->getLinkTarget($this, 'printForMembersOutput')
915  );
916  }
917  }
918 
922  protected function showMailToMemberToolbarButton(
923  ilToolbarGUI $toolbar,
924  ?string $a_back_cmd = null,
925  bool $a_separator = false
926  ): void {
927  $mail = new ilMail($this->user->getId());
928 
929  if (
930  ($this->getParentObject()->getMailToMembersType() === 1) ||
931  (
932  $this->access->checkAccess('manage_members', "", $this->getParentObject()->getRefId()) &&
933  $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId())
934  )
935  ) {
936  if ($a_separator) {
937  $toolbar->addSeparator();
938  }
939 
940  if ($a_back_cmd !== null) {
941  $this->ctrl->setParameter($this, "back_cmd", $a_back_cmd);
942  }
943 
944  $toolbar->addButton(
945  $this->lng->txt("mail_members"),
946  $this->ctrl->getLinkTargetByClass('ilMailMemberSearchGUI', '')
947  );
948  }
949  }
950 
955  public function createMailSignature(): string
956  {
957  return $this->getParentGUI()->createMailSignature();
958  }
959 
960  protected function getDefaultCommand(): string
961  {
962  $has_manage_members_permission = $this->checkRbacOrPositionAccessBool(
963  'manage_members',
964  'manage_members',
965  $this->getParentObject()->getRefId()
966  );
967  if ($has_manage_members_permission) {
968  return 'participants';
969  }
970 
971  if ($this->getParentObject()->getShowMembers()) {
972  return 'jump2UsersGallery';
973  }
974  return 'mailMembersBtn';
975  }
976 
977  public function addMemberTab(ilTabsGUI $tabs, bool $a_is_participant = false): void
978  {
979  $mail = new ilMail($this->user->getId());
980 
981  $member_tab_name = $this->getMemberTabName();
982 
983  $has_manage_members_permission = $this->checkRbacOrPositionAccessBool(
984  'manage_members',
985  'manage_members',
986  $this->getParentObject()->getRefId()
987  );
988 
989  if ($has_manage_members_permission) {
990  $tabs->addTab(
991  'members',
992  $member_tab_name,
993  $this->ctrl->getLinkTarget($this, '')
994  );
995  } elseif (
996  $this->getParentObject()->getShowMembers() &&
997  $a_is_participant
998  ) {
999  $tabs->addTab(
1000  'members',
1001  $member_tab_name,
1002  $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilusersgallerygui'), 'view')
1003  );
1004  } elseif (
1005  $this->getParentObject()->getMailToMembersType() === 1 &&
1006  $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId()) &&
1007  $a_is_participant
1008  ) {
1009  $tabs->addTab(
1010  'members',
1011  $member_tab_name,
1012  $this->ctrl->getLinkTarget($this, "mailMembersBtn")
1013  );
1014  }
1015  }
1016 
1017  protected function getMemberTabName(): string
1018  {
1019  return $this->lng->txt('members');
1020  }
1021 
1025  protected function setSubTabs(ilTabsGUI $tabs): void
1026  {
1027  if ($this->checkRbacOrPositionAccessBool(
1028  'manage_members',
1029  'manage_members',
1030  $this->getParentObject()->getRefId()
1031  )) {
1032  $tabs->addSubTabTarget(
1033  $this->getParentObject()->getType() . "_member_administration",
1034  $this->ctrl->getLinkTarget($this, 'participants'),
1035  "members",
1036  get_class($this)
1037  );
1038 
1039  // show group overview
1040  if ($this instanceof ilCourseMembershipGUI) {
1041  $tabs->addSubTabTarget(
1042  "crs_members_groups",
1043  $this->ctrl->getLinkTargetByClass("ilCourseParticipantsGroupsGUI", "show"),
1044  "",
1045  "ilCourseParticipantsGroupsGUI"
1046  );
1047  }
1048 
1049  $children = $this->tree->getSubTree(
1050  $this->tree->getNodeData($this->getParentObject()->getRefId()),
1051  false,
1052  ['sess']
1053  );
1054  if (count($children)) {
1055  $tabs->addSubTabTarget(
1056  'events',
1057  $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilsessionoverviewgui'), 'listSessions'),
1058  '',
1059  'ilsessionoverviewgui'
1060  );
1061  }
1062  $tabs->addSubTabTarget(
1063  $this->getParentObject()->getType() . '_members_gallery',
1064  $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilUsersGalleryGUI')),
1065  'view',
1066  'ilUsersGalleryGUI'
1067  );
1068  } elseif ($this->getParentObject()->getShowMembers()) {
1069  // gallery
1070  $tabs->addSubTabTarget(
1071  $this->getParentObject()->getType() . '_members_gallery',
1072  $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilUsersGalleryGUI')),
1073  'view',
1074  'ilUsersGalleryGUI'
1075  );
1076  }
1077 
1078  if (ilMapUtil::isActivated() && $this->getParentObject()->getEnableMap()) {
1079  $tabs->addSubTabTarget(
1080  $this->getParentObject()->getType() . '_members_map',
1081  $this->ctrl->getLinkTarget($this, 'membersMap'),
1082  "membersMap",
1083  get_class($this)
1084  );
1085  }
1086 
1087  if (ilPrivacySettings::getInstance()->checkExportAccess($this->getParentObject()->getRefId())) {
1088  $tabs->addSubTabTarget(
1089  'export_members',
1090  $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilmemberexportgui'), 'show'),
1091  '',
1092  'ilmemberexportgui'
1093  );
1094  }
1095  }
1096 
1101  public function readMemberData(array $usr_ids, array $columns): array
1102  {
1103  return $this->getParentGUI()->readMemberData($usr_ids, $columns);
1104  }
1105 
1109  public function getLocalRoles(): array
1110  {
1111  return $this->getParentGUI()->getLocalRoles();
1112  }
1113 
1118  {
1119  $subscribers = $this->getMembersObject()->getSubscribers();
1120  $filtered_subscribers = $this->filterUserIdsByRbacOrPositionOfCurrentUser($subscribers);
1121  if (!count($filtered_subscribers)) {
1122  return null;
1123  }
1124  $subscriber = $this->initSubscriberTable();
1125  $subscriber->readSubscriberData(
1126  $filtered_subscribers
1127  );
1128  return $subscriber;
1129  }
1130 
1132  {
1133  $subscriber = new ilSubscriberTableGUI($this, $this->getParentObject(), true, true);
1134  $subscriber->setTitle($this->lng->txt('group_new_registrations'));
1135  return $subscriber;
1136  }
1137 
1141  public function confirmAssignSubscribers(): void
1142  {
1143  $subscribers = $this->initSubscribersFromPost();
1144  if (!count($subscribers)) {
1145  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1146  $this->ctrl->redirect($this, 'participants');
1147  }
1148 
1149  $c_gui = new ilConfirmationGUI();
1150 
1151  // set confirm/cancel commands
1152  $c_gui->setFormAction($this->ctrl->getFormAction($this, "assignSubscribers"));
1153  $c_gui->setHeaderText($this->lng->txt("info_assign_sure"));
1154  $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1155  $c_gui->setConfirm($this->lng->txt("confirm"), "assignSubscribers");
1156 
1157  foreach ($subscribers as $subscriber) {
1158  $name = ilObjUser::_lookupName($subscriber);
1159 
1160  $c_gui->addItem(
1161  'subscribers[]',
1162  (string) $name['user_id'],
1163  $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1164  ilUtil::getImagePath('standard/icon_usr.svg')
1165  );
1166  }
1167  $this->tpl->setContent($c_gui->getHTML());
1168  }
1169 
1173  public function confirmRefuseSubscribers(): void
1174  {
1175  $subscribers = $this->initSubscribersFromPost();
1176  if (!count($subscribers)) {
1177  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1178  $this->ctrl->redirect($this, 'participants');
1179  }
1180  $this->lng->loadLanguageModule('mmbr');
1181  $c_gui = new ilConfirmationGUI();
1182  // set confirm/cancel commands
1183  $c_gui->setFormAction($this->ctrl->getFormAction($this, "refuseSubscribers"));
1184  $c_gui->setHeaderText($this->lng->txt("info_refuse_sure"));
1185  $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1186  $c_gui->setConfirm($this->lng->txt("confirm"), "refuseSubscribers");
1187 
1188  foreach ($subscribers as $subscriber_id) {
1189  $name = ilObjUser::_lookupName($subscriber_id);
1190 
1191  $c_gui->addItem(
1192  'subscribers[]',
1193  (string) $name['user_id'],
1194  $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1195  ilUtil::getImagePath('standard/icon_usr.svg')
1196  );
1197  }
1198 
1199  $this->tpl->setContent($c_gui->getHTML());
1200  }
1201 
1202  protected function refuseSubscribers(): void
1203  {
1204  $subscribers = $this->initSubscribersFromPost();
1205  if (!count($subscribers)) {
1206  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1207  $this->ctrl->redirect($this, 'participants');
1208  }
1209 
1210  if (!$this->getMembersObject()->deleteSubscribers($subscribers)) {
1211  $this->tpl->setOnScreenMessage('failure', $this->error->getMessage(), true);
1212  $this->ctrl->redirect($this, 'participants');
1213  } else {
1214  foreach ($subscribers as $usr_id) {
1215  if ($this instanceof ilCourseMembershipGUI) {
1216  $this->getMembersObject()->sendNotification(
1218  $usr_id
1219  );
1220  }
1221  if ($this instanceof ilGroupMembershipGUI) {
1222  $this->getMembersObject()->sendNotification(
1224  $usr_id
1225  );
1226  }
1227  if ($this instanceof ilSessionMembershipGUI) {
1229  $noti->setRefId($this->getParentObject()->getRefId());
1230  $noti->setRecipients(array($usr_id));
1232  $noti->send();
1233  }
1234  if ($this instanceof ilLearningSequenceMembershipGUI) {
1235  $this->getMembersObject()->sendNotification(
1237  $usr_id
1238  );
1239  }
1240  }
1241  }
1242 
1243  $this->tpl->setOnScreenMessage('success', $this->lng->txt("crs_subscribers_deleted"), true);
1244  $this->ctrl->redirect($this, 'participants');
1245  }
1246 
1250  public function assignSubscribers(): void
1251  {
1252  $subscribers = $this->initSubscribersFromPost();
1253  if (!count($subscribers)) {
1254  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1255  $this->ctrl->redirect($this, 'participants');
1256  }
1257 
1258  if (!$this->getMembersObject()->assignSubscribers($subscribers)) {
1259  $this->tpl->setOnScreenMessage('failure', $this->error->getMessage(), true);
1260  $this->ctrl->redirect($this, 'participants');
1261  } else {
1262  foreach ($subscribers as $usr_id) {
1263  if ($this instanceof ilCourseMembershipGUI) {
1264  $this->getMembersObject()->sendNotification(
1266  $usr_id
1267  );
1268  $this->getParentObject()->checkLPStatusSync($usr_id);
1269  }
1270  if ($this instanceof ilGroupMembershipGUI) {
1271  $this->getMembersObject()->sendNotification(
1273  $usr_id
1274  );
1275  }
1276  if ($this instanceof ilSessionMembershipGUI) {
1277  // todo refactor to participants
1279  $noti->setRefId($this->getParentObject()->getRefId());
1280  $noti->setRecipients(array($usr_id));
1282  $noti->send();
1283  }
1284  }
1285  }
1286  $this->tpl->setOnScreenMessage('success', $this->lng->txt("crs_subscribers_assigned"), true);
1287  $this->ctrl->redirect($this, 'participants');
1288  }
1289 
1294  {
1295  $wait = $this->initWaitingList();
1296 
1297  $wait_users = $this->filterUserIdsByRbacOrPositionOfCurrentUser($wait->getUserIds());
1298  if (!count($wait_users)) {
1299  return null;
1300  }
1301 
1302  $waiting_table = new ilWaitingListTableGUI($this, $this->getParentObject(), $wait);
1303  $waiting_table->setUserIds(
1304  $wait_users
1305  );
1306  $waiting_table->readUserData();
1307  $waiting_table->setTitle($this->lng->txt('crs_waiting_list'));
1308 
1309  return $waiting_table;
1310  }
1311 
1315  public function confirmAssignFromWaitingList(): void
1316  {
1317  $waiting_list_ids = $this->initWaitingListIdsFromPost();
1318  if (!count($waiting_list_ids)) {
1319  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_users_selected"), true);
1320  $this->ctrl->redirect($this, 'participants');
1321  }
1322  $c_gui = new ilConfirmationGUI();
1323  // set confirm/cancel commands
1324  $c_gui->setFormAction($this->ctrl->getFormAction($this, "assignFromWaitingList"));
1325  $c_gui->setHeaderText($this->lng->txt("info_assign_sure"));
1326  $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1327  $c_gui->setConfirm($this->lng->txt("confirm"), "assignFromWaitingList");
1328 
1329  foreach ($waiting_list_ids as $waiting) {
1330  $name = ilObjUser::_lookupName($waiting);
1331 
1332  $c_gui->addItem(
1333  'waiting[]',
1334  (string) $name['user_id'],
1335  $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1336  ilUtil::getImagePath('standard/icon_usr.svg')
1337  );
1338  }
1339 
1340  $this->tpl->setContent($c_gui->getHTML());
1341  }
1342 
1346  public function assignFromWaitingList(): void
1347  {
1348  $waiting_list_ids = $this->initWaitingListIdsFromPost();
1349  if (!count($waiting_list_ids)) {
1350  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_users_selected"), true);
1351  $this->ctrl->redirect($this, 'participants');
1352  }
1353 
1354  $waiting_list = $this->initWaitingList();
1355 
1356  $added_users = 0;
1357  foreach ($waiting_list_ids as $user_id) {
1358  if (!$tmp_obj = ilObjectFactory::getInstanceByObjId((int) $user_id, false)) {
1359  continue;
1360  }
1361  if ($this->getMembersObject()->isAssigned((int) $user_id)) {
1362  continue;
1363  }
1364 
1365  if ($this instanceof ilCourseMembershipGUI) {
1366  $this->getMembersObject()->add($user_id, ilParticipants::IL_CRS_MEMBER);
1367  $this->getMembersObject()->sendNotification(
1369  (int) $user_id,
1370  true
1371  );
1372  $this->getParentObject()->checkLPStatusSync((int) $user_id);
1373  }
1374  if ($this instanceof ilGroupMembershipGUI) {
1375  $this->getMembersObject()->add($user_id, ilParticipants::IL_GRP_MEMBER);
1376  $this->getMembersObject()->sendNotification(
1378  (int) $user_id,
1379  true
1380  );
1381  }
1382  if ($this instanceof ilSessionMembershipGUI) {
1383  $this->getMembersObject()->register((int) $user_id);
1385  $noti->setRefId($this->getParentObject()->getRefId());
1386  $noti->setRecipients(array($user_id));
1388  $noti->send();
1389  }
1390 
1391  $waiting_list->removeFromList((int) $user_id);
1392  ++$added_users;
1393  }
1394 
1395  if ($added_users) {
1396  $this->tpl->setOnScreenMessage('success', $this->lng->txt("crs_users_added"), true);
1397  } else {
1398  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_users_already_assigned"), true);
1399  }
1400  $this->ctrl->redirect($this, 'participants');
1401  }
1402 
1406  public function confirmRefuseFromList(): void
1407  {
1408  $waiting_list_ids = $this->initWaitingListIdsFromPost();
1409  if (!count($waiting_list_ids)) {
1410  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1411  $this->ctrl->redirect($this, 'participants');
1412  }
1413  $this->lng->loadLanguageModule('mmbr');
1414  $c_gui = new ilConfirmationGUI();
1415 
1416  // set confirm/cancel commands
1417  $c_gui->setFormAction($this->ctrl->getFormAction($this, "refuseFromList"));
1418  $c_gui->setHeaderText($this->lng->txt("info_refuse_sure"));
1419  $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1420  $c_gui->setConfirm($this->lng->txt("confirm"), "refuseFromList");
1421 
1422  foreach ($waiting_list_ids as $waiting) {
1423  $name = ilObjUser::_lookupName($waiting);
1424 
1425  $c_gui->addItem(
1426  'waiting[]',
1427  (string) $name['user_id'],
1428  $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1429  ilUtil::getImagePath('standard/icon_usr.svg')
1430  );
1431  }
1432  $this->tpl->setContent($c_gui->getHTML());
1433  }
1434 
1438  protected function refuseFromList(): void
1439  {
1440  $waiting_list_ids = $this->initWaitingListIdsFromPost();
1441  if (!count($waiting_list_ids)) {
1442  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
1443  $this->ctrl->redirect($this, 'participants');
1444  }
1445 
1446  $waiting_list = $this->initWaitingList();
1447 
1448  foreach ($waiting_list_ids as $user_id) {
1449  $waiting_list->removeFromList((int) $user_id);
1450 
1451  if ($this instanceof ilCourseMembershipGUI) {
1452  $this->getMembersObject()->sendNotification(
1454  (int) $user_id,
1455  true
1456  );
1457  }
1458  if ($this instanceof ilGroupMembershipGUI) {
1459  $this->getMembersObject()->sendNotification(
1461  (int) $user_id,
1462  true
1463  );
1464  }
1465  if ($this instanceof ilSessionMembershipGUI) {
1467  $noti->setRefId($this->getParentObject()->getRefId());
1468  $noti->setRecipients(array($user_id));
1470  $noti->send();
1471  }
1472  }
1473  $this->tpl->setOnScreenMessage('success', $this->lng->txt('crs_users_removed_from_list'), true);
1474  $this->ctrl->redirect($this, 'participants');
1475  }
1476 
1480  protected function addToClipboard(): void
1481  {
1482  // begin-patch clipboard
1483  $users = [];
1484  if ($this->http->wrapper()->post()->has('participants')) {
1485  $users = $this->initParticipantsFromPost();
1486  } elseif ($this->http->wrapper()->post()->has('subscribers')) {
1487  $users = $this->initSubscribersFromPost();
1488  } elseif ($this->http->wrapper()->post()->has('waiting')) {
1489  $users = $this->initWaitingListIdsFromPost();
1490  }
1491  // end-patch clipboard
1492  if (!count($users)) {
1493  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
1494  $this->ctrl->redirect($this, 'participants');
1495  }
1496  $clip = ilUserClipboard::getInstance($this->user->getId());
1497  $clip->add($users);
1498  $clip->save();
1499 
1500  $this->lng->loadLanguageModule('user');
1501  $this->tpl->setOnScreenMessage('success', $this->lng->txt('clipboard_user_added'), true);
1502  $this->ctrl->redirect($this, 'participants');
1503  }
1504 
1505  protected function getDefaultRole(): ?int
1506  {
1507  return null;
1508  }
1509 
1510  protected function activateSubTab(string $a_sub_tab): void
1511  {
1512  $this->tabs->activateSubTab($a_sub_tab);
1513  }
1514 
1518  protected function printMembers(): void
1519  {
1520  $this->checkPermission('read');
1521 
1522  $this->tabs->clearTargets();
1523 
1524  $this->tabs->setBackTarget(
1525  $this->lng->txt('back'),
1526  $this->ctrl->getLinkTarget($this, 'participants')
1527  );
1528 
1529  $list = $this->initAttendanceList();
1530  $form = $list->initForm('printMembersOutput');
1531  $this->tpl->setContent($form->getHTML());
1532  }
1533 
1537  protected function printMembersOutput(): void
1538  {
1539  $this->tabs->clearTargets();
1540  $this->tabs->setBackTarget(
1541  $this->lng->txt('back'),
1542  $this->ctrl->getLinkTarget($this, 'participants')
1543  );
1544 
1545  $list = $this->initAttendanceList();
1546  $list->initFromForm();
1547  $list->setCallback([$this, 'getAttendanceListUserData']);
1548  $this->member_data = $this->getPrintMemberData(
1550  $this->getMembersObject()->getParticipants()
1551  )
1552  );
1553 
1554  $list->getNonMemberUserData($this->member_data);
1555  $list->getFullscreenHTML();
1556  }
1557 
1561  protected function printForMembersOutput(): void
1562  {
1563  $this->tabs->clearTargets();
1564  $this->tabs->setBackTarget(
1565  $this->lng->txt('back'),
1566  $this->ctrl->getLinkTarget($this, 'jump2UsersGallery')
1567  );
1568 
1569  $list = $this->initAttendanceList();
1570  $list->setTitle($this->lng->txt('obj_' . $this->getParentObject()->getType()) . ': ' . $this->getParentObject()->getTitle());
1571  $list->initFromSettings();
1572  $list->setCallback([$this, 'getAttendanceListUserData']);
1573  $this->member_data = $this->getPrintMemberData($this->getMembersObject()->getParticipants());
1574  $list->getNonMemberUserData($this->member_data);
1575  $list->getFullscreenHTML();
1576  }
1577 
1578  protected function jump2UsersGallery(): void
1579  {
1580  $this->ctrl->redirectByClass('ilUsersGalleryGUI');
1581  }
1582 
1583  protected function initAttendanceList(bool $a_for_members = false): ?ilAttendanceList
1584  {
1585  global $DIC;
1586 
1587  $waiting_list = $this->initWaitingList();
1588 
1589  if ($this instanceof ilSessionMembershipGUI) {
1590  /*
1591  * TODO this exact logic is also in ilSessionParticipantsTableGUI and ilSessionMembershipGUI,
1592  * should be centralized.
1593  */
1594  $member_id = $DIC->repositoryTree()->checkForParentType(
1595  $this->getParentObject()->getRefId(),
1596  'grp'
1597  );
1598  if (!$member_id) {
1599  $member_id = $DIC->repositoryTree()->checkForParentType(
1600  $this->getParentObject()->getRefId(),
1601  'crs'
1602  );
1603  }
1604  if (!$member_id) {
1605  $DIC->logger()->sess()->warning('Cannot find parent course or group for ref_id: ' . $this->getParentObject()->getRefId());
1606  $member_id = $this->getParentObject()->getRefId();
1607  }
1608  $part = ilParticipants::getInstance($member_id);
1609 
1610  $list = new ilAttendanceList(
1611  $this,
1612  $this->getParentObject(),
1613  $part,
1614  $waiting_list
1615  );
1616  } else {
1617  $list = new ilAttendanceList(
1618  $this,
1619  $this->getParentObject(),
1620  $this->getMembersObject(),
1621  $waiting_list
1622  );
1623  }
1624  $list->setId($this->getParentObject()->getType() . '_memlist_' . $this->getParentObject()->getId());
1625 
1626  $list->setTitle(
1627  $this->lng->txt($this->getParentObject()->getType() . '_members_print_title'),
1628  $this->lng->txt('obj_' . $this->getParentObject()->getType()) . ': ' . $this->getParentObject()->getTitle()
1629  );
1630 
1631  $show_tracking =
1633  if ($show_tracking) {
1634  $olp = ilObjectLP::getInstance($this->getParentObject()->getId());
1635  $show_tracking = $olp->isActive();
1636  }
1637  if ($show_tracking && $this->getParentObject()->getType() !== 'sess') {
1638  $list->addPreset('progress', $this->lng->txt('learning_progress'), true);
1639  }
1640 
1641  $privacy = ilPrivacySettings::getInstance();
1642  if ($privacy->enabledAccessTimesByType($this->getParentObject()->getType())) {
1643  $list->addPreset('access', $this->lng->txt('last_access'), true);
1644  }
1645 
1646  switch ($this->getParentObject()->getType()) {
1647  case 'crs':
1648  $list->addPreset('status', $this->lng->txt('crs_status'), true);
1649  $list->addPreset('passed', $this->lng->txt('crs_passed'), true);
1650  break;
1651 
1652  case 'sess':
1653  $list->addPreset('mark', $this->lng->txt('trac_mark'), true);
1654  $list->addPreset('comment', $this->lng->txt('trac_comment'), true);
1655  if ($this->getParentObject()->enabledRegistration()) {
1656  $list->addPreset('registered', $this->lng->txt('event_tbl_registered'), true);
1657  }
1658  $list->addPreset('participated', $this->lng->txt('event_tbl_participated'), true);
1659  $list->addBlank($this->lng->txt('sess_signature'));
1660 
1661  $list->addUserFilter('registered', $this->lng->txt('event_list_registered_only'));
1662  break;
1663 
1664  case 'grp':
1665  default:
1666  break;
1667  }
1668  return $list;
1669  }
1670 }
readMemberData(array $usr_ids, array $columns)
Required for member table guis.
Class ilCourseParticipantsGroupsGUI.
setSubTabs(ilTabsGUI $tabs)
Set sub tabs.
Base class for member tab content.
confirmDeleteParticipants()
Show confirmation screen for participants deletion.
checkPermissionBool(string $a_permission, string $a_cmd='', string $a_type='', int $a_ref_id=0)
printMembersOutput()
print members output
addToClipboard()
Add selected users to user clipboard.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAttendanceListUserData(int $user_id, array $filters=[])
updateParticipants()
update members
checkPermission(string $a_permission, string $a_cmd="")
Check permission If not granted redirect to parent gui.
static getInstance(int $a_ref_id)
assignFromWaitingList()
Assign from waiting list.
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
participantsResetFilter()
reset participants filter
ilUsersGalleryGUI: ilPublicUserProfileGUI ilUsersGalleryGUI: ilCourseMembershipGUI, ilGroupMembershipGUI
isAdmin(int $a_usr_id)
check if user is admin
static _lookupName(int $a_user_id)
lookup user name
GlobalHttpState $http
confirmAssignSubscribers()
Show subscription confirmation.
filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids)
Filter user ids by access.
editMember()
Edit one participant.
__construct(ilObjectGUI $repository_gui, ilObject $repository_obj)
printForMembersOutput()
print members output
parseWaitingListTable()
Parse table of subscription request.
static isReferenceMemberUpdateConfirmationRequired(int $course_ref_id, array $participants)
Base class for attendance lists.
addSubTabTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)
ilCtrlInterface $ctrl
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$provider
Definition: ltitoken.php:80
static getMapGUI()
Get an instance of the GUI class.
static http()
Fetches the global http state from ILIAS.
addButton(string $a_txt, string $a_cmd, string $a_target="", ?int $a_acc_key=null, string $a_additional_attrs='', string $a_id="", string $a_class='submit')
addMemberTab(ilTabsGUI $tabs, bool $a_is_participant=false)
assignSubscribers()
Do assignment of subscription request.
editParticipants(array $post_participants=array())
Edit participants.
GUI class for membership features.
Class ilObjectGUI Basic methods of all Output classes.
createMailSignature()
Create Mail signature.
initAttendanceList(bool $a_for_members=false)
global $DIC
Definition: shib_login.php:22
checkRbacOrPermissionAccess(string $a_rbac_perm, string $a_pos_perm)
check rbac or position access
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
GUI class for course/group subscriptions.
ilParticipants $participants
showMailToMemberToolbarButton(ilToolbarGUI $toolbar, ?string $a_back_cmd=null, bool $a_separator=false)
Show mail to member toolbar button.
updateLPFromStatus(int $usr_id, bool $has_passed)
ilGlobalTemplateInterface $tpl
confirmAssignFromWaitingList()
Assign from waiting list (confirmatoin)
Class ilUsersGalleryParticipants.
showParticipantsToolbar()
Show participants toolbar.
GUI class for membership features.
static redirect(string $a_script)
confirmRefuseSubscribers()
Refuse subscriber confirmation.
static isActivated()
Checks whether Map feature is activated.
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.
parseSubscriberTable()
Parse table of subscription request.
static setRecipients(array $recipients, string $type='to')
static fillAutoCompleteToolbar(object $parent_object, ?ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt(&#39;user&#39;), auto_complete_size = 15, user_type = array(ilCoursePar...
ilErrorHandling $error
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
GUI class for course/group waiting list.
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
participants()
Show participant table, subscriber table, wating list table;.
ilAccessHandler $access
showMemberExportToolbarButton(ilToolbarGUI $toolbar, ?string $a_back_cmd=null, bool $a_separator=false)
refuseFromList()
refuse from waiting list
membersMap()
Members map.
activateSubTab(string $a_sub_tab)
confirmRefuseFromList()
Refuse from waiting list (confirmation)
checkRbacOrPositionAccessBool(string $a_rbac_perm, string $a_pos_perm, int $a_ref_id=0)
static getInstance(int $obj_id)
canAddOrSearchUsers()
Check if current user is allowed to add / search users.
Class ilAbstractMailMemberRoles.
static getInstance(int $a_usr_id)
GUI class for learning sequence membership features.
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
participantsApplyFilter()
Apply filter for participant table.
static _lookupLogin(int $a_user_id)