ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  var $tpl;
14  var $lng;
15  var $ilias;
16  var $ctrl;
17 
21  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  function executeCommand()
46  {
47  global $ilUser, $ilCtrl, $tpl, $ilTabs, $lng;
48 
49  $next_class = $this->ctrl->getNextClass();
50 
51  switch($next_class)
52  {
53  case 'ilpersonalchatsettingsformgui':
54  $this->__initSubTabs($this->ctrl->getCmd());
55  $this->setHeader();
56 
57  require_once 'Modules/Chatroom/classes/class.ilPersonalChatSettingsFormGUI.php';
58  $chatSettingsGui = new ilPersonalChatSettingsFormGUI();
59  $this->ctrl->forwardCommand($chatSettingsGui);
60  break;
61 
62  default:
63  $cmd = $this->ctrl->getCmd("showGeneralSettings");
64  $this->$cmd();
65  break;
66  }
67  return true;
68  }
69 
74  public function saveMailOptions()
75  {
83  global $ilUser, $lng, $ilTabs, $ilSetting, $rbacsystem;
84 
85  include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
86  if(!$rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()))
87  {
88  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
89  }
90 
91  $lng->loadLanguageModule('mail');
92 
93  $this->__initSubTabs('showMailOptions');
94  $ilTabs->activateTab('mail_settings');
95 
96  $this->setHeader();
97 
98  require_once 'Services/Mail/classes/class.ilMailOptions.php';
99  $mailOptions = new ilMailOptions($ilUser->getId());
100  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1' &&
101  $ilSetting->get('usr_settings_disable_mail_incoming_mail') != '1')
102  {
103  $incoming_type = (int)$_POST['incoming_type'];
104  }
105  else
106  {
107  $incoming_type = $mailOptions->getIncomingType();
108  }
109 
110  $this->initMailOptionsForm();
111  if($this->form->checkInput())
112  {
113  $mailOptions->updateOptions(
114  ilUtil::stripSlashes($_POST['signature']),
115  (int)$_POST['linebreak'],
116  $incoming_type,
117  (int)$_POST['cronjob_notification']
118  );
119 
120  ilUtil::sendSuccess($lng->txt('mail_options_saved'));
121  }
122 
123  if(!isset($_POST['incoming_type']))
124  {
125  $_POST['incoming_type'] = $mailOptions->getIncomingType();
126  }
127 
128  $this->form->setValuesByPost();
129 
130  $this->tpl->setContent($this->form->getHTML());
131  $this->tpl->show();
132  }
133 
137  private function initMailOptionsForm()
138  {
139  global $ilCtrl, $ilSetting, $lng, $ilUser;
140 
141  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
142  $this->form = new ilPropertyFormGUI();
143 
144  $this->form->setFormAction($ilCtrl->getFormAction($this, 'saveMailOptions'));
145  $this->form->setTitle($lng->txt('mail_settings'));
146 
147  // BEGIN INCOMING
148  include_once 'Services/Mail/classes/class.ilMailOptions.php';
149  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1')
150  {
151  $options = array(
152  IL_MAIL_LOCAL => $this->lng->txt('mail_incoming_local'),
153  IL_MAIL_EMAIL => $this->lng->txt('mail_incoming_smtp'),
154  IL_MAIL_BOTH => $this->lng->txt('mail_incoming_both')
155  );
156  $si = new ilSelectInputGUI($lng->txt('mail_incoming'), 'incoming_type');
157  $si->setOptions($options);
158  if(!strlen(ilObjUser::_lookupEmail($ilUser->getId())) ||
159  $ilSetting->get('usr_settings_disable_mail_incoming_mail') == '1')
160  {
161  $si->setDisabled(true);
162  }
163  $this->form->addItem($si);
164  }
165 
166  // BEGIN LINEBREAK_OPTIONS
167  $options = array();
168  for($i = 50; $i <= 80; $i++)
169  {
170  $options[$i] = $i;
171  }
172  $si = new ilSelectInputGUI($lng->txt('linebreak'), 'linebreak');
173  $si->setOptions($options);
174  $this->form->addItem($si);
175 
176  // BEGIN SIGNATURE
177  $ta = new ilTextAreaInputGUI($lng->txt('signature'), 'signature');
178  $ta->setRows(10);
179  $ta->setCols(60);
180  $this->form->addItem($ta);
181 
182  // BEGIN CRONJOB NOTIFICATION
183  if($ilSetting->get('mail_notification'))
184  {
185  $cb = new ilCheckboxInputGUI($lng->txt('cron_mail_notification'), 'cronjob_notification');
186  $cb->setInfo($lng->txt('mail_cronjob_notification_info'));
187  $cb->setValue(1);
188  $this->form->addItem($cb);
189  }
190 
191  $this->form->addCommandButton('saveMailOptions', $lng->txt('save'));
192  }
193 
197  private function setMailOptionsValuesByDB()
198  {
199  global $ilUser, $ilSetting;
200 
201  require_once 'Services/Mail/classes/class.ilMailOptions.php';
202  $mailOptions = new ilMailOptions($ilUser->getId());
203 
204  $data = array(
205  'linebreak' => $mailOptions->getLinebreak(),
206  'signature' => $mailOptions->getSignature(),
207  'cronjob_notification' => $mailOptions->getCronjobNotification()
208  );
209 
210  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1')
211  {
212  $data['incoming_type'] = $mailOptions->getIncomingType();
213  }
214 
215  $this->form->setValuesByArray($data);
216  }
217 
221  public function showMailOptions()
222  {
228  global $ilTabs, $lng, $rbacsystem;
229 
230  include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
231  if(!$rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()))
232  {
233  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
234  }
235 
236  $lng->loadLanguageModule('mail');
237 
238  $this->__initSubTabs('showMailOptions');
239  $ilTabs->activateTab('mail_settings');
240 
241  $this->setHeader();
242 
243  $this->initMailOptionsForm();
244  $this->setMailOptionsValuesByDB();
245 
246  $this->tpl->setContent($this->form->getHTML());
247  $this->tpl->show();
248  }
249 
250  // init sub tabs
251  function __initSubTabs($a_cmd)
252  {
256  global $ilTabs, $ilSetting, $ilHelp, $rbacsystem, $ilUser;
257 
258  $ilHelp->setScreenIdComponent("user");
259 
260  $showPassword = ($a_cmd == 'showPassword') ? true : false;
261  $showGeneralSettings = ($a_cmd == 'showGeneralSettings') ? true : false;
262  $showMailOptions = ($a_cmd == 'showMailOptions') ? true : false;
263 
264  // old profile
265 
266  // general settings
267  $ilTabs->addTarget("general_settings", $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
268  "", "", "", $showGeneralSettings);
269 
270  // password
271  if ($this->allowPasswordChange())
272  {
273  $ilTabs->addTarget("password", $this->ctrl->getLinkTarget($this, "showPassword"),
274  "", "", "", $showPassword);
275  }
276 
277  include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
278  if($rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()))
279  {
280  $ilTabs->addTarget("mail_settings", $this->ctrl->getLinkTarget($this, "showMailOptions"), "", "", "", $showMailOptions);
281  }
282 
283  require_once 'Modules/Chatroom/classes/class.ilPersonalChatSettingsFormGUI.php';
284  $chatSettingsGui = new ilPersonalChatSettingsFormGUI(false);
285  if($chatSettingsGui->isAccessible())
286  {
288  $ilTabs->addTarget(
289  'chat_settings', $this->ctrl->getLinkTarget($chatSettingsGui, 'showChatOptions'), '', 'ilPersonalChatSettingsFormGUI', '', method_exists($chatSettingsGui, $a_cmd)
290  );
291  }
292 
293  include_once "./Services/Administration/classes/class.ilSetting.php";
294 
295  if((bool)$ilSetting->get('user_delete_own_account') &&
296  $ilUser->getId() != SYSTEM_USER_ID)
297  {
298  $ilTabs->addTab("delacc", $this->lng->txt('user_delete_own_account'),
299  $this->ctrl->getLinkTarget($this, "deleteOwnAccount1"));
300  }
301  }
302 
306  public function setHeader()
307  {
308  $this->tpl->setVariable('HEADER', $this->lng->txt('personal_settings'));
309  }
310  //
311  //
312  // PASSWORD FORM
313  //
314  //
315 
320  function showPassword($a_no_init = false, $hide_form = false)
321  {
322  global $ilTabs, $ilUser;
323 
324  $this->__initSubTabs("showPersonalData");
325  $ilTabs->activateTab("password");
326 
327  $this->setHeader();
328  // check whether password of user have to be changed
329  // due to first login or password of user is expired
330  if($ilUser->isPasswordChangeDemanded())
331  {
333  $this->lng->txt('password_change_on_first_login_demand')
334  );
335  }
336  else if($ilUser->isPasswordExpired())
337  {
338  $msg = $this->lng->txt('password_expired');
339  $password_age = $ilUser->getPasswordAge();
340  ilUtil::sendInfo(sprintf($msg, $password_age));
341  }
342 
343  if (!$a_no_init && !$hide_form)
344  {
345  $this->initPasswordForm();
346  }
347  $this->tpl->setContent(!$hide_form ? $this->form->getHTML() : '');
348  $this->tpl->show();
349  }
350 
356  public function initPasswordForm()
357  {
358  global $lng, $ilUser, $ilSetting;
359 
360  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
361  $this->form = new ilPropertyFormGUI();
362 
363  // Check whether password change is allowed
364  if ($this->allowPasswordChange())
365  {
366  // The current password needs to be checked for verification
367  // unless the user uses Shibboleth authentication with additional
368  // local authentication for WebDAV.
369  //if (
370  // ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local"))
371  //)
372  if($ilUser->getAuthMode(true) == AUTH_LOCAL)
373  {
374  // current password
375  $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
376  $cpass->setRetype(false);
377  $cpass->setSkipSyntaxCheck(true);
378  // only if a password exists.
379  if($ilUser->getPasswd())
380  {
381  $cpass->setRequired(true);
382  }
383  $this->form->addItem($cpass);
384  }
385 
386  // new password
387  $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
388  $ipass->setRequired(true);
389  $ipass->setInfo(ilUtil::getPasswordRequirementsInfo());
390 
391  $this->form->addItem($ipass);
392  $this->form->addCommandButton("savePassword", $lng->txt("save"));
393 
394  switch ($ilUser->getAuthMode(true))
395  {
396  case AUTH_LOCAL :
397  $this->form->setTitle($lng->txt("chg_password"));
398  break;
399 
400  case AUTH_SHIBBOLETH :
401  case AUTH_CAS:
402  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
404  {
405  $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
406  }
407  else
408  {
409  $this->form->setTitle($lng->txt("chg_ilias_password"));
410  }
411  break;
412  default :
413  $this->form->setTitle($lng->txt("chg_ilias_password"));
414  break;
415  }
416  $this->form->setFormAction($this->ctrl->getFormAction($this));
417  }
418  }
419 
423  protected function allowPasswordChange()
424  {
425  global $ilUser;
426 
427  if (\ilSession::get('used_external_auth')) {
428  return false;
429  }
430 
431  $status = ilAuthUtils::isPasswordModificationEnabled($ilUser->getAuthMode(true));
432  if ($status) {
433  return true;
434  }
435 
436  return \ilAuthUtils::isPasswordModificationHidden() && ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired());
437  }
438 
443  public function savePassword()
444  {
445  global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting;
446 
447  // normally we should not end up here
448  if (!$this->allowPasswordChange())
449  {
450  $ilCtrl->redirect($this, "showPersonalData");
451  return;
452  }
453 
454  $this->initPasswordForm();
455  if ($this->form->checkInput())
456  {
457  $cp = $this->form->getItemByPostVar("current_password");
458  $np = $this->form->getItemByPostVar("new_password");
459  $error = false;
460 
461  // The old password needs to be checked for verification
462  // unless the user uses Shibboleth authentication with additional
463  // local authentication for WebDAV.
464  #if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
465  if($ilUser->getAuthMode(true) == AUTH_LOCAL)
466  {
467  require_once 'Services/User/classes/class.ilUserPasswordManager.php';
468  if(!ilUserPasswordManager::getInstance()->verifyPassword($ilUser, ilUtil::stripSlashes($_POST['current_password'])))
469  {
470  $error = true;
471  $cp->setAlert($this->lng->txt('passwd_wrong'));
472  }
473  }
474 
475  if(!ilUtil::isPassword($_POST["new_password"],$custom_error))
476  {
477  $error = true;
478  if ($custom_error != '')
479  {
480  $np->setAlert($custom_error);
481  }
482  else
483  {
484  $np->setAlert($this->lng->txt("passwd_invalid"));
485  }
486  }
487  $error_lng_var = '';
488  if(!ilUtil::isPasswordValidForUserContext($_POST["new_password"], $ilUser, $error_lng_var))
489  {
490  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
491  $np->setAlert($this->lng->txt($error_lng_var));
492  $error = true;
493  }
494  if(
495  ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
496  $_POST["current_password"] == $_POST["new_password"])
497  {
498  $error = true;
499  $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
500  }
501 
502  if (!$error)
503  {
504  $ilUser->resetPassword($_POST["new_password"], $_POST["new_password"]);
505  if ($_POST["current_password"] != $_POST["new_password"])
506  {
507  $ilUser->setLastPasswordChangeToNow();
508  }
509 
510  if(ilSession::get('orig_request_target'))
511  {
512  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
513  $target = ilSession::get('orig_request_target');
514  ilSession::set('orig_request_target', '');
515  ilUtil::redirect($target);
516  }
517  else
518  {
519  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
520  $this->showPassword(true, true);
521  return;
522  }
523  }
524  }
525  $this->form->setValuesByPost();
526  $this->showPassword(true);
527  }
528 
529  //
530  //
531  // GENERAL SETTINGS FORM
532  //
533  //
534 
539  function workWithUserSetting($setting)
540  {
541  $result = TRUE;
542  if ($this->settings["usr_settings_hide_".$setting] == 1)
543  {
544  $result = FALSE;
545  }
546  if ($this->settings["usr_settings_disable_".$setting] == 1)
547  {
548  $result = FALSE;
549  }
550  return $result;
551  }
552 
557  function userSettingVisible($setting)
558  {
559  $result = TRUE;
560  if (isset($this->settings["usr_settings_hide_".$setting]) &&
561  $this->settings["usr_settings_hide_".$setting] == 1)
562  {
563  $result = FALSE;
564  }
565  return $result;
566  }
567 
572  function userSettingEnabled($setting)
573  {
574  $result = TRUE;
575  if ($this->settings["usr_settings_disable_".$setting] == 1)
576  {
577  $result = FALSE;
578  }
579  return $result;
580  }
581 
585  function showGeneralSettings($a_no_init = false)
586  {
587  global $ilTabs, $ilToolbar, $ilCtrl;
588 
589  // test to other base class
590 // $ilToolbar->addButton("test",
591 // $ilCtrl->getLinkTargetByClass(array("ilmailgui","ilmailformgui"), "mailUser"));
592 
593  $this->__initSubTabs("showPersonalData");
594  $ilTabs->activateTab("general_settings");
595 
596  $this->setHeader();
597 
598  if (!$a_no_init)
599  {
600  $this->initGeneralSettingsForm();
601  }
602  $this->tpl->setContent($this->form->getHTML());
603  $this->tpl->show();
604  }
605 
610  public function initGeneralSettingsForm()
611  {
612  global $lng, $ilUser, $styleDefinition, $ilSetting;
613 
614 
615  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
616  $this->form = new ilPropertyFormGUI();
617 
618  // language
619  if ($this->userSettingVisible("language"))
620  {
621  $languages = $this->lng->getInstalledLanguages();
622  $options = array();
623  foreach($languages as $lang_key)
624  {
625  $options[$lang_key] = ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key);
626  }
627 
628  $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
629  $si->setOptions($options);
630  $si->setValue($ilUser->getLanguage());
631  $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
632  $this->form->addItem($si);
633  }
634 
635  // skin/style
636  if ($this->userSettingVisible("skin_style"))
637  {
638  $skins = $styleDefinition->getAllSkins();
639  if (is_array($skins))
640  {
641  $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
642 
643  $options = array();
644  foreach($skins as $skin)
645  {
646  foreach($skin->getStyles() as $style)
647  {
648  include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
649  if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(),$style->getId()) || $style->isSubstyle())
650  {
651  continue;
652  }
653 
654  $options[$skin->getId().":".$style->getId()] = $skin->getName()." / ".$style->getName();
655  }
656  }
657  $si->setOptions($options);
658  $si->setValue($ilUser->skin.":".$ilUser->prefs["style"]);
659  $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
660  $this->form->addItem($si);
661  }
662  }
663 
664  // screen reader optimization
665  if ($this->userSettingVisible("screen_reader_optimization"))
666  {
667  $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
668  $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
669  $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
670  $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
671  $this->form->addItem($cb);
672  }
673 
674  // hits per page
675  if ($this->userSettingVisible("hits_per_page"))
676  {
677  $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
678 
679  $hits_options = array(10,15,20,30,40,50,100,9999);
680  $options = array();
681 
682  foreach($hits_options as $hits_option)
683  {
684  $hstr = ($hits_option == 9999)
685  ? $this->lng->txt("no_limit")
686  : $hits_option;
687  $options[$hits_option] = $hstr;
688  }
689  $si->setOptions($options);
690  $si->setValue($ilUser->prefs["hits_per_page"]);
691  $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
692  $this->form->addItem($si);
693  }
694 
695  // Users Online
696  /*
697  if ($this->userSettingVisible("show_users_online"))
698  {
699  $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
700 
701  $options = array(
702  "y" => $this->lng->txt("users_online_show_y"),
703  "associated" => $this->lng->txt("users_online_show_associated"),
704  "n" => $this->lng->txt("users_online_show_n"));
705  $si->setOptions($options);
706  $si->setValue($ilUser->prefs["show_users_online"]);
707  $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
708  $this->form->addItem($si);
709  }*/
710 
711  // Store last visited
712  $lv = new ilSelectInputGUI($this->lng->txt("user_store_last_visited"), "store_last_visited");
713  $options = array(
714  0 => $this->lng->txt("user_lv_keep_entries"),
715  1 => $this->lng->txt("user_lv_keep_only_for_session"),
716  2 => $this->lng->txt("user_lv_do_not_store"));
717  $lv->setOptions($options);
718  $lv->setValue((int) $ilUser->prefs["store_last_visited"]);
719  $this->form->addItem($lv);
720 
721  // hide_own_online_status
722  $awrn_set = new ilSetting("awrn");
723  if ($awrn_set->get("awrn_enabled", false) && $this->userSettingVisible("hide_own_online_status"))
724  {
725  $this->lng->loadLanguageModule("awrn");
726  $cb = new ilCheckboxInputGUI($this->lng->txt("awrn_hide_from_awareness"), "hide_own_online_status");
727  $cb->setInfo($this->lng->txt("awrn_hide_from_awareness_info"));
728  $cb->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
729  $cb->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
730  $this->form->addItem($cb);
731  }
732 
733  require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
734  if(ilBuddySystem::getInstance()->isEnabled() && $this->userSettingVisible('bs_allow_to_contact_me'))
735  {
736  $this->lng->loadLanguageModule('buddysystem');
737  $allow_to_contact_be = new ilCheckboxInputGUI($this->lng->txt('buddy_allow_to_contact_me'), 'bs_allow_to_contact_me');
738  $allow_to_contact_be->setInfo($this->lng->txt('buddy_allow_to_contact_me_info'));
739  $allow_to_contact_be->setChecked($ilUser->prefs['bs_allow_to_contact_me'] == 'y');
740  $allow_to_contact_be->setDisabled($ilSetting->get('usr_settings_disable_bs_allow_to_contact_me'));
741  $this->form->addItem($allow_to_contact_be);
742  }
743 
744  include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
745  if(ilSessionReminder::isGloballyActivated())
746  {
747  $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
748  $cb->setInfo($this->lng->txt('session_reminder_info'));
749  $cb->setValue(1);
750  $cb->setChecked((int)$ilUser->getPref('session_reminder_enabled'));
751 
753  $lead_time_gui = new ilNumberInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
754  $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilDatePresentation::secondsToString($expires, true)));
755 
757  $max_value = max($min_value, ((int)$expires / 60) - 1);
758 
759  $current_user_value = $ilUser->getPref('session_reminder_lead_time');
760  if($current_user_value < $min_value ||
761  $current_user_value > $max_value)
762  {
763  $current_user_value = ilSessionReminder::SUGGESTED_LEAD_TIME;
764  }
765  $value = min(
766  max(
767  $min_value, $current_user_value
768  ),
769  $max_value
770  );
771 
772  $lead_time_gui->setValue($value);
773  $lead_time_gui->setSize(3);
774  $lead_time_gui->setMinValue($min_value);
775  $lead_time_gui->setMaxValue($max_value);
776  $cb->addSubItem($lead_time_gui);
777 
778  $this->form->addItem($cb);
779  }
780 
781  // calendar settings (copied here to be reachable when calendar is inactive)
782  // they cannot be hidden/deactivated
783 
784  include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
785  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
786  $lng->loadLanguageModule("dateplaner");
787  $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
788 
789  $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'),'timezone');
791  $select->setInfo($lng->txt('cal_timezone_info'));
792  $select->setValue($user_settings->getTimeZone());
793  $this->form->addItem($select);
794 
795  $year = date("Y");
796  $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'),'date_format');
797  $select->setOptions(array(
798  ilCalendarSettings::DATE_FORMAT_DMY => '31.10.'.$year,
799  ilCalendarSettings::DATE_FORMAT_YMD => $year."-10-31",
800  ilCalendarSettings::DATE_FORMAT_MDY => "10/31/".$year));
801  $select->setInfo($lng->txt('cal_date_format_info'));
802  $select->setValue($user_settings->getDateFormat());
803  $this->form->addItem($select);
804 
805  $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'),'time_format');
806  $select->setOptions(array(
809  $select->setInfo($lng->txt('cal_time_format_info'));
810  $select->setValue($user_settings->getTimeFormat());
811  $this->form->addItem($select);
812 
813 
814  // starting point
815  include_once "Services/User/classes/class.ilUserUtil.php";
817  {
818  $this->lng->loadLanguageModule("administration");
819  $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "usr_start");
820  $si->setRequired(true);
821  $si->setInfo($this->lng->txt("adm_user_starting_point_info"));
822  $def_opt = new ilRadioOption($this->lng->txt("adm_user_starting_point_inherit"), 0);
823  $def_opt->setInfo($this->lng->txt("adm_user_starting_point_inherit_info"));
824  $si->addOption($def_opt);
825  foreach(ilUserUtil::getPossibleStartingPoints() as $value => $caption)
826  {
827  $si->addOption(new ilRadioOption($caption, $value));
828  }
831  : 0);
832  $this->form->addItem($si);
833 
834  // starting point: repository object
835  $repobj = new ilRadioOption($lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ);
836  $repobj_id = new ilTextInputGUI($lng->txt("adm_user_starting_point_ref_id"), "usr_start_ref_id");
837  $repobj_id->setInfo($lng->txt("adm_user_starting_point_ref_id_info"));
838  $repobj_id->setRequired(true);
839  $repobj_id->setSize(5);
840  if($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ)
841  {
842  $start_ref_id = ilUserUtil::getPersonalStartingObject();
843  $repobj_id->setValue($start_ref_id);
844  if($start_ref_id)
845  {
846  $start_obj_id = ilObject::_lookupObjId($start_ref_id);
847  if($start_obj_id)
848  {
849  $repobj_id->setInfo($lng->txt("obj_".ilObject::_lookupType($start_obj_id)).
850  ": ".ilObject::_lookupTitle($start_obj_id));
851  }
852  }
853  }
854  $repobj->addSubItem($repobj_id);
855  $si->addOption($repobj);
856  }
857 
858  // selector for unicode characters
859  global $ilSetting;
860  if ($ilSetting->get('char_selector_availability') > 0)
861  {
862  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
864  $char_selector->getConfig()->setAvailability($ilUser->getPref('char_selector_availability'));
865  $char_selector->getConfig()->setDefinition($ilUser->getPref('char_selector_definition'));
866  $char_selector->addFormProperties($this->form);
867  $char_selector->setFormValues($this->form);
868  }
869 
870  $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
871  $this->form->setTitle($lng->txt("general_settings"));
872  $this->form->setFormAction($this->ctrl->getFormAction($this));
873 
874  }
875 
879  public function saveGeneralSettings()
880  {
881  global $tpl, $lng, $ilCtrl, $ilUser;
882 
883  $this->initGeneralSettingsForm();
884  if ($this->form->checkInput())
885  {
886  if ($this->workWithUserSetting("skin_style"))
887  {
888  //set user skin and style
889  if ($_POST["skin_style"] != "")
890  {
891  $sknst = explode(":", $_POST["skin_style"]);
892 
893  if ($ilUser->getPref("style") != $sknst[1] ||
894  $ilUser->getPref("skin") != $sknst[0])
895  {
896  $ilUser->setPref("skin", $sknst[0]);
897  $ilUser->setPref("style", $sknst[1]);
898  }
899  }
900  }
901 
902  // language
903  if ($this->workWithUserSetting("language"))
904  {
905  $ilUser->setLanguage($_POST["language"]);
906  }
907 
908  // hits per page
909  if ($this->workWithUserSetting("hits_per_page"))
910  {
911  if ($_POST["hits_per_page"] != "")
912  {
913  $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
914  }
915  }
916 
917  // set show users online
918  /*
919  if ($this->workWithUserSetting("show_users_online"))
920  {
921  $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
922  }*/
923 
924  // store last visited?
925  global $ilNavigationHistory;
926  $ilUser->setPref("store_last_visited", (int) $_POST["store_last_visited"]);
927  if ((int) $_POST["store_last_visited"] > 0)
928  {
929  $ilNavigationHistory->deleteDBEntries();
930  if ((int) $_POST["store_last_visited"] == 2)
931  {
932  $ilNavigationHistory->deleteSessionEntries();
933  }
934  }
935 
936  // set hide own online_status
937  if ($this->workWithUserSetting("hide_own_online_status"))
938  {
939  if ($_POST["hide_own_online_status"] == 1)
940  {
941  $ilUser->setPref("hide_own_online_status","y");
942  }
943  else
944  {
945  $ilUser->setPref("hide_own_online_status","n");
946  }
947  }
948 
949  require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
950  if(ilBuddySystem::getInstance()->isEnabled() && $this->workWithUserSetting('bs_allow_to_contact_me'))
951  {
952  if(isset($_POST['bs_allow_to_contact_me']) && $_POST['bs_allow_to_contact_me'] == 1)
953  {
954  $ilUser->setPref('bs_allow_to_contact_me', 'y');
955  }
956  else
957  {
958  $ilUser->setPref('bs_allow_to_contact_me', 'n');
959  }
960  }
961 
962  // set show users online
963  if ($this->workWithUserSetting("screen_reader_optimization"))
964  {
965  $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
966  }
967 
968  // session reminder
969  include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
970  if(ilSessionReminder::isGloballyActivated())
971  {
972  $ilUser->setPref('session_reminder_enabled', (int)$this->form->getInput('session_reminder_enabled'));
973  $ilUser->setPref('session_reminder_lead_time', $this->form->getInput('session_reminder_lead_time'));
974  }
975 
976  // starting point
977  include_once "Services/User/classes/class.ilUserUtil.php";
979  {
980  ilUserUtil::setPersonalStartingPoint($this->form->getInput('usr_start'),
981  $this->form->getInput('usr_start_ref_id'));
982  }
983 
984  // selector for unicode characters
985  global $ilSetting;
986  if ($ilSetting->get('char_selector_availability') > 0)
987  {
988  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
990  $char_selector->getFormValues($this->form);
991  $ilUser->setPref('char_selector_availability', $char_selector->getConfig()->getAvailability());
992  $ilUser->setPref('char_selector_definition', $char_selector->getConfig()->getDefinition());
993  }
994 
995  $ilUser->update();
996 
997  // calendar settings
998  include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
999  $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
1000  $user_settings->setTimeZone($this->form->getInput("timezone"));
1001  $user_settings->setDateFormat((int)$this->form->getInput("date_format"));
1002  $user_settings->setTimeFormat((int)$this->form->getInput("time_format"));
1003  $user_settings->save();
1004 
1005  ilUtil::sendSuccess($lng->txtlng("common", "msg_obj_modified", $ilUser->getLanguage()), true);
1006  $ilCtrl->redirect($this, "showGeneralSettings");
1007  }
1008 
1009  $this->form->setValuesByPost();
1010  $this->showGeneralSettings(true);
1011  }
1012 
1016  protected function deleteOwnAccount1()
1017  {
1018  global $ilTabs, $ilToolbar, $ilUser, $ilSetting;
1019 
1020  if(!(bool)$ilSetting->get('user_delete_own_account') ||
1021  $ilUser->getId() == SYSTEM_USER_ID)
1022  {
1023  $this->ctrl->redirect($this, "showGeneralSettings");
1024  }
1025 
1026  // too make sure
1027  $ilUser->removeDeletionFlag();
1028 
1029  $this->setHeader();
1030  $this->__initSubTabs("deleteOwnAccount");
1031  $ilTabs->activateTab("delacc");
1032 
1033  ilUtil::sendInfo($this->lng->txt('user_delete_own_account_info'));
1034  $ilToolbar->addButton($this->lng->txt('btn_next'),
1035  $this->ctrl->getLinkTarget($this, 'deleteOwnAccount2'));
1036 
1037  $this->tpl->show();
1038  }
1039 
1043  protected function deleteOwnAccount2()
1044  {
1045  global $ilTabs, $ilUser, $ilSetting;
1046 
1047  if(!(bool)$ilSetting->get('user_delete_own_account') ||
1048  $ilUser->getId() == SYSTEM_USER_ID)
1049  {
1050  $this->ctrl->redirect($this, "showGeneralSettings");
1051  }
1052 
1053  $this->setHeader();
1054  $this->__initSubTabs("deleteOwnAccount");
1055  $ilTabs->activateTab("delacc");
1056 
1057  include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
1058  $cgui = new ilConfirmationGUI();
1059  $cgui->setHeaderText($this->lng->txt('user_delete_own_account_logout_confirmation'));
1060  $cgui->setFormAction($this->ctrl->getFormAction($this));
1061  $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
1062  $cgui->setConfirm($this->lng->txt("user_delete_own_account_logout_button"), "deleteOwnAccountLogout");
1063  $this->tpl->setContent($cgui->getHTML());
1064  $this->tpl->show();
1065  }
1066 
1067  protected function abortDeleteOwnAccount()
1068  {
1069  global $ilCtrl, $ilUser;
1070 
1071  $ilUser->removeDeletionFlag();
1072 
1073  ilUtil::sendInfo($this->lng->txt("user_delete_own_account_aborted"), true);
1074  $ilCtrl->redirect($this, "showGeneralSettings");
1075  }
1076 
1077  protected function deleteOwnAccountLogout()
1078  {
1079  global $ilAuth, $ilUser;
1080 
1081  // we are setting the flag and ending the session in the same step
1082 
1083  $ilUser->activateDeletionFlag();
1084 
1085  // see ilStartupGUI::showLogout()
1087  $GLOBALS['DIC']['ilAuthSession']->logout();
1088 
1089  ilUtil::redirect("login.php?target=usr_".md5("usrdelown"));
1090  }
1091 
1095  protected function deleteOwnAccount3()
1096  {
1097  global $ilTabs, $ilUser, $ilSetting;
1098 
1099  if(!(bool)$ilSetting->get('user_delete_own_account') ||
1100  $ilUser->getId() == SYSTEM_USER_ID ||
1101  !$ilUser->hasDeletionFlag())
1102  {
1103  $this->ctrl->redirect($this, "showGeneralSettings");
1104  }
1105 
1106  $this->setHeader();
1107  $this->__initSubTabs("deleteOwnAccount");
1108  $ilTabs->activateTab("delacc");
1109 
1110  include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
1111  $cgui = new ilConfirmationGUI();
1112  $cgui->setHeaderText($this->lng->txt('user_delete_own_account_final_confirmation'));
1113  $cgui->setFormAction($this->ctrl->getFormAction($this));
1114  $cgui->setCancel($this->lng->txt("cancel"), "abortDeleteOwnAccount");
1115  $cgui->setConfirm($this->lng->txt("confirm"), "deleteOwnAccount4");
1116  $this->tpl->setContent($cgui->getHTML());
1117  $this->tpl->show();
1118  }
1119 
1123  protected function deleteOwnAccount4()
1124  {
1125  global $ilUser, $ilAuth, $ilSetting, $ilLog;
1126 
1127  if(!(bool)$ilSetting->get('user_delete_own_account') ||
1128  $ilUser->getId() == SYSTEM_USER_ID ||
1129  !$ilUser->hasDeletionFlag())
1130  {
1131  $this->ctrl->redirect($this, "showGeneralSettings");
1132  }
1133 
1134  // build notification
1135 
1136  include_once "./Services/Notification/classes/class.ilSystemNotification.php";
1137  $ntf = new ilSystemNotification();
1138  $ntf->setLangModules(array("user"));
1139  $ntf->addAdditionalInfo("profile", $ilUser->getProfileAsString($this->lng), true);
1140 
1141  // mail message
1143  $ntf->setIntroductionDirect(
1144  sprintf($this->lng->txt("user_delete_own_account_email_body"),
1145  $ilUser->getLogin(),
1146  ILIAS_HTTP_PATH,
1148 
1149  $message = $ntf->composeAndGetMessage($ilUser->getId(), null, null, true);
1150  $subject = $this->lng->txt("user_delete_own_account_email_subject");
1151 
1152 
1153  // send notification
1154 
1155  include_once "Services/Mail/classes/class.ilMail.php";
1156  $mail = new ilMail(ANONYMOUS_USER_ID);
1157 
1158  $user_email = $ilUser->getEmail();
1159  $admin_mail = $ilSetting->get("user_delete_own_account_email");
1160 
1161  // to user, admin as bcc
1162  if($user_email)
1163  {
1164  $mail->sendMimeMail($user_email, null, $admin_mail, $subject, $message, null, true);
1165  }
1166  // admin only
1167  else if($admin_mail)
1168  {
1169  $mail->sendMimeMail($admin_mail, null, null, $subject, $message, null, true);
1170  }
1171 
1172  $ilLog->write("Account deleted: ".$ilUser->getLogin()." (".$ilUser->getId().")");
1173 
1174  $ilUser->delete();
1175 
1176  // terminate session
1177  $GLOBALS['DIC']['ilAuthSession']->logout();
1178  ilUtil::redirect("login.php?accdel=1");
1179  }
1180 }
1181 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
deleteOwnAccount1()
Delete own account dialog - 1st confirmation.
$error
Definition: Error.php:17
This class represents an option in a radio group.
ILIAS Setting Class.
Class UserMail this class handles user mails.
$style
Definition: example_012.php:70
const IL_MAIL_BOTH
const IL_MAIL_EMAIL
static _getInstance()
Get instance.
static hasPersonalStartPointPref()
Did user set any personal starting point (yet)?
This class represents a selection list property in a property form.
$result
This class represents a property form user interface.
This shows a character selector.
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static _getInstanceByUserId($a_user_id)
get singleton instance
savePassword()
Save password form.
const AUTH_CAS
initGeneralSettingsForm()
Init general settings form.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
static getPersonalStartingPoint()
Get current personal starting point.
const AUTH_SHIBBOLETH
static get($a_var)
Get a value.
setMailOptionsValuesByDB()
Fetches data from model and loads this data into form.
static set($a_var, $a_val)
Set a value.
This class represents a checkbox property in a property form.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
static _isActive()
Static getter.
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
static _lookupEntry($a_lang_key, $a_mod, $a_id)
showPassword($a_no_init=false, $hide_form=false)
const IL_CAL_UNIX
static _getShortTimeZoneList()
get short timezone list
saveGeneralSettings()
Save general settings.
setInfo($a_info)
Set Info.
static isPassword($a_passwd, &$customError=null)
validates a password public
setRetype($a_val)
Set retype on/off.
const IL_MAIL_LOCAL
deleteOwnAccount3()
Delete own account dialog - final confirmation.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static hasPersonalStartingPoint()
Can starting point be personalized?
userSettingVisible($setting)
Returns TRUE if user setting is visible, FALSE otherwise.
global $ilCtrl
Definition: ilias.php:18
static getPossibleStartingPoints($a_force_all=false)
Get all valid starting points.
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setChecked($a_checked)
Set Checked.
deleteOwnAccount4()
Delete own account dialog - action incl.
workWithUserSetting($setting)
Returns TRUE if working with the given user setting is allowed, FALSE otherwise.
This class represents a property in a property form.
initPasswordForm()
Init password form.
setValue($a_value)
Set Value.
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
if(!is_array($argv)) $options
const SESSION_CLOSE_USER
This class represents a number property in a property form.
This class handles base functions for mail handling.
static _lookupObjId($a_id)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
This class represents a password property in a property form.
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
const AUTH_LOCAL
showGeneralSettings($a_no_init=false)
General settings form.
setOptions($a_options)
Set Options.
initMailOptionsForm()
Initialises the mail options form.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
GUI class for personal profile.
settings()
Definition: settings.php:2
allowPasswordChange()
Check, whether password change is allowed for user.
static setClosingContext($a_context)
set closing context (for statistics)
global $ilSetting
Definition: privfeed.php:17
userSettingEnabled($setting)
Returns TRUE if user setting is enabled, FALSE otherwise.
static _lookupEmail($a_user_id)
Lookup email.
This class represents a text area property in a property form.
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable...
Class ilPersonalChatSettingsFormGUI ilPersonalChatSettingsFormGUI: ilPersonalSettingsGUI.
const START_REPOSITORY_OBJ
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$languages
Definition: cssgen2.php:34
static getPersonalStartingObject()
Get ref id of personal starting object.
static redirect($a_script)
http redirect to other script
static getSessionExpireValue()
Returns the session expiration value.
static isPasswordModificationEnabled($a_authmode)
Check if password modification is enabled.
Wrapper classes for system notifications.
$_POST["username"]
static getInstance()
Single method to reduce footprint (included files, created instances)
setRequired($a_required)
Set Required.
static setPersonalStartingPoint($a_value, $a_ref_id=null)
Set personal starting point setting.
Confirmation screen class.
deleteOwnAccount2()
Delete own account dialog - login redirect.