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