ILIAS  release_8 Revision v8.24
class.ilMailOptionsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22use ILIAS\Refinery\Factory as Refinery;
23
29{
36 protected Refinery $refinery;
39
40 public function __construct(
43 ilLanguage $lng = null,
44 ilObjUser $user = null,
46 Refinery $refinery = null,
48 ) {
49 global $DIC;
50 $this->tpl = $tpl ?? $DIC->ui()->mainTemplate();
51 $this->ctrl = $ctrl ?? $DIC->ctrl();
52 $this->lng = $lng ?? $DIC->language();
53 $this->user = $user ?? $DIC->user();
54 $this->http = $http ?? $DIC->http();
55 $this->refinery = $refinery ?? $DIC->refinery();
56 $this->mail_options = $mail_options ?? new ilMailOptions($this->user->getId());
57
58 $this->lng->loadLanguageModule('mail');
59 $this->ctrl->saveParameter($this, 'mobj_id');
60 }
61
62 public function executeCommand(): void
63 {
64 if (!$this->mail_options->mayManageInvididualSettings()) {
65 $referrer = '';
66 if ($this->http->wrapper()->query()->has('referrer')) {
67 $referrer = $this->http->wrapper()->query()->retrieve(
68 'referrer',
69 $this->refinery->kindlyTo()->string()
70 );
71 }
72 if (strtolower(ilPersonalSettingsGUI::class) === strtolower($referrer)) {
73 $this->ctrl->redirectByClass(ilPersonalSettingsGUI::class);
74 }
75 $this->ctrl->redirectByClass(ilMailGUI::class);
76 }
77
78 $nextClass = $this->ctrl->getNextClass($this);
79 switch ($nextClass) {
80 default:
81 if (!($cmd = $this->ctrl->getCmd())) {
82 $cmd = 'showOptions';
83 }
84
85 $this->$cmd();
86 break;
87 }
88 }
89
90 public function setForm(ilMailOptionsFormGUI $form): void
91 {
92 $this->form = $form;
93 }
94
95 protected function getForm(): ilMailOptionsFormGUI
96 {
97 return $this->form ?? new ilMailOptionsFormGUI(
98 $this->mail_options,
99 $this,
100 'saveOptions'
101 );
102 }
103
104 protected function saveOptions(): void
105 {
106 $this->tpl->setTitle($this->lng->txt('mail'));
107
108 $form = $this->getForm();
109 if ($form->save()) {
110 $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_options_saved'), true);
111 $this->ctrl->redirect($this, 'showOptions');
112 }
113
114 $this->showOptions($form);
115 }
116
117 protected function showOptions(ilMailOptionsFormGUI $form = null): void
118 {
119 if (null === $form) {
120 $form = $this->getForm();
121 $form->populate();
122 } else {
124 }
125
126 $this->tpl->setContent($form->getHTML());
127 $this->tpl->printToStdout();
128 }
129}
Builds data types.
Definition: Factory.php:21
language handling
Class ilMailOptionsFormGUI.
showOptions(ilMailOptionsFormGUI $form=null)
ilGlobalTemplateInterface $tpl
ilMailOptionsFormGUI $form
__construct(ilGlobalTemplateInterface $tpl=null, ilCtrlInterface $ctrl=null, ilLanguage $lng=null, ilObjUser $user=null, GlobalHttpState $http=null, Refinery $refinery=null, ilMailOptions $mail_options=null)
setForm(ilMailOptionsFormGUI $form)
Class ilMailOptions this class handles user mails.
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
form( $class_path, string $cmd)