ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMailOptionsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\Refinery\Factory as Refinery;
24
26{
28 private readonly ilCtrlInterface $ctrl;
29 private readonly ilLanguage $lng;
30 private readonly ilSetting $settings;
31 private readonly ilObjUser $user;
33 protected Refinery $refinery;
36
37 public function __construct(
39 ?ilCtrlInterface $ctrl = null,
40 ?ilLanguage $lng = null,
41 ?ilObjUser $user = null,
42 ?GlobalHttpState $http = null,
43 ?Refinery $refinery = null,
45 ) {
46 global $DIC;
47 $this->tpl = $tpl ?? $DIC->ui()->mainTemplate();
48 $this->ctrl = $ctrl ?? $DIC->ctrl();
49 $this->lng = $lng ?? $DIC->language();
50 $this->user = $user ?? $DIC->user();
51 $this->http = $http ?? $DIC->http();
52 $this->refinery = $refinery ?? $DIC->refinery();
53 $this->mail_options = $mail_options ?? new ilMailOptions($this->user->getId());
54
55 $this->lng->loadLanguageModule('mail');
56 $this->ctrl->saveParameter($this, 'mobj_id');
57 }
58
59 public function executeCommand(): void
60 {
61 if (!$this->mail_options->mayManageInvididualSettings()) {
62 $referrer = '';
63 if ($this->http->wrapper()->query()->has('referrer')) {
64 $referrer = $this->http->wrapper()->query()->retrieve(
65 'referrer',
66 $this->refinery->kindlyTo()->string()
67 );
68 }
69 if (strtolower(ilPersonalSettingsGUI::class) === strtolower($referrer)) {
70 $this->ctrl->redirectByClass(PersonalSettingsGUI::class);
71 }
72 $this->ctrl->redirectByClass(ilMailGUI::class);
73 }
74
75 if (!($cmd = $this->ctrl->getCmd())) {
76 $cmd = 'showOptions';
77 }
78 $this->$cmd();
79 }
80
81 public function setForm(ilMailOptionsFormGUI $form): void
82 {
83 $this->form = $form;
84 }
85
86 protected function getForm(): ilMailOptionsFormGUI
87 {
88 return $this->form ?? new ilMailOptionsFormGUI(
89 $this->mail_options,
90 $this,
91 'saveOptions'
92 );
93 }
94
95 protected function saveOptions(): void
96 {
97 $this->tpl->setTitle($this->lng->txt('mail'));
98
99 $form = $this->getForm();
100 if ($form->save()) {
101 $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_options_saved'), true);
102 $this->ctrl->redirect($this, 'showOptions');
103 }
104
105 $this->showOptions($form);
106 }
107
108 protected function showOptions(?ilMailOptionsFormGUI $form = null): void
109 {
110 if (null === $form) {
111 $form = $this->getForm();
112 $form->populate();
113 } else {
115 }
116
117 $this->tpl->setContent($form->getHTML());
118 $this->tpl->printToStdout();
119 }
120}
Builds data types.
Definition: Factory.php:36
@ilCtrl_Calls ILIAS\User\Settings\PersonalSettingsGUI: ILIAS\User\Account\DeleteAccountGUI @ilCtrl_Ca...
language handling
__construct(?ilGlobalTemplateInterface $tpl=null, ?ilCtrlInterface $ctrl=null, ?ilLanguage $lng=null, ?ilObjUser $user=null, ?GlobalHttpState $http=null, ?Refinery $refinery=null, ?ilMailOptions $mail_options=null)
showOptions(?ilMailOptionsFormGUI $form=null)
readonly ilLanguage $lng
ilMailOptionsFormGUI $form
readonly ilGlobalTemplateInterface $tpl
readonly ilCtrlInterface $ctrl
readonly ilObjUser $user
setForm(ilMailOptionsFormGUI $form)
readonly ilSetting $settings
User class.
ILIAS Setting Class.
Interface GlobalHttpState.
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, string $submit_caption="")
global $DIC
Definition: shib_login.php:26