ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPersonalProfileGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
15 {
16  var $tpl;
17  var $lng;
18  var $ilias;
19  var $ctrl;
20 
22 
23 
28  {
29  global $ilias, $tpl, $lng, $rbacsystem, $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  $this->upload_error = "";
41  $this->password_error = "";
42  $lng->loadLanguageModule("user");
43  $ilCtrl->saveParameter($this, "user_page");
44  }
45 
49  function &executeCommand()
50  {
51  global $ilUser, $ilCtrl, $tpl, $ilTabs, $lng;
52 
53  $next_class = $this->ctrl->getNextClass();
54 
55  switch($next_class)
56  {
57  case "ilpublicuserprofilegui":
58  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
59  $pub_profile_gui = new ilPublicUserProfileGUI($ilUser->getId());
60  $ilCtrl->forwardCommand($pub_profile_gui);
61  break;
62 
63 
64  case 'ilextpublicprofilepagegui':
65  $this->initExtProfile();
66  $ilTabs->clearTargets();
67  $ilTabs->setBackTarget($lng->txt("back"),
68  $ilCtrl->getLinkTarget($this, "showExtendedProfile"));
69  include_once("./Services/User/classes/class.ilExtPublicProfilePageGUI.php");
70  $page_gui = new ilExtPublicProfilePageGUI($_GET["user_page"]);
71  $tpl->setCurrentBlock("ContentStyle");
72  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
74  $tpl->parseCurrentBlock();
75  $ret = $this->ctrl->forwardCommand($page_gui);
76  if ($ret != "")
77  {
78  $tpl->setContent($ret);
79  }
80  $tpl->show();
81  break;
82 
83 
84  default:
85  //$this->setTabs();
86 
87  $cmd = $this->ctrl->getCmd("showPersonalData");
88 
89  // check whether password of user have to be changed
90  // due to first login or password of user is expired
91  if( $ilUser->isPasswordChangeDemanded() && $cmd != 'savePassword' )
92  {
93  $cmd = 'showPassword';
94 
96  $this->lng->txt('password_change_on_first_login_demand'), true
97  );
98  }
99  elseif( $ilUser->isPasswordExpired() && $cmd != 'savePassword' )
100  {
101  $cmd = 'showPassword';
102 
103  $msg = $this->lng->txt('password_expired');
104  $password_age = $ilUser->getPasswordAge();
105 
106  ilUtil::sendInfo( sprintf($msg,$password_age), true );
107  }
108 
109  $this->$cmd();
110  break;
111  }
112  return true;
113  }
114 
115 
120  function workWithUserSetting($setting)
121  {
122  $result = TRUE;
123  if ($this->settings["usr_settings_hide_".$setting] == 1)
124  {
125  $result = FALSE;
126  }
127  if ($this->settings["usr_settings_disable_".$setting] == 1)
128  {
129  $result = FALSE;
130  }
131  return $result;
132  }
133 
138  function userSettingVisible($setting)
139  {
140  $result = TRUE;
141  if (isset($this->settings["usr_settings_hide_".$setting]) &&
142  $this->settings["usr_settings_hide_".$setting] == 1)
143  {
144  $result = FALSE;
145  }
146  return $result;
147  }
148 
153  function userSettingEnabled($setting)
154  {
155  $result = TRUE;
156  if ($this->settings["usr_settings_disable_".$setting] == 1)
157  {
158  $result = FALSE;
159  }
160  return $result;
161  }
162 
166  function uploadUserPicture()
167  {
168  global $ilUser;
169 
170  if ($this->workWithUserSetting("upload"))
171  {
172  $userfile_input = $this->form->getItemByPostVar("userfile");
173 
174  if ($_FILES["userfile"]["tmp_name"] == "")
175  {
176  if ($userfile_input->getDeletionFlag())
177  {
178  $ilUser->removeUserPicture();
179  }
180  return;
181  }
182 
183  if ($_FILES["userfile"]["size"] != 0)
184  {
185  $webspace_dir = ilUtil::getWebspaceDir();
186  $image_dir = $webspace_dir."/usr_images";
187  $store_file = "usr_".$ilUser->getID()."."."jpg";
188 
189  // store filename
190  $ilUser->setPref("profile_image", $store_file);
191  $ilUser->update();
192 
193  // move uploaded file
194  $uploaded_file = $image_dir."/upload_".$ilUser->getId()."pic";
195 
196  if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
197  $uploaded_file, false))
198  {
199  ilUtil::sendFailure($this->lng->txt("upload_error", true));
200  $this->ctrl->redirect($this, "showProfile");
201  }
202  chmod($uploaded_file, 0770);
203 
204  // take quality 100 to avoid jpeg artefacts when uploading jpeg files
205  // taking only frame [0] to avoid problems with animated gifs
206  $show_file = "$image_dir/usr_".$ilUser->getId().".jpg";
207  $thumb_file = "$image_dir/usr_".$ilUser->getId()."_small.jpg";
208  $xthumb_file = "$image_dir/usr_".$ilUser->getId()."_xsmall.jpg";
209  $xxthumb_file = "$image_dir/usr_".$ilUser->getId()."_xxsmall.jpg";
210  $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
211  $show_file = ilUtil::escapeShellArg($show_file);
212  $thumb_file = ilUtil::escapeShellArg($thumb_file);
213  $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
214  $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
215  ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200 -quality 100 JPEG:".$show_file);
216  ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100 -quality 100 JPEG:".$thumb_file);
217  ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75 -quality 100 JPEG:".$xthumb_file);
218  ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30 -quality 100 JPEG:".$xxthumb_file);
219  }
220  }
221 
222 // $this->saveProfile();
223  }
224 
228  function removeUserPicture()
229  {
230  global $ilUser;
231 
232  $ilUser->removeUserPicture();
233 
234  $this->saveProfile();
235  }
236 
237 
242  {
243  global $ilUser, $ilSetting;
244 
245  /*
246  include_once('Services/LDAP/classes/class.ilLDAPServer.php');
247  if($ilUser->getAuthMode(true) == AUTH_LDAP and ($server_ids = ilLDAPServer::_getPasswordServers()))
248  {
249  include_once('Services/LDAP/classes/class.ilLDAPPasswordSynchronization.php');
250  $pwd_sync = new ilLDAPPasswordSynchronization($server_ids[0]);
251  $pwd_sync->setOldPassword($_POST["current_password"]);
252  $pwd_sync->setNewPassword($_POST["desired_password"]);
253  $pwd_sync->setRetypePassword($_POST["retype_password"]);
254  if(!$pwd_sync->synchronize())
255  {
256  $this->password_error = $pwd_sync->getError();
257  }
258  $this->saveProfile();
259  return false;
260  }
261  */
262  // do nothing if auth mode is not local database
263  if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
264  ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
265  ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local")) &&
266  ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local"))
267  )
268  {
269  $this->password_error = $this->lng->txt("not_changeable_for_non_local_auth");
270  }
271 
272  // select password from auto generated passwords
273  if ($this->ilias->getSetting("passwd_auto_generate") == 1)
274  {
275  // The old password needs to be checked for verification
276  // unless the user uses Shibboleth authentication with additional
277  // local authentication for WebDAV.
278  if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
279  {
280  // check old password
281  if (md5($_POST["current_password"]) != $ilUser->getPasswd())
282  {
283  $this->password_error = $this->lng->txt("passwd_wrong");
284  }
285  }
286  // validate transmitted password
287  if (!ilUtil::isPassword($_POST["new_passwd"]))
288  {
289  $this->password_error = $this->lng->txt("passwd_not_selected");
290  }
291 
292  if (empty($this->password_error))
293  {
294  ilUtil::sendSuccess($this->lng->txt("saved_successfully"));
295  $ilUser->updatePassword($_POST["current_password"], $_POST["new_passwd"], $_POST["new_passwd"]);
296  }
297  }
298  else
299  {
300  // check old password
301  if (md5($_POST["current_password"]) != $ilUser->getPasswd())
302  {
303  $this->password_error = $this->lng->txt("passwd_wrong");
304  }
305  // check new password
306  else if ($_POST["desired_password"] != $_POST["retype_password"])
307  {
308  $this->password_error = $this->lng->txt("passwd_not_match");
309  }
310  // validate password
311  else if (!ilUtil::isPassword($_POST["desired_password"],$custom_error))
312  {
313  if( $custom_error != '' )
314  $this->password_error = $custom_error;
315  else $this->password_error = $this->lng->txt("passwd_invalid");
316  }
317  else if ($_POST["current_password"] != "" and empty($this->password_error))
318  {
319  if( $ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded() )
320  {
321  if( $_POST["current_password"] != $_POST["desired_password"] )
322  {
323  if( $ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]) )
324  {
325  ilUtil::sendSuccess($this->lng->txt("saved_successfully"));
326  $ilUser->setLastPasswordChangeToNow();
327  }
328  }
329  else
330  {
331  $this->password_error = $this->lng->txt("new_pass_equals_old_pass");
332  }
333  }
334  else
335  {
336  ilUtil::sendSuccess($this->lng->txt("saved_successfully"));
337  $ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]);
338  $ilUser->setLastPasswordChangeToNow();
339  }
340  }
341  }
342 
343  $this->saveProfile();
344  }
345 
346 
347 
351  function saveProfile()
352  {
353  global $ilUser ,$ilSetting, $ilAuth;
354 
355  //init checking var
356  $form_valid = true;
357 
358  // testing by ratana ty:
359  // if people check on check box it will
360  // write some datata to table usr_pref
361  // if check on Public Profile
362  if (($_POST["chk_pub"])=="on")
363  {
364  $ilUser->setPref("public_profile","y");
365  }
366  else
367  {
368  $ilUser->setPref("public_profile","n");
369  }
370 
371  // if check on Institute
372  $val_array = array("institution", "department", "upload", "street",
373  "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
374  "fax", "email", "hobby", "matriculation");
375 
376  // set public profile preferences
377  foreach($val_array as $key => $value)
378  {
379  if (($_POST["chk_".$value]) == "on")
380  {
381  $ilUser->setPref("public_".$value,"y");
382  }
383  else
384  {
385  $ilUser->setPref("public_".$value,"n");
386  }
387  }
388 
389  $d_set = new ilSetting("delicious");
390  if ($d_set->get("user_profile"))
391  {
392  if (($_POST["chk_delicious"]) == "on")
393  {
394  $ilUser->setPref("public_delicious","y");
395  }
396  else
397  {
398  $ilUser->setPref("public_delicious","n");
399  }
400  }
401 
402 
403  // check dynamically required fields
404  foreach($this->settings as $key => $val)
405  {
406  if (substr($key,0,8) == "require_")
407  {
408  $require_keys[] = substr($key,8);
409  }
410  }
411 
412  foreach($require_keys as $key => $val)
413  {
414  // exclude required system and registration-only fields
415  $system_fields = array("login", "default_role", "passwd", "passwd2");
416  if (!in_array($val, $system_fields))
417  {
418  if ($this->workWithUserSetting($val))
419  {
420  if (isset($this->settings["require_" . $val]) && $this->settings["require_" . $val])
421  {
422  if (empty($_POST["usr_" . $val]))
423  {
424  ilUtil::sendFailure($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val));
425  $form_valid = false;
426  }
427  }
428  }
429  }
430  }
431 
432  // Check user defined required fields
433  if($form_valid and !$this->__checkUserDefinedRequiredFields())
434  {
435  ilUtil::sendFailure($this->lng->txt("fill_out_all_required_fields"));
436  $form_valid = false;
437  }
438 
439  // check email
440  if ($this->workWithUserSetting("email"))
441  {
442  if (!ilUtil::is_email($_POST["usr_email"]) and !empty($_POST["usr_email"]) and $form_valid)
443  {
444  ilUtil::sendFailure($this->lng->txt("email_not_valid"));
445  $form_valid = false;
446  }
447  }
448 
449  //update user data (not saving!)
450  if ($this->workWithUserSetting("firstname"))
451  {
452  $ilUser->setFirstName(ilUtil::stripSlashes($_POST["usr_firstname"]));
453  }
454  if ($this->workWithUserSetting("lastname"))
455  {
456  $ilUser->setLastName(ilUtil::stripSlashes($_POST["usr_lastname"]));
457  }
458  if ($this->workWithUserSetting("gender"))
459  {
460  $ilUser->setGender($_POST["usr_gender"]);
461  }
462  if ($this->workWithUserSetting("title"))
463  {
464  $ilUser->setUTitle(ilUtil::stripSlashes($_POST["usr_title"]));
465  }
466  $ilUser->setFullname();
467  if ($this->workWithUserSetting("institution"))
468  {
469  $ilUser->setInstitution(ilUtil::stripSlashes($_POST["usr_institution"]));
470  }
471  if ($this->workWithUserSetting("department"))
472  {
473  $ilUser->setDepartment(ilUtil::stripSlashes($_POST["usr_department"]));
474  }
475  if ($this->workWithUserSetting("street"))
476  {
477  $ilUser->setStreet(ilUtil::stripSlashes($_POST["usr_street"]));
478  }
479  if ($this->workWithUserSetting("zipcode"))
480  {
481  $ilUser->setZipcode(ilUtil::stripSlashes($_POST["usr_zipcode"]));
482  }
483  if ($this->workWithUserSetting("city"))
484  {
485  $ilUser->setCity(ilUtil::stripSlashes($_POST["usr_city"]));
486  }
487  if ($this->workWithUserSetting("country"))
488  {
489  $ilUser->setCountry(ilUtil::stripSlashes($_POST["usr_country"]));
490  }
491  if ($this->workWithUserSetting("phone_office"))
492  {
493  $ilUser->setPhoneOffice(ilUtil::stripSlashes($_POST["usr_phone_office"]));
494  }
495  if ($this->workWithUserSetting("phone_home"))
496  {
497  $ilUser->setPhoneHome(ilUtil::stripSlashes($_POST["usr_phone_home"]));
498  }
499  if ($this->workWithUserSetting("phone_mobile"))
500  {
501  $ilUser->setPhoneMobile(ilUtil::stripSlashes($_POST["usr_phone_mobile"]));
502  }
503  if ($this->workWithUserSetting("fax"))
504  {
505  $ilUser->setFax(ilUtil::stripSlashes($_POST["usr_fax"]));
506  }
507  if ($this->workWithUserSetting("email"))
508  {
509  $ilUser->setEmail(ilUtil::stripSlashes($_POST["usr_email"]));
510  }
511  if ($this->workWithUserSetting("hobby"))
512  {
513  $ilUser->setHobby(ilUtil::stripSlashes($_POST["usr_hobby"]));
514  }
515  if ($this->workWithUserSetting("referral_comment"))
516  {
517  $ilUser->setComment(ilUtil::stripSlashes($_POST["usr_referral_comment"]));
518  }
519  if ($this->workWithUserSetting("matriculation"))
520  {
521  $ilUser->setMatriculation(ilUtil::stripSlashes($_POST["usr_matriculation"]));
522  }
523 
524  // delicious
525  $d_set = new ilSetting("delicious");
526  if ($d_set->get("user_profile"))
527  {
528  $ilUser->setDelicious(ilUtil::stripSlashes($_POST["usr_delicious"]));
529  }
530 
531  // set instant messengers
532  if ($this->workWithUserSetting("instant_messengers"))
533  {
534  $ilUser->setInstantMessengerId('icq',ilUtil::stripSlashes($_POST["usr_im_icq"]));
535  $ilUser->setInstantMessengerId('yahoo',ilUtil::stripSlashes($_POST["usr_im_yahoo"]));
536  $ilUser->setInstantMessengerId('msn',ilUtil::stripSlashes($_POST["usr_im_msn"]));
537  $ilUser->setInstantMessengerId('aim',ilUtil::stripSlashes($_POST["usr_im_aim"]));
538  $ilUser->setInstantMessengerId('skype',ilUtil::stripSlashes($_POST["usr_im_skype"]));
539  $ilUser->setInstantMessengerId('jabber',ilUtil::stripSlashes($_POST["usr_im_jabber"]));
540  $ilUser->setInstantMessengerId('voip',ilUtil::stripSlashes($_POST["usr_im_voip"]));
541  }
542 
543  // Set user defined data
544  $ilUser->setUserDefinedData($_POST['udf']);
545 
546  // everthing's ok. save form data
547  if ($form_valid)
548  {
549  // init reload var. page should only be reloaded if skin or style were changed
550  $reload = false;
551 
552  if ($this->workWithUserSetting("skin_style"))
553  {
554  //set user skin and style
555  if ($_POST["usr_skin_style"] != "")
556  {
557  $sknst = explode(":", $_POST["usr_skin_style"]);
558 
559  if ($ilUser->getPref("style") != $sknst[1] ||
560  $ilUser->getPref("skin") != $sknst[0])
561  {
562  $ilUser->setPref("skin", $sknst[0]);
563  $ilUser->setPref("style", $sknst[1]);
564  $reload = true;
565  }
566  }
567  }
568 
569  if ($this->workWithUserSetting("language"))
570  {
571  // reload page if language was changed
572  //if ($_POST["usr_language"] != "" and $_POST["usr_language"] != $_SESSION['lang'])
573  // (this didn't work as expected, alex)
574  if ($_POST["usr_language"] != $ilUser->getLanguage())
575  {
576  $reload = true;
577  }
578 
579  // set user language
580  $ilUser->setLanguage($_POST["usr_language"]);
581 
582  }
583  if ($this->workWithUserSetting("hits_per_page"))
584  {
585  // set user hits per page
586  if ($_POST["hits_per_page"] != "")
587  {
588  $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
589  }
590  }
591 
592  // set show users online
593  if ($this->workWithUserSetting("show_users_online"))
594  {
595  $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
596  }
597 
598  // set hide own online_status
599  if ($this->workWithUserSetting("hide_own_online_status"))
600  {
601  if ($_POST["chk_hide_own_online_status"] != "")
602  {
603  $ilUser->setPref("hide_own_online_status","y");
604  }
605  else
606  {
607  $ilUser->setPref("hide_own_online_status","n");
608  }
609  }
610 
611  // personal desktop items in news block
612 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
613  if ($_POST["pd_items_news"] != "")
614  {
615  $ilUser->setPref("pd_items_news","y");
616  }
617  else
618  {
619  $ilUser->setPref("pd_items_news","n");
620  }
621 */
622 
623  // profile ok
624  $ilUser->setProfileIncomplete(false);
625 
626  // save user data & object_data
627  $ilUser->setTitle($ilUser->getFullname());
628  $ilUser->setDescription($ilUser->getEmail());
629 
630  $ilUser->update();
631 
632  // reload page only if skin or style were changed
633  // feedback
634  if (!empty($this->password_error))
635  {
636  ilUtil::sendFailure($this->password_error,true);
637  }
638  elseif (!empty($this->upload_error))
639  {
640  ilUtil::sendFailure($this->upload_error,true);
641  }
642  else if ($reload)
643  {
644  // feedback
645  ilUtil::sendSuccess($this->lng->txt("saved_successfully"),true);
646  $this->ctrl->redirect($this, "");
647  //$this->tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./start.php\";\n</script>\n");
648  }
649  else
650  {
651  ilUtil::sendSuccess($this->lng->txt("saved_successfully"),true);
652  }
653  }
654 
655  $this->showProfile();
656  }
657 
663  function showProfile()
664  {
665  $this->showPersonalData();
666  }
667 
675  public function saveMailOptions()
676  {
677  global $ilUser, $lng, $ilTabs, $ilSetting;
678 
679  $lng->loadLanguageModule('mail');
680 
681  $this->__initSubTabs('showMailOptions');
682  $ilTabs->setSubTabActive('mail_settings');
683 
684  //$this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
685  // $lng->txt('personal_desktop'));
686  $this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
687  "");
688  $this->tpl->setTitle($lng->txt('personal_desktop'));
689 
690  require_once 'Services/Mail/classes/class.ilMailOptions.php';
691  $mailOptions = new ilMailOptions($ilUser->getId());
692  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1' &&
693  $ilSetting->get('usr_settings_disable_mail_incoming_mail') != '1')
694  {
695  $incoming_type = (int)$_POST['incoming_type'];
696  }
697  else
698  {
699  $incoming_type = $mailOptions->getIncomingType();
700  }
701 
702  $this->initMailOptionsForm();
703  if($this->form->checkInput())
704  {
705  $mailOptions->updateOptions(
706  ilUtil::stripSlashes($_POST['signature']),
707  (int)$_POST['linebreak'],
708  $incoming_type,
709  (int)$_POST['cronjob_notification']
710  );
711 
712  ilUtil::sendSuccess($lng->txt('mail_options_saved'));
713  }
714 
715  if(!isset($_POST['incoming_type']))
716  {
717  $_POST['incoming_type'] = $mailOptions->getIncomingType();
718  }
719 
720  $this->form->setValuesByPost();
721 
722  $this->tpl->setContent($this->form->getHTML());
723  $this->tpl->show();
724  }
725 
732  private function initMailOptionsForm()
733  {
734  global $ilCtrl, $ilSetting, $lng, $ilUser;
735 
736  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
737  $this->form = new ilPropertyFormGUI();
738 
739  $this->form->setFormAction($ilCtrl->getFormAction($this, 'saveMailOptions'));
740  $this->form->setTitle($lng->txt('mail_settings'));
741 
742  // BEGIN INCOMING
743  include_once 'Services/Mail/classes/class.ilMailOptions.php';
744  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1')
745  {
746  $options = array(
747  IL_MAIL_LOCAL => $this->lng->txt('mail_incoming_local'),
748  IL_MAIL_EMAIL => $this->lng->txt('mail_incoming_smtp'),
749  IL_MAIL_BOTH => $this->lng->txt('mail_incoming_both')
750  );
751  $si = new ilSelectInputGUI($lng->txt('mail_incoming'), 'incoming_type');
752  $si->setOptions($options);
753  if(!strlen(ilObjUser::_lookupEmail($ilUser->getId())) ||
754  $ilSetting->get('usr_settings_disable_mail_incoming_mail') == '1')
755  {
756  $si->setDisabled(true);
757  }
758  $this->form->addItem($si);
759  }
760 
761  // BEGIN LINEBREAK_OPTIONS
762  $options = array();
763  for($i = 50; $i <= 80; $i++)
764  {
765  $options[$i] = $i;
766  }
767  $si = new ilSelectInputGUI($lng->txt('linebreak'), 'linebreak');
768  $si->setOptions($options);
769  $this->form->addItem($si);
770 
771  // BEGIN SIGNATURE
772  $ta = new ilTextAreaInputGUI($lng->txt('signature'), 'signature');
773  $ta->setRows(10);
774  $ta->setCols(60);
775  $this->form->addItem($ta);
776 
777  // BEGIN CRONJOB NOTIFICATION
778  if($ilSetting->get('mail_notification'))
779  {
780  $cb = new ilCheckboxInputGUI($lng->txt('cron_mail_notification'), 'cronjob_notification');
781  $cb->setInfo($lng->txt('mail_cronjob_notification_info'));
782  $cb->setValue(1);
783  $this->form->addItem($cb);
784  }
785 
786  $this->form->addCommandButton('saveMailOptions', $lng->txt('save'));
787  }
788 
795  private function setMailOptionsValuesByDB()
796  {
797  global $ilUser, $ilSetting;
798 
799  require_once 'Services/Mail/classes/class.ilMailOptions.php';
800  $mailOptions = new ilMailOptions($ilUser->getId());
801 
802  $data = array(
803  'linebreak' => $mailOptions->getLinebreak(),
804  'signature' => $mailOptions->getSignature(),
805  'cronjob_notification' => $mailOptions->getCronjobNotification()
806  );
807 
808  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1')
809  {
810  $data['incoming_type'] = $mailOptions->getIncomingType();
811  }
812 
813  $this->form->setValuesByArray($data);
814  }
815 
822  public function showMailOptions()
823  {
824  global $ilTabs, $lng;
825 
826  $lng->loadLanguageModule('mail');
827 
828  $this->__initSubTabs('showMailOptions');
829  $ilTabs->setSubTabActive('mail_settings');
830 
831  //$this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
832  // $lng->txt('personal_desktop'));
833  $this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
834  "");
835  $this->tpl->setTitle($lng->txt('personal_desktop'));
836 
837  $this->initMailOptionsForm();
838  $this->setMailOptionsValuesByDB();
839 
840  $this->tpl->setContent($this->form->getHTML());
841  $this->tpl->show();
842  }
843 
844  function showjsMath()
845  {
846  global $lng, $ilCtrl, $tpl, $ilUser;
847 
848  $this->__initSubTabs("showjsMath");
849  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
850  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), "");
851  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
852 
853  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
854  $form = new ilPropertyFormGUI();
855  $form->setFormAction($ilCtrl->getFormAction($this));
856  $form->setTitle($lng->txt("jsmath_settings"));
857 
858  // Enable jsMath
859  include_once "./Services/Administration/classes/class.ilSetting.php";
860  $jsMathSetting = new ilSetting("jsMath");
861  $enable = new ilCheckboxInputGUI($lng->txt("jsmath_enable_user"), "enable");
862  $checked = ($ilUser->getPref("js_math") === FALSE) ? $jsMathSetting->get("makedefault") : $ilUser->getPref("js_math");
863  $enable->setChecked($checked);
864  $enable->setInfo($lng->txt("jsmath_enable_user_desc"));
865  $form->addItem($enable);
866 
867  $form->addCommandButton("savejsMath", $lng->txt("save"));
868  $form->addCommandButton("showjsMath", $lng->txt("cancel"));
869 
870  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
871  $this->tpl->show();
872  }
873 
874  function savejsMath()
875  {
876  global $ilCtrl, $ilUser;
877 
878  include_once "./Services/Administration/classes/class.ilSetting.php";
879  $jsMathSetting = new ilSetting("jsMath");
880  if ($jsMathSetting->get("enable"))
881  {
882  if ($_POST["enable"])
883  {
884  $ilUser->writePref("js_math", "1");
885  }
886  else
887  {
888  $ilUser->writePref("js_math", "0");
889  }
890  }
891  $ilCtrl->redirect($this, "showjsMath");
892  }
893 
894  function showLocation()
895  {
896  global $ilUser, $ilCtrl, $ilUser, $lng;
897 
898  $lng->loadLanguageModule("gmaps");
899 
900  // check google map activation
901  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
903  {
904  return;
905  }
906 
907  $this->__initSubTabs("showLocation");
908 
909  $latitude = $ilUser->getLatitude();
910  $longitude = $ilUser->getLongitude();
911  $zoom = $ilUser->getLocationZoom();
912 
913  // Get Default settings, when nothing is set
914  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
915  {
917  $latitude = $def["latitude"];
918  $longitude = $def["longitude"];
919  $zoom = $def["zoom"];
920  }
921 
922  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
923  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), "");
924  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
925 
926  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
927  $form = new ilPropertyFormGUI();
928  $form->setFormAction($ilCtrl->getFormAction($this));
929 
930  $form->setTitle($this->lng->txt("location")." ".
931  strtolower($this->lng->txt("of"))." ".$ilUser->getFullname());
932 
933  // public profile
934  $public = new ilCheckboxInputGUI($this->lng->txt("public_profile"),
935  "public_location");
936  $public->setValue("y");
937  $public->setInfo($this->lng->txt("gmaps_public_profile_info"));
938  $public->setChecked($ilUser->getPref("public_location"));
939  $form->addItem($public);
940 
941  // location property
942  $loc_prop = new ilLocationInputGUI($this->lng->txt("location"),
943  "location");
944  $loc_prop->setLatitude($latitude);
945  $loc_prop->setLongitude($longitude);
946  $loc_prop->setZoom($zoom);
947 
948  $street = $ilUser->getStreet();
949  if (!$street)
950  {
951  $street = $this->lng->txt("street");
952  }
953 
954  $city = $ilUser->getCity();
955  if (!$city)
956  {
957  $city = $this->lng->txt("city");
958  }
959 
960  $country = $ilUser->getCountry();
961  if (!$country)
962  {
963  $country = $this->lng->txt("country");
964  }
965 
966  $loc_prop->setAddress($street.",".$city.",".$country);
967 
968  $form->addItem($loc_prop);
969 
970  $form->addCommandButton("saveLocation", $this->lng->txt("save"));
971 
972  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
973  $this->tpl->show();
974  }
975 
976  function saveLocation()
977  {
978  global $ilCtrl, $ilUser, $lng;
979 
980  $ilUser->writePref("public_location", $_POST["public_location"]);
981 
982  $ilUser->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
983  $ilUser->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
984  $ilUser->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
985  $ilUser->update();
986  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
987 
988  $ilCtrl->redirect($this, "showLocation");
989  }
990 
991  // init sub tabs
992  function __initSubTabs($a_cmd)
993  {
994  global $ilTabs, $ilSetting;
995 
996  $showProfile = ($a_cmd == 'showProfile') ? true : false;
997  $showPersonalData = ($a_cmd == 'showPersonalData') ? true : false;
998  $showPublicProfile = ($a_cmd == 'showPublicProfile') ? true : false;
999  $showPassword = ($a_cmd == 'showPassword') ? true : false;
1000  $showGeneralSettings = ($a_cmd == 'showGeneralSettings') ? true : false;
1001  $showMailOptions = ($a_cmd == 'showMailOptions') ? true : false;
1002  $showLocation = ($a_cmd == 'showLocation') ? true : false;
1003  $showjsMath = ($a_cmd == 'showjsMath') ? true : false;
1004  $showChatOptions = ($a_cmd == 'showChatOptions') ? true : false;
1005 
1006  // old profile
1007 /*
1008  $ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showProfile"),
1009  "", "", "", $showProfile);
1010 */
1011 
1012  // personal data
1013  $ilTabs->addSubTabTarget("personal_data", $this->ctrl->getLinkTarget($this, "showPersonalData"));
1014 
1015  // public profile
1016  $ilTabs->addSubTabTarget("public_profile", $this->ctrl->getLinkTarget($this, "showPublicProfile"));
1017 
1018  if ($ilSetting->get('user_ext_profiles'))
1019  {
1020  $ilTabs->addSubTabTarget("user_ext_profile",
1021  $this->ctrl->getLinkTarget($this, "showExtendedProfile"));
1022  }
1023 
1024  // password
1025  if ($this->allowPasswordChange())
1026  {
1027  $ilTabs->addSubTabTarget("password", $this->ctrl->getLinkTarget($this, "showPassword"),
1028  "", "", "", $showPassword);
1029  }
1030 
1031  // general settings
1032  $ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
1033  "", "", "", $showGeneralSettings);
1034 
1035 
1036  // check google map activation
1037  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1039  {
1040  $ilTabs->addSubTabTarget("location", $this->ctrl->getLinkTarget($this, "showLocation"),
1041  "", "", "", $showLocation);
1042  }
1043 
1044  $ilTabs->addSubTabTarget("mail_settings", $this->ctrl->getLinkTarget($this, "showMailOptions"),
1045  "", "", "", $showMailOptions);
1046 
1047  include_once "./Services/Administration/classes/class.ilSetting.php";
1048  $jsMathSetting = new ilSetting("jsMath");
1049  if ($jsMathSetting->get("enable"))
1050  {
1051  $ilTabs->addSubTabTarget("jsmath_extt_jsmath", $this->ctrl->getLinkTarget($this, "showjsMath"),
1052  "", "", "", $showjsMath);
1053  }
1054  }
1055 
1056 
1058  {
1059  $d_set = new ilSetting("delicous");
1060  if($this->userSettingVisible("matriculation") or count($this->user_defined_fields->getVisibleDefinitions())
1061  or $d_set->get("user_profile") == "1")
1062  {
1063  return true;
1064  }
1065  return false;
1066  }
1067 
1069  {
1070  global $ilUser;
1071 
1072  $user_defined_data = $ilUser->getUserDefinedData();
1073  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1074  {
1075  if($definition['field_type'] == UDF_TYPE_TEXT)
1076  {
1077  $this->tpl->setCurrentBlock("field_text");
1078  $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($user_defined_data[$field_id]));
1079  if(!$definition['changeable'])
1080  {
1081  $this->tpl->setVariable("DISABLED_FIELD",'disabled=\"disabled\"');
1082  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1083  }
1084  else
1085  {
1086  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1087  }
1088  $this->tpl->parseCurrentBlock();
1089  }
1090  else
1091  {
1092  if($definition['changeable'])
1093  {
1094  $name = 'udf['.$definition['field_id'].']';
1095  $disabled = false;
1096  }
1097  else
1098  {
1099  $name = '';
1100  $disabled = true;
1101  }
1102  $this->tpl->setCurrentBlock("field_select");
1103  $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($user_defined_data[$field_id],
1104  $name,
1105  $this->user_defined_fields->fieldValuesToSelectArray(
1106  $definition['field_values']),
1107  false,
1108  true,0,'','',$disabled));
1109  $this->tpl->parseCurrentBlock();
1110  }
1111  $this->tpl->setCurrentBlock("user_defined");
1112 
1113  if($definition['required'])
1114  {
1115  $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
1116  }
1117  else
1118  {
1119  $name = $definition['field_name'];
1120  }
1121  $this->tpl->setVariable("TXT_FIELD_NAME",$name);
1122  $this->tpl->parseCurrentBlock();
1123  }
1124  return true;
1125  }
1126 
1128  {
1129  foreach($this->user_defined_fields->getVisibleDefinitions() as $definition)
1130  {
1131  $field_id = $definition['field_id'];
1132  if($definition['required'] and !strlen($_POST['udf'][$field_id]))
1133  {
1134  return false;
1135  }
1136  }
1137  return true;
1138  }
1139 
1140 
1141  //
1142  //
1143  // PERSONAL DATA FORM
1144  //
1145  //
1146 
1150  function showPersonalData($a_no_init = false)
1151  {
1152  global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting, $ilTabs;
1153  $this->__initSubTabs("showPersonalData");
1154  $ilTabs->setSubTabActive("personal_data");
1155 
1156  $settings = $ilias->getAllSettings();
1157 
1158  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
1159 
1160 
1161  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1162  // $this->lng->txt("personal_desktop"));
1163  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1164  "");
1165  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1166 
1167  if (!$a_no_init)
1168  {
1169  $this->initPersonalDataForm();
1170  // catch feedback message
1171  if ($ilUser->getProfileIncomplete())
1172  {
1173  ilUtil::sendInfo($lng->txt("profile_incomplete"));
1174  }
1175  }
1176  $this->tpl->setContent($this->form->getHTML());
1177 
1178  $this->tpl->show();
1179  }
1180 
1185  {
1186  global $ilSetting, $lng, $ilUser, $styleDefinition, $rbacreview;
1187 
1188  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1189  $this->form = new ilPropertyFormGUI();
1190  $this->form->setFormAction($this->ctrl->getFormAction($this));
1191 
1192  // user defined fields
1193  $user_defined_data = $ilUser->getUserDefinedData();
1194 
1195  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1196  {
1197  if($definition['field_type'] == UDF_TYPE_TEXT)
1198  {
1199  $this->input["udf_".$definition['field_id']] =
1200  new ilTextInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1201  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
1202  $this->input["udf_".$definition['field_id']]->setMaxLength(255);
1203  $this->input["udf_".$definition['field_id']]->setSize(40);
1204  }
1205  else if($definition['field_type'] == UDF_TYPE_WYSIWYG)
1206  {
1207  $this->input["udf_".$definition['field_id']] =
1208  new ilTextAreaInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1209  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
1210  $this->input["udf_".$definition['field_id']]->setUseRte(true);
1211  }
1212  else
1213  {
1214  $this->input["udf_".$definition['field_id']] =
1215  new ilSelectInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1216  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
1217  $this->input["udf_".$definition['field_id']]->setOptions(
1218  $this->user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
1219  }
1220  if(!$definition['changeable'])
1221  {
1222  $this->input["udf_".$definition['field_id']]->setDisabled(true);
1223  }
1224  if($definition['required'])
1225  {
1226  $this->input["udf_".$definition['field_id']]->setRequired(true);
1227  }
1228  }
1229 
1230  // standard fields
1231  include_once("./Services/User/classes/class.ilUserProfile.php");
1232  $up = new ilUserProfile();
1233  $up->skipField("password");
1234  $up->skipGroup("settings");
1235  $up->skipGroup("preferences");
1236 
1237  // standard fields
1238  $up->addStandardFieldsToForm($this->form, $ilUser, $this->input);
1239 
1240  $this->form->addCommandButton("savePersonalData", $lng->txt("save"));
1241 
1242  }
1243 
1248  public function savePersonalData()
1249  {
1250  global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting, $ilAuth;
1251 
1252  $this->initPersonalDataForm();
1253  if ($this->form->checkInput())
1254  {
1255  $form_valid = true;
1256 
1257  // if form field name differs from setter
1258  $map = array(
1259  "firstname" => "FirstName",
1260  "lastname" => "LastName",
1261  "title" => "UTitle",
1262  "sel_country" => "SelectedCountry",
1263  "phone_office" => "PhoneOffice",
1264  "phone_home" => "PhoneHome",
1265  "phone_mobile" => "PhoneMobile",
1266  "referral_comment" => "Comment"
1267  );
1268  include_once("./Services/User/classes/class.ilUserProfile.php");
1269  $up = new ilUserProfile();
1270  foreach($up->getStandardFields() as $f => $p)
1271  {
1272  $ilUser->setFirstName($_POST["usr_firstname"]);
1273  }
1274  if ($this->workWithUserSetting("lastname"))
1275  {
1276  $ilUser->setLastName($_POST["usr_lastname"]);
1277  }
1278  if ($this->workWithUserSetting("gender"))
1279  {
1280  $ilUser->setGender($_POST["usr_gender"]);
1281  }
1282  if ($this->workWithUserSetting("title"))
1283  {
1284  $ilUser->setUTitle($_POST["usr_title"]);
1285  }
1286  if ($this->workWithUserSetting("birthday"))
1287  {
1288  if (is_array($_POST['usr_birthday']))
1289  {
1290  if (is_array($_POST['usr_birthday']['date']))
1291  {
1292  if (($_POST['usr_birthday']['d'] > 0) && ($_POST['usr_birthday']['m'] > 0) && ($_POST['usr_birthday']['y'] > 0))
1293  {
1294  $ilUser->setBirthday(sprintf("%04d-%02d-%02d", $_POST['user_birthday']['y'], $_POST['user_birthday']['m'], $_POST['user_birthday']['d']));
1295  }
1296  else
1297  {
1298  $ilUser->setBirthday("");
1299  }
1300  }
1301  else
1302  {
1303  $ilUser->setBirthday($_POST['usr_birthday']['date']);
1304  }
1305  }
1306  }
1307  $ilUser->setFullname();
1308  if ($this->workWithUserSetting("institution"))
1309  {
1310  $ilUser->setInstitution($_POST["usr_institution"]);
1311  }
1312  if ($this->workWithUserSetting("department"))
1313  {
1314  $ilUser->setDepartment($_POST["usr_department"]);
1315  }
1316  if ($this->workWithUserSetting("street"))
1317  {
1318  $ilUser->setStreet($_POST["usr_street"]);
1319  }
1320  if ($this->workWithUserSetting("zipcode"))
1321  {
1322  $ilUser->setZipcode($_POST["usr_zipcode"]);
1323  }
1324  if ($this->workWithUserSetting("city"))
1325  {
1326  $ilUser->setCity($_POST["usr_city"]);
1327  }
1328  if ($this->workWithUserSetting("country"))
1329  {
1330  $ilUser->setCountry($_POST["usr_country"]);
1331  }
1332  if ($this->workWithUserSetting("sel_country"))
1333  {
1334  $ilUser->setSelectedCountry($_POST["usr_sel_country"]);
1335  }
1336  if ($this->workWithUserSetting("phone_office"))
1337  {
1338  $ilUser->setPhoneOffice($_POST["usr_phone_office"]);
1339  }
1340  if ($this->workWithUserSetting("phone_home"))
1341  {
1342  $ilUser->setPhoneHome($_POST["usr_phone_home"]);
1343  }
1344  if ($this->workWithUserSetting("phone_mobile"))
1345  {
1346  $ilUser->setPhoneMobile($_POST["usr_phone_mobile"]);
1347  }
1348  if ($this->workWithUserSetting("fax"))
1349  {
1350  $ilUser->setFax($_POST["usr_fax"]);
1351  }
1352  if ($this->workWithUserSetting("email"))
1353  {
1354  $ilUser->setEmail($_POST["usr_email"]);
1355  }
1356  if ($this->workWithUserSetting("hobby"))
1357  {
1358  $ilUser->setHobby($_POST["usr_hobby"]);
1359  }
1360  if ($this->workWithUserSetting("referral_comment"))
1361  {
1362  $ilUser->setComment($_POST["usr_referral_comment"]);
1363  }
1364  if ($this->workWithUserSetting("matriculation"))
1365  {
1366  $ilUser->setMatriculation($_POST["usr_matriculation"]);
1367  }
1368  if ($this->workWithUserSetting("delicious"))
1369  {
1370  $ilUser->setDelicious($_POST["usr_delicious"]);
1371  }
1372 
1373  // delicious
1374  $d_set = new ilSetting("delicious");
1375  if ($d_set->get("user_profile"))
1376  {
1377  $ilUser->setDelicious($_POST["usr_delicious"]);
1378  }
1379 
1380  // set instant messengers
1381  if ($this->workWithUserSetting("instant_messengers"))
1382  {
1383  $ilUser->setInstantMessengerId('icq',$_POST["usr_im_icq"]);
1384  $ilUser->setInstantMessengerId('yahoo',$_POST["usr_im_yahoo"]);
1385  $ilUser->setInstantMessengerId('msn',$_POST["usr_im_msn"]);
1386  $ilUser->setInstantMessengerId('aim',$_POST["usr_im_aim"]);
1387  $ilUser->setInstantMessengerId('skype',$_POST["usr_im_skype"]);
1388  $ilUser->setInstantMessengerId('jabber',$_POST["usr_im_jabber"]);
1389  $ilUser->setInstantMessengerId('voip',$_POST["usr_im_voip"]);
1390  }
1391 
1392  // Set user defined data
1393  $defs = $this->user_defined_fields->getVisibleDefinitions();
1394  $udf = array();
1395  foreach ($defs as $definition)
1396  {
1397  $f = "udf_".$definition['field_id'];
1398  $item = $this->form->getItemByPostVar($f);
1399  if ($item && !$item->getDisabled())
1400  {
1401  $udf[$definition['field_id']] = $this->form->getInput($f);
1402  }
1403  }
1404  $ilUser->setUserDefinedData($udf);
1405 
1406  // if loginname is changeable -> validate
1407  $un = $this->form->getInput('username');
1408  if((int)$ilSetting->get('allow_change_loginname') &&
1409  $un != $ilUser->getLogin())
1410  {
1411  if(!strlen($un) || !ilUtil::isLogin($un))
1412  {
1413  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
1414  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('login_invalid'));
1415  $form_valid = false;
1416  }
1417  else if(ilObjUser::_loginExists($un, $ilUser->getId()))
1418  {
1419  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
1420  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('loginname_already_exists'));
1421  $form_valid = false;
1422  }
1423  else
1424  {
1425  $ilUser->setLogin($un);
1426 
1427  try
1428  {
1429  $ilUser->updateLogin($ilUser->getLogin());
1430  $ilAuth->setAuth($ilUser->getLogin());
1431  $ilAuth->start();
1432  }
1433  catch (ilUserException $e)
1434  {
1435  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
1436  $this->form->getItemByPostVar('username')->setAlert($e->getMessage());
1437  $form_valid = false;
1438  }
1439  }
1440  }
1441 
1442  // everthing's ok. save form data
1443  if ($form_valid)
1444  {
1445  $this->uploadUserPicture();
1446 
1447  // profile ok
1448  $ilUser->setProfileIncomplete(false);
1449 
1450  // save user data & object_data
1451  $ilUser->setTitle($ilUser->getFullname());
1452  $ilUser->setDescription($ilUser->getEmail());
1453 
1454  $ilUser->update();
1455 
1456  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1457  if ($redirect = $_SESSION['profile_complete_redirect']) {
1458  unset($_SESSION['profile_complete_redirect']);
1460  }
1461  else
1462  $ilCtrl->redirect($this, "showPersonalData");
1463  }
1464  }
1465 
1466  $this->form->setValuesByPost();
1467  $this->showPersonalData(true);
1468  }
1469 
1470  //
1471  //
1472  // PUBLIC PROFILE FORM
1473  //
1474  //
1475 
1479  function showPublicProfile($a_no_init = false)
1480  {
1481  global $ilUser, $lng, $ilSetting, $ilTabs;
1482 
1483  $this->__initSubTabs("showPersonalData");
1484  $ilTabs->setSubTabActive("public_profile");
1485 
1486  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1487  // $this->lng->txt("personal_desktop"));
1488  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1489  "");
1490  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1491 
1492  if (!$a_no_init)
1493  {
1494  $this->initPublicProfileForm();
1495  }
1496 
1497  $ptpl = new ilTemplate("tpl.edit_personal_profile.html", true, true, "Services/User");
1498  $ptpl->setVariable("FORM", $this->form->getHTML());
1499  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
1500  $pub_profile = new ilPublicUserProfileGUI($ilUser->getId());
1501  $ptpl->setVariable("PREVIEW", $pub_profile->getHTML(true));
1502  $this->tpl->setContent($ptpl->get());
1503  $this->tpl->show();
1504  }
1505 
1511  public function initPublicProfileForm()
1512  {
1513  global $lng, $ilUser, $ilSetting;
1514 
1515  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1516  $this->form = new ilPropertyFormGUI();
1517 
1518  // Activate public profile
1519  $radg = new ilRadioGroupInputGUI($lng->txt("user_activate_public_profile"), "public_profile");
1520  $radg->setInfo($this->lng->txt("user_activate_public_profile_info"));
1521  $pub_prof = in_array($ilUser->prefs["public_profile"], array("y", "n", "g"))
1522  ? $ilUser->prefs["public_profile"]
1523  : "n";
1524  if (!$ilSetting->get('enable_global_profiles') && $pub_prof == "g")
1525  {
1526  $pub_prof = "y";
1527  }
1528  $radg->setValue($pub_prof);
1529  $op1 = new ilRadioOption($lng->txt("usr_public_profile_disabled"), "n",$lng->txt("usr_public_profile_disabled_info"));
1530  $radg->addOption($op1);
1531  $op2 = new ilRadioOption($lng->txt("usr_public_profile_logged_in"), "y",$lng->txt("usr_public_profile_logged_in_info"));
1532  $radg->addOption($op2);
1533  if ($ilSetting->get('enable_global_profiles'))
1534  {
1535  $op3 = new ilRadioOption($lng->txt("usr_public_profile_global"), "g",$lng->txt("usr_public_profile_global_info"));
1536  $radg->addOption($op3);
1537  }
1538  $this->form->addItem($radg);
1539  /*$cb = new ilCheckboxInputGUI($this->lng->txt("user_activate_public_profile"), "public_profile");
1540 
1541  if ($ilUser->prefs["public_profile"] == "y")
1542  {
1543  $cb->setChecked(true);
1544  }
1545  $this->form->addItem($cb);*/
1546 
1547  $birthday = $ilUser->getBirthday();
1548  if($birthday)
1549  {
1550  $birthday = ilDatePresentation::formatDate(new ilDate($birthday, IL_CAL_DATE));
1551  }
1552  $gender = $ilUser->getGender();
1553  if($gender)
1554  {
1555  $gender = $lng->txt("gender_".$gender);
1556  }
1557 
1558  if ($ilUser->getSelectedCountry() != "")
1559  {
1560  $lng->loadLanguageModule("meta");
1561  $txt_sel_country = $lng->txt("meta_c_".$ilUser->getSelectedCountry());
1562  }
1563 
1564  // personal data
1565  $val_array = array(
1566  "title" => $ilUser->getUTitle(),
1567  "birthday" => $birthday,
1568  "gender" => $gender,
1569  "institution" => $ilUser->getInstitution(),
1570  "department" => $ilUser->getDepartment(),
1571  "upload" => "",
1572  "street" => $ilUser->getStreet(),
1573  "zipcode" => $ilUser->getZipcode(),
1574  "city" => $ilUser->getCity(),
1575  "country" => $ilUser->getCountry(),
1576  "sel_country" => $txt_sel_country,
1577  "phone_office" => $ilUser->getPhoneOffice(),
1578  "phone_home" => $ilUser->getPhoneHome(),
1579  "phone_mobile" => $ilUser->getPhoneMobile(),
1580  "fax" => $ilUser->getFax(),
1581  "email" => $ilUser->getEmail(),
1582  "hobby" => $ilUser->getHobby(),
1583  "matriculation" => $ilUser->getMatriculation(),
1584  "delicious" => $ilUser->getDelicious()
1585  );
1586  foreach($val_array as $key => $value)
1587  {
1588  if ($this->userSettingVisible($key))
1589  {
1590  // public setting
1591  if ($key == "upload")
1592  {
1593  $cb = new ilCheckboxInputGUI($this->lng->txt("personal_picture"), "chk_".$key);
1594  }
1595  else
1596  {
1597  $cb = new ilCheckboxInputGUI($this->lng->txt($key), "chk_".$key);
1598  }
1599  if ($ilUser->prefs["public_".$key] == "y")
1600  {
1601  $cb->setChecked(true);
1602  }
1603  //$cb->setInfo($value);
1604  $cb->setOptionTitle($value);
1605  $this->form->addItem($cb);
1606  }
1607  }
1608 
1609  $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
1610  if ($this->userSettingVisible("instant_messengers"))
1611  {
1612  foreach ($im_arr as $im)
1613  {
1614  // public setting
1615  $cb = new ilCheckboxInputGUI($this->lng->txt("im_".$im), "chk_im_".$im);
1616  //$cb->setInfo($ilUser->getInstantMessengerId($im));
1617  $cb->setOptionTitle($ilUser->getInstantMessengerId($im));
1618  if ($ilUser->prefs["public_im_".$im] != "n")
1619  {
1620  $cb->setChecked(true);
1621  }
1622  $this->form->addItem($cb);
1623  }
1624  }
1625 
1626  // additional defined user data fields
1627  $user_defined_data = $ilUser->getUserDefinedData();
1628  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1629  {
1630  // public setting
1631  $cb = new ilCheckboxInputGUI($definition["field_name"], "chk_udf_".$definition["field_id"]);
1632  $cb->setOptionTitle($user_defined_data["f_".$definition["field_id"]]);
1633  if ($ilUser->prefs["public_udf_".$definition["field_id"]] == "y")
1634  {
1635  $cb->setChecked(true);
1636  }
1637  $this->form->addItem($cb);
1638  }
1639 
1640 
1641  // save and cancel commands
1642  $this->form->addCommandButton("savePublicProfile", $lng->txt("save"));
1643 
1644  $this->form->setTitle($lng->txt("public_profile"));
1645  $this->form->setDescription($lng->txt("user_public_profile_info"));
1646  $this->form->setFormAction($this->ctrl->getFormAction($this));
1647  }
1648 
1653  public function savePublicProfile()
1654  {
1655  global $tpl, $lng, $ilCtrl, $ilUser;
1656 
1657  $this->initPublicProfileForm();
1658  if ($this->form->checkInput())
1659  {
1660  /*if (($_POST["public_profile"]))
1661  {
1662  $ilUser->setPref("public_profile","y");
1663  }
1664  else
1665  {
1666  $ilUser->setPref("public_profile","n");
1667  }*/
1668  $ilUser->setPref("public_profile", $_POST["public_profile"]);
1669 
1670  // if check on Institute
1671  $val_array = array("title", "birthday", "gender", "institution", "department", "upload", "street",
1672  "zipcode", "city", "country", "sel_country", "phone_office", "phone_home", "phone_mobile",
1673  "fax", "email", "hobby", "matriculation");
1674 
1675  // set public profile preferences
1676  foreach($val_array as $key => $value)
1677  {
1678  if (($_POST["chk_".$value]))
1679  {
1680  $ilUser->setPref("public_".$value,"y");
1681  }
1682  else
1683  {
1684  $ilUser->setPref("public_".$value,"n");
1685  }
1686  }
1687 
1688  $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
1689  if ($this->userSettingVisible("instant_messengers"))
1690  {
1691  foreach ($im_arr as $im)
1692  {
1693  if (($_POST["chk_im_".$im]))
1694  {
1695  $ilUser->setPref("public_im_".$im,"y");
1696  }
1697  else
1698  {
1699  $ilUser->setPref("public_im_".$im,"n");
1700  }
1701  }
1702  }
1703 
1704 // $d_set = new ilSetting("delicious");
1705 // if ($d_set->get("user_profile"))
1706 // {
1707  if (($_POST["chk_delicious"]))
1708  {
1709  $ilUser->setPref("public_delicious","y");
1710  }
1711  else
1712  {
1713  $ilUser->setPref("public_delicious","n");
1714  }
1715 // }
1716 
1717  // additional defined user data fields
1718  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1719  {
1720  if (($_POST["chk_udf_".$definition["field_id"]]))
1721  {
1722  $ilUser->setPref("public_udf_".$definition["field_id"], "y");
1723  }
1724  else
1725  {
1726  $ilUser->setPref("public_udf_".$definition["field_id"], "n");
1727  }
1728  }
1729 
1730  $ilUser->update();
1731  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1732  $ilCtrl->redirect($this, "showPublicProfile");
1733  }
1734  $this->form->setValuesByPost();
1735  $tpl->showPublicProfile(true);
1736  }
1737 
1738 
1739  //
1740  //
1741  // PASSWORD FORM
1742  //
1743  //
1744 
1748  function showPassword($a_no_init = false)
1749  {
1750  global $ilTabs;
1751 
1752  $this->__initSubTabs("showPersonalData");
1753  $ilTabs->setSubTabActive("password");
1754 
1755  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1756  // $this->lng->txt("personal_desktop"));
1757  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1758  "");
1759  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1760 
1761  if (!$a_no_init)
1762  {
1763  $this->initPasswordForm();
1764  }
1765  $this->tpl->setContent($this->form->getHTML());
1766  $this->tpl->show();
1767  }
1768 
1774  public function initPasswordForm()
1775  {
1776  global $lng, $ilUser, $ilSetting;
1777 
1778  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1779  $this->form = new ilPropertyFormGUI();
1780 
1781  // Check whether password change is allowed
1782  if ($this->allowPasswordChange())
1783  {
1784  // The current password needs to be checked for verification
1785  // unless the user uses Shibboleth authentication with additional
1786  // local authentication for WebDAV.
1787  //if (
1788  // ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local"))
1789  //)
1790  if($ilUser->getAuthMode(true) == AUTH_LOCAL)
1791  {
1792  // current password
1793  $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
1794  $cpass->setRetype(false);
1795  $cpass->setSkipSyntaxCheck(true);
1796  // only if a password exists.
1797  if($ilUser->getPasswd())
1798  {
1799  $cpass->setRequired(true);
1800  }
1801  $this->form->addItem($cpass);
1802  }
1803 
1804  // new password
1805  $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
1806  $ipass->setRequired(true);
1807  $ipass->setInfo(ilUtil::getPasswordRequirementsInfo());
1808 
1809  if ($ilSetting->get("passwd_auto_generate") == 1) // auto generation list
1810  {
1811  $ipass->setPreSelection(true);
1812 
1813  $this->form->addItem($ipass);
1814  $this->form->addCommandButton("savePassword", $lng->txt("save"));
1815  $this->form->addCommandButton("showPassword", $lng->txt("new_list_password"));
1816  }
1817  else // user enters password
1818  {
1819  $this->form->addItem($ipass);
1820  $this->form->addCommandButton("savePassword", $lng->txt("save"));
1821  }
1822 
1823  switch ($ilUser->getAuthMode(true))
1824  {
1825  case AUTH_LOCAL :
1826  $this->form->setTitle($lng->txt("chg_password"));
1827  break;
1828 
1829  case AUTH_SHIBBOLETH :
1830  case AUTH_CAS:
1831  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1832  if (ilDAVServer::_isActive())
1833  {
1834  $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
1835  }
1836  else
1837  {
1838  $this->form->setTitle($lng->txt("chg_ilias_password"));
1839  }
1840  break;
1841  default :
1842  $this->form->setTitle($lng->txt("chg_ilias_password"));
1843  break;
1844  }
1845  $this->form->setFormAction($this->ctrl->getFormAction($this));
1846  }
1847  }
1848 
1853  {
1854  global $ilUser, $ilSetting;
1855 
1856 
1857  return ilAuthUtils::isPasswordModificationEnabled($ilUser->getAuthMode(true));
1858 
1859  // Moved to ilAuthUtils
1860 
1861  // do nothing if auth mode is not local database
1862  if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
1863  ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
1864  ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local")) &&
1865  ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local")) &&
1866  ($ilUser->getAuthMode(true) != AUTH_OPENID)
1867  )
1868  {
1869  return false;
1870  }
1871  if (!$this->userSettingVisible('password') ||
1872  $this->ilias->getSetting('usr_settings_disable_password'))
1873  {
1874  return false;
1875  }
1876  return true;
1877  }
1878 
1883  public function savePassword()
1884  {
1885  global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting;
1886 
1887  // normally we should not end up here
1888  if (!$this->allowPasswordChange())
1889  {
1890  $ilCtrl->redirect($this, "showPersonalData");
1891  return;
1892  }
1893 
1894  $this->initPasswordForm();
1895  if ($this->form->checkInput())
1896  {
1897  $cp = $this->form->getItemByPostVar("current_password");
1898  $np = $this->form->getItemByPostVar("new_password");
1899  $error = false;
1900 
1901  // The old password needs to be checked for verification
1902  // unless the user uses Shibboleth authentication with additional
1903  // local authentication for WebDAV.
1904  #if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
1905  if($ilUser->getAuthMode(true) == AUTH_LOCAL)
1906  {
1907  // check current password
1908  if (md5($_POST["current_password"]) != $ilUser->getPasswd() and
1909  $ilUser->getPasswd())
1910  {
1911  $error = true;
1912  $cp->setAlert($this->lng->txt("passwd_wrong"));
1913  }
1914  }
1915 
1916  // select password from auto generated passwords
1917  if ($this->ilias->getSetting("passwd_auto_generate") == 1 &&
1918  (!ilUtil::isPassword($_POST["new_password"])))
1919  {
1920  $error = true;
1921  $np->setAlert($this->lng->txt("passwd_not_selected"));
1922  }
1923 
1924 
1925  if ($this->ilias->getSetting("passwd_auto_generate") != 1 &&
1926  !ilUtil::isPassword($_POST["new_password"],$custom_error))
1927  {
1928  $error = true;
1929  if ($custom_error != '')
1930  {
1931  $np->setAlert($custom_error);
1932  }
1933  else
1934  {
1935  $np->setAlert($this->lng->txt("passwd_invalid"));
1936  }
1937  }
1938  if ($this->ilias->getSetting("passwd_auto_generate") != 1 &&
1939  ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
1940  ($_POST["current_password"] == $_POST["new_password"]))
1941  {
1942  $error = true;
1943  $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
1944  }
1945 
1946  if (!$error)
1947  {
1948  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
1949  $ilUser->resetPassword($_POST["new_password"], $_POST["new_password"]);
1950  if ($_POST["current_password"] != $_POST["new_password"])
1951  {
1952  $ilUser->setLastPasswordChangeToNow();
1953  }
1954  $ilCtrl->redirect($this, "showPassword");
1955  }
1956  }
1957  $this->form->setValuesByPost();
1958  $this->showPassword(true);
1959  }
1960 
1961  //
1962  //
1963  // GENERAL SETTINGS FORM
1964  //
1965  //
1966 
1970  function showGeneralSettings($a_no_init = false)
1971  {
1972  global $ilTabs;
1973 
1974  $this->__initSubTabs("showPersonalData");
1975  $ilTabs->setSubTabActive("general_settings");
1976 
1977  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1978  // $this->lng->txt("personal_desktop"));
1979  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1980  "");
1981  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1982 
1983  if (!$a_no_init)
1984  {
1985  $this->initGeneralSettingsForm();
1986  }
1987  $this->tpl->setContent($this->form->getHTML());
1988  $this->tpl->show();
1989  }
1990 
1995  public function initGeneralSettingsForm()
1996  {
1997  global $lng, $ilUser, $styleDefinition, $ilSetting;
1998 
1999 
2000  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2001  $this->form = new ilPropertyFormGUI();
2002 
2003  // language
2004  if ($this->userSettingVisible("language"))
2005  {
2006  $languages = $this->lng->getInstalledLanguages();
2007  $options = array();
2008  foreach($languages as $lang_key)
2009  {
2010  $options[$lang_key] = ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key);
2011  }
2012 
2013  $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
2014  $si->setOptions($options);
2015  $si->setValue($ilUser->getLanguage());
2016  $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
2017  $this->form->addItem($si);
2018  }
2019 
2020  // skin/style
2021  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
2022  if ($this->userSettingVisible("skin_style"))
2023  {
2024  $templates = $styleDefinition->getAllTemplates();
2025  if (is_array($templates))
2026  {
2027  $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
2028 
2029  $options = array();
2030  foreach($templates as $template)
2031  {
2032  // get styles information of template
2033  $styleDef = new ilStyleDefinition($template["id"]);
2034  $styleDef->startParsing();
2035  $styles = $styleDef->getStyles();
2036 
2037  foreach($styles as $style)
2038  {
2039  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
2040  {
2041  continue;
2042  }
2043 
2044  $options[$template["id"].":".$style["id"]] =
2045  $styleDef->getTemplateName()." / ".$style["name"];
2046  }
2047  }
2048  $si->setOptions($options);
2049  $si->setValue($ilUser->skin.":".$ilUser->prefs["style"]);
2050  $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
2051  $this->form->addItem($si);
2052  }
2053  }
2054 
2055  // screen reader optimization
2056  if ($this->userSettingVisible("screen_reader_optimization"))
2057  {
2058  $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
2059  $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
2060  $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
2061  $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
2062  $this->form->addItem($cb);
2063  }
2064 
2065  // hits per page
2066  if ($this->userSettingVisible("hits_per_page"))
2067  {
2068  $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
2069 
2070  $hits_options = array(10,15,20,30,40,50,100,9999);
2071  $options = array();
2072 
2073  foreach($hits_options as $hits_option)
2074  {
2075  $hstr = ($hits_option == 9999)
2076  ? $this->lng->txt("no_limit")
2077  : $hits_option;
2078  $options[$hits_option] = $hstr;
2079  }
2080  $si->setOptions($options);
2081  $si->setValue($ilUser->prefs["hits_per_page"]);
2082  $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
2083  $this->form->addItem($si);
2084  }
2085 
2086  // Users Online
2087  if ($this->userSettingVisible("show_users_online"))
2088  {
2089  $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
2090 
2091  $options = array(
2092  "y" => $this->lng->txt("users_online_show_y"),
2093  "associated" => $this->lng->txt("users_online_show_associated"),
2094  "n" => $this->lng->txt("users_online_show_n"));
2095  $si->setOptions($options);
2096  $si->setValue($ilUser->prefs["show_users_online"]);
2097  $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
2098  $this->form->addItem($si);
2099  }
2100 
2101  // hide_own_online_status
2102  if ($this->userSettingVisible("hide_own_online_status"))
2103  {
2104  $cb = new ilCheckboxInputGUI($this->lng->txt("hide_own_online_status"), "hide_own_online_status");
2105  $cb->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
2106  $cb->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
2107  $this->form->addItem($cb);
2108  }
2109 
2110  // session reminder
2111  if((int)$ilSetting->get('session_handling_type') == 0 &&
2112  (int)$ilSetting->get('session_reminder_enabled'))
2113  {
2114  $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
2115  $cb->setInfo($this->lng->txt('session_reminder_info'));
2116  $cb->setValue(1);
2117  $cb->setChecked((int)$ilUser->getPref('session_reminder_enabled'));
2118 
2119  global $ilClientIniFile;
2120 
2121  $lead_time_gui = new ilTextInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
2122  $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilFormat::_secondsToString($ilClientIniFile->readVariable('session', 'expire'))));
2123  $lead_time_gui->setValue($ilUser->getPref('session_reminder_lead_time'));
2124  $lead_time_gui->setMaxLength(10);
2125  $lead_time_gui->setSize(10);
2126  $cb->addSubItem($lead_time_gui);
2127 
2128  $this->form->addItem($cb);
2129  }
2130 
2131 
2132  // calendar settings (copied here to be reachable when calendar is inactive)
2133  // they cannot be hidden/deactivated
2134 
2135  include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
2136  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
2137  $lng->loadLanguageModule("dateplaner");
2138  $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
2139 
2140  $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'),'timezone');
2142  $select->setInfo($lng->txt('cal_timezone_info'));
2143  $select->setValue($user_settings->getTimeZone());
2144  $this->form->addItem($select);
2145 
2146  $year = date("Y");
2147  $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'),'date_format');
2148  $select->setOptions(array(
2149  ilCalendarSettings::DATE_FORMAT_DMY => '31.10.'.$year,
2150  ilCalendarSettings::DATE_FORMAT_YMD => $year."-10-31",
2151  ilCalendarSettings::DATE_FORMAT_MDY => "10/31/".$year));
2152  $select->setInfo($lng->txt('cal_date_format_info'));
2153  $select->setValue($user_settings->getDateFormat());
2154  $this->form->addItem($select);
2155 
2156  $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'),'time_format');
2157  $select->setOptions(array(
2159  ilCalendarSettings::TIME_FORMAT_12 => '1:00pm'));
2160  $select->setInfo($lng->txt('cal_time_format_info'));
2161  $select->setValue($user_settings->getTimeFormat());
2162  $this->form->addItem($select);
2163 
2164 
2165  $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
2166  $this->form->setTitle($lng->txt("general_settings"));
2167  $this->form->setFormAction($this->ctrl->getFormAction($this));
2168 
2169  }
2170 
2175  public function saveGeneralSettings()
2176  {
2177  global $tpl, $lng, $ilCtrl, $ilUser;
2178 
2179  $this->initGeneralSettingsForm();
2180  if ($this->form->checkInput())
2181  {
2182  if ($this->workWithUserSetting("skin_style"))
2183  {
2184  //set user skin and style
2185  if ($_POST["skin_style"] != "")
2186  {
2187  $sknst = explode(":", $_POST["skin_style"]);
2188 
2189  if ($ilUser->getPref("style") != $sknst[1] ||
2190  $ilUser->getPref("skin") != $sknst[0])
2191  {
2192  $ilUser->setPref("skin", $sknst[0]);
2193  $ilUser->setPref("style", $sknst[1]);
2194  }
2195  }
2196  }
2197 
2198  // language
2199  if ($this->workWithUserSetting("language"))
2200  {
2201  $ilUser->setLanguage($_POST["language"]);
2202  }
2203 
2204  // hits per page
2205  if ($this->workWithUserSetting("hits_per_page"))
2206  {
2207  if ($_POST["hits_per_page"] != "")
2208  {
2209  $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
2210  }
2211  }
2212 
2213  // set show users online
2214  if ($this->workWithUserSetting("show_users_online"))
2215  {
2216  $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
2217  }
2218 
2219  // set hide own online_status
2220  if ($this->workWithUserSetting("hide_own_online_status"))
2221  {
2222  if ($_POST["hide_own_online_status"] == 1)
2223  {
2224  $ilUser->setPref("hide_own_online_status","y");
2225  }
2226  else
2227  {
2228  $ilUser->setPref("hide_own_online_status","n");
2229  }
2230  }
2231 
2232  // set show users online
2233  if ($this->workWithUserSetting("screen_reader_optimization"))
2234  {
2235  $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
2236  }
2237 
2238  // session reminder
2239  global $ilSetting;
2240  if((int)$ilSetting->get('session_handling_type') == 0 &&
2241  (int)$ilSetting->get('session_reminder_enabled'))
2242  {
2243  $ilUser->setPref('session_reminder_enabled', (int)$_POST['session_reminder_enabled']);
2244 
2245  if(!preg_match('/^([0]|([1-9][0-9]*))([\.][0-9][0-9]*)?$/', $_POST['session_reminder_lead_time']))
2246  $_POST['session_reminder_lead_time'] = 0;
2247  $ilUser->setPref('session_reminder_lead_time', $_POST['session_reminder_lead_time']);
2248  }
2249 
2250  $ilUser->update();
2251 
2252  // calendar settings
2253  include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
2254  $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
2255  $user_settings->setTimeZone($this->form->getInput("timezone"));
2256  $user_settings->setDateFormat((int)$this->form->getInput("date_format"));
2257  $user_settings->setTimeFormat((int)$this->form->getInput("time_format"));
2258  $user_settings->save();
2259 
2260  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2261  $ilCtrl->redirect($this, "showGeneralSettings");
2262  }
2263 
2264  $this->form->setValuesByPost();
2265  $tpl->showGeneralSettings(true);
2266  }
2267 
2268  //
2269  //
2270  // Extended user profile
2271  //
2272  //
2273 
2281  {
2282  global $tpl, $ilTabs, $ilToolbar, $lng, $ilCtrl;
2283 
2284  $this->initExtProfile();
2285  $ilToolbar->addButton($lng->txt("user_add_page"),
2286  $ilCtrl->getLinkTarget($this, "addProfilePage"));
2287 
2288  include_once("./Services/User/classes/class.ilExtendedProfileTableGUI.php");
2289  $tab = new ilExtendedProfileTableGUI($this, "showExtendedProfile");
2290  $tpl->setContent($tab->getHTML());
2291 
2292  $tpl->show();
2293  }
2294 
2301  function addProfilePage()
2302  {
2303  global $tpl, $ilTabs;
2304 
2305  $this->initExtProfile();
2306  $this->initProfilePageForm("create");
2307  $tpl->setContent($this->form->getHTML());
2308 
2309  $tpl->show();
2310 
2311  }
2312 
2318  public function initProfilePageForm($a_mode = "edit")
2319  {
2320  global $lng, $ilCtrl;
2321 
2322  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2323  $this->form = new ilPropertyFormGUI();
2324 
2325 
2326  // save and cancel commands
2327  if ($a_mode == "create")
2328  {
2329  // title
2330  $ti = new ilTextInputGUI($lng->txt("title"), "title");
2331  $ti->setMaxLength(200);
2332  $ti->setRequired(true);
2333  $this->form->addItem($ti);
2334 
2335  $this->form->addCommandButton("saveProfilePage", $lng->txt("save"));
2336  $this->form->addCommandButton("showExtendedProfile", $lng->txt("cancel"));
2337  $this->form->setTitle($lng->txt("user_new_profile_page"));
2338  }
2339  else
2340  {
2341  $this->form->addCommandButton("updateProfilePage", $lng->txt("save"));
2342  $this->form->addCommandButton("showExtendedProfile", $lng->txt("cancel"));
2343  $this->form->setTitle($lng->txt("user_add_profile_page"));
2344  }
2345 
2346  $this->form->setFormAction($ilCtrl->getFormAction($this));
2347  }
2348 
2352  public function saveProfilePage()
2353  {
2354  global $tpl, $lng, $ilCtrl, $ilUser, $ilTabs;
2355 
2356  $this->initProfilePageForm("create");
2357  if ($this->form->checkInput())
2358  {
2359  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2360  $page = new ilExtPublicProfilePage();
2361  $page->setUserId($ilUser->getId());
2362  $page->setTitle($_POST["title"]);
2363  $page->create();
2364  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2365  $ilCtrl->redirect($this, "showExtendedProfile");
2366  }
2367 
2368  $this->initExtProfile();
2369  $this->form->setValuesByPost();
2370  $tpl->setContent($this->form->getHtml());
2371  $tpl->show();
2372  }
2373 
2377  public function getProfilePageValues()
2378  {
2379  $values = array();
2380 
2381  $values["title"] = "";
2382 
2383  $this->form->setValuesByArray($values);
2384  }
2385 
2389  function initExtProfile()
2390  {
2391  global $ilTabs;
2392 
2393  $this->__initSubTabs("showPersonalData");
2394  $ilTabs->setSubTabActive("user_ext_profile");
2395  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2396  "");
2397  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
2398  }
2399 
2404  {
2405  global $ilCtrl, $tpl, $lng;
2406 
2407  if (!is_array($_POST["user_page"]) || count($_POST["user_page"]) == 0)
2408  {
2409  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2410  $ilCtrl->redirect($this, "showExtendedProfile");
2411  }
2412  else
2413  {
2414  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2415  $cgui = new ilConfirmationGUI();
2416  $cgui->setFormAction($ilCtrl->getFormAction($this));
2417  $cgui->setHeaderText($lng->txt("user_sure_delete_pages"));
2418  $cgui->setCancel($lng->txt("cancel"), "showExtendedProfile");
2419  $cgui->setConfirm($lng->txt("delete"), "deleteProfilePages");
2420 
2421  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2422  foreach ($_POST["user_page"] as $i => $v)
2423  {
2424  $cgui->addItem("user_page[]", $i, ilExtPublicProfilePage::lookupTitle($i));
2425  }
2426 
2427  $this->initExtProfile();
2428  $tpl->setContent($cgui->getHTML());
2429 
2430  $tpl->show();
2431  }
2432  }
2433 
2441  {
2442  global $ilDB, $ilUser, $lng, $ilCtrl;
2443 
2444  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2445  if (is_array($_POST["user_page"]))
2446  {
2447  foreach ($_POST["user_page"] as $i => $v)
2448  {
2450  if ($page->getUserId() == $ilUser->getId())
2451  {
2452  $page->delete();
2453  }
2454  }
2455  ilExtPublicProfilePage::fixOrdering($ilUser->getId());
2456  }
2457  ilUtil::sendSuccess($lng->txt("user_selected_pages_deleted"), true);
2458  $ilCtrl->redirect($this, "showExtendedProfile");
2459  }
2460 
2468  {
2469  global $ilCtrl, $ilUser, $lng;
2470 
2471  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2472 
2473  if (is_array($_POST["title"]))
2474  {
2475  foreach ($_POST["title"] as $k => $v)
2476  {
2478  if ($page->getUserId() == $ilUser->getId())
2479  {
2480  $page->setTitle(ilUtil::stripSlashes($v));
2481  $page->setOrderNr(ilUtil::stripSlashes($_POST["order"][$k]));
2482  $page->update();
2483  }
2484  }
2485  ilExtPublicProfilePage::fixOrdering($ilUser->getId());
2486  }
2487  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2488  $ilCtrl->redirect($this, "showExtendedProfile");
2489  }
2490 }
2491 ?>