ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
13 public $tpl;
14 public $lng;
15 public $ilias;
16 public $ctrl;
17
21 public function __construct()
22 {
23 global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl;
24
25 include_once './Services/User/classes/class.ilUserDefinedFields.php';
26 $this->user_defined_fields =&ilUserDefinedFields::_getInstance();
27
28 $this->tpl =&$tpl;
29 $this->lng =&$lng;
30 $this->ilias =&$ilias;
31 $this->ctrl =&$ilCtrl;
32 $this->settings = $ilias->getAllSettings();
33 // $lng->loadLanguageModule("jsmath");
34 $lng->loadLanguageModule('chatroom');
35 $lng->loadLanguageModule('chatroom_adm');
36 $this->upload_error = "";
37 $this->password_error = "";
38 $lng->loadLanguageModule("user");
39 $ilCtrl->saveParameter($this, "user_page");
40 }
41
45 public function executeCommand()
46 {
47 global $DIC;
48
49 $next_class = $this->ctrl->getNextClass();
50
51 switch ($next_class) {
52 case 'ilmailoptionsgui':
53 require_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
54 if (!$DIC->rbac()->system()->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
55 $this->ilias->raiseError($DIC->language()->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
56 }
57
58 $this->__initSubTabs('showMailOptions');
59 $DIC->tabs()->activateTab('mail_settings');
60 $this->setHeader();
61
62 require_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
63 $this->ctrl->forwardCommand(new ilMailOptionsGUI());
64 break;
65
66 case 'ilpersonalchatsettingsformgui':
67 $this->__initSubTabs($this->ctrl->getCmd());
68 $this->setHeader();
69
70 require_once 'Modules/Chatroom/classes/class.ilPersonalChatSettingsFormGUI.php';
71 $chatSettingsGui = new ilPersonalChatSettingsFormGUI();
72 $this->ctrl->forwardCommand($chatSettingsGui);
73 break;
74
75 default:
76 $cmd = $this->ctrl->getCmd("showGeneralSettings");
77 $this->$cmd();
78 break;
79 }
80 return true;
81 }
82
83 // init sub tabs
84 public function __initSubTabs($a_cmd)
85 {
89 global $ilTabs, $ilSetting, $ilHelp, $rbacsystem, $ilUser;
90
91 $ilHelp->setScreenIdComponent("user");
92
93 $showPassword = ($a_cmd == 'showPassword') ? true : false;
94 $showGeneralSettings = ($a_cmd == 'showGeneralSettings') ? true : false;
95
96 // old profile
97
98 // general settings
99 $ilTabs->addTarget(
100 "general_settings",
101 $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
102 "",
103 "",
104 "",
105 $showGeneralSettings
106 );
107
108 // password
109 if ($this->allowPasswordChange()) {
110 $ilTabs->addTarget(
111 "password",
112 $this->ctrl->getLinkTarget($this, "showPassword"),
113 "",
114 "",
115 "",
116 $showPassword
117 );
118 }
119
120 require_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
121 if ($rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
122 $ilTabs->addTarget(
123 "mail_settings",
124 $this->ctrl->getLinkTargetByClass('ilMailOptionsGUI'),
125 "",
126 array('ilMailOptionsGUI')
127 );
128 }
129
130 require_once 'Modules/Chatroom/classes/class.ilPersonalChatSettingsFormGUI.php';
131 $chatSettingsGui = new ilPersonalChatSettingsFormGUI(false);
132 if ($chatSettingsGui->isAccessible()) {
134 $ilTabs->addTarget(
135 'chat_settings',
136 $this->ctrl->getLinkTarget($chatSettingsGui, 'showChatOptions'),
137 '',
138 'ilPersonalChatSettingsFormGUI',
139 '',
140 method_exists($chatSettingsGui, $a_cmd)
141 );
142 }
143
144 include_once "./Services/Administration/classes/class.ilSetting.php";
145
146 if ((bool) $ilSetting->get('user_delete_own_account') &&
147 $ilUser->getId() != SYSTEM_USER_ID) {
148 $ilTabs->addTab(
149 "delacc",
150 $this->lng->txt('user_delete_own_account'),
151 $this->ctrl->getLinkTarget($this, "deleteOwnAccount1")
152 );
153 }
154 }
155
159 public function setHeader()
160 {
161 $this->tpl->setVariable('HEADER', $this->lng->txt('personal_settings'));
162 }
163 //
164 //
165 // PASSWORD FORM
166 //
167 //
168
173 public function showPassword($a_no_init = false, $hide_form = false)
174 {
175 global $ilTabs, $ilUser;
176
177 $this->__initSubTabs("showPersonalData");
178 $ilTabs->activateTab("password");
179
180 $this->setHeader();
181 // check whether password of user have to be changed
182 // due to first login or password of user is expired
183 if ($ilUser->isPasswordChangeDemanded()) {
185 $this->lng->txt('password_change_on_first_login_demand')
186 );
187 } elseif ($ilUser->isPasswordExpired()) {
188 $msg = $this->lng->txt('password_expired');
189 $password_age = $ilUser->getPasswordAge();
190 ilUtil::sendInfo(sprintf($msg, $password_age));
191 }
192
193 if (!$a_no_init && !$hide_form) {
194 $this->initPasswordForm();
195 }
196 $this->tpl->setContent(!$hide_form ? $this->form->getHTML() : '');
197 $this->tpl->show();
198 }
199
205 public function initPasswordForm()
206 {
207 global $lng, $ilUser, $ilSetting;
208
209 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
210 $this->form = new ilPropertyFormGUI();
211
212 // Check whether password change is allowed
213 if ($this->allowPasswordChange()) {
214 // The current password needs to be checked for verification
215 // unless the user uses Shibboleth authentication with additional
216 // local authentication for WebDAV.
217 //if (
218 // ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local"))
219 //)
220 if ($ilUser->getAuthMode(true) == AUTH_LOCAL) {
221 // current password
222 $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
223 $cpass->setRetype(false);
224 $cpass->setSkipSyntaxCheck(true);
225 // only if a password exists.
226 if ($ilUser->getPasswd()) {
227 $cpass->setRequired(true);
228 }
229 $this->form->addItem($cpass);
230 }
231
232 // new password
233 $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
234 $ipass->setRequired(true);
235 $ipass->setInfo(ilUtil::getPasswordRequirementsInfo());
236
237 $this->form->addItem($ipass);
238 $this->form->addCommandButton("savePassword", $lng->txt("save"));
239
240 switch ($ilUser->getAuthMode(true)) {
241 case AUTH_LOCAL:
242 $this->form->setTitle($lng->txt("chg_password"));
243 break;
244
245 case AUTH_SHIBBOLETH:
246 case AUTH_CAS:
247 require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
249 $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
250 } else {
251 $this->form->setTitle($lng->txt("chg_ilias_password"));
252 }
253 break;
254 default:
255 $this->form->setTitle($lng->txt("chg_ilias_password"));
256 break;
257 }
258 $this->form->setFormAction($this->ctrl->getFormAction($this));
259 }
260 }
261
265 protected function allowPasswordChange()
266 {
267 global $ilUser;
268
269 if (\ilSession::get('used_external_auth')) {
270 return false;
271 }
272
273 $status = ilAuthUtils::isPasswordModificationEnabled($ilUser->getAuthMode(true));
274 if ($status) {
275 return true;
276 }
277
278 return \ilAuthUtils::isPasswordModificationHidden() && ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired());
279 }
280
285 public function savePassword()
286 {
288
289 // normally we should not end up here
290 if (!$this->allowPasswordChange()) {
291 $ilCtrl->redirect($this, "showPersonalData");
292 return;
293 }
294
295 $this->initPasswordForm();
296 if ($this->form->checkInput()) {
297 $cp = $this->form->getItemByPostVar("current_password");
298 $np = $this->form->getItemByPostVar("new_password");
299 $error = false;
300
301 // The old password needs to be checked for verification
302 // unless the user uses Shibboleth authentication with additional
303 // local authentication for WebDAV.
304 #if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
305 if ($ilUser->getAuthMode(true) == AUTH_LOCAL) {
306 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
307 if (!ilUserPasswordManager::getInstance()->verifyPassword($ilUser, ilUtil::stripSlashes($_POST['current_password']))) {
308 $error = true;
309 $cp->setAlert($this->lng->txt('passwd_wrong'));
310 }
311 }
312
313 if (!ilUtil::isPassword($_POST["new_password"], $custom_error)) {
314 $error = true;
315 if ($custom_error != '') {
316 $np->setAlert($custom_error);
317 } else {
318 $np->setAlert($this->lng->txt("passwd_invalid"));
319 }
320 }
321 $error_lng_var = '';
322 if (!ilUtil::isPasswordValidForUserContext($_POST["new_password"], $ilUser, $error_lng_var)) {
323 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
324 $np->setAlert($this->lng->txt($error_lng_var));
325 $error = true;
326 }
327 if (
328 ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
329 $_POST["current_password"] == $_POST["new_password"]) {
330 $error = true;
331 $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
332 }
333
334 if (!$error) {
335 $ilUser->resetPassword($_POST["new_password"], $_POST["new_password"]);
336 if ($_POST["current_password"] != $_POST["new_password"]) {
337 $ilUser->setLastPasswordChangeToNow();
338 }
339
340 if (ilSession::get('orig_request_target')) {
341 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
342 $target = ilSession::get('orig_request_target');
343 ilSession::set('orig_request_target', '');
345 } else {
346 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
347 $this->showPassword(true, true);
348 return;
349 }
350 }
351 }
352 $this->form->setValuesByPost();
353 $this->showPassword(true);
354 }
355
356 //
357 //
358 // GENERAL SETTINGS FORM
359 //
360 //
361
366 public function workWithUserSetting($setting)
367 {
368 $result = true;
369 if ($this->settings["usr_settings_hide_" . $setting] == 1) {
370 $result = false;
371 }
372 if ($this->settings["usr_settings_disable_" . $setting] == 1) {
373 $result = false;
374 }
375 return $result;
376 }
377
382 public function userSettingVisible($setting)
383 {
384 $result = true;
385 if (isset($this->settings["usr_settings_hide_" . $setting]) &&
386 $this->settings["usr_settings_hide_" . $setting] == 1) {
387 $result = false;
388 }
389 return $result;
390 }
391
396 public function userSettingEnabled($setting)
397 {
398 $result = true;
399 if ($this->settings["usr_settings_disable_" . $setting] == 1) {
400 $result = false;
401 }
402 return $result;
403 }
404
408 public function showGeneralSettings($a_no_init = false)
409 {
410 global $ilTabs;
411
412 $this->__initSubTabs("showPersonalData");
413 $ilTabs->activateTab("general_settings");
414
415 $this->setHeader();
416
417 if (!$a_no_init) {
419 }
420 $this->tpl->setContent($this->form->getHTML());
421 $this->tpl->show();
422 }
423
428 public function initGeneralSettingsForm()
429 {
430 global $lng, $ilUser, $styleDefinition, $ilSetting;
431
432
433 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
434 $this->form = new ilPropertyFormGUI();
435
436 // language
437 if ($this->userSettingVisible("language")) {
438 $languages = $this->lng->getInstalledLanguages();
439 $options = array();
440 foreach ($languages as $lang_key) {
441 $options[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
442 }
443
444 $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
445 $si->setOptions($options);
446 $si->setValue($ilUser->getLanguage());
447 $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
448 $this->form->addItem($si);
449 }
450
451 // skin/style
452 if ($this->userSettingVisible("skin_style")) {
453 $skins = $styleDefinition->getAllSkins();
454 if (is_array($skins)) {
455 $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
456
457 $options = array();
458 foreach ($skins as $skin) {
459 foreach ($skin->getStyles() as $style) {
460 include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
461 if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId()) || $style->isSubstyle()) {
462 continue;
463 }
464
465 $options[$skin->getId() . ":" . $style->getId()] = $skin->getName() . " / " . $style->getName();
466 }
467 }
468 $si->setOptions($options);
469 $si->setValue($ilUser->skin . ":" . $ilUser->prefs["style"]);
470 $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
471 $this->form->addItem($si);
472 }
473 }
474
475 // screen reader optimization
476 if ($this->userSettingVisible("screen_reader_optimization")) {
477 $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
478 $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
479 $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
480 $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
481 $this->form->addItem($cb);
482 }
483
484 // hits per page
485 if ($this->userSettingVisible("hits_per_page")) {
486 $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
487
488 $hits_options = array(10,15,20,30,40,50,100,9999);
489 $options = array();
490
491 foreach ($hits_options as $hits_option) {
492 $hstr = ($hits_option == 9999)
493 ? $this->lng->txt("no_limit")
494 : $hits_option;
495 $options[$hits_option] = $hstr;
496 }
497 $si->setOptions($options);
498 $si->setValue($ilUser->prefs["hits_per_page"]);
499 $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
500 $this->form->addItem($si);
501 }
502
503 // Users Online
504 /*
505 if ($this->userSettingVisible("show_users_online"))
506 {
507 $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
508
509 $options = array(
510 "y" => $this->lng->txt("users_online_show_y"),
511 "associated" => $this->lng->txt("users_online_show_associated"),
512 "n" => $this->lng->txt("users_online_show_n"));
513 $si->setOptions($options);
514 $si->setValue($ilUser->prefs["show_users_online"]);
515 $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
516 $this->form->addItem($si);
517 }*/
518
519 // Store last visited
520 $lv = new ilSelectInputGUI($this->lng->txt("user_store_last_visited"), "store_last_visited");
521 $options = array(
522 0 => $this->lng->txt("user_lv_keep_entries"),
523 1 => $this->lng->txt("user_lv_keep_only_for_session"),
524 2 => $this->lng->txt("user_lv_do_not_store"));
525 $lv->setOptions($options);
526 $lv->setValue((int) $ilUser->prefs["store_last_visited"]);
527 $this->form->addItem($lv);
528
529 // hide_own_online_status
530 $awrn_set = new ilSetting("awrn");
531 if ($awrn_set->get("awrn_enabled", false) && $this->userSettingVisible("hide_own_online_status")) {
532 $this->lng->loadLanguageModule("awrn");
533
534 $default = ($this->settings['hide_own_online_status'] == "n")
535 ? $this->lng->txt("user_awrn_show")
536 : $this->lng->txt("user_awrn_hide");
537
538 $options = array(
539 "" => $this->lng->txt("user_awrn_default")." (".$default.")",
540 "n" => $this->lng->txt("user_awrn_show"),
541 "y" => $this->lng->txt("user_awrn_hide"));
542 $si = new ilSelectInputGUI($lng->txt("awrn_user_show"), "hide_own_online_status");
543 $si->setOptions($options);
544 $si->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
545 $si->setValue($ilUser->prefs["hide_own_online_status"]);
546 $si->setInfo($lng->txt("awrn_hide_from_awareness_info"));
547 $this->form->addItem($si);
548
549 $cb = new ilCheckboxInputGUI($this->lng->txt("awrn_hide_from_awareness"), "hide_own_online_status");
550 $cb->setInfo($this->lng->txt("awrn_hide_from_awareness_info"));
551 $cb->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
552 $cb->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
553 //$this->form->addItem($cb);
554 }
555
556 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
557 if (ilBuddySystem::getInstance()->isEnabled() && $this->userSettingVisible('bs_allow_to_contact_me')) {
558 $this->lng->loadLanguageModule('buddysystem');
559 $allow_to_contact_be = new ilCheckboxInputGUI($this->lng->txt('buddy_allow_to_contact_me'), 'bs_allow_to_contact_me');
560 $allow_to_contact_be->setInfo($this->lng->txt('buddy_allow_to_contact_me_info'));
561 $allow_to_contact_be->setChecked($ilUser->prefs['bs_allow_to_contact_me'] == 'y');
562 $allow_to_contact_be->setDisabled($ilSetting->get('usr_settings_disable_bs_allow_to_contact_me'));
563 $this->form->addItem($allow_to_contact_be);
564 }
565
566 include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
567 if (ilSessionReminder::isGloballyActivated()) {
568 $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
569 $cb->setInfo($this->lng->txt('session_reminder_info'));
570 $cb->setValue(1);
571 $cb->setChecked((int) $ilUser->getPref('session_reminder_enabled'));
572
574 $lead_time_gui = new ilNumberInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
575 $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilDatePresentation::secondsToString($expires, true)));
576
578 $max_value = max($min_value, ((int) $expires / 60) - 1);
579
580 $current_user_value = $ilUser->getPref('session_reminder_lead_time');
581 if ($current_user_value < $min_value ||
582 $current_user_value > $max_value) {
583 $current_user_value = ilSessionReminder::SUGGESTED_LEAD_TIME;
584 }
585 $value = min(
586 max(
587 $min_value,
588 $current_user_value
589 ),
590 $max_value
591 );
592
593 $lead_time_gui->setValue($value);
594 $lead_time_gui->setSize(3);
595 $lead_time_gui->setMinValue($min_value);
596 $lead_time_gui->setMaxValue($max_value);
597 $cb->addSubItem($lead_time_gui);
598
599 $this->form->addItem($cb);
600 }
601
602 // calendar settings (copied here to be reachable when calendar is inactive)
603 // they cannot be hidden/deactivated
604
605 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
606 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
607 $lng->loadLanguageModule("dateplaner");
608 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
609
610 $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'), 'timezone');
611 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
612 $select->setInfo($lng->txt('cal_timezone_info'));
613 $select->setValue($user_settings->getTimeZone());
614 $this->form->addItem($select);
615
616 $year = date("Y");
617 $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'), 'date_format');
618 $select->setOptions(array(
619 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
620 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
621 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
622 $select->setInfo($lng->txt('cal_date_format_info'));
623 $select->setValue($user_settings->getDateFormat());
624 $this->form->addItem($select);
625
626 $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'), 'time_format');
627 $select->setOptions(array(
630 $select->setInfo($lng->txt('cal_time_format_info'));
631 $select->setValue($user_settings->getTimeFormat());
632 $this->form->addItem($select);
633
634
635 // starting point
636 include_once "Services/User/classes/class.ilUserUtil.php";
638 $this->lng->loadLanguageModule("administration");
639 $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "usr_start");
640 $si->setRequired(true);
641 $si->setInfo($this->lng->txt("adm_user_starting_point_info"));
642 $def_opt = new ilRadioOption($this->lng->txt("adm_user_starting_point_inherit"), 0);
643 $def_opt->setInfo($this->lng->txt("adm_user_starting_point_inherit_info"));
644 $si->addOption($def_opt);
645 foreach (ilUserUtil::getPossibleStartingPoints() as $value => $caption) {
646 $si->addOption(new ilRadioOption($caption, $value));
647 }
650 : 0);
651 $this->form->addItem($si);
652
653 // starting point: repository object
654 $repobj = new ilRadioOption($lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ);
655 $repobj_id = new ilTextInputGUI($lng->txt("adm_user_starting_point_ref_id"), "usr_start_ref_id");
656 $repobj_id->setInfo($lng->txt("adm_user_starting_point_ref_id_info"));
657 $repobj_id->setRequired(true);
658 $repobj_id->setSize(5);
659 if ($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ) {
661 $repobj_id->setValue($start_ref_id);
662 if ($start_ref_id) {
663 $start_obj_id = ilObject::_lookupObjId($start_ref_id);
664 if ($start_obj_id) {
665 $repobj_id->setInfo($lng->txt("obj_" . ilObject::_lookupType($start_obj_id)) .
666 ": " . ilObject::_lookupTitle($start_obj_id));
667 }
668 }
669 }
670 $repobj->addSubItem($repobj_id);
671 $si->addOption($repobj);
672 }
673
674 // selector for unicode characters
675 global $ilSetting;
676 if ($ilSetting->get('char_selector_availability') > 0) {
677 require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
679 $char_selector->getConfig()->setAvailability($ilUser->getPref('char_selector_availability'));
680 $char_selector->getConfig()->setDefinition($ilUser->getPref('char_selector_definition'));
681 $char_selector->addFormProperties($this->form);
682 $char_selector->setFormValues($this->form);
683 }
684
685 $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
686 $this->form->setTitle($lng->txt("general_settings"));
687 $this->form->setFormAction($this->ctrl->getFormAction($this));
688 }
689
693 public function saveGeneralSettings()
694 {
695 global $tpl, $lng, $ilCtrl, $ilUser;
696
698 if ($this->form->checkInput()) {
699 if ($this->workWithUserSetting("skin_style")) {
700 //set user skin and style
701 if ($_POST["skin_style"] != "") {
702 $sknst = explode(":", $_POST["skin_style"]);
703
704 if ($ilUser->getPref("style") != $sknst[1] ||
705 $ilUser->getPref("skin") != $sknst[0]) {
706 $ilUser->setPref("skin", $sknst[0]);
707 $ilUser->setPref("style", $sknst[1]);
708 }
709 }
710 }
711
712 // language
713 if ($this->workWithUserSetting("language")) {
714 $ilUser->setLanguage($_POST["language"]);
715 }
716
717 // hits per page
718 if ($this->workWithUserSetting("hits_per_page")) {
719 if ($_POST["hits_per_page"] != "") {
720 $ilUser->setPref("hits_per_page", $_POST["hits_per_page"]);
721 }
722 }
723
724 // set show users online
725 /*
726 if ($this->workWithUserSetting("show_users_online"))
727 {
728 $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
729 }*/
730
731 // store last visited?
732 global $ilNavigationHistory;
733 $ilUser->setPref("store_last_visited", (int) $_POST["store_last_visited"]);
734 if ((int) $_POST["store_last_visited"] > 0) {
735 $ilNavigationHistory->deleteDBEntries();
736 if ((int) $_POST["store_last_visited"] == 2) {
737 $ilNavigationHistory->deleteSessionEntries();
738 }
739 }
740
741 // set hide own online_status
742 if ($this->workWithUserSetting("hide_own_online_status")) {
743 /*if ($_POST["hide_own_online_status"] == 1) {
744 $ilUser->setPref("hide_own_online_status", "y");
745 } else {
746 $ilUser->setPref("hide_own_online_status", "n");
747 }*/
748 $ilUser->setPref("hide_own_online_status", ilUtil::stripSlashes($_POST["hide_own_online_status"]));
749 }
750
751 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
752 if (ilBuddySystem::getInstance()->isEnabled() && $this->workWithUserSetting('bs_allow_to_contact_me')) {
753 if (isset($_POST['bs_allow_to_contact_me']) && $_POST['bs_allow_to_contact_me'] == 1) {
754 $ilUser->setPref('bs_allow_to_contact_me', 'y');
755 } else {
756 $ilUser->setPref('bs_allow_to_contact_me', 'n');
757 }
758 }
759
760 // set show users online
761 if ($this->workWithUserSetting("screen_reader_optimization")) {
762 $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
763 }
764
765 // session reminder
766 include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
767 if (ilSessionReminder::isGloballyActivated()) {
768 $ilUser->setPref('session_reminder_enabled', (int) $this->form->getInput('session_reminder_enabled'));
769 $ilUser->setPref('session_reminder_lead_time', $this->form->getInput('session_reminder_lead_time'));
770 }
771
772 // starting point
773 include_once "Services/User/classes/class.ilUserUtil.php";
776 $this->form->getInput('usr_start'),
777 $this->form->getInput('usr_start_ref_id')
778 );
779 }
780
781 // selector for unicode characters
782 global $ilSetting;
783 if ($ilSetting->get('char_selector_availability') > 0) {
784 require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
786 $char_selector->getFormValues($this->form);
787 $ilUser->setPref('char_selector_availability', $char_selector->getConfig()->getAvailability());
788 $ilUser->setPref('char_selector_definition', $char_selector->getConfig()->getDefinition());
789 }
790
791 $ilUser->update();
792
793 // calendar settings
794 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
795 $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
796 $user_settings->setTimeZone($this->form->getInput("timezone"));
797 $user_settings->setDateFormat((int) $this->form->getInput("date_format"));
798 $user_settings->setTimeFormat((int) $this->form->getInput("time_format"));
799 $user_settings->save();
800
801 ilUtil::sendSuccess($lng->txtlng("common", "msg_obj_modified", $ilUser->getLanguage()), true);
802 $ilCtrl->redirect($this, "showGeneralSettings");
803 }
804
805 $this->form->setValuesByPost();
806 $this->showGeneralSettings(true);
807 }
808
812 protected function deleteOwnAccount1()
813 {
814 global $ilTabs, $ilToolbar, $ilUser, $ilSetting;
815
816 if (!(bool) $ilSetting->get('user_delete_own_account') ||
817 $ilUser->getId() == SYSTEM_USER_ID) {
818 $this->ctrl->redirect($this, "showGeneralSettings");
819 }
820
821 // too make sure
822 $ilUser->removeDeletionFlag();
823
824 $this->setHeader();
825 $this->__initSubTabs("deleteOwnAccount");
826 $ilTabs->activateTab("delacc");
827
828 ilUtil::sendInfo($this->lng->txt('user_delete_own_account_info'));
829 $ilToolbar->addButton(
830 $this->lng->txt('btn_next'),
831 $this->ctrl->getLinkTarget($this, 'deleteOwnAccount2')
832 );
833
834 $this->tpl->show();
835 }
836
840 protected function deleteOwnAccount2()
841 {
842 global $ilTabs, $ilUser, $ilSetting;
843
844 if (!(bool) $ilSetting->get('user_delete_own_account') ||
845 $ilUser->getId() == SYSTEM_USER_ID) {
846 $this->ctrl->redirect($this, "showGeneralSettings");
847 }
848
849 $this->setHeader();
850 $this->__initSubTabs("deleteOwnAccount");
851 $ilTabs->activateTab("delacc");
852
853 include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
854 $cgui = new ilConfirmationGUI();
855 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_logout_confirmation'));
856 $cgui->setFormAction($this->ctrl->getFormAction($this));
857 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
858 $cgui->setConfirm($this->lng->txt("user_delete_own_account_logout_button"), "deleteOwnAccountLogout");
859 $this->tpl->setContent($cgui->getHTML());
860 $this->tpl->show();
861 }
862
863 protected function abortDeleteOwnAccount()
864 {
865 global $ilCtrl, $ilUser;
866
867 $ilUser->removeDeletionFlag();
868
869 ilUtil::sendInfo($this->lng->txt("user_delete_own_account_aborted"), true);
870 $ilCtrl->redirect($this, "showGeneralSettings");
871 }
872
873 protected function deleteOwnAccountLogout()
874 {
875 global $ilAuth, $ilUser;
876
877 // we are setting the flag and ending the session in the same step
878
879 $ilUser->activateDeletionFlag();
880
881 // see ilStartupGUI::showLogout()
883 $GLOBALS['DIC']['ilAuthSession']->logout();
884
885 ilUtil::redirect("login.php?target=usr_" . md5("usrdelown"));
886 }
887
891 protected function deleteOwnAccount3()
892 {
893 global $ilTabs, $ilUser, $ilSetting;
894
895 if (!(bool) $ilSetting->get('user_delete_own_account') ||
896 $ilUser->getId() == SYSTEM_USER_ID ||
897 !$ilUser->hasDeletionFlag()) {
898 $this->ctrl->redirect($this, "showGeneralSettings");
899 }
900
901 $this->setHeader();
902 $this->__initSubTabs("deleteOwnAccount");
903 $ilTabs->activateTab("delacc");
904
905 include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
906 $cgui = new ilConfirmationGUI();
907 $cgui->setHeaderText($this->lng->txt('user_delete_own_account_final_confirmation'));
908 $cgui->setFormAction($this->ctrl->getFormAction($this));
909 $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
910 $cgui->setConfirm($this->lng->txt("confirm"), "deleteOwnAccount4");
911 $this->tpl->setContent($cgui->getHTML());
912 $this->tpl->show();
913 }
914
918 protected function deleteOwnAccount4()
919 {
920 global $ilUser, $ilAuth, $ilSetting, $ilLog;
921
922 if (!(bool) $ilSetting->get('user_delete_own_account') ||
923 $ilUser->getId() == SYSTEM_USER_ID ||
924 !$ilUser->hasDeletionFlag()) {
925 $this->ctrl->redirect($this, "showGeneralSettings");
926 }
927
928 // build notification
929
930 include_once "./Services/Notification/classes/class.ilSystemNotification.php";
931 $ntf = new ilSystemNotification();
932 $ntf->setLangModules(array("user"));
933 $ntf->addAdditionalInfo("profile", $ilUser->getProfileAsString($this->lng), true);
934
935 // mail message
937 $ntf->setIntroductionDirect(
938 sprintf(
939 $this->lng->txt("user_delete_own_account_email_body"),
940 $ilUser->getLogin(),
941 ILIAS_HTTP_PATH,
943 )
944 );
945
946 $message = $ntf->composeAndGetMessage($ilUser->getId(), null, null, true);
947 $subject = $this->lng->txt("user_delete_own_account_email_subject");
948
949
950 // send notification
951
952 include_once "Services/Mail/classes/class.ilMail.php";
953 $mail = new ilMail(ANONYMOUS_USER_ID);
954
955 $user_email = $ilUser->getEmail();
956 $admin_mail = $ilSetting->get("user_delete_own_account_email");
957
958 // to user, admin as bcc
959 if ($user_email) {
960 $mail->sendMimeMail($user_email, null, $admin_mail, $subject, $message, null, true);
961 }
962 // admin only
963 elseif ($admin_mail) {
964 $mail->sendMimeMail($admin_mail, null, null, $subject, $message, null, true);
965 }
966
967 $ilLog->write("Account deleted: " . $ilUser->getLogin() . " (" . $ilUser->getId() . ")");
968
969 $ilUser->delete();
970
971 // terminate session
972 $GLOBALS['DIC']['ilAuthSession']->logout();
973 ilUtil::redirect("login.php?accdel=1");
974 }
975}
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$result
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$_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)
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.
This class handles base functions for mail handling.
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 @ilCtrl_IsCalledBy ilPersonalChatSettingsFormGUI: ilPersonalSetti...
GUI class for personal profile.
initGeneralSettingsForm()
Init general settings form.
userSettingEnabled($setting)
Returns TRUE if user setting is enabled, FALSE otherwise.
deleteOwnAccount4()
Delete own account dialog - action incl.
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.
userSettingVisible($setting)
Returns TRUE if user setting is visible, FALSE otherwise.
saveGeneralSettings()
Save general settings.
showPassword($a_no_init=false, $hide_form=false)
workWithUserSetting($setting)
Returns TRUE if working with the given user setting is allowed, FALSE otherwise.
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.
ILIAS Setting Class.
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)
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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.
$style
Definition: example_012.php:70
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
$error
Definition: Error.php:17
catch(Exception $e) $message
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18