ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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 $this->ctrl->redirectByClass(ilMailGUI::class);
63 }
64
65 if (!($cmd = $this->ctrl->getCmd())) {
66 $cmd = 'showOptions';
67 }
68 $this->$cmd();
69 }
70
71 public function setForm(ilMailOptionsFormGUI $form): void
72 {
73 $this->form = $form;
74 }
75
76 protected function getForm(): ilMailOptionsFormGUI
77 {
78 return $this->form ?? new ilMailOptionsFormGUI(
79 $this->mail_options,
80 $this,
81 'saveOptions'
82 );
83 }
84
85 protected function saveOptions(): void
86 {
87 $this->tpl->setTitle($this->lng->txt('mail'));
88
89 $form = $this->getForm();
90 if ($form->save()) {
91 $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_options_saved'), true);
92 $this->ctrl->redirect($this, 'showOptions');
93 }
94
95 $this->showOptions($form);
96 }
97
98 protected function showOptions(?ilMailOptionsFormGUI $form = null): void
99 {
100 if (null === $form) {
101 $form = $this->getForm();
102 $form->populate();
103 } else {
105 }
106
107 $this->tpl->setContent($form->getHTML());
108 $this->tpl->printToStdout();
109 }
110}
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(?array $class_path, string $cmd, string $submit_caption="")
global $DIC
Definition: shib_login.php:26