ILIAS  release_8 Revision v8.24
class.ilPersonalSettingsGUI.php
Go to the documentation of this file.
1<?php
2
25{
27 protected string $entered_new_password;
28 protected string $entered_current_password;
29 protected string $password_error;
31 protected string $upload_error;
32 protected \ILIAS\User\StandardGUIRequest $request;
35 public ilCtrl $ctrl;
37
38 public function __construct()
39 {
40 global $DIC;
41
42 $this->user_defined_fields = ilUserDefinedFields::_getInstance();
43
44 $this->tpl = $DIC->ui()->mainTemplate();
45 $this->lng = $DIC->language();
46 $this->ctrl = $DIC->ctrl();
47 $this->upload_error = "";
48 $this->password_error = "";
49 $this->lng->loadLanguageModule("user");
50 $this->ctrl->saveParameter($this, "user_page");
51
52 $this->user_settings_config = new ilUserSettingsConfig();
53 $this->request = new \ILIAS\User\StandardGUIRequest(
54 $DIC->http(),
55 $DIC->refinery()
56 );
57 $this->entered_new_password = $this->request->getNewPassword();
58 $this->entered_current_password = $this->request->getCurrentPassword();
59 }
60
64 public function executeCommand(): void
65 {
66 global $DIC;
67
68 $next_class = $this->ctrl->getNextClass();
69
70 switch ($next_class) {
71 case 'ilmailoptionsgui':
72 if (!$DIC->rbac()->system()->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
73 throw new ilPermissionException($DIC->language()->txt('permission_denied'));
74 }
75
76 $this->__initSubTabs('showMailOptions');
77 $DIC->tabs()->activateTab('mail_settings');
78 $this->setHeader();
79 $this->ctrl->forwardCommand(new ilMailOptionsGUI());
80 break;
81
82 default:
83 $cmd = $this->ctrl->getCmd("showGeneralSettings");
84 $this->$cmd();
85 break;
86 }
87 }
88
89 // init sub tabs
90 public function __initSubTabs(string $a_cmd): void
91 {
92 global $DIC;
93
94 $ilTabs = $DIC['ilTabs'];
95 $ilSetting = $DIC['ilSetting'];
96 $ilHelp = $DIC['ilHelp'];
97 $rbacsystem = $DIC['rbacsystem'];
98 $ilUser = $DIC['ilUser'];
99
100 $ilHelp->setScreenIdComponent("user");
101
102 $showPassword = $a_cmd == 'showPassword';
103 $showGeneralSettings = $a_cmd == 'showGeneralSettings';
104
105 // old profile
106
107 // general settings
108 $ilTabs->addTarget(
109 "general_settings",
110 $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
111 "",
112 "",
113 "",
114 $showGeneralSettings
115 );
116
117 // password
118 if ($this->allowPasswordChange()) {
119 $ilTabs->addTarget(
120 "password",
121 $this->ctrl->getLinkTarget($this, "showPassword"),
122 "",
123 "",
124 "",
125 $showPassword
126 );
127 }
128
129 if ($rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()) && $ilSetting->get('show_mail_settings')) {
130 $this->ctrl->setParameter($this, 'referrer', 'ilPersonalSettingsGUI');
131
132 $ilTabs->addTarget(
133 "mail_settings",
134 $this->ctrl->getLinkTargetByClass('ilMailOptionsGUI'),
135 "",
136 array('ilMailOptionsGUI')
137 );
138 }
139
140 if ($ilSetting->get('user_delete_own_account') &&
141 $ilUser->getId() != SYSTEM_USER_ID) {
142 $ilTabs->addTab(
143 "delacc",
144 $this->lng->txt('user_delete_own_account'),
145 $this->ctrl->getLinkTarget($this, "deleteOwnAccount1")
146 );
147 }
148 }
149
153 public function setHeader(): void
154 {
155 $this->tpl->setTitle($this->lng->txt('personal_settings'));
156 }
157
158 //
159 //
160 // PASSWORD FORM
161 //
162 //
163
164 public function showPassword(
165 bool $a_no_init = false,
166 bool $hide_form = false
167 ): void {
168 global $DIC;
169
170 $ilTabs = $DIC['ilTabs'];
171 $ilUser = $DIC['ilUser'];
172
173 $this->__initSubTabs("showPersonalData");
174 $ilTabs->activateTab("password");
175
176 $this->setHeader();
177 // check whether password of user have to be changed
178 // due to first login or password of user is expired
179 if ($ilUser->isPasswordChangeDemanded()) {
180 $this->tpl->setOnScreenMessage('info', $this->lng->txt('password_change_on_first_login_demand'));
181 } elseif ($ilUser->isPasswordExpired()) {
182 $msg = $this->lng->txt('password_expired');
183 $password_age = $ilUser->getPasswordAge();
184 $this->tpl->setOnScreenMessage('info', sprintf($msg, $password_age));
185 }
186
187 if (!$a_no_init && !$hide_form) {
188 $this->initPasswordForm();
189 }
190 $this->tpl->setContent(!$hide_form ? $this->form->getHTML() : '');
191 $this->tpl->printToStdout();
192 }
193
194 public function initPasswordForm(): void
195 {
196 global $DIC;
197
198 $lng = $DIC['lng'];
199 $ilUser = $DIC['ilUser'];
200 $ilSetting = $DIC['ilSetting'];
201
202 $this->form = new ilPropertyFormGUI();
203
204 // Check whether password change is allowed
205 if ($this->allowPasswordChange()) {
206 // The current password needs to be checked for verification
207 // unless the user uses Shibboleth authentication with additional
208 // local authentication for WebDAV.
209 //if (
210 // ($ilUser->getAuthMode(true) != ilAuthUtils::AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local"))
211 //)
212 $pw_info_set = false;
213 if ($ilUser->getAuthMode(true) == ilAuthUtils::AUTH_LOCAL) {
214 // current password
215 $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
217 $cpass->setRetype(false);
218 $cpass->setSkipSyntaxCheck(true);
219 $pw_info_set = true;
220 // only if a password exists.
221 if ($ilUser->getPasswd()) {
222 $cpass->setRequired(true);
223 }
224 $this->form->addItem($cpass);
225 }
226
227 // new password
228 $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
229 if ($pw_info_set === false) {
231 }
232 $ipass->setRequired(true);
233 $ipass->setUseStripSlashes(false);
234
235 $this->form->addItem($ipass);
236 $this->form->addCommandButton("savePassword", $lng->txt("save"));
237
238 switch ($ilUser->getAuthMode(true)) {
240 $this->form->setTitle($lng->txt("chg_password"));
241 break;
242
246 $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
247 } else {
248 $this->form->setTitle($lng->txt("chg_ilias_password"));
249 }
250 break;
251 default:
252 $this->form->setTitle($lng->txt("chg_ilias_password"));
253 break;
254 }
255 $this->form->setFormAction($this->ctrl->getFormAction($this));
256 }
257 }
258
262 protected function allowPasswordChange(): bool
263 {
264 global $DIC;
265
266 $ilUser = $DIC['ilUser'];
267
268 if (\ilSession::get('used_external_auth')) {
269 return false;
270 }
271
272 $status = ilAuthUtils::isPasswordModificationEnabled($ilUser->getAuthMode(true));
273 if ($status) {
274 return true;
275 }
276
277 return \ilAuthUtils::isPasswordModificationHidden() && ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired());
278 }
279
280 public function savePassword(): void
281 {
282 global $DIC;
283
284 $ilCtrl = $DIC['ilCtrl'];
285 $ilUser = $DIC['ilUser'];
286
287 // normally we should not end up here
288 if (!$this->allowPasswordChange()) {
289 $ilCtrl->redirect($this, "showPersonalData");
290 return;
291 }
292
293 $this->initPasswordForm();
294 if ($this->form->checkInput()) {
295 $cp = $this->form->getItemByPostVar("current_password");
296 $np = $this->form->getItemByPostVar("new_password");
297 $error = false;
298
299 // The old password needs to be checked for verification
300 // unless the user uses Shibboleth authentication with additional
301 // local authentication for WebDAV.
302 #if ($ilUser->getAuthMode(true) != ilAuthUtils::AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
303 if ($ilUser->getAuthMode(true) == ilAuthUtils::AUTH_LOCAL) {
304 if (!ilUserPasswordManager::getInstance()->verifyPassword($ilUser, $this->entered_current_password)) {
305 $error = true;
306 $cp->setAlert($this->lng->txt('passwd_wrong'));
307 }
308 }
309
310 if (!ilSecuritySettingsChecker::isPassword($this->entered_new_password, $custom_error)) {
311 $error = true;
312 if ($custom_error != '') {
313 $np->setAlert($custom_error);
314 } else {
315 $np->setAlert($this->lng->txt("passwd_invalid"));
316 }
317 }
318 $error_lng_var = '';
320 $this->entered_new_password,
321 $ilUser,
322 $error_lng_var
323 )) {
324 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
325 $np->setAlert($this->lng->txt($error_lng_var));
326 $error = true;
327 }
328 if (
329 ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
330 $this->entered_current_password == $this->entered_new_password) {
331 $error = true;
332 $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
333 }
334
335 if (!$error) {
336 $ilUser->resetPassword($this->entered_new_password, $this->entered_new_password);
337 if ($this->entered_current_password != $this->entered_new_password) {
338 $ilUser->setLastPasswordChangeToNow();
339 $ilUser->setPasswordPolicyResetStatus(false);
340 $ilUser->update();
341 }
342
343 if (ilSession::get('orig_request_target')) {
344 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
345 $target = ilSession::get('orig_request_target');
346 ilSession::set('orig_request_target', '');
347 ilUtil::redirect($target);
348 } else {
349 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
350 $this->showPassword(true, true);
351 return;
352 }
353 }
354 }
355 $this->form->setValuesByPost();
356 $this->showPassword(true);
357 }
358
359 //
360 //
361 // GENERAL SETTINGS FORM
362 //
363 //
364
365 public function workWithUserSetting(string $setting): bool
366 {
367 return $this->user_settings_config->isVisibleAndChangeable($setting);
368 }
369
370 public function userSettingVisible(string $setting): bool
371 {
372 return $this->user_settings_config->isVisible($setting);
373 }
374
375 public function userSettingEnabled(string $setting): bool
376 {
377 return $this->user_settings_config->isChangeable($setting);
378 }
379
380 public function showGeneralSettings(bool $a_no_init = false): void
381 {
382 global $DIC;
383
384 $ilTabs = $DIC['ilTabs'];
385
386 $this->__initSubTabs("showPersonalData");
387 $ilTabs->activateTab("general_settings");
388
389 $this->setHeader();
390
391 if (!$a_no_init) {
392 $this->initGeneralSettingsForm();
393 }
394 $this->tpl->setContent($this->form->getHTML());
395 $this->tpl->printToStdout();
396 }
397
398 public function initGeneralSettingsForm(): void
399 {
400 global $DIC;
401
402 $lng = $DIC['lng'];
403 $ilUser = $DIC['ilUser'];
404 $styleDefinition = $DIC['styleDefinition'];
405 $ilSetting = $DIC['ilSetting'];
406
407 $this->form = new ilPropertyFormGUI();
408
409 // language
410 if ($this->userSettingVisible("language")) {
411 $languages = $this->lng->getInstalledLanguages();
412 $options = array();
413 foreach ($languages as $lang_key) {
414 $options[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
415 }
416
417 $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
418 $si->setOptions($options);
419 $si->setValue($ilUser->getLanguage());
420 $si->setDisabled(
421 $ilSetting->get("usr_settings_disable_language") === '1'
422 || count($options) <= 1
423 );
424 $this->form->addItem($si);
425 }
426
427 // skin/style
428 if ($this->userSettingVisible("skin_style")) {
429 $skins = $styleDefinition->getAllSkins();
430 if (is_array($skins)) {
431 $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
432
433 $options = array();
434 foreach ($skins as $skin) {
435 foreach ($skin->getStyles() as $style) {
436 if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId()) || $style->isSubstyle()) {
437 continue;
438 }
439
440 $options[$skin->getId() . ":" . $style->getId()] = $skin->getName() . " / " . $style->getName();
441 }
442 }
443 $si->setOptions($options);
444 $si->setValue($ilUser->skin . ":" . $ilUser->prefs["style"]);
445 $si->setDisabled((bool) $ilSetting->get("usr_settings_disable_skin_style"));
446 $this->form->addItem($si);
447 }
448 }
449
450 // help tooltips
451 $module_id = (int) $ilSetting->get("help_module");
452 if (((int) OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de" &&
453 $ilSetting->get("help_mode") != "1") {
454 $this->lng->loadLanguageModule("help");
455 $cb = new ilCheckboxInputGUI($this->lng->txt("help_toggle_tooltips"), "help_tooltips");
456 $cb->setChecked(!($ilUser->prefs["hide_help_tt"] ?? false));
457 $cb->setInfo($this->lng->txt("help_toggle_tooltips_info"));
458 $this->form->addItem($cb);
459 }
460
461 // hits per page
462 if ($this->userSettingVisible("hits_per_page")) {
463 $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
464
465 $hits_options = array(10,15,20,30,40,50,100,9999);
466 $options = array();
467
468 foreach ($hits_options as $hits_option) {
469 $hstr = ($hits_option == 9999)
470 ? $this->lng->txt("no_limit")
471 : $hits_option;
472 $options[$hits_option] = $hstr;
473 }
474 $si->setOptions($options);
475 $si->setValue($ilUser->prefs["hits_per_page"]);
476 $si->setDisabled((bool) $ilSetting->get("usr_settings_disable_hits_per_page"));
477 $this->form->addItem($si);
478 }
479
480 // Store last visited
481 $lv = new ilSelectInputGUI($this->lng->txt("user_store_last_visited"), "store_last_visited");
482 $options = array(
483 0 => $this->lng->txt("user_lv_keep_entries"),
484 1 => $this->lng->txt("user_lv_keep_only_for_session"),
485 2 => $this->lng->txt("user_lv_do_not_store"));
486 $lv->setOptions($options);
487 $last_visited = (int) ($ilUser->prefs["store_last_visited"] ?? 0);
488 $lv->setValue($last_visited);
489 $this->form->addItem($lv);
490
491
492 if (ilSessionReminder::isGloballyActivated()) {
493 $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
494 $cb->setInfo($this->lng->txt('session_reminder_info'));
495 $cb->setValue(1);
496 $cb->setChecked((bool) $ilUser->getPref('session_reminder_enabled'));
497
499 $lead_time_gui = new ilNumberInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
500 $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilDatePresentation::secondsToString($expires, true)));
501
503 $max_value = max($min_value, ($expires / 60) - 1);
504
505 $current_user_value = $ilUser->getPref('session_reminder_lead_time');
506 if ($current_user_value < $min_value ||
507 $current_user_value > $max_value) {
508 $current_user_value = ilSessionReminder::SUGGESTED_LEAD_TIME;
509 }
510 $value = min(
511 max(
512 $min_value,
513 $current_user_value
514 ),
515 $max_value
516 );
517
518 $lead_time_gui->setValue($value);
519 $lead_time_gui->setSize(3);
520 $lead_time_gui->setMinValue($min_value);
521 $lead_time_gui->setMaxValue($max_value);
522 $cb->addSubItem($lead_time_gui);
523
524 $this->form->addItem($cb);
525 }
526
527 // calendar settings (copied here to be reachable when calendar is inactive)
528 // they cannot be hidden/deactivated
529
530 $lng->loadLanguageModule("dateplaner");
531 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
532
533 $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'), 'timezone');
534 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
535 $select->setInfo($lng->txt('cal_timezone_info'));
536 $select->setValue($user_settings->getTimeZone());
537 $this->form->addItem($select);
538
539 $year = date("Y");
540 $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'), 'date_format');
541 $select->setOptions(array(
542 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
543 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
544 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
545 $select->setInfo($lng->txt('cal_date_format_info'));
546 $select->setValue($user_settings->getDateFormat());
547 $this->form->addItem($select);
548
549 $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'), 'time_format');
550 $select->setOptions(array(
553 $select->setInfo($lng->txt('cal_time_format_info'));
554 $select->setValue($user_settings->getTimeFormat());
555 $this->form->addItem($select);
556
557
558 // starting point
560 $this->lng->loadLanguageModule("administration");
561 $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "usr_start");
562 $si->setRequired(true);
563 $si->setInfo($this->lng->txt("adm_user_starting_point_info"));
564 $def_opt = new ilRadioOption($this->lng->txt("adm_user_starting_point_inherit"), 0);
565 $def_opt->setInfo($this->lng->txt("adm_user_starting_point_inherit_info"));
566 $si->addOption($def_opt);
567 foreach (ilUserUtil::getPossibleStartingPoints() as $value => $caption) {
568 if ($value === ilUserUtil::START_REPOSITORY_OBJ) {
569 continue;
570 }
571 $si->addOption(new ilRadioOption($caption, $value));
572 }
575 : 0);
576 $this->form->addItem($si);
577
578 // starting point: repository object
579 $repobj = new ilRadioOption($lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ);
580 $repobj_id = new ilTextInputGUI($lng->txt("adm_user_starting_point_ref_id"), "usr_start_ref_id");
581 $repobj_id->setInfo($lng->txt("adm_user_starting_point_ref_id_info"));
582 $repobj_id->setRequired(true);
583 $repobj_id->setSize(5);
584 if ($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ) {
586 $repobj_id->setValue($start_ref_id);
587 if ($start_ref_id) {
588 $start_obj_id = ilObject::_lookupObjId($start_ref_id);
589 if ($start_obj_id) {
590 $repobj_id->setInfo($lng->txt("obj_" . ilObject::_lookupType($start_obj_id)) .
591 ": " . ilObject::_lookupTitle($start_obj_id));
592 }
593 }
594 }
595 $repobj->addSubItem($repobj_id);
596 $si->addOption($repobj);
597 }
598
599 // selector for unicode characters
600 global $DIC;
601
602 $ilSetting = $DIC['ilSetting'];
603 if ($ilSetting->get('char_selector_availability') > 0) {
605 $char_selector->getConfig()->setAvailability((int) $ilUser->getPref('char_selector_availability'));
606 $char_selector->getConfig()->setDefinition((string) $ilUser->getPref('char_selector_definition'));
607 $char_selector->addFormProperties($this->form);
608 $char_selector->setFormValues($this->form);
609 }
610
611 $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
612 $this->form->setTitle($lng->txt("general_settings"));
613 $this->form->setFormAction($this->ctrl->getFormAction($this));
614 }
615
619 public function saveGeneralSettings(): void
620 {
621 global $DIC;
622
623 $tpl = $DIC['tpl'];
624 $lng = $DIC['lng'];
625 $ilCtrl = $DIC['ilCtrl'];
626 $ilUser = $DIC['ilUser'];
627 $ilSetting = $DIC->settings();
628
629 $this->initGeneralSettingsForm();
630 if ($this->form->checkInput()
631 && $this->checkPersonalStartingPoint()) {
632 if ($this->workWithUserSetting("skin_style")) {
633 //set user skin and style
634 if ($this->form->getInput("skin_style") != "") {
635 $sknst = explode(":", $this->form->getInput("skin_style"));
636
637 if ($ilUser->getPref("style") != $sknst[1] ||
638 $ilUser->getPref("skin") != $sknst[0]) {
639 $ilUser->setPref("skin", $sknst[0]);
640 $ilUser->setPref("style", $sknst[1]);
641 }
642 }
643 }
644
645 // language
646 if ($this->workWithUserSetting("language")) {
647 $ilUser->setLanguage($this->form->getInput("language"));
648 }
649
650 // hits per page
651 if ($this->workWithUserSetting("hits_per_page")) {
652 if ($this->form->getInput("hits_per_page") != "") {
653 $ilUser->setPref("hits_per_page", $this->form->getInput("hits_per_page"));
654 }
655 }
656
657 // help tooltips
658 $module_id = (int) $ilSetting->get("help_module");
659 if (((int) OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de" &&
660 $ilSetting->get("help_mode") != "1") {
661 $ilUser->setPref("hide_help_tt", (int) !$this->form->getInput("help_tooltips"));
662 }
663
664 // store last visited?
665 global $DIC;
666
667 $ilNavigationHistory = $DIC['ilNavigationHistory'];
668 $ilUser->setPref("store_last_visited", (int) $this->form->getInput("store_last_visited"));
669 if ((int) $this->form->getInput("store_last_visited") > 0) {
670 $ilNavigationHistory->deleteDBEntries();
671 if ((int) $this->form->getInput("store_last_visited") == 2) {
672 $ilNavigationHistory->deleteSessionEntries();
673 }
674 }
675
676 // session reminder
677 if (ilSessionReminder::isGloballyActivated()) {
678 $ilUser->setPref('session_reminder_enabled', (int) $this->form->getInput('session_reminder_enabled'));
679 $ilUser->setPref('session_reminder_lead_time', $this->form->getInput('session_reminder_lead_time'));
680 }
681
682 // starting point
684 $s_ref_id = $this->form->getInput('usr_start_ref_id');
685 $s_ref_id = ($s_ref_id == "")
686 ? null
687 : (int) $s_ref_id;
689 (int) $this->form->getInput('usr_start'),
690 $s_ref_id
691 );
692 }
693
694 // selector for unicode characters
695 global $DIC;
696
697 $ilSetting = $DIC['ilSetting'];
698 if ($ilSetting->get('char_selector_availability') > 0) {
700 $char_selector->getFormValues($this->form);
701 $ilUser->setPref('char_selector_availability', $char_selector->getConfig()->getAvailability());
702 $ilUser->setPref('char_selector_definition', $char_selector->getConfig()->getDefinition());
703 }
704
705 $ilUser->update();
706
707 // calendar settings
708 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
709 $user_settings->setTimeZone($this->form->getInput("timezone"));
710 $user_settings->setDateFormat((int) $this->form->getInput("date_format"));
711 $user_settings->setTimeFormat((int) $this->form->getInput("time_format"));
712 $user_settings->save();
713
714 $this->tpl->setOnScreenMessage('success', $lng->txtlng("common", "msg_obj_modified", $ilUser->getLanguage()), true);
715
716 $ilCtrl->redirect($this, "showGeneralSettings");
717 }
718
719 $this->form->setValuesByPost();
720 $this->showGeneralSettings(true);
721 }
722
723 private function checkPersonalStartingPoint(): bool
724 {
726 || (int) $this->form->getInput('usr_start') !== ilUserUtil::START_REPOSITORY_OBJ) {
727 return true;
728 }
729
730 $ref_id = $this->form->getInput('usr_start_ref_id');
731 if (!is_numeric($ref_id) || !ilObject::_exists($ref_id, true)) {
732 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('obj_ref_id_not_exist'), true);
733 return false;
734 }
735
736 return true;
737 }
738
742 protected function deleteOwnAccount1(): void
743 {
744 global $DIC;
745
746 $ilTabs = $DIC['ilTabs'];
747 $ilToolbar = $DIC['ilToolbar'];
748 $ilUser = $DIC['ilUser'];
749 $ilSetting = $DIC['ilSetting'];
750
751 if (!(bool) $ilSetting->get('user_delete_own_account') ||
752 $ilUser->getId() == SYSTEM_USER_ID) {
753 $this->ctrl->redirect($this, "showGeneralSettings");
754 }
755
756 // too make sure
757 $ilUser->removeDeletionFlag();
758
759 $this->setHeader();
760 $this->__initSubTabs("deleteOwnAccount");
761 $ilTabs->activateTab("delacc");
762
763 $this->tpl->setOnScreenMessage('info', $this->lng->txt('user_delete_own_account_info'));
764 $ilToolbar->addButton(
765 $this->lng->txt('btn_next'),
766 $this->ctrl->getLinkTarget($this, 'deleteOwnAccount2')
767 );
768
769 $this->tpl->printToStdout();
770 }
771
775 protected function deleteOwnAccount2(): void
776 {
777 global $DIC;
778
779 $ilTabs = $DIC['ilTabs'];
780 $ilUser = $DIC['ilUser'];
781 $ilSetting = $DIC['ilSetting'];
782
783 if (!(bool) $ilSetting->get('user_delete_own_account') ||
784 $ilUser->getId() == SYSTEM_USER_ID) {
785 $this->ctrl->redirect($this, "showGeneralSettings");
786 }
787
788 $this->setHeader();
789 $this->__initSubTabs("deleteOwnAccount");
790 $ilTabs->activateTab("delacc");
791
792 $cgui = new ilConfirmationGUI();
793 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_logout_confirmation'));
794 $cgui->setFormAction($this->ctrl->getFormAction($this));
795 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
796 $cgui->setConfirm($this->lng->txt("user_delete_own_account_logout_button"), "deleteOwnAccountLogout");
797 $this->tpl->setContent($cgui->getHTML());
798 $this->tpl->printToStdout();
799 }
800
801 protected function abortDeleteOwnAccount(): void
802 {
803 global $DIC;
804
805 $ilCtrl = $DIC['ilCtrl'];
806 $ilUser = $DIC['ilUser'];
807
808 $ilUser->removeDeletionFlag();
809
810 $this->tpl->setOnScreenMessage('info', $this->lng->txt("user_delete_own_account_aborted"), true);
811 $ilCtrl->redirect($this, "showGeneralSettings");
812 }
813
814 protected function deleteOwnAccountLogout(): void
815 {
816 global $DIC;
817
818 $ilUser = $DIC['ilUser'];
819
820 // we are setting the flag and ending the session in the same step
821
822 $ilUser->activateDeletionFlag();
823
824 // see ilStartupGUI::doLogout()
826 $GLOBALS['DIC']['ilAuthSession']->logout();
827
828 ilUtil::redirect("login.php?cmd=force_login&target=usr_" . md5("usrdelown"));
829 }
830
834 protected function deleteOwnAccount3(): void
835 {
836 global $DIC;
837
838 $ilTabs = $DIC['ilTabs'];
839 $ilUser = $DIC['ilUser'];
840 $ilSetting = $DIC['ilSetting'];
841
842 if (!(bool) $ilSetting->get('user_delete_own_account') ||
843 $ilUser->getId() == SYSTEM_USER_ID ||
844 !$ilUser->hasDeletionFlag()) {
845 $this->ctrl->redirect($this, "showGeneralSettings");
846 }
847
848 $this->setHeader();
849 $this->__initSubTabs("deleteOwnAccount");
850 $ilTabs->activateTab("delacc");
851
852 $cgui = new ilConfirmationGUI();
853 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_final_confirmation'));
854 $cgui->setFormAction($this->ctrl->getFormAction($this));
855 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
856 $cgui->setConfirm($this->lng->txt("confirm"), "deleteOwnAccount4");
857 $this->tpl->setContent($cgui->getHTML());
858 $this->tpl->printToStdout();
859 }
860
864 protected function deleteOwnAccount4(): void
865 {
866 global $DIC;
867
868 $ilUser = $DIC['ilUser'];
869 $ilSetting = $DIC['ilSetting'];
870 $ilLog = $DIC['ilLog'];
871
872 if (!(bool) $ilSetting->get('user_delete_own_account') ||
873 $ilUser->getId() == SYSTEM_USER_ID ||
874 !$ilUser->hasDeletionFlag()) {
875 $this->ctrl->redirect($this, "showGeneralSettings");
876 }
877
878 // build notification
879
880 $ntf = new ilSystemNotification();
881 $ntf->setLangModules(array("user"));
882 $ntf->addAdditionalInfo("profile", $ilUser->getProfileAsString($this->lng), true);
883
884 // mail message
886 $ntf->setIntroductionDirect(
887 sprintf(
888 $this->lng->txt("user_delete_own_account_email_body"),
889 $ilUser->getLogin(),
890 ILIAS_HTTP_PATH,
892 )
893 );
894
895 $message = $ntf->composeAndGetMessage($ilUser->getId(), null, 'read', true);
896 $subject = $this->lng->txt("user_delete_own_account_email_subject");
897
898
899 // send notification
900 $user_email = $ilUser->getEmail();
901 $admin_mail = $ilSetting->get("user_delete_own_account_email");
903 $senderFactory = $GLOBALS["DIC"]["mail.mime.sender.factory"];
904
905 $mmail = new ilMimeMail();
906 $mmail->From($senderFactory->system());
907 // to user, admin as bcc
908 if ($user_email) {
909 $mmail->To($user_email);
910 $mmail->Bcc($admin_mail);
911 $mmail->Subject($subject, true);
912 $mmail->Body($message);
913 $mmail->Send();
914 }
915 // admin only
916 elseif ($admin_mail) {
917 $mmail->To($admin_mail);
918 $mmail->Subject($subject, true);
919 $mmail->Body($message);
920 $mmail->Send();
921 }
922
923 $ilLog->write("Account deleted: " . $ilUser->getLogin() . " (" . $ilUser->getId() . ")");
924
925 $ilUser->delete();
926
927 // terminate session
928 $GLOBALS['DIC']['ilAuthSession']->logout();
929 ilUtil::redirect("login.php?accdel=1");
930 }
931}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const IL_CAL_UNIX
static isPasswordModificationEnabled($a_authmode)
Check if password modification is enabled.
static _getInstanceByUserId(int $a_user_id)
static _getShortTimeZoneList()
get short timezone list
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
static setUseRelativeDates(bool $a_status)
set use relative dates
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupEntry(string $a_lang_key, string $a_mod, string $a_id)
This class represents a number property in a property form.
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
ilUserDefinedFields $user_defined_fields
showGeneralSettings(bool $a_no_init=false)
deleteOwnAccount1()
Delete own account dialog - 1st confirmation.
deleteOwnAccount2()
Delete own account dialog - login redirect.
deleteOwnAccount3()
Delete own account dialog - final confirmation.
ILIAS User StandardGUIRequest $request
allowPasswordChange()
Check, whether password change is allowed for user.
ilUserSettingsConfig $user_settings_config
showPassword(bool $a_no_init=false, bool $hide_form=false)
saveGeneralSettings()
Save general settings.
This class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isPassword(string $a_passwd, ?string &$customError=null)
static isPasswordValidForUserContext(string $clear_text_password, $user, ?string &$error_language_variable=null)
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
This class represents a selection list property in a property form.
static get(string $a_var)
const SESSION_CLOSE_USER
static setClosingContext(int $a_context)
set closing context (for statistics)
static getSessionExpireValue()
Returns the session expiration value.
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated
This class represents a text property in a property form.
Additional user data fields definition.
static getInstance()
Singleton method to reduce footprint (included files, created instances)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPossibleStartingPoints(bool $a_force_all=false)
Get all valid starting points.
static getPersonalStartingObject()
Get ref id of personal starting object.
static hasPersonalStartPointPref()
Did user set any personal starting point (yet)?
static hasPersonalStartingPoint()
Can starting point be personalized?
static getPersonalStartingPoint()
Get current personal starting point.
const START_REPOSITORY_OBJ
static setPersonalStartingPoint(int $a_value, int $a_ref_id=null)
Set personal starting point setting.
static redirect(string $a_script)
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$ref_id
Definition: ltiauth.php:67
form( $class_path, string $cmd)
global $ilSetting
Definition: privfeed.php:17
$lng
$message
Definition: xapiexit.php:32