ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPersonalSettingsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
16 protected $tpl;
17
18
19 public $lng;
20 public $ilias;
21 public $ctrl;
22
27
31 public function __construct()
32 {
33 global $DIC;
34
35 $ilias = $DIC['ilias'];
36
37 $this->user_defined_fields = ilUserDefinedFields::_getInstance();
38
39 $this->tpl = $DIC->ui()->mainTemplate();
40 $this->lng = $DIC->language();
41 $this->ilias = $ilias;
42 $this->ctrl = $DIC->ctrl();
43
44 $this->settings = $ilias->getAllSettings();
45 $this->upload_error = "";
46 $this->password_error = "";
47 $this->lng->loadLanguageModule("user");
48 $this->ctrl->saveParameter($this, "user_page");
49
50 $this->user_settings_config = new ilUserSettingsConfig();
51 }
52
56 public function executeCommand()
57 {
58 global $DIC;
59
60 $next_class = $this->ctrl->getNextClass();
61
62 switch ($next_class) {
63 case 'ilmailoptionsgui':
64 require_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
65 if (!$DIC->rbac()->system()->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
66 $this->ilias->raiseError($DIC->language()->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
67 }
68
69 $this->__initSubTabs('showMailOptions');
70 $DIC->tabs()->activateTab('mail_settings');
71 $this->setHeader();
72
73 require_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
74 $this->ctrl->forwardCommand(new ilMailOptionsGUI());
75 break;
76
77 default:
78 $cmd = $this->ctrl->getCmd("showGeneralSettings");
79 $this->$cmd();
80 break;
81 }
82 return true;
83 }
84
85 // init sub tabs
86 public function __initSubTabs($a_cmd)
87 {
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') ? true : false;
103 $showGeneralSettings = ($a_cmd == 'showGeneralSettings') ? true : false;
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 require_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
130 if ($rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()) && $ilSetting->get('show_mail_settings')) {
131 $this->ctrl->setParameter($this, 'referrer', 'ilPersonalSettingsGUI');
132
133 $ilTabs->addTarget(
134 "mail_settings",
135 $this->ctrl->getLinkTargetByClass('ilMailOptionsGUI'),
136 "",
137 array('ilMailOptionsGUI')
138 );
139 }
140
141 include_once "./Services/Administration/classes/class.ilSetting.php";
142
143 if ((bool) $ilSetting->get('user_delete_own_account') &&
144 $ilUser->getId() != SYSTEM_USER_ID) {
145 $ilTabs->addTab(
146 "delacc",
147 $this->lng->txt('user_delete_own_account'),
148 $this->ctrl->getLinkTarget($this, "deleteOwnAccount1")
149 );
150 }
151 }
152
156 public function setHeader()
157 {
158 $this->tpl->setTitle($this->lng->txt('personal_settings'));
159 }
160
161 //
162 //
163 // PASSWORD FORM
164 //
165 //
166
171 public function showPassword($a_no_init = false, $hide_form = false)
172 {
173 global $DIC;
174
175 $ilTabs = $DIC['ilTabs'];
176 $ilUser = $DIC['ilUser'];
177
178 $this->__initSubTabs("showPersonalData");
179 $ilTabs->activateTab("password");
180
181 $this->setHeader();
182 // check whether password of user have to be changed
183 // due to first login or password of user is expired
184 if ($ilUser->isPasswordChangeDemanded()) {
186 $this->lng->txt('password_change_on_first_login_demand')
187 );
188 } elseif ($ilUser->isPasswordExpired()) {
189 $msg = $this->lng->txt('password_expired');
190 $password_age = $ilUser->getPasswordAge();
191 ilUtil::sendInfo(sprintf($msg, $password_age));
192 }
193
194 if (!$a_no_init && !$hide_form) {
195 $this->initPasswordForm();
196 }
197 $this->tpl->setContent(!$hide_form ? $this->form->getHTML() : '');
198 $this->tpl->printToStdout();
199 }
200
206 public function initPasswordForm()
207 {
208 global $DIC;
209
210 $lng = $DIC['lng'];
211 $ilUser = $DIC['ilUser'];
212 $ilSetting = $DIC['ilSetting'];
213
214 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
215 $this->form = new ilPropertyFormGUI();
216
217 // Check whether password change is allowed
218 if ($this->allowPasswordChange()) {
219 // The current password needs to be checked for verification
220 // unless the user uses Shibboleth authentication with additional
221 // local authentication for WebDAV.
222 //if (
223 // ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local"))
224 //)
225 $pw_info_set = false;
226 if ($ilUser->getAuthMode(true) == AUTH_LOCAL) {
227 // current password
228 $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
229 $cpass->setInfo(ilUtil::getPasswordRequirementsInfo());
230 $cpass->setRetype(false);
231 $cpass->setSkipSyntaxCheck(true);
232 $pw_info_set = true;
233 // only if a password exists.
234 if ($ilUser->getPasswd()) {
235 $cpass->setRequired(true);
236 }
237 $this->form->addItem($cpass);
238 }
239
240 // new password
241 $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
242 if ($pw_info_set === false) {
243 $ipass->setInfo(ilUtil::getPasswordRequirementsInfo());
244 }
245 $ipass->setRequired(true);
246 $ipass->setUseStripSlashes(false);
247
248 $this->form->addItem($ipass);
249 $this->form->addCommandButton("savePassword", $lng->txt("save"));
250
251 switch ($ilUser->getAuthMode(true)) {
252 case AUTH_LOCAL:
253 $this->form->setTitle($lng->txt("chg_password"));
254 break;
255
256 case AUTH_SHIBBOLETH:
257 case AUTH_CAS:
258 require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
260 $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
261 } else {
262 $this->form->setTitle($lng->txt("chg_ilias_password"));
263 }
264 break;
265 default:
266 $this->form->setTitle($lng->txt("chg_ilias_password"));
267 break;
268 }
269 $this->form->setFormAction($this->ctrl->getFormAction($this));
270 }
271 }
272
276 protected function allowPasswordChange()
277 {
278 global $DIC;
279
280 $ilUser = $DIC['ilUser'];
281
282 if (\ilSession::get('used_external_auth')) {
283 return false;
284 }
285
286 $status = ilAuthUtils::isPasswordModificationEnabled($ilUser->getAuthMode(true));
287 if ($status) {
288 return true;
289 }
290
291 return \ilAuthUtils::isPasswordModificationHidden() && ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired());
292 }
293
298 public function savePassword()
299 {
300 global $DIC;
301
302 $tpl = $DIC['tpl'];
303 $lng = $DIC['lng'];
304 $ilCtrl = $DIC['ilCtrl'];
305 $ilUser = $DIC['ilUser'];
306 $ilSetting = $DIC['ilSetting'];
307
308 // normally we should not end up here
309 if (!$this->allowPasswordChange()) {
310 $ilCtrl->redirect($this, "showPersonalData");
311 return;
312 }
313
314 $this->initPasswordForm();
315 if ($this->form->checkInput()) {
316 $cp = $this->form->getItemByPostVar("current_password");
317 $np = $this->form->getItemByPostVar("new_password");
318 $error = false;
319
320 // The old password needs to be checked for verification
321 // unless the user uses Shibboleth authentication with additional
322 // local authentication for WebDAV.
323 if ($ilUser->getAuthMode(true) == AUTH_LOCAL) {
324 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
325 if (!ilUserPasswordManager::getInstance()->verifyPassword($ilUser, ilUtil::stripSlashes($_POST['current_password']))) {
326 $error = true;
327 $cp->setAlert($this->lng->txt('passwd_wrong'));
328 }
329 }
330
331 if (!ilUtil::isPassword($_POST["new_password"], $custom_error)) {
332 $error = true;
333 if ($custom_error != '') {
334 $np->setAlert($custom_error);
335 } else {
336 $np->setAlert($this->lng->txt("passwd_invalid"));
337 }
338 }
339 $error_lng_var = '';
340 if (!ilUtil::isPasswordValidForUserContext($_POST["new_password"], $ilUser, $error_lng_var)) {
341 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
342 $np->setAlert($this->lng->txt($error_lng_var));
343 $error = true;
344 }
345 if (
346 ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
347 $_POST["current_password"] == $_POST["new_password"]) {
348 $error = true;
349 $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
350 }
351
352 if (!$error) {
353 $ilUser->resetPassword($_POST["new_password"], $_POST["new_password"]);
354 if ($_POST["current_password"] != $_POST["new_password"]) {
355 $ilUser->setLastPasswordChangeToNow();
356 $ilUser->setPasswordPolicyResetStatus(false);
357 $ilUser->update();
358 }
359
360 if (ilSession::get('orig_request_target')) {
361 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
362 $target = ilSession::get('orig_request_target');
363 ilSession::set('orig_request_target', '');
364 ilUtil::redirect($target);
365 } else {
366 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
367 $this->showPassword(true, true);
368 return;
369 }
370 }
371 }
372 $this->form->setValuesByPost();
373 $this->showPassword(true);
374 }
375
376 //
377 //
378 // GENERAL SETTINGS FORM
379 //
380 //
381
386 public function workWithUserSetting(string $setting) : bool
387 {
388 return $this->user_settings_config->isVisibleAndChangeable($setting);
389 }
390
395 public function userSettingVisible(string $setting) : bool
396 {
397 return $this->user_settings_config->isVisible($setting);
398 }
399
404 public function userSettingEnabled(string $setting) : bool
405 {
406 return $this->user_settings_config->isChangeable($setting);
407 }
408
412 public function showGeneralSettings($a_no_init = false)
413 {
414 global $DIC;
415
416 $ilTabs = $DIC['ilTabs'];
417
418 $this->__initSubTabs("showPersonalData");
419 $ilTabs->activateTab("general_settings");
420
421 $this->setHeader();
422
423 if (!$a_no_init) {
425 }
426 $this->tpl->setContent($this->form->getHTML());
427 $this->tpl->printToStdout();
428 }
429
434 public function initGeneralSettingsForm()
435 {
436 global $DIC;
437
438 $lng = $DIC['lng'];
439 $ilUser = $DIC['ilUser'];
440 $styleDefinition = $DIC['styleDefinition'];
441 $ilSetting = $DIC['ilSetting'];
442
443
444 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
445 $this->form = new ilPropertyFormGUI();
446
447 // language
448 if ($this->userSettingVisible("language")) {
449 $languages = $this->lng->getInstalledLanguages();
450 $options = array();
451 foreach ($languages as $lang_key) {
452 $options[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
453 }
454
455 $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
456 $si->setOptions($options);
457 $si->setValue($ilUser->getLanguage());
458 $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
459 $this->form->addItem($si);
460 }
461
462 // skin/style
463 if ($this->userSettingVisible("skin_style")) {
464 $skins = $styleDefinition->getAllSkins();
465 if (is_array($skins)) {
466 $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
467
468 $options = array();
469 foreach ($skins as $skin) {
470 foreach ($skin->getStyles() as $style) {
471 include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
472 if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId()) || $style->isSubstyle()) {
473 continue;
474 }
475
476 $options[$skin->getId() . ":" . $style->getId()] = $skin->getName() . " / " . $style->getName();
477 }
478 }
479 $si->setOptions($options);
480 $si->setValue($ilUser->skin . ":" . $ilUser->prefs["style"]);
481 $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
482 $this->form->addItem($si);
483 }
484 }
485
486 // screen reader optimization
487 if ($this->userSettingVisible("screen_reader_optimization")) {
488 $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
489 $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
490 $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
491 $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
492 $this->form->addItem($cb);
493 }
494
495 // help tooltips
496 $module_id = (int) $ilSetting->get("help_module");
497 if ((OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de" &&
498 $ilSetting->get("help_mode") != "1") {
499 $this->lng->loadLanguageModule("help");
500 $cb = new ilCheckboxInputGUI($this->lng->txt("help_toggle_tooltips"), "help_tooltips");
501 $cb->setChecked(!$ilUser->prefs["hide_help_tt"]);
502 $cb->setInfo($this->lng->txt("help_toggle_tooltips_info"));
503 $this->form->addItem($cb);
504 }
505
506 // hits per page
507 if ($this->userSettingVisible("hits_per_page")) {
508 $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
509
510 $hits_options = array(10,15,20,30,40,50,100,9999);
511 $options = array();
512
513 foreach ($hits_options as $hits_option) {
514 $hstr = ($hits_option == 9999)
515 ? $this->lng->txt("no_limit")
516 : $hits_option;
517 $options[$hits_option] = $hstr;
518 }
519 $si->setOptions($options);
520 $si->setValue($ilUser->prefs["hits_per_page"]);
521 $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
522 $this->form->addItem($si);
523 }
524
525 // Users Online
526 /*
527 if ($this->userSettingVisible("show_users_online"))
528 {
529 $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
530
531 $options = array(
532 "y" => $this->lng->txt("users_online_show_y"),
533 "associated" => $this->lng->txt("users_online_show_associated"),
534 "n" => $this->lng->txt("users_online_show_n"));
535 $si->setOptions($options);
536 $si->setValue($ilUser->prefs["show_users_online"]);
537 $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
538 $this->form->addItem($si);
539 }*/
540
541 // Store last visited
542 $lv = new ilSelectInputGUI($this->lng->txt("user_store_last_visited"), "store_last_visited");
543 $options = array(
544 0 => $this->lng->txt("user_lv_keep_entries"),
545 1 => $this->lng->txt("user_lv_keep_only_for_session"),
546 2 => $this->lng->txt("user_lv_do_not_store"));
547 $lv->setOptions($options);
548 $lv->setValue((int) $ilUser->prefs["store_last_visited"]);
549 $this->form->addItem($lv);
550
551
552 include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
553 if (ilSessionReminder::isGloballyActivated()) {
554 $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
555 $cb->setInfo($this->lng->txt('session_reminder_info'));
556 $cb->setValue(1);
557 $cb->setChecked((int) $ilUser->getPref('session_reminder_enabled'));
558
560 $lead_time_gui = new ilNumberInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
561 $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilDatePresentation::secondsToString($expires, true)));
562
564 $max_value = max($min_value, ((int) $expires / 60) - 1);
565
566 $current_user_value = $ilUser->getPref('session_reminder_lead_time');
567 if ($current_user_value < $min_value ||
568 $current_user_value > $max_value) {
569 $current_user_value = ilSessionReminder::SUGGESTED_LEAD_TIME;
570 }
571 $value = min(
572 max(
573 $min_value,
574 $current_user_value
575 ),
576 $max_value
577 );
578
579 $lead_time_gui->setValue($value);
580 $lead_time_gui->setSize(3);
581 $lead_time_gui->setMinValue($min_value);
582 $lead_time_gui->setMaxValue($max_value);
583 $cb->addSubItem($lead_time_gui);
584
585 $this->form->addItem($cb);
586 }
587
588 // calendar settings (copied here to be reachable when calendar is inactive)
589 // they cannot be hidden/deactivated
590
591 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
592 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
593 $lng->loadLanguageModule("dateplaner");
594 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
595
596 $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'), 'timezone');
597 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
598 $select->setInfo($lng->txt('cal_timezone_info'));
599 $select->setValue($user_settings->getTimeZone());
600 $this->form->addItem($select);
601
602 $year = date("Y");
603 $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'), 'date_format');
604 $select->setOptions(array(
605 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
606 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
607 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
608 $select->setInfo($lng->txt('cal_date_format_info'));
609 $select->setValue($user_settings->getDateFormat());
610 $this->form->addItem($select);
611
612 $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'), 'time_format');
613 $select->setOptions(array(
616 $select->setInfo($lng->txt('cal_time_format_info'));
617 $select->setValue($user_settings->getTimeFormat());
618 $this->form->addItem($select);
619
620
621 // starting point
622 include_once "Services/User/classes/class.ilUserUtil.php";
624 $this->lng->loadLanguageModule("administration");
625 $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "usr_start");
626 $si->setRequired(true);
627 $si->setInfo($this->lng->txt("adm_user_starting_point_info"));
628 $def_opt = new ilRadioOption($this->lng->txt("adm_user_starting_point_inherit"), 0);
629 $def_opt->setInfo($this->lng->txt("adm_user_starting_point_inherit_info"));
630 $si->addOption($def_opt);
631 foreach (ilUserUtil::getPossibleStartingPoints() as $value => $caption) {
632 $si->addOption(new ilRadioOption($caption, $value));
633 }
636 : 0);
637 $this->form->addItem($si);
638
639 // starting point: repository object
640 $repobj = new ilRadioOption($lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ);
641 $repobj_id = new ilTextInputGUI($lng->txt("adm_user_starting_point_ref_id"), "usr_start_ref_id");
642 $repobj_id->setInfo($lng->txt("adm_user_starting_point_ref_id_info"));
643 $repobj_id->setRequired(true);
644 $repobj_id->setSize(5);
645 if ($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ) {
647 $repobj_id->setValue($start_ref_id);
648 if ($start_ref_id) {
649 $start_obj_id = ilObject::_lookupObjId($start_ref_id);
650 if ($start_obj_id) {
651 $repobj_id->setInfo($lng->txt("obj_" . ilObject::_lookupType($start_obj_id)) .
652 ": " . ilObject::_lookupTitle($start_obj_id));
653 }
654 }
655 }
656 $repobj->addSubItem($repobj_id);
657 $si->addOption($repobj);
658 }
659
660 // selector for unicode characters
661 global $DIC;
662
663 $ilSetting = $DIC['ilSetting'];
664 if ($ilSetting->get('char_selector_availability') > 0) {
665 require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
667 $char_selector->getConfig()->setAvailability($ilUser->getPref('char_selector_availability'));
668 $char_selector->getConfig()->setDefinition($ilUser->getPref('char_selector_definition'));
669 $char_selector->addFormProperties($this->form);
670 $char_selector->setFormValues($this->form);
671 }
672
673 $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
674 $this->form->setTitle($lng->txt("general_settings"));
675 $this->form->setFormAction($this->ctrl->getFormAction($this));
676 }
677
681 public function saveGeneralSettings()
682 {
683 global $DIC;
684
685 $tpl = $DIC['tpl'];
686 $lng = $DIC['lng'];
687 $ilCtrl = $DIC['ilCtrl'];
688 $ilUser = $DIC['ilUser'];
689 $ilSetting = $DIC->settings();
690
692 if ($this->form->checkInput()
693 && $this->checkPersonalStartingPoint()) {
694 if ($this->workWithUserSetting("skin_style")) {
695 //set user skin and style
696 if ($_POST["skin_style"] != "") {
697 $sknst = explode(":", $_POST["skin_style"]);
698
699 if ($ilUser->getPref("style") != $sknst[1] ||
700 $ilUser->getPref("skin") != $sknst[0]) {
701 $ilUser->setPref("skin", $sknst[0]);
702 $ilUser->setPref("style", $sknst[1]);
703 }
704 }
705 }
706
707 // language
708 if ($this->workWithUserSetting("language")) {
709 $ilUser->setLanguage($_POST["language"]);
710 }
711
712 // hits per page
713 if ($this->workWithUserSetting("hits_per_page")) {
714 if ($_POST["hits_per_page"] != "") {
715 $ilUser->setPref("hits_per_page", $_POST["hits_per_page"]);
716 }
717 }
718
719 // help tooltips
720 $module_id = (int) $ilSetting->get("help_module");
721 if ((OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de" &&
722 $ilSetting->get("help_mode") != "1") {
723 $ilUser->setPref("hide_help_tt", (int) !$_POST["help_tooltips"]);
724 }
725
726 // set show users online
727 /*
728 if ($this->workWithUserSetting("show_users_online"))
729 {
730 $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
731 }*/
732
733 // store last visited?
734 global $DIC;
735
736 $ilNavigationHistory = $DIC['ilNavigationHistory'];
737 $ilUser->setPref("store_last_visited", (int) $_POST["store_last_visited"]);
738 if ((int) $_POST["store_last_visited"] > 0) {
739 $ilNavigationHistory->deleteDBEntries();
740 if ((int) $_POST["store_last_visited"] == 2) {
741 $ilNavigationHistory->deleteSessionEntries();
742 }
743 }
744
745 // set show users online
746 if ($this->workWithUserSetting("screen_reader_optimization")) {
747 $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
748 }
749
750 // session reminder
751 include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
752 if (ilSessionReminder::isGloballyActivated()) {
753 $ilUser->setPref('session_reminder_enabled', (int) $this->form->getInput('session_reminder_enabled'));
754 $ilUser->setPref('session_reminder_lead_time', $this->form->getInput('session_reminder_lead_time'));
755 }
756
757 // starting point
758 include_once "Services/User/classes/class.ilUserUtil.php";
761 $this->form->getInput('usr_start'),
762 $this->form->getInput('usr_start_ref_id')
763 );
764 }
765
766 // selector for unicode characters
767 global $DIC;
768
769 $ilSetting = $DIC['ilSetting'];
770 if ($ilSetting->get('char_selector_availability') > 0) {
771 require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
773 $char_selector->getFormValues($this->form);
774 $ilUser->setPref('char_selector_availability', $char_selector->getConfig()->getAvailability());
775 $ilUser->setPref('char_selector_definition', $char_selector->getConfig()->getDefinition());
776 }
777
778 $ilUser->update();
779
780 // calendar settings
781 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
782 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
783 $user_settings->setTimeZone($this->form->getInput("timezone"));
784 $user_settings->setDateFormat((int) $this->form->getInput("date_format"));
785 $user_settings->setTimeFormat((int) $this->form->getInput("time_format"));
786 $user_settings->save();
787
788 ilUtil::sendSuccess($lng->txtlng("common", "msg_obj_modified", $ilUser->getLanguage()), true);
789
790 $ilCtrl->redirect($this, "showGeneralSettings");
791 }
792
793 $this->form->setValuesByPost();
794 $this->showGeneralSettings(true);
795 }
796
797 private function checkPersonalStartingPoint(): bool
798 {
800 || (int) $this->form->getInput('usr_start') !== ilUserUtil::START_REPOSITORY_OBJ) {
801 return true;
802 }
803
804 $ref_id = $this->form->getInput('usr_start_ref_id');
805 if (!is_numeric($ref_id) || !ilObject::_exists($ref_id, true)) {
806 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('obj_ref_id_not_exist'), true);
807 return false;
808 }
809
810 return true;
811 }
812
816 protected function deleteOwnAccount1()
817 {
818 global $DIC;
819
820 $ilTabs = $DIC['ilTabs'];
821 $ilToolbar = $DIC['ilToolbar'];
822 $ilUser = $DIC['ilUser'];
823 $ilSetting = $DIC['ilSetting'];
824
825 if (!(bool) $ilSetting->get('user_delete_own_account') ||
826 $ilUser->getId() == SYSTEM_USER_ID) {
827 $this->ctrl->redirect($this, "showGeneralSettings");
828 }
829
830 // too make sure
831 $ilUser->removeDeletionFlag();
832
833 $this->setHeader();
834 $this->__initSubTabs("deleteOwnAccount");
835 $ilTabs->activateTab("delacc");
836
837 ilUtil::sendInfo($this->lng->txt('user_delete_own_account_info'));
838 $ilToolbar->addButton(
839 $this->lng->txt('btn_next'),
840 $this->ctrl->getLinkTarget($this, 'deleteOwnAccount2')
841 );
842
843 $this->tpl->printToStdout();
844 }
845
849 protected function deleteOwnAccount2()
850 {
851 global $DIC;
852
853 $ilTabs = $DIC['ilTabs'];
854 $ilUser = $DIC['ilUser'];
855 $ilSetting = $DIC['ilSetting'];
856
857 if (!(bool) $ilSetting->get('user_delete_own_account') ||
858 $ilUser->getId() == SYSTEM_USER_ID) {
859 $this->ctrl->redirect($this, "showGeneralSettings");
860 }
861
862 $this->setHeader();
863 $this->__initSubTabs("deleteOwnAccount");
864 $ilTabs->activateTab("delacc");
865
866 include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
867 $cgui = new ilConfirmationGUI();
868 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_logout_confirmation'));
869 $cgui->setFormAction($this->ctrl->getFormAction($this));
870 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
871 $cgui->setConfirm($this->lng->txt("user_delete_own_account_logout_button"), "deleteOwnAccountLogout");
872 $this->tpl->setContent($cgui->getHTML());
873 $this->tpl->printToStdout();
874 }
875
876 protected function abortDeleteOwnAccount()
877 {
878 global $DIC;
879
880 $ilCtrl = $DIC['ilCtrl'];
881 $ilUser = $DIC['ilUser'];
882
883 $ilUser->removeDeletionFlag();
884
885 ilUtil::sendInfo($this->lng->txt("user_delete_own_account_aborted"), true);
886 $ilCtrl->redirect($this, "showGeneralSettings");
887 }
888
889 protected function deleteOwnAccountLogout()
890 {
891 global $DIC;
892
893 $ilUser = $DIC['ilUser'];
894
895 // we are setting the flag and ending the session in the same step
896
897 $ilUser->activateDeletionFlag();
898
899 // see ilStartupGUI::doLogout()
901 $GLOBALS['DIC']['ilAuthSession']->logout();
902
903 ilUtil::redirect("login.php?cmd=force_login&target=usr_" . md5("usrdelown"));
904 }
905
909 protected function deleteOwnAccount3()
910 {
911 global $DIC;
912
913 $ilTabs = $DIC['ilTabs'];
914 $ilUser = $DIC['ilUser'];
915 $ilSetting = $DIC['ilSetting'];
916
917 if (!(bool) $ilSetting->get('user_delete_own_account') ||
918 $ilUser->getId() == SYSTEM_USER_ID ||
919 !$ilUser->hasDeletionFlag()) {
920 $this->ctrl->redirect($this, "showGeneralSettings");
921 }
922
923 $this->setHeader();
924 $this->__initSubTabs("deleteOwnAccount");
925 $ilTabs->activateTab("delacc");
926
927 include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
928 $cgui = new ilConfirmationGUI();
929 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_final_confirmation'));
930 $cgui->setFormAction($this->ctrl->getFormAction($this));
931 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
932 $cgui->setConfirm($this->lng->txt("confirm"), "deleteOwnAccount4");
933 $this->tpl->setContent($cgui->getHTML());
934 $this->tpl->printToStdout();
935 }
936
940 protected function deleteOwnAccount4()
941 {
942 global $DIC;
943
944 $ilUser = $DIC['ilUser'];
945 $ilSetting = $DIC['ilSetting'];
946 $ilLog = $DIC['ilLog'];
947
948 if (!(bool) $ilSetting->get('user_delete_own_account') ||
949 $ilUser->getId() == SYSTEM_USER_ID ||
950 !$ilUser->hasDeletionFlag()) {
951 $this->ctrl->redirect($this, "showGeneralSettings");
952 }
953
954 // build notification
955
956 include_once "./Services/Notification/classes/class.ilSystemNotification.php";
957 $ntf = new ilSystemNotification();
958 $ntf->setLangModules(array("user"));
959 $ntf->addAdditionalInfo("profile", $ilUser->getProfileAsString($this->lng), true);
960
961 // mail message
963 $ntf->setIntroductionDirect(
964 sprintf(
965 $this->lng->txt("user_delete_own_account_email_body"),
966 $ilUser->getLogin(),
967 ILIAS_HTTP_PATH,
969 )
970 );
971
972 $message = $ntf->composeAndGetMessage($ilUser->getId(), null, null, true);
973 $subject = $this->lng->txt("user_delete_own_account_email_subject");
974
975
976 // send notification
977 $user_email = $ilUser->getEmail();
978 $admin_mail = $ilSetting->get("user_delete_own_account_email");
980 $senderFactory = $GLOBALS["DIC"]["mail.mime.sender.factory"];
981
982 $mmail = new ilMimeMail();
983 $mmail->From($senderFactory->system());
984 // to user, admin as bcc
985 if ($user_email) {
986 $mmail->To($user_email);
987 $mmail->Bcc($admin_mail);
988 $mmail->Subject($subject, true);
989 $mmail->Body($message);
990 $mmail->Send();
991 }
992 // admin only
993 elseif ($admin_mail) {
994 $mmail->To($admin_mail);
995 $mmail->Subject($subject, true);
996 $mmail->Body($message);
997 $mmail->Send();
998 }
999
1000 $ilLog->write("Account deleted: " . $ilUser->getLogin() . " (" . $ilUser->getId() . ")");
1001
1002 $ilUser->delete();
1003
1004 // terminate session
1005 $GLOBALS['DIC']['ilAuthSession']->logout();
1006 ilUtil::redirect("login.php?accdel=1");
1007 }
1008}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const AUTH_SHIBBOLETH
const AUTH_LOCAL
const AUTH_CAS
const IL_CAL_UNIX
static isPasswordModificationEnabled($a_authmode)
Check if password modification is enabled.
static _getInstanceByUserId($a_user_id)
get singleton instance
static _getShortTimeZoneList()
get short timezone list
This shows a character selector.
This class represents a checkbox property in a property form.
Confirmation screen class.
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
@classDescription Date and time handling
static _lookupEntry($a_lang_key, $a_mod, $a_id)
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable.
Class ilMimeMail.
This class represents a number property in a property form.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a password property in a property form.
GUI class for personal profile.
initGeneralSettingsForm()
Init general settings form.
deleteOwnAccount1()
Delete own account dialog - 1st confirmation.
deleteOwnAccount2()
Delete own account dialog - login redirect.
deleteOwnAccount3()
Delete own account dialog - final confirmation.
initPasswordForm()
Init password form.
allowPasswordChange()
Check, whether password change is allowed for user.
saveGeneralSettings()
Save general settings.
showPassword($a_no_init=false, $hide_form=false)
showGeneralSettings($a_no_init=false)
General settings form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
const SESSION_CLOSE_USER
static set($a_var, $a_val)
Set a value.
static setClosingContext($a_context)
set closing context (for statistics)
static get($a_var)
Get a value.
static getSessionExpireValue()
Returns the session expiration value.
Wrapper classes for system notifications.
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
This class represents a text property in a property form.
static _getInstance()
Get instance.
static getInstance()
Single method to reduce footprint (included files, created instances)
User settings configuration (what preferences can be visible/changed/...)
static getPersonalStartingObject()
Get ref id of personal starting object.
static getPossibleStartingPoints($a_force_all=false)
Get all valid starting points.
static hasPersonalStartPointPref()
Did user set any personal starting point (yet)?
static hasPersonalStartingPoint()
Can starting point be personalized?
static getPersonalStartingPoint()
Get current personal starting point.
static setPersonalStartingPoint($a_value, $a_ref_id=null)
Set personal starting point setting.
const START_REPOSITORY_OBJ
static redirect($a_script)
static isPassword($a_passwd, &$customError=null)
validates a password @access public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
const SYSTEM_USER_ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: constants.php:24
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
$message
Definition: xapiexit.php:14