ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.PersonalSettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\User\Settings;
22
28use ILIAS\UI\Factory as UIFactory;
31use Psr\Http\Message\ServerRequestInterface;
32
38{
39 private readonly \ilGlobalTemplateInterface $tpl;
40 private readonly UIFactory $ui_factory;
41 private readonly Renderer $ui_renderer;
42 private readonly \ilLanguage $lng;
43 private readonly \ilCtrl $ctrl;
44 private readonly ServerRequestInterface $request;
45 private readonly LoggingServices $log;
46 private readonly \ilMailMimeSenderFactory $mail_sender_factory;
47 private readonly \ilHelpGUI $help;
48 private readonly \ilToolbarGUI $toolbar;
49 private \ilObjUser $current_user;
50 private readonly \ilSetting $settings;
51 private readonly \ilAuthSession $auth_session;
52 private readonly \ilRbacSystem $rbac_system;
54 private readonly SettingsTabs $tabs;
55
56 public function __construct()
57 {
59 global $DIC;
60
61 $this->tpl = $DIC['tpl'];
62 $this->ui_factory = $DIC['ui.factory'];
63 $this->ui_renderer = $DIC['ui.renderer'];
64 $this->lng = $DIC['lng'];
65 $this->ctrl = $DIC['ilCtrl'];
66 $this->request = $DIC['http']->request();
67 $this->log = $DIC->logger();
68 $this->mail_sender_factory = $DIC->mail()->mime()->senderFactory();
69 $this->help = $DIC['ilHelp'];
70 $this->toolbar = $DIC['ilToolbar'];
71 $this->current_user = $DIC['ilUser'];
72 $this->settings = $DIC['ilSetting'];
73 $this->auth_session = $DIC['ilAuthSession'];
74 $this->rbac_system = $DIC['rbacsystem'];
75
76 $this->lng->loadLanguageModule('user');
77 $this->lng->loadLanguageModule('administration');
78 $this->lng->loadLanguageModule('mail');
79
80 $this->ctrl->saveParameter($this, 'user_page');
81
82 $this->user_settings = LocalDIC::dic()[Settings::class];
83
84 $this->tabs = new SettingsTabs(
85 $DIC['ilTabs'],
86 $this->lng,
87 $this->ctrl,
88 $this->settings,
89 $this->current_user
90 );
91 }
92
93 public function executeCommand(): void
94 {
95 $this->help->setScreenIdComponent('user');
96 $this->tabs->initializeTabs();
97
98 switch ($this->ctrl->getNextClass()) {
99 case strtolower(\ilLocalUserPasswordSettingsGUI::class):
100 $this->ctrl->forwardCommand(
102 );
103 break;
104 case strtolower(DeleteAccountGUI::class):
105 $this->ctrl->forwardCommand(
107 $this->ctrl,
108 $this->lng,
109 $this->tpl,
110 $this->ui_factory,
111 $this->ui_renderer,
112 $this->toolbar,
113 $this->log,
114 $this->mail_sender_factory,
115 $this->settings,
116 $this->auth_session,
117 $this->current_user
118 )
119 );
120 break;
121 default:
122 $this->tpl->setTitle($this->lng->txt('personal_settings'));
123 $cmd = $this->ctrl->getCmd('show') . 'Cmd';
124 $this->$cmd();
125 }
126 }
127
128 public function showCmd(?StandardForm $form = null): void
129 {
130 if ($form === null) {
131 $form = $this->initForm();
132 }
133 $this->tpl->setContent($this->ui_renderer->render($form));
134 $this->tpl->printToStdout();
135 }
136
137 public function saveCmd(): void
138 {
139 $form = $this->initForm()->withRequest($this->request);
140 $data = $form->getData();
141 if ($data === null) {
142 $this->showCmd($form);
143 return;
144 }
145
146 $this->current_user = $this->user_settings->saveForm(
147 $data['settings'],
148 [AvailablePages::MainSettings],
149 Context::User,
150 $this->current_user
151 );
152
153 $this->tpl->setOnScreenMessage(
154 'success',
155 $this->lng->txtlng('common', 'msg_obj_modified', $this->current_user->getLanguage()),
156 true
157 );
158
159 $this->ctrl->redirectByClass([\ilDashboardGUI::class, self::class], 'show');
160 }
161
162 private function initForm(): StandardForm
163 {
164 return $this->ui_factory->input()->container()->form()->standard(
165 $this->ctrl->getFormActionByClass(self::class, 'save'),
166 [
167 'settings' => $this->ui_factory->input()->field()->section(
168 $this->user_settings->buildFormInputs(
169 [AvailablePages::MainSettings],
170 Context::User,
171 $this->current_user
172 ),
173 $this->lng->txt('settings')
174 )
175 ]
176 );
177 }
178}
Provides fluid interface to LoggingServices.
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
@ilCtrl_Calls ILIAS\User\Settings\PersonalSettingsGUI: ILIAS\User\Account\DeleteAccountGUI @ilCtrl_Ca...
readonly ilMailMimeSenderFactory $mail_sender_factory
readonly SettingsImplementation $user_settings
readonly ilGlobalTemplateInterface $tpl
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76
This describes a standard form.
Definition: Standard.php:29
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26