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