ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilMailingListsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
30 {
31  private readonly \ILIAS\HTTP\GlobalHttpState $http;
32  private readonly Refinery $refinery;
33  private readonly ilGlobalTemplateInterface $tpl;
34  private readonly ilCtrlInterface $ctrl;
35  private readonly ilLanguage $lng;
36  private readonly ilObjUser $user;
37  private readonly ilErrorHandling $error;
38  private readonly ilToolbarGUI $toolbar;
39  private readonly ilRbacSystem $rbacsystem;
40  private readonly ilFormatMail $umail;
41  private readonly ilMailingLists $mlists;
43  private readonly \ILIAS\UI\Factory $ui_factory;
44  private readonly \ILIAS\UI\Renderer $ui_renderer;
45  private readonly ilTabsGUI $tabs;
46 
47  public function __construct()
48  {
49  global $DIC;
50 
51  $this->tpl = $DIC->ui()->mainTemplate();
52  $this->ctrl = $DIC['ilCtrl'];
53  $this->lng = $DIC['lng'];
54  $this->rbacsystem = $DIC['rbacsystem'];
55  $this->user = $DIC['ilUser'];
56  $this->error = $DIC['ilErr'];
57  $this->toolbar = $DIC['ilToolbar'];
58  $this->http = $DIC->http();
59  $this->refinery = $DIC->refinery();
60  $this->ui_factory = $DIC->ui()->factory();
61  $this->ui_renderer = $DIC->ui()->renderer();
62  $this->tabs = $DIC->tabs();
63 
64  $this->umail = new ilFormatMail($this->user->getId());
65  $this->mlists = new ilMailingLists($this->user);
66  $this->mlists->setCurrentMailingList($this->getQueryMailingListId());
67 
68  $this->ctrl->saveParameter($this, 'mobj_id');
69  $this->ctrl->saveParameter($this, 'ref');
70 
71  $this->lng->loadLanguageModule('mail');
72  }
73 
74  private function getQueryMailingListId(): int
75  {
76  return $this->http->wrapper()->query()->retrieve(
77  'ml_id',
78  $this->refinery->byTrying([
79  $this->refinery->kindlyTo()->int(),
80  $this->refinery->always(
81  current(
82  $this->http->wrapper()->query()->retrieve(
83  'contact_mailinglist_list_ml_ids',
84  $this->refinery->byTrying([
85  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
86  $this->refinery->always([0])
87  ])
88  )
89  ) ?: 0
90  )
91  ])
92  );
93  }
94 
95  public function executeCommand(): bool
96  {
97  if (
98  !ilBuddySystem::getInstance()->isEnabled() ||
99  (
100  0 === count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) &&
101  !$this->mlists->hasAny()
102  )
103  ) {
104  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
105  }
106 
107  if (!($cmd = $this->ctrl->getCmd())) {
108  $cmd = 'showMailingLists';
109  }
110 
111  $this->$cmd();
112 
113  return true;
114  }
115 
116  private function handleMailingListMemberActions(): void
117  {
118  $action = $this->http->wrapper()->query()->retrieve(
119  'contact_mailinglist_members_action',
120  $this->refinery->byTrying([
121  $this->refinery->kindlyTo()->string(),
122  $this->refinery->always('')
123  ])
124  );
125  match ($action) {
126  'confirmDeleteMembers' => $this->confirmDeleteMembers(),
127  default => $this->ctrl->redirect($this, 'showMailingLists'),
128  };
129  }
130 
131  private function handleMailingListActions(): void
132  {
133  $action = $this->http->wrapper()->query()->retrieve(
134  'contact_mailinglist_list_action',
135  $this->refinery->byTrying([
136  $this->refinery->kindlyTo()->string(),
137  $this->refinery->always('')
138  ])
139  );
140  match ($action) {
141  'mailToList' => $this->mailToList(),
142  'confirmDelete' => $this->confirmDelete(),
143  'showMembersList' => $this->showMembersList(),
144  'showForm' => $this->showForm(),
145  default => $this->ctrl->redirect($this, 'showMailingLists'),
146  };
147  }
148 
152  private function getMailingListIdsFromRequest(): array
153  {
154  if ($this->http->wrapper()->query()->has('ml_id')) {
155  $ml_ids = [
156  $this->http->wrapper()->query()->retrieve('ml_id', $this->refinery->kindlyTo()->int())
157  ];
158  } elseif ($this->http->wrapper()->post()->has('ml_id')) {
159  $ml_ids = $this->http->wrapper()->post()->retrieve(
160  'ml_id',
161  $this->refinery->kindlyTo()->listOf(
162  $this->refinery->kindlyTo()->int()
163  )
164  );
165  } else {
166  $ml_ids = $this->http->wrapper()->query()->retrieve(
167  'contact_mailinglist_list_ml_ids',
168  $this->refinery->byTrying([
169  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
170  $this->refinery->always([])
171  ])
172  );
173  }
174 
175  return array_filter($ml_ids);
176  }
177 
178  public function confirmDelete(): bool
179  {
180  $ml_ids = $this->getMailingListIdsFromRequest();
181  if ($ml_ids === []) {
182  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one_entry'));
183  $this->showMailingLists();
184  return true;
185  }
186 
187  if ((string) current($ml_ids) === 'ALL_OBJECTS') {
188  $entries = $this->mlists->getAll();
189  } else {
190  $entries = $this->mlists->getSelected(
191  array_map(intval(...), $ml_ids)
192  );
193  }
194 
195  $c_gui = new ilConfirmationGUI();
196 
197  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDelete'));
198  $c_gui->setHeaderText($this->lng->txt('mail_sure_delete_entry'));
199  $c_gui->setCancel($this->lng->txt('cancel'), 'showMailingLists');
200  $c_gui->setConfirm($this->lng->txt('confirm'), 'performDelete');
201 
202  foreach ($entries as $entry) {
203  $c_gui->addItem('ml_id[]', (string) $entry->getId(), $entry->getTitle());
204  }
205 
206  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
207  $this->tpl->addBlockFile(
208  'ADM_CONTENT',
209  'adm_content',
210  'tpl.mail_mailing_lists_list.html',
211  'components/ILIAS/Contact'
212  );
213  $this->tpl->setVariable('DELETE_CONFIRMATION', $c_gui->getHTML());
214 
215  $this->tpl->printToStdout();
216 
217  return true;
218  }
219 
220  public function performDelete(): bool
221  {
222  if ($this->http->wrapper()->post()->has('ml_id')) {
223  $ml_ids = array_filter(
224  $this->http->wrapper()->post()->retrieve(
225  'ml_id',
226  $this->refinery->kindlyTo()->listOf(
227  $this->refinery->kindlyTo()->int()
228  )
229  )
230  );
231 
232  $counter = 0;
233  foreach ($ml_ids as $id) {
234  if ($this->mlists->isOwner($id, $this->user->getId())) {
235  $this->mlists->get($id)->delete();
236  ++$counter;
237  }
238  }
239 
240  if ($counter !== 0) {
241  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_deleted_entry'));
242  }
243  } else {
244  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_delete_error'));
245  }
246 
247  $this->showMailingLists();
248 
249  return true;
250  }
251 
252  public function mailToList(): bool
253  {
254  // check if current user may send mails
255  $mail = new ilMail($this->user->getId());
256  $mailing_allowed = $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
257 
258  if (!$mailing_allowed) {
259  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'));
260  return true;
261  }
262 
263  $ml_ids = $this->getMailingListIdsFromRequest();
264  if ($ml_ids === []) {
265  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one_entry'));
266  $this->showMailingLists();
267  return true;
268  }
269 
270  if ((string) current($ml_ids) === 'ALL_OBJECTS') {
271  $entries = $this->mlists->getAll();
272  $ml_ids = [];
273  foreach ($entries as $entry) {
274  $ml_ids[] = $entry->getId();
275  }
276  } else {
277  $ml_ids = array_map(intval(...), $ml_ids);
278  }
279 
280  $mail_data = $this->umail->retrieveFromStage();
281  $lists = [];
282  foreach ($ml_ids as $id) {
283  if ($this->mlists->isOwner($id, $this->user->getId()) &&
284  !$this->umail->existsRecipient('#il_ml_' . $id, (string) $mail_data['rcp_to'])) {
285  $lists['#il_ml_' . $id] = '#il_ml_' . $id;
286  }
287  }
288 
289  if ($lists !== []) {
290  $mail_data = $this->umail->appendSearchResult(array_values($lists), 'to');
291  $this->umail->persistToStage(
292  (int) $mail_data['user_id'],
293  $mail_data['attachments'],
294  $mail_data['rcp_to'],
295  $mail_data['rcp_cc'],
296  $mail_data['rcp_bcc'],
297  $mail_data['m_subject'],
298  $mail_data['m_message'],
299  $mail_data['use_placeholders'],
300  $mail_data['tpl_ctx_id'],
301  $mail_data['tpl_ctx_params']
302  );
303  }
304 
305  ilUtil::redirect('ilias.php?baseClass=ilMailGUI&type=search_res');
306 
307  return true;
308  }
309 
310  public function showMailingLists(): bool
311  {
312  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
313  $this->tpl->addBlockFile(
314  'ADM_CONTENT',
315  'adm_content',
316  'tpl.mail_mailing_lists_list.html',
317  'components/ILIAS/Contact'
318  );
319 
320  // check if current user may send mails
321  $mail = new ilMail($this->user->getId());
322 
323  $this->toolbar->addComponent(
324  $this->ui_factory->button()->standard(
325  $this->lng->txt('create'),
326  $this->ctrl->getLinkTarget($this, 'showForm')
327  )
328  );
329 
330  $tbl = new MailingListsTable(
331  $this->mlists,
332  $this->ctrl,
333  $this->lng,
334  $this->ui_factory,
335  $this->http
336  );
337  $tbl->setMailingAllowed($this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId()));
338  $this->tpl->setVariable('MAILING_LISTS', $this->ui_renderer->render($tbl->getComponent()));
339  $this->tpl->printToStdout();
340 
341  return true;
342  }
343 
344  public function cancel(): void
345  {
346  if (
347  $this->http->wrapper()->query()->has('ref') &&
348  $this->http->wrapper()->query()->retrieve('ref', $this->refinery->kindlyTo()->string()) === 'mail') {
349  $this->ctrl->returnToParent($this);
350  }
351 
352  $this->showMailingLists();
353  }
354 
355  public function saveForm(): void
356  {
357  if ($this->mlists->getCurrentMailingList() && $this->mlists->getCurrentMailingList()->getId()) {
358  if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->user->getId())) {
359  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
360  }
361 
362  $this->ctrl->setParameter($this, 'ml_id', $this->mlists->getCurrentMailingList()->getId());
363  $this->initForm();
364  } else {
365  $this->initForm();
366  }
367 
368  if ($this->form_gui->checkInput()) {
369  $this->mlists->getCurrentMailingList()->setTitle(
370  $this->form_gui->getInput('title')
371  );
372  $this->mlists->getCurrentMailingList()->setDescription(
373  $this->form_gui->getInput('description')
374  );
375 
376  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
377  if ($this->mlists->getCurrentMailingList()->getId() > 0) {
378  $this->mlists->getCurrentMailingList()->setChangedate(date('Y-m-d H:i:s'));
379  $this->mlists->getCurrentMailingList()->update();
380  $this->ctrl->redirect($this, 'showMailingLists');
381  } else {
382  $this->mlists->getCurrentMailingList()->setCreatedate(date('Y-m-d H:i:s'));
383  $this->mlists->getCurrentMailingList()->insert();
384 
385  $this->ctrl->setParameter($this, 'ml_id', $this->mlists->getCurrentMailingList()->getId());
386  $this->ctrl->redirect($this, 'showMembersList');
387  }
388  }
389 
390  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
391  $this->tpl->addBlockFile(
392  'ADM_CONTENT',
393  'adm_content',
394  'tpl.mail_mailing_lists_form.html',
395  'components/ILIAS/Contact'
396  );
397 
398  $this->form_gui->setValuesByPost();
399 
400  $this->tpl->setVariable('FORM', $this->form_gui->getHTML());
401  $this->tpl->printToStdout();
402  }
403 
404  private function initForm(): void
405  {
406  $this->form_gui = new ilPropertyFormGUI();
407  $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'saveForm'));
408  $this->form_gui->setTitle($this->lng->txt('mail_mailing_list'));
409  $titleGui = new ilTextInputGUI($this->lng->txt('title'), 'title');
410  $titleGui->setRequired(true);
411  $this->form_gui->addItem($titleGui);
412  $descriptionGui = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
413  $descriptionGui->setCols(40);
414  $descriptionGui->setRows(8);
415  $this->form_gui->addItem($descriptionGui);
416  $this->form_gui->addCommandButton('saveForm', $this->lng->txt('save'));
417  $this->form_gui->addCommandButton('showMailingLists', $this->lng->txt('cancel'));
418  }
419 
420  private function setValuesByObject(): void
421  {
422  $this->form_gui->setValuesByArray([
423  'title' => $this->mlists->getCurrentMailingList()->getTitle(),
424  'description' => $this->mlists->getCurrentMailingList()->getDescription() ?? ''
425  ]);
426  }
427 
428  private function setDefaultValues(): void
429  {
430  $this->form_gui->setValuesByArray([
431  'title' => '',
432  'description' => ''
433  ]);
434  }
435 
436  public function showForm(): void
437  {
438  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
439  $this->tpl->addBlockFile(
440  'ADM_CONTENT',
441  'adm_content',
442  'tpl.mail_mailing_lists_form.html',
443  'components/ILIAS/Contact'
444  );
445 
446  if ($this->mlists->getCurrentMailingList() && $this->mlists->getCurrentMailingList()->getId()) {
447  if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->user->getId())) {
448  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
449  }
450 
451  $this->ctrl->setParameter($this, 'ml_id', $this->mlists->getCurrentMailingList()->getId());
452  $this->initForm();
453  $this->setValuesByObject();
454  } else {
455  $this->initForm();
456  $this->setDefaultValues();
457  }
458 
459  $this->tpl->setVariable('FORM', $this->form_gui->getHTML());
460  $this->tpl->printToStdout();
461  }
462 
463  public function showMembersList(): bool
464  {
465  if ($this->mlists->getCurrentMailingList()->getId() === 0) {
466  $this->showMailingLists();
467 
468  return true;
469  }
470 
471  $this->tabs->clearTargets();
472  $this->tabs->setBackTarget(
473  $this->lng->txt('back'),
474  $this->ctrl->getLinkTarget($this, 'showMailingLists')
475  );
476 
477  $this->ctrl->setParameter($this, 'ml_id', $this->mlists->getCurrentMailingList()->getId());
478 
479  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
480  $this->tpl->addBlockFile(
481  'ADM_CONTENT',
482  'adm_content',
483  'tpl.mail_mailing_lists_members.html',
484  'components/ILIAS/Contact'
485  );
486 
487  $availale_usr_ids = array_diff(
488  array_map(
489  static function (ilBuddySystemRelation $relation): int {
490  return $relation->getBuddyUsrId();
491  },
492  ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()->toArray()
493  ),
494  array_map(
495  static function (array $entry): int {
496  return $entry['usr_id'];
497  },
498  $this->mlists->getCurrentMailingList()->getAssignedEntries()
499  ),
500  );
501 
502  if ($availale_usr_ids !== []) {
503  $this->toolbar->addComponent(
504  $this->ui_factory->button()->standard(
505  $this->lng->txt('add'),
506  $this->ctrl->getLinkTarget($this, 'showAssignmentForm')
507  )
508  );
509  }
510 
511  $tbl = new MailingListsMembersTable(
512  $this->mlists->getCurrentMailingList(),
513  $this->ctrl,
514  $this->lng,
517  );
518  $this->tpl->setVariable('MEMBERS_LIST', $this->ui_renderer->render($tbl->getComponent()));
519  $this->tpl->printToStdout();
520 
521  return true;
522  }
523 
524  public function confirmDeleteMembers(): bool
525  {
526  $requested_record_ids = $this->http->wrapper()->query()->retrieve(
527  'contact_mailinglist_members_entry_ids',
528  $this->refinery->byTrying([
529  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
530  $this->refinery->always([])
531  ])
532  );
533 
534  if ($requested_record_ids === []) {
535  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one_entry'));
536  $this->showMembersList();
537 
538  return true;
539  }
540 
541  if ((string) current($requested_record_ids) === 'ALL_OBJECTS') {
542  $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
543  $requested_record_ids = [];
544  foreach ($assigned_entries as $entry) {
545  $requested_record_ids[] = $entry['a_id'];
546  }
547  } else {
548  $requested_record_ids = array_map(intval(...), $requested_record_ids);
549  }
550 
551  $c_gui = new ilConfirmationGUI();
552  $this->ctrl->setParameter($this, 'ml_id', $this->mlists->getCurrentMailingList()->getId());
553  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteMembers'));
554  $c_gui->setHeaderText($this->lng->txt('mail_sure_remove_user'));
555  $c_gui->setCancel($this->lng->txt('cancel'), 'showMembersList');
556  $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteMembers');
557 
558  $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
559  $usr_ids = array_map(static fn(array $entry): int => $entry['usr_id'], $assigned_entries);
560  $names = ilUserUtil::getNamePresentation($usr_ids, false, false, '', false, false, false);
561 
562  foreach ($assigned_entries as $entry) {
563  if (in_array($entry['a_id'], $requested_record_ids, true)) {
564  $c_gui->addItem('a_id[]', (string) $entry['a_id'], $names[$entry['usr_id']]);
565  }
566  }
567 
568  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
569  $this->tpl->addBlockFile(
570  'ADM_CONTENT',
571  'adm_content',
572  'tpl.mail_mailing_lists_members.html',
573  'components/ILIAS/Contact'
574  );
575  $this->tpl->setVariable('DELETE_CONFIRMATION', $c_gui->getHTML());
576 
577  $this->tpl->printToStdout();
578 
579  return true;
580  }
581 
582  public function performDeleteMembers(): bool
583  {
584  if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->user->getId())) {
585  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
586  }
587 
588  if (
589  $this->http->wrapper()->post()->has('a_id') &&
590  ($requested_entry_ids = $this->http->wrapper()->post()->retrieve(
591  'a_id',
592  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
593  )) !== []
594  ) {
595  $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
596  foreach ($requested_entry_ids as $id) {
597  if (isset($assigned_entries[$id])) {
598  $this->mlists->getCurrentMailingList()->deleteEntry($id);
599  }
600  }
601  $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_success_removed_user'));
602  } else {
603  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mail_delete_error'));
604  }
605 
606  $this->showMembersList();
607 
608  return true;
609  }
610 
611  protected function getAssignmentForm(): ilPropertyFormGUI
612  {
613  $form = new ilPropertyFormGUI();
614  $this->ctrl->setParameter($this, 'ml_id', $this->mlists->getCurrentMailingList()->getId());
615  $form->setFormAction($this->ctrl->getFormAction($this, 'saveAssignmentForm'));
616  $form->setTitle(
617  sprintf(
618  $this->lng->txt('mail_assign_entry_to_mailing_list'),
619  $this->mlists->getCurrentMailingList()->getTitle()
620  )
621  );
622 
623  $options = [];
624  $options[''] = $this->lng->txt('please_select');
625 
626  $relations = ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations();
628  array_keys($relations->toArray()),
629  false,
630  false,
631  '',
632  false,
633  false,
634  false
635  );
636  foreach ($relations as $relation) {
638  $options[$relation->getBuddyUsrId()] = $names[$relation->getBuddyUsrId()];
639  }
640 
641  $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
642  foreach ($assigned_entries as $assigned_entry) {
643  if (array_key_exists($assigned_entry['usr_id'], $options)) {
644  unset($options[$assigned_entry['usr_id']]);
645  }
646  }
647 
648  if (count($options) > 1) {
649  $formItem = new ilSelectInputGUI($this->lng->txt('mail_entry_of_contacts'), 'usr_id');
650  $formItem->setRequired(true);
651  $formItem->setOptions($options);
652  $form->addItem($formItem);
653 
654  $form->addCommandButton('saveAssignmentForm', $this->lng->txt('mail_assign_to_mailing_list'));
655  } elseif (count($options) === 1 && count($relations) > 0) {
656  $this->tpl->setOnScreenMessage(
657  'info',
658  $this->lng->txt('mail_mailing_lists_all_contact_entries_assigned'),
659  true
660  );
661  $this->ctrl->redirect($this, 'showMembersList');
662  } elseif (count($relations) === 0) {
663  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_mailing_lists_no_contact_entries'), true);
664  $this->ctrl->redirect($this, 'showMembersList');
665  }
666  $form->addCommandButton('showMembersList', $this->lng->txt('cancel'));
667 
668  return $form;
669  }
670 
671  public function saveAssignmentForm(): bool
672  {
673  if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->user->getId())) {
674  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
675  }
676 
677  $form = $this->getAssignmentForm();
678  if (!$form->checkInput()) {
679  $form->setValuesByPost();
680  $this->showAssignmentForm($form);
681 
682  return true;
683  }
684 
685  if (
686  ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId(
687  $this->http->wrapper()->post()->retrieve('usr_id', $this->refinery->kindlyTo()->int())
688  )->isLinked()
689  ) {
690  $this->mlists->getCurrentMailingList()->assignUser(
691  $this->http->wrapper()->post()->retrieve('usr_id', $this->refinery->kindlyTo()->int())
692  );
693  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
694  $this->showMembersList();
695 
696  return true;
697  }
698 
699  $this->showAssignmentForm($form);
700 
701  return true;
702  }
703 
704  public function showAssignmentForm(?ilPropertyFormGUI $form = null): bool
705  {
706  if ($this->mlists->getCurrentMailingList()->getId() === 0) {
707  $this->showMembersList();
708 
709  return true;
710  }
711 
712  if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->user->getId())) {
713  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
714  }
715 
716  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
717  $this->tpl->addBlockFile(
718  'ADM_CONTENT',
719  'adm_content',
720  'tpl.mail_mailing_lists_members_form.html',
721  'components/ILIAS/Contact'
722  );
723 
724  if (!($form instanceof ilPropertyFormGUI)) {
725  $form = $this->getAssignmentForm();
726  }
727 
728  $this->tpl->setVariable('FORM', $form->getHTML());
729  $this->tpl->printToStdout();
730 
731  return true;
732  }
733 }
readonly Refinery $refinery
$relation
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilFormatMail $umail
readonly ilObjUser $user
readonly ilLanguage $lng
readonly ILIAS UI Factory $ui_factory
readonly ilRbacSystem $rbacsystem
readonly ilMailingLists $mlists
static http()
Fetches the global http state from ILIAS.
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
readonly ilToolbarGUI $toolbar
ilPropertyFormGUI $form_gui
global $DIC
Definition: shib_login.php:25
readonly ilGlobalTemplateInterface $tpl
showAssignmentForm(?ilPropertyFormGUI $form=null)
setRequired(bool $a_required)
static redirect(string $a_script)
static getInstanceByGlobalUser(ilObjUser $user=null)
readonly ilTabsGUI $tabs
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
This class represents a text area property in a property form.
readonly ILIAS HTTP GlobalHttpState $http
readonly ilCtrlInterface $ctrl
readonly ilErrorHandling $error
readonly ILIAS UI Renderer $ui_renderer