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