ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 case 'ilpersonalchatsettingsformgui':
78 $this->__initSubTabs($this->ctrl->getCmd());
79 $this->setHeader();
80
81 $DIC->tabs()->activateTab('chat_settings');
82
83 $chatSettingsGui = new ilPersonalChatSettingsFormGUI();
84 $this->ctrl->forwardCommand($chatSettingsGui);
85 break;
86
87 default:
88 $cmd = $this->ctrl->getCmd("showGeneralSettings");
89 $this->$cmd();
90 break;
91 }
92 return true;
93 }
94
95 // init sub tabs
96 public function __initSubTabs($a_cmd)
97 {
102 global $DIC;
103
104 $ilTabs = $DIC['ilTabs'];
105 $ilSetting = $DIC['ilSetting'];
106 $ilHelp = $DIC['ilHelp'];
107 $rbacsystem = $DIC['rbacsystem'];
108 $ilUser = $DIC['ilUser'];
109
110 $ilHelp->setScreenIdComponent("user");
111
112 $showPassword = ($a_cmd == 'showPassword') ? true : false;
113 $showGeneralSettings = ($a_cmd == 'showGeneralSettings') ? true : false;
114
115 // old profile
116
117 // general settings
118 $ilTabs->addTarget(
119 "general_settings",
120 $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
121 "",
122 "",
123 "",
124 $showGeneralSettings
125 );
126
127 // password
128 if ($this->allowPasswordChange()) {
129 $ilTabs->addTarget(
130 "password",
131 $this->ctrl->getLinkTarget($this, "showPassword"),
132 "",
133 "",
134 "",
135 $showPassword
136 );
137 }
138
139 require_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
140 if ($rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()) && $ilSetting->get('show_mail_settings')) {
141 $this->ctrl->setParameter($this, 'referrer', 'ilPersonalSettingsGUI');
142
143 $ilTabs->addTarget(
144 "mail_settings",
145 $this->ctrl->getLinkTargetByClass('ilMailOptionsGUI'),
146 "",
147 array('ilMailOptionsGUI')
148 );
149 }
150
151 $chatSettingsGui = new ilPersonalChatSettingsFormGUI();
152 if ($chatSettingsGui->isAccessible()) {
153 $ilTabs->addTarget(
154 'chat_settings',
155 $this->ctrl->getLinkTarget($chatSettingsGui, 'showChatOptions'),
156 '',
157 ['ilPersonalChatSettingsFormGUI']
158 );
159 }
160
161 include_once "./Services/Administration/classes/class.ilSetting.php";
162
163 if ((bool) $ilSetting->get('user_delete_own_account') &&
164 $ilUser->getId() != SYSTEM_USER_ID) {
165 $ilTabs->addTab(
166 "delacc",
167 $this->lng->txt('user_delete_own_account'),
168 $this->ctrl->getLinkTarget($this, "deleteOwnAccount1")
169 );
170 }
171 }
172
176 public function setHeader()
177 {
178 $this->tpl->setTitle($this->lng->txt('personal_settings'));
179 }
180
181 //
182 //
183 // PASSWORD FORM
184 //
185 //
186
191 public function showPassword($a_no_init = false, $hide_form = false)
192 {
193 global $DIC;
194
195 $ilTabs = $DIC['ilTabs'];
196 $ilUser = $DIC['ilUser'];
197
198 $this->__initSubTabs("showPersonalData");
199 $ilTabs->activateTab("password");
200
201 $this->setHeader();
202 // check whether password of user have to be changed
203 // due to first login or password of user is expired
204 if ($ilUser->isPasswordChangeDemanded()) {
206 $this->lng->txt('password_change_on_first_login_demand')
207 );
208 } elseif ($ilUser->isPasswordExpired()) {
209 $msg = $this->lng->txt('password_expired');
210 $password_age = $ilUser->getPasswordAge();
211 ilUtil::sendInfo(sprintf($msg, $password_age));
212 }
213
214 if (!$a_no_init && !$hide_form) {
215 $this->initPasswordForm();
216 }
217 $this->tpl->setContent(!$hide_form ? $this->form->getHTML() : '');
218 $this->tpl->printToStdout();
219 }
220
226 public function initPasswordForm()
227 {
228 global $DIC;
229
230 $lng = $DIC['lng'];
231 $ilUser = $DIC['ilUser'];
232 $ilSetting = $DIC['ilSetting'];
233
234 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
235 $this->form = new ilPropertyFormGUI();
236
237 // Check whether password change is allowed
238 if ($this->allowPasswordChange()) {
239 // The current password needs to be checked for verification
240 // unless the user uses Shibboleth authentication with additional
241 // local authentication for WebDAV.
242 //if (
243 // ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local"))
244 //)
245 $pw_info_set = false;
246 if ($ilUser->getAuthMode(true) == AUTH_LOCAL) {
247 // current password
248 $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
249 $cpass->setInfo(ilUtil::getPasswordRequirementsInfo());
250 $cpass->setRetype(false);
251 $cpass->setSkipSyntaxCheck(true);
252 $pw_info_set = true;
253 // only if a password exists.
254 if ($ilUser->getPasswd()) {
255 $cpass->setRequired(true);
256 }
257 $this->form->addItem($cpass);
258 }
259
260 // new password
261 $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
262 if($pw_info_set === false) {
263 $ipass->setInfo(ilUtil::getPasswordRequirementsInfo());
264 }
265 $ipass->setRequired(true);
266
267 $this->form->addItem($ipass);
268 $this->form->addCommandButton("savePassword", $lng->txt("save"));
269
270 switch ($ilUser->getAuthMode(true)) {
271 case AUTH_LOCAL:
272 $this->form->setTitle($lng->txt("chg_password"));
273 break;
274
275 case AUTH_SHIBBOLETH:
276 case AUTH_CAS:
277 require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
279 $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
280 } else {
281 $this->form->setTitle($lng->txt("chg_ilias_password"));
282 }
283 break;
284 default:
285 $this->form->setTitle($lng->txt("chg_ilias_password"));
286 break;
287 }
288 $this->form->setFormAction($this->ctrl->getFormAction($this));
289 }
290 }
291
295 protected function allowPasswordChange()
296 {
297 global $DIC;
298
299 $ilUser = $DIC['ilUser'];
300
301 if (\ilSession::get('used_external_auth')) {
302 return false;
303 }
304
305 $status = ilAuthUtils::isPasswordModificationEnabled($ilUser->getAuthMode(true));
306 if ($status) {
307 return true;
308 }
309
310 return \ilAuthUtils::isPasswordModificationHidden() && ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired());
311 }
312
317 public function savePassword()
318 {
319 global $DIC;
320
321 $tpl = $DIC['tpl'];
322 $lng = $DIC['lng'];
323 $ilCtrl = $DIC['ilCtrl'];
324 $ilUser = $DIC['ilUser'];
325 $ilSetting = $DIC['ilSetting'];
326
327 // normally we should not end up here
328 if (!$this->allowPasswordChange()) {
329 $ilCtrl->redirect($this, "showPersonalData");
330 return;
331 }
332
333 $this->initPasswordForm();
334 if ($this->form->checkInput()) {
335 $cp = $this->form->getItemByPostVar("current_password");
336 $np = $this->form->getItemByPostVar("new_password");
337 $error = false;
338
339 // The old password needs to be checked for verification
340 // unless the user uses Shibboleth authentication with additional
341 // local authentication for WebDAV.
342 #if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
343 if ($ilUser->getAuthMode(true) == AUTH_LOCAL) {
344 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
345 if (!ilUserPasswordManager::getInstance()->verifyPassword($ilUser, ilUtil::stripSlashes($_POST['current_password']))) {
346 $error = true;
347 $cp->setAlert($this->lng->txt('passwd_wrong'));
348 }
349 }
350
351 if (!ilUtil::isPassword($_POST["new_password"], $custom_error)) {
352 $error = true;
353 if ($custom_error != '') {
354 $np->setAlert($custom_error);
355 } else {
356 $np->setAlert($this->lng->txt("passwd_invalid"));
357 }
358 }
359 $error_lng_var = '';
360 if (!ilUtil::isPasswordValidForUserContext($_POST["new_password"], $ilUser, $error_lng_var)) {
361 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
362 $np->setAlert($this->lng->txt($error_lng_var));
363 $error = true;
364 }
365 if (
366 ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
367 $_POST["current_password"] == $_POST["new_password"]) {
368 $error = true;
369 $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
370 }
371
372 if (!$error) {
373 $ilUser->resetPassword($_POST["new_password"], $_POST["new_password"]);
374 if ($_POST["current_password"] != $_POST["new_password"]) {
375 $ilUser->setLastPasswordChangeToNow();
376 $ilUser->setPasswordPolicyResetStatus(false);
377 $ilUser->update();
378 }
379
380 if (ilSession::get('orig_request_target')) {
381 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
382 $target = ilSession::get('orig_request_target');
383 ilSession::set('orig_request_target', '');
384 ilUtil::redirect($target);
385 } else {
386 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
387 $this->showPassword(true, true);
388 return;
389 }
390 }
391 }
392 $this->form->setValuesByPost();
393 $this->showPassword(true);
394 }
395
396 //
397 //
398 // GENERAL SETTINGS FORM
399 //
400 //
401
406 public function workWithUserSetting(string $setting) : bool
407 {
408 return $this->user_settings_config->isVisibleAndChangeable($setting);
409 }
410
415 public function userSettingVisible(string $setting) : bool
416 {
417 return $this->user_settings_config->isVisible($setting);
418 }
419
424 public function userSettingEnabled(string $setting) : bool
425 {
426 return $this->user_settings_config->isChangeable($setting);
427 }
428
432 public function showGeneralSettings($a_no_init = false)
433 {
434 global $DIC;
435
436 $ilTabs = $DIC['ilTabs'];
437
438 $this->__initSubTabs("showPersonalData");
439 $ilTabs->activateTab("general_settings");
440
441 $this->setHeader();
442
443 if (!$a_no_init) {
445 }
446 $this->tpl->setContent($this->form->getHTML());
447 $this->tpl->printToStdout();
448 }
449
454 public function initGeneralSettingsForm()
455 {
456 global $DIC;
457
458 $lng = $DIC['lng'];
459 $ilUser = $DIC['ilUser'];
460 $styleDefinition = $DIC['styleDefinition'];
461 $ilSetting = $DIC['ilSetting'];
462
463
464 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
465 $this->form = new ilPropertyFormGUI();
466
467 // language
468 if ($this->userSettingVisible("language")) {
469 $languages = $this->lng->getInstalledLanguages();
470 $options = array();
471 foreach ($languages as $lang_key) {
472 $options[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
473 }
474
475 $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
476 $si->setOptions($options);
477 $si->setValue($ilUser->getLanguage());
478 $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
479 $this->form->addItem($si);
480 }
481
482 // skin/style
483 if ($this->userSettingVisible("skin_style")) {
484 $skins = $styleDefinition->getAllSkins();
485 if (is_array($skins)) {
486 $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
487
488 $options = array();
489 foreach ($skins as $skin) {
490 foreach ($skin->getStyles() as $style) {
491 include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
492 if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId()) || $style->isSubstyle()) {
493 continue;
494 }
495
496 $options[$skin->getId() . ":" . $style->getId()] = $skin->getName() . " / " . $style->getName();
497 }
498 }
499 $si->setOptions($options);
500 $si->setValue($ilUser->skin . ":" . $ilUser->prefs["style"]);
501 $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
502 $this->form->addItem($si);
503 }
504 }
505
506 // screen reader optimization
507 if ($this->userSettingVisible("screen_reader_optimization")) {
508 $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
509 $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
510 $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
511 $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
512 $this->form->addItem($cb);
513 }
514
515 // help tooltips
516 $module_id = (int) $ilSetting->get("help_module");
517 if ((OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de" &&
518 $ilSetting->get("help_mode") != "1") {
519 $this->lng->loadLanguageModule("help");
520 $cb = new ilCheckboxInputGUI($this->lng->txt("help_toggle_tooltips"), "help_tooltips");
521 $cb->setChecked(!$ilUser->prefs["hide_help_tt"]);
522 $cb->setInfo($this->lng->txt("help_toggle_tooltips_info"));
523 $this->form->addItem($cb);
524 }
525
526 // hits per page
527 if ($this->userSettingVisible("hits_per_page")) {
528 $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
529
530 $hits_options = array(10,15,20,30,40,50,100,9999);
531 $options = array();
532
533 foreach ($hits_options as $hits_option) {
534 $hstr = ($hits_option == 9999)
535 ? $this->lng->txt("no_limit")
536 : $hits_option;
537 $options[$hits_option] = $hstr;
538 }
539 $si->setOptions($options);
540 $si->setValue($ilUser->prefs["hits_per_page"]);
541 $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
542 $this->form->addItem($si);
543 }
544
545 // Users Online
546 /*
547 if ($this->userSettingVisible("show_users_online"))
548 {
549 $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
550
551 $options = array(
552 "y" => $this->lng->txt("users_online_show_y"),
553 "associated" => $this->lng->txt("users_online_show_associated"),
554 "n" => $this->lng->txt("users_online_show_n"));
555 $si->setOptions($options);
556 $si->setValue($ilUser->prefs["show_users_online"]);
557 $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
558 $this->form->addItem($si);
559 }*/
560
561 // Store last visited
562 $lv = new ilSelectInputGUI($this->lng->txt("user_store_last_visited"), "store_last_visited");
563 $options = array(
564 0 => $this->lng->txt("user_lv_keep_entries"),
565 1 => $this->lng->txt("user_lv_keep_only_for_session"),
566 2 => $this->lng->txt("user_lv_do_not_store"));
567 $lv->setOptions($options);
568 $lv->setValue((int) $ilUser->prefs["store_last_visited"]);
569 $this->form->addItem($lv);
570
571
572 include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
573 if (ilSessionReminder::isGloballyActivated()) {
574 $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
575 $cb->setInfo($this->lng->txt('session_reminder_info'));
576 $cb->setValue(1);
577 $cb->setChecked((int) $ilUser->getPref('session_reminder_enabled'));
578
580 $lead_time_gui = new ilNumberInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
581 $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilDatePresentation::secondsToString($expires, true)));
582
584 $max_value = max($min_value, ((int) $expires / 60) - 1);
585
586 $current_user_value = $ilUser->getPref('session_reminder_lead_time');
587 if ($current_user_value < $min_value ||
588 $current_user_value > $max_value) {
589 $current_user_value = ilSessionReminder::SUGGESTED_LEAD_TIME;
590 }
591 $value = min(
592 max(
593 $min_value,
594 $current_user_value
595 ),
596 $max_value
597 );
598
599 $lead_time_gui->setValue($value);
600 $lead_time_gui->setSize(3);
601 $lead_time_gui->setMinValue($min_value);
602 $lead_time_gui->setMaxValue($max_value);
603 $cb->addSubItem($lead_time_gui);
604
605 $this->form->addItem($cb);
606 }
607
608 // calendar settings (copied here to be reachable when calendar is inactive)
609 // they cannot be hidden/deactivated
610
611 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
612 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
613 $lng->loadLanguageModule("dateplaner");
614 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
615
616 $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'), 'timezone');
617 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
618 $select->setInfo($lng->txt('cal_timezone_info'));
619 $select->setValue($user_settings->getTimeZone());
620 $this->form->addItem($select);
621
622 $year = date("Y");
623 $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'), 'date_format');
624 $select->setOptions(array(
625 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
626 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
627 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
628 $select->setInfo($lng->txt('cal_date_format_info'));
629 $select->setValue($user_settings->getDateFormat());
630 $this->form->addItem($select);
631
632 $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'), 'time_format');
633 $select->setOptions(array(
636 $select->setInfo($lng->txt('cal_time_format_info'));
637 $select->setValue($user_settings->getTimeFormat());
638 $this->form->addItem($select);
639
640
641 // starting point
642 include_once "Services/User/classes/class.ilUserUtil.php";
644 $this->lng->loadLanguageModule("administration");
645 $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "usr_start");
646 $si->setRequired(true);
647 $si->setInfo($this->lng->txt("adm_user_starting_point_info"));
648 $def_opt = new ilRadioOption($this->lng->txt("adm_user_starting_point_inherit"), 0);
649 $def_opt->setInfo($this->lng->txt("adm_user_starting_point_inherit_info"));
650 $si->addOption($def_opt);
651 foreach (ilUserUtil::getPossibleStartingPoints() as $value => $caption) {
652 $si->addOption(new ilRadioOption($caption, $value));
653 }
656 : 0);
657 $this->form->addItem($si);
658
659 // starting point: repository object
660 $repobj = new ilRadioOption($lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ);
661 $repobj_id = new ilTextInputGUI($lng->txt("adm_user_starting_point_ref_id"), "usr_start_ref_id");
662 $repobj_id->setInfo($lng->txt("adm_user_starting_point_ref_id_info"));
663 $repobj_id->setRequired(true);
664 $repobj_id->setSize(5);
665 if ($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ) {
667 $repobj_id->setValue($start_ref_id);
668 if ($start_ref_id) {
669 $start_obj_id = ilObject::_lookupObjId($start_ref_id);
670 if ($start_obj_id) {
671 $repobj_id->setInfo($lng->txt("obj_" . ilObject::_lookupType($start_obj_id)) .
672 ": " . ilObject::_lookupTitle($start_obj_id));
673 }
674 }
675 }
676 $repobj->addSubItem($repobj_id);
677 $si->addOption($repobj);
678 }
679
680 // selector for unicode characters
681 global $DIC;
682
683 $ilSetting = $DIC['ilSetting'];
684 if ($ilSetting->get('char_selector_availability') > 0) {
685 require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
687 $char_selector->getConfig()->setAvailability($ilUser->getPref('char_selector_availability'));
688 $char_selector->getConfig()->setDefinition($ilUser->getPref('char_selector_definition'));
689 $char_selector->addFormProperties($this->form);
690 $char_selector->setFormValues($this->form);
691 }
692
693 $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
694 $this->form->setTitle($lng->txt("general_settings"));
695 $this->form->setFormAction($this->ctrl->getFormAction($this));
696 }
697
701 public function saveGeneralSettings()
702 {
703 global $DIC;
704
705 $tpl = $DIC['tpl'];
706 $lng = $DIC['lng'];
707 $ilCtrl = $DIC['ilCtrl'];
708 $ilUser = $DIC['ilUser'];
709 $ilSetting = $DIC->settings();
710
712 if ($this->form->checkInput()) {
713 if ($this->workWithUserSetting("skin_style")) {
714 //set user skin and style
715 if ($_POST["skin_style"] != "") {
716 $sknst = explode(":", $_POST["skin_style"]);
717
718 if ($ilUser->getPref("style") != $sknst[1] ||
719 $ilUser->getPref("skin") != $sknst[0]) {
720 $ilUser->setPref("skin", $sknst[0]);
721 $ilUser->setPref("style", $sknst[1]);
722 }
723 }
724 }
725
726 // language
727 if ($this->workWithUserSetting("language")) {
728 $ilUser->setLanguage($_POST["language"]);
729 }
730
731 // hits per page
732 if ($this->workWithUserSetting("hits_per_page")) {
733 if ($_POST["hits_per_page"] != "") {
734 $ilUser->setPref("hits_per_page", $_POST["hits_per_page"]);
735 }
736 }
737
738 // help tooltips
739 $module_id = (int) $ilSetting->get("help_module");
740 if ((OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de" &&
741 $ilSetting->get("help_mode") != "1") {
742 $ilUser->setPref("hide_help_tt", (int) !$_POST["help_tooltips"]);
743 }
744
745 // set show users online
746 /*
747 if ($this->workWithUserSetting("show_users_online"))
748 {
749 $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
750 }*/
751
752 // store last visited?
753 global $DIC;
754
755 $ilNavigationHistory = $DIC['ilNavigationHistory'];
756 $ilUser->setPref("store_last_visited", (int) $_POST["store_last_visited"]);
757 if ((int) $_POST["store_last_visited"] > 0) {
758 $ilNavigationHistory->deleteDBEntries();
759 if ((int) $_POST["store_last_visited"] == 2) {
760 $ilNavigationHistory->deleteSessionEntries();
761 }
762 }
763
764 // set show users online
765 if ($this->workWithUserSetting("screen_reader_optimization")) {
766 $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
767 }
768
769 // session reminder
770 include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
771 if (ilSessionReminder::isGloballyActivated()) {
772 $ilUser->setPref('session_reminder_enabled', (int) $this->form->getInput('session_reminder_enabled'));
773 $ilUser->setPref('session_reminder_lead_time', $this->form->getInput('session_reminder_lead_time'));
774 }
775
776 // starting point
777 include_once "Services/User/classes/class.ilUserUtil.php";
780 $this->form->getInput('usr_start'),
781 $this->form->getInput('usr_start_ref_id')
782 );
783 }
784
785 // selector for unicode characters
786 global $DIC;
787
788 $ilSetting = $DIC['ilSetting'];
789 if ($ilSetting->get('char_selector_availability') > 0) {
790 require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
792 $char_selector->getFormValues($this->form);
793 $ilUser->setPref('char_selector_availability', $char_selector->getConfig()->getAvailability());
794 $ilUser->setPref('char_selector_definition', $char_selector->getConfig()->getDefinition());
795 }
796
797 $ilUser->update();
798
799 // calendar settings
800 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
801 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
802 $user_settings->setTimeZone($this->form->getInput("timezone"));
803 $user_settings->setDateFormat((int) $this->form->getInput("date_format"));
804 $user_settings->setTimeFormat((int) $this->form->getInput("time_format"));
805 $user_settings->save();
806
807 ilUtil::sendSuccess($lng->txtlng("common", "msg_obj_modified", $ilUser->getLanguage()), true);
808
809 $ilCtrl->redirect($this, "showGeneralSettings");
810 }
811
812 $this->form->setValuesByPost();
813 $this->showGeneralSettings(true);
814 }
815
819 protected function deleteOwnAccount1()
820 {
821 global $DIC;
822
823 $ilTabs = $DIC['ilTabs'];
824 $ilToolbar = $DIC['ilToolbar'];
825 $ilUser = $DIC['ilUser'];
826 $ilSetting = $DIC['ilSetting'];
827
828 if (!(bool) $ilSetting->get('user_delete_own_account') ||
829 $ilUser->getId() == SYSTEM_USER_ID) {
830 $this->ctrl->redirect($this, "showGeneralSettings");
831 }
832
833 // too make sure
834 $ilUser->removeDeletionFlag();
835
836 $this->setHeader();
837 $this->__initSubTabs("deleteOwnAccount");
838 $ilTabs->activateTab("delacc");
839
840 ilUtil::sendInfo($this->lng->txt('user_delete_own_account_info'));
841 $ilToolbar->addButton(
842 $this->lng->txt('btn_next'),
843 $this->ctrl->getLinkTarget($this, 'deleteOwnAccount2')
844 );
845
846 $this->tpl->printToStdout();
847 }
848
852 protected function deleteOwnAccount2()
853 {
854 global $DIC;
855
856 $ilTabs = $DIC['ilTabs'];
857 $ilUser = $DIC['ilUser'];
858 $ilSetting = $DIC['ilSetting'];
859
860 if (!(bool) $ilSetting->get('user_delete_own_account') ||
861 $ilUser->getId() == SYSTEM_USER_ID) {
862 $this->ctrl->redirect($this, "showGeneralSettings");
863 }
864
865 $this->setHeader();
866 $this->__initSubTabs("deleteOwnAccount");
867 $ilTabs->activateTab("delacc");
868
869 include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
870 $cgui = new ilConfirmationGUI();
871 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_logout_confirmation'));
872 $cgui->setFormAction($this->ctrl->getFormAction($this));
873 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
874 $cgui->setConfirm($this->lng->txt("user_delete_own_account_logout_button"), "deleteOwnAccountLogout");
875 $this->tpl->setContent($cgui->getHTML());
876 $this->tpl->printToStdout();
877 }
878
879 protected function abortDeleteOwnAccount()
880 {
881 global $DIC;
882
883 $ilCtrl = $DIC['ilCtrl'];
884 $ilUser = $DIC['ilUser'];
885
886 $ilUser->removeDeletionFlag();
887
888 ilUtil::sendInfo($this->lng->txt("user_delete_own_account_aborted"), true);
889 $ilCtrl->redirect($this, "showGeneralSettings");
890 }
891
892 protected function deleteOwnAccountLogout()
893 {
894 global $DIC;
895
896 $ilUser = $DIC['ilUser'];
897
898 // we are setting the flag and ending the session in the same step
899
900 $ilUser->activateDeletionFlag();
901
902 // see ilStartupGUI::doLogout()
904 $GLOBALS['DIC']['ilAuthSession']->logout();
905
906 ilUtil::redirect("login.php?cmd=force_login&target=usr_" . md5("usrdelown"));
907 }
908
912 protected function deleteOwnAccount3()
913 {
914 global $DIC;
915
916 $ilTabs = $DIC['ilTabs'];
917 $ilUser = $DIC['ilUser'];
918 $ilSetting = $DIC['ilSetting'];
919
920 if (!(bool) $ilSetting->get('user_delete_own_account') ||
921 $ilUser->getId() == SYSTEM_USER_ID ||
922 !$ilUser->hasDeletionFlag()) {
923 $this->ctrl->redirect($this, "showGeneralSettings");
924 }
925
926 $this->setHeader();
927 $this->__initSubTabs("deleteOwnAccount");
928 $ilTabs->activateTab("delacc");
929
930 include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
931 $cgui = new ilConfirmationGUI();
932 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_final_confirmation'));
933 $cgui->setFormAction($this->ctrl->getFormAction($this));
934 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
935 $cgui->setConfirm($this->lng->txt("confirm"), "deleteOwnAccount4");
936 $this->tpl->setContent($cgui->getHTML());
937 $this->tpl->printToStdout();
938 }
939
943 protected function deleteOwnAccount4()
944 {
945 global $DIC;
946
947 $ilUser = $DIC['ilUser'];
948 $ilSetting = $DIC['ilSetting'];
949 $ilLog = $DIC['ilLog'];
950
951 if (!(bool) $ilSetting->get('user_delete_own_account') ||
952 $ilUser->getId() == SYSTEM_USER_ID ||
953 !$ilUser->hasDeletionFlag()) {
954 $this->ctrl->redirect($this, "showGeneralSettings");
955 }
956
957 // build notification
958
959 include_once "./Services/Notification/classes/class.ilSystemNotification.php";
960 $ntf = new ilSystemNotification();
961 $ntf->setLangModules(array("user"));
962 $ntf->addAdditionalInfo("profile", $ilUser->getProfileAsString($this->lng), true);
963
964 // mail message
966 $ntf->setIntroductionDirect(
967 sprintf(
968 $this->lng->txt("user_delete_own_account_email_body"),
969 $ilUser->getLogin(),
972 )
973 );
974
975 $message = $ntf->composeAndGetMessage($ilUser->getId(), null, null, true);
976 $subject = $this->lng->txt("user_delete_own_account_email_subject");
977
978
979 // send notification
980 $user_email = $ilUser->getEmail();
981 $admin_mail = $ilSetting->get("user_delete_own_account_email");
983 $senderFactory = $GLOBALS["DIC"]["mail.mime.sender.factory"];
984
985 $mmail = new ilMimeMail();
986 $mmail->From($senderFactory->system());
987 // to user, admin as bcc
988 if ($user_email) {
989 $mmail->To($user_email);
990 $mmail->Bcc($admin_mail);
991 $mmail->Subject($subject, true);
992 $mmail->Body($message);
993 $mmail->Send();
994 }
995 // admin only
996 elseif ($admin_mail) {
997 $mmail->To($admin_mail);
998 $mmail->Subject($subject, true);
999 $mmail->Body($message);
1000 $mmail->Send();
1001 }
1002
1003 $ilLog->write("Account deleted: " . $ilUser->getLogin() . " (" . $ilUser->getId() . ")");
1004
1005 $ilUser->delete();
1006
1007 // terminate session
1008 $GLOBALS['DIC']['ilAuthSession']->logout();
1009 ilUtil::redirect("login.php?accdel=1");
1010 }
1011}
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 _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a password property in a property form.
Class ilPersonalChatSettingsFormGUI.
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.
global $ilCtrl
Definition: ilias.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
$ilUser
Definition: imgupload.php:18
$message
Definition: xapiexit.php:14
$DIC
Definition: xapitoken.php:46