ILIAS  Release_4_1_x_branch Revision 61804
 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  if(((int)$ilSetting->get('chat_sound_status') &&
1048  ((int)$ilSetting->get('chat_new_invitation_sound_status') ||
1049  (int)$ilSetting->get('chat_new_message_sound_status'))) ||
1050  (int)$ilSetting->get('chat_message_notify_status') == 1)
1051  {
1052  $ilTabs->addSubTabTarget("chat_settings", $this->ctrl->getLinkTarget($this, "showChatOptions"),
1053  "", "", "", $showChatOptions);
1054  }
1055 
1056  include_once "./Services/Administration/classes/class.ilSetting.php";
1057  $jsMathSetting = new ilSetting("jsMath");
1058  if ($jsMathSetting->get("enable"))
1059  {
1060  $ilTabs->addSubTabTarget("jsmath_extt_jsmath", $this->ctrl->getLinkTarget($this, "showjsMath"),
1061  "", "", "", $showjsMath);
1062  }
1063  }
1064 
1065 
1067  {
1068  $d_set = new ilSetting("delicous");
1069  if($this->userSettingVisible("matriculation") or count($this->user_defined_fields->getVisibleDefinitions())
1070  or $d_set->get("user_profile") == "1")
1071  {
1072  return true;
1073  }
1074  return false;
1075  }
1076 
1078  {
1079  global $ilUser;
1080 
1081  $user_defined_data = $ilUser->getUserDefinedData();
1082  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1083  {
1084  if($definition['field_type'] == UDF_TYPE_TEXT)
1085  {
1086  $this->tpl->setCurrentBlock("field_text");
1087  $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($user_defined_data[$field_id]));
1088  if(!$definition['changeable'])
1089  {
1090  $this->tpl->setVariable("DISABLED_FIELD",'disabled=\"disabled\"');
1091  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1092  }
1093  else
1094  {
1095  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1096  }
1097  $this->tpl->parseCurrentBlock();
1098  }
1099  else
1100  {
1101  if($definition['changeable'])
1102  {
1103  $name = 'udf['.$definition['field_id'].']';
1104  $disabled = false;
1105  }
1106  else
1107  {
1108  $name = '';
1109  $disabled = true;
1110  }
1111  $this->tpl->setCurrentBlock("field_select");
1112  $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($user_defined_data[$field_id],
1113  $name,
1114  $this->user_defined_fields->fieldValuesToSelectArray(
1115  $definition['field_values']),
1116  false,
1117  true,0,'','',$disabled));
1118  $this->tpl->parseCurrentBlock();
1119  }
1120  $this->tpl->setCurrentBlock("user_defined");
1121 
1122  if($definition['required'])
1123  {
1124  $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
1125  }
1126  else
1127  {
1128  $name = $definition['field_name'];
1129  }
1130  $this->tpl->setVariable("TXT_FIELD_NAME",$name);
1131  $this->tpl->parseCurrentBlock();
1132  }
1133  return true;
1134  }
1135 
1137  {
1138  foreach($this->user_defined_fields->getVisibleDefinitions() as $definition)
1139  {
1140  $field_id = $definition['field_id'];
1141  if($definition['required'] and !strlen($_POST['udf'][$field_id]))
1142  {
1143  return false;
1144  }
1145  }
1146  return true;
1147  }
1148 
1149 
1150  private function getChatSettingsForm()
1151  {
1152  global $ilCtrl, $ilSetting, $lng;
1153 
1154  $lng->loadLanguageModule('chat');
1155 
1156  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1157  $form = new ilPropertyFormGUI();
1158 
1159  $form->setFormAction($this->ctrl->getFormAction($this, 'saveChatOptions'));
1160  $form->setTitle($lng->txt("chat_settings"));
1161 
1162  if((int)$ilSetting->get('chat_message_notify_status'))
1163  {
1164  // chat message notification in ilias
1165  //$rg_parent = new ilRadioGroupInputGUI($this->lng->txt('chat_message_notify'), 'chat_message_notify_status');
1166  //$rg_parent->setValue(0);
1167 
1168  $ro_parent = new ilCheckboxInputGUI($this->lng->txt('chat_message_notify_activate'), 'chat_message_notify_activate');
1169  //$rg_parent->addOption($ro_parent);
1170  #$ro_parent->setValue(0);
1171 
1172  if((int)$ilSetting->get('chat_sound_status') &&
1173  ((int)$ilSetting->get('chat_new_invitation_sound_status') ||
1174  (int)$ilSetting->get('chat_new_message_sound_status')))
1175  {
1176  // sound activation/deactivation for new chat invitations and messages
1177  #$rg = new ilRadioGroupInputGUI($this->lng->txt('chat_sounds'), 'chat_sound_status');
1178  #$rg->setValue(0);
1179  #$ro = new ilCheckboxInputGUI($this->lng->txt('chat_sound_status_activate'), 1);
1180  if((int)$ilSetting->get('chat_new_invitation_sound_status'))
1181  {
1182  $chb = new ilCheckboxInputGUI('', 'chat_new_invitation_sound_status');
1183  $chb->setOptionTitle($this->lng->txt('chat_new_invitation_sound_status'));
1184  $chb->setChecked(false);
1185  $ro_parent->addSubItem($chb);
1186  }
1187 
1188  if((int)$ilSetting->get('chat_new_message_sound_status'))
1189  {
1190  $chb = new ilCheckBoxInputGUI('','chat_new_message_sound_status');
1191  $chb->setOptionTitle($this->lng->txt('chat_new_message_sound_status'));
1192  $chb->setChecked(false);
1193  $ro_parent->addSubItem($chb);
1194  }
1195  #$rg->addOption($ro);
1196 
1197  //$ro = new ilRadioOption($this->lng->txt('chat_sound_status_deactivate'), 0);
1198  //$rg->addOption($ro);
1199 
1200  #$ro_parent->addSubItem($rg);
1201  //$form->addItem($rg);
1202  }
1203 
1204 
1205  #$ro_parent = new ilRadioOption($this->lng->txt('chat_message_notify_deactivate'), 0);
1206  #$rg_parent->addOption($ro_parent);
1207  $form->addItem($ro_parent);
1208  }
1209 
1210  $form->addCommandButton("saveChatOptions", $lng->txt("save"));
1211  return $form;
1212  }
1213 
1214  public function saveChatOptions()
1215  {
1216  global $ilUser, $ilSetting, $lng;
1217 
1218  if((int)$ilSetting->get('chat_message_notify_status'))
1219  {
1220  $ilUser->setPref('chat_message_notify_status', (int)$_POST['chat_message_notify_activate']);
1221  }
1222 
1223  if((int)$ilSetting->get('chat_sound_status') &&
1224  ((int)$ilSetting->get('chat_new_invitation_sound_status') ||
1225  (int)$ilSetting->get('chat_new_message_sound_status')))
1226  {
1227  $ilUser->setPref('chat_sound_status', (int)$_POST['chat_sound_status']);
1228  if((int)$ilSetting->get('chat_new_invitation_sound_status'))
1229  {
1230  $ilUser->setPref('chat_new_invitation_sound_status', (int)$_POST['chat_new_invitation_sound_status']);
1231  }
1232  if((int)$ilSetting->get('chat_new_message_sound_status'))
1233  {
1234  $ilUser->setPref('chat_new_message_sound_status', (int)$_POST['chat_new_message_sound_status']);
1235  }
1236  }
1237 
1238  $ilUser->writePrefs();
1239 
1240  ilUtil::sendSuccess($lng->txt('saved'));
1241 
1242  $this->showChatOptions(true);
1243  }
1244 
1248  public function showChatOptions($by_post = false)
1249  {
1250  global $ilCtrl, $ilSetting, $lng, $ilUser;
1251 
1252  $this->__initSubTabs('showChatOptions');
1253 
1254  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
1255  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), "");
1256  $this->tpl->setVariable('HEADER', $this->lng->txt('personal_desktop'));
1257 
1258  $form = false;
1259  if($by_post)
1260  {
1261  $form = $this->getChatSettingsForm();
1262  $form->setValuesByPost();
1263  }
1264  else
1265  {
1266  $values = array();
1267  $values['chat_message_notify_status'] = $ilUser->getPref('chat_message_notify_status');
1268  $values['chat_message_notify_activate'] = $ilUser->getPref('chat_message_notify_status');
1269 
1270  $values['chat_sound_status'] = $ilUser->getPref('chat_sound_status');
1271  $values['chat_new_invitation_sound_status'] = $ilUser->getPref('chat_new_invitation_sound_status');
1272  $values['chat_new_message_sound_status'] = $ilUser->getPref('chat_new_message_sound_status');
1273 
1274  $form = $this->getChatSettingsForm();
1275  $form->setValuesByArray($values);
1276 
1277  }
1278  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1279  $this->tpl->show();
1280  }
1281 
1282  //
1283  //
1284  // PERSONAL DATA FORM
1285  //
1286  //
1287 
1291  function showPersonalData($a_no_init = false)
1292  {
1293  global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting, $ilTabs;
1294  $this->__initSubTabs("showPersonalData");
1295  $ilTabs->setSubTabActive("personal_data");
1296 
1297  $settings = $ilias->getAllSettings();
1298 
1299  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
1300 
1301 
1302  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1303  // $this->lng->txt("personal_desktop"));
1304  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1305  "");
1306  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1307 
1308  if (!$a_no_init)
1309  {
1310  $this->initPersonalDataForm();
1311  // catch feedback message
1312  if ($ilUser->getProfileIncomplete())
1313  {
1314  ilUtil::sendInfo($lng->txt("profile_incomplete"));
1315  }
1316  }
1317  $this->tpl->setContent($this->form->getHTML());
1318 
1319  $this->tpl->show();
1320  }
1321 
1326  {
1327  global $ilSetting, $lng, $ilUser, $styleDefinition, $rbacreview;
1328 
1329  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1330  $this->form = new ilPropertyFormGUI();
1331  $this->form->setFormAction($this->ctrl->getFormAction($this));
1332 
1333  // user defined fields
1334  $user_defined_data = $ilUser->getUserDefinedData();
1335 
1336  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1337  {
1338  if($definition['field_type'] == UDF_TYPE_TEXT)
1339  {
1340  $this->input["udf_".$definition['field_id']] =
1341  new ilTextInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1342  $this->input["udf_".$definition['field_id']]->setMaxLength(255);
1343  $this->input["udf_".$definition['field_id']]->setSize(40);
1344  }
1345  else if($definition['field_type'] == UDF_TYPE_WYSIWYG)
1346  {
1347  $this->input["udf_".$definition['field_id']] =
1348  new ilTextAreaInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1349  $this->input["udf_".$definition['field_id']]->setUseRte(true);
1350  }
1351  else
1352  {
1353  $this->input["udf_".$definition['field_id']] =
1354  new ilSelectInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1355  $this->input["udf_".$definition['field_id']]->setOptions(
1356  $this->user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
1357  }
1358 
1359  $value = $user_defined_data["f_".$field_id];
1360  $this->input["udf_".$definition['field_id']]->setValue($value);
1361 
1362  if($definition['required'])
1363  {
1364  $this->input["udf_".$definition['field_id']]->setRequired(true);
1365  }
1366  if(!$definition['changeable'] && (!$definition['required'] || $value))
1367  {
1368  $this->input["udf_".$definition['field_id']]->setDisabled(true);
1369  }
1370  }
1371 
1372  // standard fields
1373  include_once("./Services/User/classes/class.ilUserProfile.php");
1374  $up = new ilUserProfile();
1375  $up->skipField("password");
1376  $up->skipGroup("settings");
1377  $up->skipGroup("preferences");
1378 
1379  // standard fields
1380  $up->addStandardFieldsToForm($this->form, $ilUser, $this->input);
1381 
1382  $this->form->addCommandButton("savePersonalData", $lng->txt("save"));
1383 
1384  }
1385 
1390  public function savePersonalData()
1391  {
1392  global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting, $ilAuth;
1393 
1394  $this->initPersonalDataForm();
1395  if ($this->form->checkInput())
1396  {
1397  $form_valid = true;
1398 
1399  // if form field name differs from setter
1400  $map = array(
1401  "firstname" => "FirstName",
1402  "lastname" => "LastName",
1403  "title" => "UTitle",
1404  "sel_country" => "SelectedCountry",
1405  "phone_office" => "PhoneOffice",
1406  "phone_home" => "PhoneHome",
1407  "phone_mobile" => "PhoneMobile",
1408  "referral_comment" => "Comment"
1409  );
1410  include_once("./Services/User/classes/class.ilUserProfile.php");
1411  $up = new ilUserProfile();
1412  foreach($up->getStandardFields() as $f => $p)
1413  {
1414  // if item is part of form, it is currently valid (if not disabled)
1415  $item = $this->form->getItemByPostVar("usr_".$f);
1416  if($item && !$item->getDisabled())
1417  {
1418  $value = $this->form->getInput("usr_".$f);
1419  switch($f)
1420  {
1421  case "birthday":
1422  if (is_array($value))
1423  {
1424  if (is_array($value['date']))
1425  {
1426  if (($value['d'] > 0) && ($value['m'] > 0) && ($value['y'] > 0))
1427  {
1428  $ilUser->setBirthday(sprintf("%04d-%02d-%02d", $value['y'], $value['m'], $value['d']));
1429  }
1430  else
1431  {
1432  $ilUser->setBirthday("");
1433  }
1434  }
1435  else
1436  {
1437  $ilUser->setBirthday($value['date']);
1438  }
1439  }
1440  break;
1441 
1442  default:
1443  $m = ucfirst($f);
1444  if(isset($map[$f]))
1445  {
1446  $m = $map[$f];
1447  }
1448  $ilUser->{"set".$m}($value);
1449  break;
1450  }
1451  }
1452  }
1453  $ilUser->setFullname();
1454 
1455  // set instant messengers
1456  if ($this->workWithUserSetting("instant_messengers"))
1457  {
1458  $ilUser->setInstantMessengerId('icq', $this->form->getInput("usr_im_icq"));
1459  $ilUser->setInstantMessengerId('yahoo', $this->form->getInput("usr_im_yahoo"));
1460  $ilUser->setInstantMessengerId('msn', $this->form->getInput("usr_im_msn"));
1461  $ilUser->setInstantMessengerId('aim', $this->form->getInput("usr_im_aim"));
1462  $ilUser->setInstantMessengerId('skype', $this->form->getInput("usr_im_skype"));
1463  $ilUser->setInstantMessengerId('jabber', $this->form->getInput("usr_im_jabber"));
1464  $ilUser->setInstantMessengerId('voip', $this->form->getInput("usr_im_voip"));
1465  }
1466 
1467  // Set user defined data
1468  $defs = $this->user_defined_fields->getVisibleDefinitions();
1469  $udf = array();
1470  foreach ($defs as $definition)
1471  {
1472  $f = "udf_".$definition['field_id'];
1473  $item = $this->form->getItemByPostVar($f);
1474  if ($item && !$item->getDisabled())
1475  {
1476  $udf[$definition['field_id']] = $this->form->getInput($f);
1477  }
1478  }
1479  $ilUser->setUserDefinedData($udf);
1480 
1481  // if loginname is changeable -> validate
1482  $un = $this->form->getInput('username');
1483  if((int)$ilSetting->get('allow_change_loginname') &&
1484  $un != $ilUser->getLogin())
1485  {
1486  if(!strlen($un) || !ilUtil::isLogin($un))
1487  {
1488  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
1489  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('login_invalid'));
1490  $form_valid = false;
1491  }
1492  else if(ilObjUser::_loginExists($un, $ilUser->getId()))
1493  {
1494  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
1495  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('loginname_already_exists'));
1496  $form_valid = false;
1497  }
1498  else
1499  {
1500  $ilUser->setLogin($un);
1501 
1502  try
1503  {
1504  $ilUser->updateLogin($ilUser->getLogin());
1505  $ilAuth->setAuth($ilUser->getLogin());
1506  $ilAuth->start();
1507  }
1508  catch (ilUserException $e)
1509  {
1510  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
1511  $this->form->getItemByPostVar('username')->setAlert($e->getMessage());
1512  $form_valid = false;
1513  }
1514  }
1515  }
1516 
1517  // everthing's ok. save form data
1518  if ($form_valid)
1519  {
1520  $this->uploadUserPicture();
1521 
1522  // profile ok
1523  $ilUser->setProfileIncomplete(false);
1524 
1525  // save user data & object_data
1526  $ilUser->setTitle($ilUser->getFullname());
1527  $ilUser->setDescription($ilUser->getEmail());
1528 
1529  $ilUser->update();
1530 
1531  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1532  if ($redirect = $_SESSION['profile_complete_redirect'])
1533  {
1534  unset($_SESSION['profile_complete_redirect']);
1536  }
1537  else
1538  {
1539  $ilCtrl->redirect($this, "showPersonalData");
1540  }
1541  }
1542  }
1543 
1544  $this->form->setValuesByPost();
1545  $this->showPersonalData(true);
1546  }
1547 
1548  //
1549  //
1550  // PUBLIC PROFILE FORM
1551  //
1552  //
1553 
1557  function showPublicProfile($a_no_init = false)
1558  {
1559  global $ilUser, $lng, $ilSetting, $ilTabs;
1560 
1561  $this->__initSubTabs("showPersonalData");
1562  $ilTabs->setSubTabActive("public_profile");
1563 
1564  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1565  // $this->lng->txt("personal_desktop"));
1566  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1567  "");
1568  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1569 
1570  if (!$a_no_init)
1571  {
1572  $this->initPublicProfileForm();
1573  }
1574 
1575  $ptpl = new ilTemplate("tpl.edit_personal_profile.html", true, true, "Services/User");
1576  $ptpl->setVariable("FORM", $this->form->getHTML());
1577  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
1578  $pub_profile = new ilPublicUserProfileGUI($ilUser->getId());
1579  $ptpl->setVariable("PREVIEW", $pub_profile->getHTML(true));
1580  $this->tpl->setContent($ptpl->get());
1581  $this->tpl->show();
1582  }
1583 
1589  public function initPublicProfileForm()
1590  {
1591  global $lng, $ilUser, $ilSetting;
1592 
1593  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1594  $this->form = new ilPropertyFormGUI();
1595 
1596  // Activate public profile
1597  $radg = new ilRadioGroupInputGUI($lng->txt("user_activate_public_profile"), "public_profile");
1598  $radg->setInfo($this->lng->txt("user_activate_public_profile_info"));
1599  $pub_prof = in_array($ilUser->prefs["public_profile"], array("y", "n", "g"))
1600  ? $ilUser->prefs["public_profile"]
1601  : "n";
1602  if (!$ilSetting->get('enable_global_profiles') && $pub_prof == "g")
1603  {
1604  $pub_prof = "y";
1605  }
1606  $radg->setValue($pub_prof);
1607  $op1 = new ilRadioOption($lng->txt("usr_public_profile_disabled"), "n",$lng->txt("usr_public_profile_disabled_info"));
1608  $radg->addOption($op1);
1609  $op2 = new ilRadioOption($lng->txt("usr_public_profile_logged_in"), "y",$lng->txt("usr_public_profile_logged_in_info"));
1610  $radg->addOption($op2);
1611  if ($ilSetting->get('enable_global_profiles'))
1612  {
1613  $op3 = new ilRadioOption($lng->txt("usr_public_profile_global"), "g",$lng->txt("usr_public_profile_global_info"));
1614  $radg->addOption($op3);
1615  }
1616  $this->form->addItem($radg);
1617  /*$cb = new ilCheckboxInputGUI($this->lng->txt("user_activate_public_profile"), "public_profile");
1618 
1619  if ($ilUser->prefs["public_profile"] == "y")
1620  {
1621  $cb->setChecked(true);
1622  }
1623  $this->form->addItem($cb);*/
1624 
1625  $birthday = $ilUser->getBirthday();
1626  if($birthday)
1627  {
1628  $birthday = ilDatePresentation::formatDate(new ilDate($birthday, IL_CAL_DATE));
1629  }
1630  $gender = $ilUser->getGender();
1631  if($gender)
1632  {
1633  $gender = $lng->txt("gender_".$gender);
1634  }
1635 
1636  if ($ilUser->getSelectedCountry() != "")
1637  {
1638  $lng->loadLanguageModule("meta");
1639  $txt_sel_country = $lng->txt("meta_c_".$ilUser->getSelectedCountry());
1640  }
1641 
1642  // personal data
1643  $val_array = array(
1644  "title" => $ilUser->getUTitle(),
1645  "birthday" => $birthday,
1646  "gender" => $gender,
1647  "institution" => $ilUser->getInstitution(),
1648  "department" => $ilUser->getDepartment(),
1649  "upload" => "",
1650  "street" => $ilUser->getStreet(),
1651  "zipcode" => $ilUser->getZipcode(),
1652  "city" => $ilUser->getCity(),
1653  "country" => $ilUser->getCountry(),
1654  "sel_country" => $txt_sel_country,
1655  "phone_office" => $ilUser->getPhoneOffice(),
1656  "phone_home" => $ilUser->getPhoneHome(),
1657  "phone_mobile" => $ilUser->getPhoneMobile(),
1658  "fax" => $ilUser->getFax(),
1659  "email" => $ilUser->getEmail(),
1660  "hobby" => $ilUser->getHobby(),
1661  "matriculation" => $ilUser->getMatriculation(),
1662  "delicious" => $ilUser->getDelicious()
1663  );
1664  foreach($val_array as $key => $value)
1665  {
1666  if ($this->userSettingVisible($key))
1667  {
1668  // public setting
1669  if ($key == "upload")
1670  {
1671  $cb = new ilCheckboxInputGUI($this->lng->txt("personal_picture"), "chk_".$key);
1672  }
1673  else
1674  {
1675  $cb = new ilCheckboxInputGUI($this->lng->txt($key), "chk_".$key);
1676  }
1677  if ($ilUser->prefs["public_".$key] == "y")
1678  {
1679  $cb->setChecked(true);
1680  }
1681  //$cb->setInfo($value);
1682  $cb->setOptionTitle($value);
1683  $this->form->addItem($cb);
1684  }
1685  }
1686 
1687  $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
1688  if ($this->userSettingVisible("instant_messengers"))
1689  {
1690  foreach ($im_arr as $im)
1691  {
1692  // public setting
1693  $cb = new ilCheckboxInputGUI($this->lng->txt("im_".$im), "chk_im_".$im);
1694  //$cb->setInfo($ilUser->getInstantMessengerId($im));
1695  $cb->setOptionTitle($ilUser->getInstantMessengerId($im));
1696  if ($ilUser->prefs["public_im_".$im] != "n")
1697  {
1698  $cb->setChecked(true);
1699  }
1700  $this->form->addItem($cb);
1701  }
1702  }
1703 
1704  // additional defined user data fields
1705  $user_defined_data = $ilUser->getUserDefinedData();
1706  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1707  {
1708  // public setting
1709  $cb = new ilCheckboxInputGUI($definition["field_name"], "chk_udf_".$definition["field_id"]);
1710  $cb->setOptionTitle($user_defined_data["f_".$definition["field_id"]]);
1711  if ($ilUser->prefs["public_udf_".$definition["field_id"]] == "y")
1712  {
1713  $cb->setChecked(true);
1714  }
1715  $this->form->addItem($cb);
1716  }
1717 
1718 
1719  // save and cancel commands
1720  $this->form->addCommandButton("savePublicProfile", $lng->txt("save"));
1721 
1722  $this->form->setTitle($lng->txt("public_profile"));
1723  $this->form->setDescription($lng->txt("user_public_profile_info"));
1724  $this->form->setFormAction($this->ctrl->getFormAction($this));
1725  }
1726 
1731  public function savePublicProfile()
1732  {
1733  global $tpl, $lng, $ilCtrl, $ilUser;
1734 
1735  $this->initPublicProfileForm();
1736  if ($this->form->checkInput())
1737  {
1738  /*if (($_POST["public_profile"]))
1739  {
1740  $ilUser->setPref("public_profile","y");
1741  }
1742  else
1743  {
1744  $ilUser->setPref("public_profile","n");
1745  }*/
1746  $ilUser->setPref("public_profile", $_POST["public_profile"]);
1747 
1748  // if check on Institute
1749  $val_array = array("title", "birthday", "gender", "institution", "department", "upload", "street",
1750  "zipcode", "city", "country", "sel_country", "phone_office", "phone_home", "phone_mobile",
1751  "fax", "email", "hobby", "matriculation");
1752 
1753  // set public profile preferences
1754  foreach($val_array as $key => $value)
1755  {
1756  if (($_POST["chk_".$value]))
1757  {
1758  $ilUser->setPref("public_".$value,"y");
1759  }
1760  else
1761  {
1762  $ilUser->setPref("public_".$value,"n");
1763  }
1764  }
1765 
1766  $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
1767  if ($this->userSettingVisible("instant_messengers"))
1768  {
1769  foreach ($im_arr as $im)
1770  {
1771  if (($_POST["chk_im_".$im]))
1772  {
1773  $ilUser->setPref("public_im_".$im,"y");
1774  }
1775  else
1776  {
1777  $ilUser->setPref("public_im_".$im,"n");
1778  }
1779  }
1780  }
1781 
1782 // $d_set = new ilSetting("delicious");
1783 // if ($d_set->get("user_profile"))
1784 // {
1785  if (($_POST["chk_delicious"]))
1786  {
1787  $ilUser->setPref("public_delicious","y");
1788  }
1789  else
1790  {
1791  $ilUser->setPref("public_delicious","n");
1792  }
1793 // }
1794 
1795  // additional defined user data fields
1796  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1797  {
1798  if (($_POST["chk_udf_".$definition["field_id"]]))
1799  {
1800  $ilUser->setPref("public_udf_".$definition["field_id"], "y");
1801  }
1802  else
1803  {
1804  $ilUser->setPref("public_udf_".$definition["field_id"], "n");
1805  }
1806  }
1807 
1808  $ilUser->update();
1809  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1810  $ilCtrl->redirect($this, "showPublicProfile");
1811  }
1812  $this->form->setValuesByPost();
1813  $tpl->showPublicProfile(true);
1814  }
1815 
1816 
1817  //
1818  //
1819  // PASSWORD FORM
1820  //
1821  //
1822 
1826  function showPassword($a_no_init = false)
1827  {
1828  global $ilTabs;
1829 
1830  $this->__initSubTabs("showPersonalData");
1831  $ilTabs->setSubTabActive("password");
1832 
1833  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1834  // $this->lng->txt("personal_desktop"));
1835  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1836  "");
1837  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1838 
1839  if (!$a_no_init)
1840  {
1841  $this->initPasswordForm();
1842  }
1843  $this->tpl->setContent($this->form->getHTML());
1844  $this->tpl->show();
1845  }
1846 
1852  public function initPasswordForm()
1853  {
1854  global $lng, $ilUser, $ilSetting;
1855 
1856  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1857  $this->form = new ilPropertyFormGUI();
1858 
1859  // Check whether password change is allowed
1860  if ($this->allowPasswordChange())
1861  {
1862  // The current password needs to be checked for verification
1863  // unless the user uses Shibboleth authentication with additional
1864  // local authentication for WebDAV.
1865  //if (
1866  // ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local"))
1867  //)
1868  if($ilUser->getAuthMode(true) == AUTH_LOCAL)
1869  {
1870  // current password
1871  $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
1872  $cpass->setRetype(false);
1873  $cpass->setSkipSyntaxCheck(true);
1874  // only if a password exists.
1875  if($ilUser->getPasswd())
1876  {
1877  $cpass->setRequired(true);
1878  }
1879  $this->form->addItem($cpass);
1880  }
1881 
1882  // new password
1883  $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
1884  $ipass->setRequired(true);
1885  $ipass->setInfo(ilUtil::getPasswordRequirementsInfo());
1886 
1887  if ($ilSetting->get("passwd_auto_generate") == 1) // auto generation list
1888  {
1889  $ipass->setPreSelection(true);
1890 
1891  $this->form->addItem($ipass);
1892  $this->form->addCommandButton("savePassword", $lng->txt("save"));
1893  $this->form->addCommandButton("showPassword", $lng->txt("new_list_password"));
1894  }
1895  else // user enters password
1896  {
1897  $this->form->addItem($ipass);
1898  $this->form->addCommandButton("savePassword", $lng->txt("save"));
1899  }
1900 
1901  switch ($ilUser->getAuthMode(true))
1902  {
1903  case AUTH_LOCAL :
1904  $this->form->setTitle($lng->txt("chg_password"));
1905  break;
1906 
1907  case AUTH_SHIBBOLETH :
1908  case AUTH_CAS:
1909  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1910  if (ilDAVServer::_isActive())
1911  {
1912  $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
1913  }
1914  else
1915  {
1916  $this->form->setTitle($lng->txt("chg_ilias_password"));
1917  }
1918  break;
1919  default :
1920  $this->form->setTitle($lng->txt("chg_ilias_password"));
1921  break;
1922  }
1923  $this->form->setFormAction($this->ctrl->getFormAction($this));
1924  }
1925  }
1926 
1930  function allowPasswordChange()
1931  {
1932  global $ilUser, $ilSetting;
1933 
1934 
1935  return ilAuthUtils::isPasswordModificationEnabled($ilUser->getAuthMode(true));
1936 
1937  // Moved to ilAuthUtils
1938 
1939  // do nothing if auth mode is not local database
1940  if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
1941  ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
1942  ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local")) &&
1943  ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local")) &&
1944  ($ilUser->getAuthMode(true) != AUTH_OPENID)
1945  )
1946  {
1947  return false;
1948  }
1949  if (!$this->userSettingVisible('password') ||
1950  $this->ilias->getSetting('usr_settings_disable_password'))
1951  {
1952  return false;
1953  }
1954  return true;
1955  }
1956 
1961  public function savePassword()
1962  {
1963  global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting;
1964 
1965  // normally we should not end up here
1966  if (!$this->allowPasswordChange())
1967  {
1968  $ilCtrl->redirect($this, "showPersonalData");
1969  return;
1970  }
1971 
1972  $this->initPasswordForm();
1973  if ($this->form->checkInput())
1974  {
1975  $cp = $this->form->getItemByPostVar("current_password");
1976  $np = $this->form->getItemByPostVar("new_password");
1977  $error = false;
1978 
1979  // The old password needs to be checked for verification
1980  // unless the user uses Shibboleth authentication with additional
1981  // local authentication for WebDAV.
1982  #if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
1983  if($ilUser->getAuthMode(true) == AUTH_LOCAL)
1984  {
1985  // check current password
1986  if (md5($_POST["current_password"]) != $ilUser->getPasswd() and
1987  $ilUser->getPasswd())
1988  {
1989  $error = true;
1990  $cp->setAlert($this->lng->txt("passwd_wrong"));
1991  }
1992  }
1993 
1994  // select password from auto generated passwords
1995  if ($this->ilias->getSetting("passwd_auto_generate") == 1 &&
1996  (!ilUtil::isPassword($_POST["new_password"])))
1997  {
1998  $error = true;
1999  $np->setAlert($this->lng->txt("passwd_not_selected"));
2000  }
2001 
2002 
2003  if ($this->ilias->getSetting("passwd_auto_generate") != 1 &&
2004  !ilUtil::isPassword($_POST["new_password"],$custom_error))
2005  {
2006  $error = true;
2007  if ($custom_error != '')
2008  {
2009  $np->setAlert($custom_error);
2010  }
2011  else
2012  {
2013  $np->setAlert($this->lng->txt("passwd_invalid"));
2014  }
2015  }
2016  if ($this->ilias->getSetting("passwd_auto_generate") != 1 &&
2017  ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
2018  ($_POST["current_password"] == $_POST["new_password"]))
2019  {
2020  $error = true;
2021  $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
2022  }
2023 
2024  if (!$error)
2025  {
2026  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
2027  $ilUser->resetPassword($_POST["new_password"], $_POST["new_password"]);
2028  if ($_POST["current_password"] != $_POST["new_password"])
2029  {
2030  $ilUser->setLastPasswordChangeToNow();
2031  }
2032  $ilCtrl->redirect($this, "showPassword");
2033  }
2034  }
2035  $this->form->setValuesByPost();
2036  $this->showPassword(true);
2037  }
2038 
2039  //
2040  //
2041  // GENERAL SETTINGS FORM
2042  //
2043  //
2044 
2048  function showGeneralSettings($a_no_init = false)
2049  {
2050  global $ilTabs;
2051 
2052  $this->__initSubTabs("showPersonalData");
2053  $ilTabs->setSubTabActive("general_settings");
2054 
2055  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2056  // $this->lng->txt("personal_desktop"));
2057  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2058  "");
2059  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
2060 
2061  if (!$a_no_init)
2062  {
2063  $this->initGeneralSettingsForm();
2064  }
2065  $this->tpl->setContent($this->form->getHTML());
2066  $this->tpl->show();
2067  }
2068 
2073  public function initGeneralSettingsForm()
2074  {
2075  global $lng, $ilUser, $styleDefinition, $ilSetting;
2076 
2077 
2078  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2079  $this->form = new ilPropertyFormGUI();
2080 
2081  // language
2082  if ($this->userSettingVisible("language"))
2083  {
2084  $languages = $this->lng->getInstalledLanguages();
2085  $options = array();
2086  foreach($languages as $lang_key)
2087  {
2088  $options[$lang_key] = ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key);
2089  }
2090 
2091  $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
2092  $si->setOptions($options);
2093  $si->setValue($ilUser->getLanguage());
2094  $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
2095  $this->form->addItem($si);
2096  }
2097 
2098  // skin/style
2099  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
2100  if ($this->userSettingVisible("skin_style"))
2101  {
2102  $templates = $styleDefinition->getAllTemplates();
2103  if (is_array($templates))
2104  {
2105  $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
2106 
2107  $options = array();
2108  foreach($templates as $template)
2109  {
2110  // get styles information of template
2111  $styleDef = new ilStyleDefinition($template["id"]);
2112  $styleDef->startParsing();
2113  $styles = $styleDef->getStyles();
2114 
2115  foreach($styles as $style)
2116  {
2117  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
2118  {
2119  continue;
2120  }
2121 
2122  $options[$template["id"].":".$style["id"]] =
2123  $styleDef->getTemplateName()." / ".$style["name"];
2124  }
2125  }
2126  $si->setOptions($options);
2127  $si->setValue($ilUser->skin.":".$ilUser->prefs["style"]);
2128  $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
2129  $this->form->addItem($si);
2130  }
2131  }
2132 
2133  // screen reader optimization
2134  if ($this->userSettingVisible("screen_reader_optimization"))
2135  {
2136  $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
2137  $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
2138  $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
2139  $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
2140  $this->form->addItem($cb);
2141  }
2142 
2143  // hits per page
2144  if ($this->userSettingVisible("hits_per_page"))
2145  {
2146  $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
2147 
2148  $hits_options = array(10,15,20,30,40,50,100,9999);
2149  $options = array();
2150 
2151  foreach($hits_options as $hits_option)
2152  {
2153  $hstr = ($hits_option == 9999)
2154  ? $this->lng->txt("no_limit")
2155  : $hits_option;
2156  $options[$hits_option] = $hstr;
2157  }
2158  $si->setOptions($options);
2159  $si->setValue($ilUser->prefs["hits_per_page"]);
2160  $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
2161  $this->form->addItem($si);
2162  }
2163 
2164  // Users Online
2165  if ($this->userSettingVisible("show_users_online"))
2166  {
2167  $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
2168 
2169  $options = array(
2170  "y" => $this->lng->txt("users_online_show_y"),
2171  "associated" => $this->lng->txt("users_online_show_associated"),
2172  "n" => $this->lng->txt("users_online_show_n"));
2173  $si->setOptions($options);
2174  $si->setValue($ilUser->prefs["show_users_online"]);
2175  $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
2176  $this->form->addItem($si);
2177  }
2178 
2179  // hide_own_online_status
2180  if ($this->userSettingVisible("hide_own_online_status"))
2181  {
2182  $cb = new ilCheckboxInputGUI($this->lng->txt("hide_own_online_status"), "hide_own_online_status");
2183  $cb->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
2184  $cb->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
2185  $this->form->addItem($cb);
2186  }
2187 
2188  // session reminder
2189  if((int)$ilSetting->get('session_handling_type') == 0 &&
2190  (int)$ilSetting->get('session_reminder_enabled'))
2191  {
2192  $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
2193  $cb->setInfo($this->lng->txt('session_reminder_info'));
2194  $cb->setValue(1);
2195  $cb->setChecked((int)$ilUser->getPref('session_reminder_enabled'));
2196 
2197  global $ilClientIniFile;
2198 
2199  $lead_time_gui = new ilTextInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
2200  $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilFormat::_secondsToString($ilClientIniFile->readVariable('session', 'expire'))));
2201  $lead_time_gui->setValue($ilUser->getPref('session_reminder_lead_time'));
2202  $lead_time_gui->setMaxLength(10);
2203  $lead_time_gui->setSize(10);
2204  $cb->addSubItem($lead_time_gui);
2205 
2206  $this->form->addItem($cb);
2207  }
2208 
2209 
2210  // calendar settings (copied here to be reachable when calendar is inactive)
2211  // they cannot be hidden/deactivated
2212 
2213  include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
2214  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
2215  $lng->loadLanguageModule("dateplaner");
2216  $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
2217 
2218  $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'),'timezone');
2220  $select->setInfo($lng->txt('cal_timezone_info'));
2221  $select->setValue($user_settings->getTimeZone());
2222  $this->form->addItem($select);
2223 
2224  $year = date("Y");
2225  $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'),'date_format');
2226  $select->setOptions(array(
2227  ilCalendarSettings::DATE_FORMAT_DMY => '31.10.'.$year,
2228  ilCalendarSettings::DATE_FORMAT_YMD => $year."-10-31",
2229  ilCalendarSettings::DATE_FORMAT_MDY => "10/31/".$year));
2230  $select->setInfo($lng->txt('cal_date_format_info'));
2231  $select->setValue($user_settings->getDateFormat());
2232  $this->form->addItem($select);
2233 
2234  $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'),'time_format');
2235  $select->setOptions(array(
2237  ilCalendarSettings::TIME_FORMAT_12 => '1:00pm'));
2238  $select->setInfo($lng->txt('cal_time_format_info'));
2239  $select->setValue($user_settings->getTimeFormat());
2240  $this->form->addItem($select);
2241 
2242 
2243  $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
2244  $this->form->setTitle($lng->txt("general_settings"));
2245  $this->form->setFormAction($this->ctrl->getFormAction($this));
2246 
2247  }
2248 
2253  public function saveGeneralSettings()
2254  {
2255  global $tpl, $lng, $ilCtrl, $ilUser;
2256 
2257  $this->initGeneralSettingsForm();
2258  if ($this->form->checkInput())
2259  {
2260  if ($this->workWithUserSetting("skin_style"))
2261  {
2262  //set user skin and style
2263  if ($_POST["skin_style"] != "")
2264  {
2265  $sknst = explode(":", $_POST["skin_style"]);
2266 
2267  if ($ilUser->getPref("style") != $sknst[1] ||
2268  $ilUser->getPref("skin") != $sknst[0])
2269  {
2270  $ilUser->setPref("skin", $sknst[0]);
2271  $ilUser->setPref("style", $sknst[1]);
2272  }
2273  }
2274  }
2275 
2276  // language
2277  if ($this->workWithUserSetting("language"))
2278  {
2279  $ilUser->setLanguage($_POST["language"]);
2280  }
2281 
2282  // hits per page
2283  if ($this->workWithUserSetting("hits_per_page"))
2284  {
2285  if ($_POST["hits_per_page"] != "")
2286  {
2287  $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
2288  }
2289  }
2290 
2291  // set show users online
2292  if ($this->workWithUserSetting("show_users_online"))
2293  {
2294  $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
2295  }
2296 
2297  // set hide own online_status
2298  if ($this->workWithUserSetting("hide_own_online_status"))
2299  {
2300  if ($_POST["hide_own_online_status"] == 1)
2301  {
2302  $ilUser->setPref("hide_own_online_status","y");
2303  }
2304  else
2305  {
2306  $ilUser->setPref("hide_own_online_status","n");
2307  }
2308  }
2309 
2310  // set show users online
2311  if ($this->workWithUserSetting("screen_reader_optimization"))
2312  {
2313  $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
2314  }
2315 
2316  // session reminder
2317  global $ilSetting;
2318  if((int)$ilSetting->get('session_handling_type') == 0 &&
2319  (int)$ilSetting->get('session_reminder_enabled'))
2320  {
2321  $ilUser->setPref('session_reminder_enabled', (int)$_POST['session_reminder_enabled']);
2322 
2323  if(!preg_match('/^([0]|([1-9][0-9]*))([\.][0-9][0-9]*)?$/', $_POST['session_reminder_lead_time']))
2324  $_POST['session_reminder_lead_time'] = 0;
2325  $ilUser->setPref('session_reminder_lead_time', $_POST['session_reminder_lead_time']);
2326  }
2327 
2328  $ilUser->update();
2329 
2330  // calendar settings
2331  include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
2332  $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
2333  $user_settings->setTimeZone($this->form->getInput("timezone"));
2334  $user_settings->setDateFormat((int)$this->form->getInput("date_format"));
2335  $user_settings->setTimeFormat((int)$this->form->getInput("time_format"));
2336  $user_settings->save();
2337 
2338  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2339  $ilCtrl->redirect($this, "showGeneralSettings");
2340  }
2341 
2342  $this->form->setValuesByPost();
2343  $tpl->showGeneralSettings(true);
2344  }
2345 
2346  //
2347  //
2348  // Extended user profile
2349  //
2350  //
2351 
2358  function showExtendedProfile()
2359  {
2360  global $tpl, $ilTabs, $ilToolbar, $lng, $ilCtrl;
2361 
2362  $this->initExtProfile();
2363  $ilToolbar->addButton($lng->txt("user_add_page"),
2364  $ilCtrl->getLinkTarget($this, "addProfilePage"));
2365 
2366  include_once("./Services/User/classes/class.ilExtendedProfileTableGUI.php");
2367  $tab = new ilExtendedProfileTableGUI($this, "showExtendedProfile");
2368  $tpl->setContent($tab->getHTML());
2369 
2370  $tpl->show();
2371  }
2372 
2379  function addProfilePage()
2380  {
2381  global $tpl, $ilTabs;
2382 
2383  $this->initExtProfile();
2384  $this->initProfilePageForm("create");
2385  $tpl->setContent($this->form->getHTML());
2386 
2387  $tpl->show();
2388 
2389  }
2390 
2396  public function initProfilePageForm($a_mode = "edit")
2397  {
2398  global $lng, $ilCtrl;
2399 
2400  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2401  $this->form = new ilPropertyFormGUI();
2402 
2403 
2404  // save and cancel commands
2405  if ($a_mode == "create")
2406  {
2407  // title
2408  $ti = new ilTextInputGUI($lng->txt("title"), "title");
2409  $ti->setMaxLength(200);
2410  $ti->setRequired(true);
2411  $this->form->addItem($ti);
2412 
2413  $this->form->addCommandButton("saveProfilePage", $lng->txt("save"));
2414  $this->form->addCommandButton("showExtendedProfile", $lng->txt("cancel"));
2415  $this->form->setTitle($lng->txt("user_new_profile_page"));
2416  }
2417  else
2418  {
2419  $this->form->addCommandButton("updateProfilePage", $lng->txt("save"));
2420  $this->form->addCommandButton("showExtendedProfile", $lng->txt("cancel"));
2421  $this->form->setTitle($lng->txt("user_add_profile_page"));
2422  }
2423 
2424  $this->form->setFormAction($ilCtrl->getFormAction($this));
2425  }
2426 
2430  public function saveProfilePage()
2431  {
2432  global $tpl, $lng, $ilCtrl, $ilUser, $ilTabs;
2433 
2434  $this->initProfilePageForm("create");
2435  if ($this->form->checkInput())
2436  {
2437  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2438  $page = new ilExtPublicProfilePage();
2439  $page->setUserId($ilUser->getId());
2440  $page->setTitle($_POST["title"]);
2441  $page->create();
2442  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2443  $ilCtrl->redirect($this, "showExtendedProfile");
2444  }
2445 
2446  $this->initExtProfile();
2447  $this->form->setValuesByPost();
2448  $tpl->setContent($this->form->getHtml());
2449  $tpl->show();
2450  }
2451 
2455  public function getProfilePageValues()
2456  {
2457  $values = array();
2458 
2459  $values["title"] = "";
2460 
2461  $this->form->setValuesByArray($values);
2462  }
2463 
2467  function initExtProfile()
2468  {
2469  global $ilTabs;
2470 
2471  $this->__initSubTabs("showPersonalData");
2472  $ilTabs->setSubTabActive("user_ext_profile");
2473  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2474  "");
2475  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
2476  }
2477 
2481  function confirmProfilePageDeletion()
2482  {
2483  global $ilCtrl, $tpl, $lng;
2484 
2485  if (!is_array($_POST["user_page"]) || count($_POST["user_page"]) == 0)
2486  {
2487  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2488  $ilCtrl->redirect($this, "showExtendedProfile");
2489  }
2490  else
2491  {
2492  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2493  $cgui = new ilConfirmationGUI();
2494  $cgui->setFormAction($ilCtrl->getFormAction($this));
2495  $cgui->setHeaderText($lng->txt("user_sure_delete_pages"));
2496  $cgui->setCancel($lng->txt("cancel"), "showExtendedProfile");
2497  $cgui->setConfirm($lng->txt("delete"), "deleteProfilePages");
2498 
2499  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2500  foreach ($_POST["user_page"] as $i => $v)
2501  {
2502  $cgui->addItem("user_page[]", $i, ilExtPublicProfilePage::lookupTitle($i));
2503  }
2504 
2505  $this->initExtProfile();
2506  $tpl->setContent($cgui->getHTML());
2507 
2508  $tpl->show();
2509  }
2510  }
2511 
2518  function deleteProfilePages()
2519  {
2520  global $ilDB, $ilUser, $lng, $ilCtrl;
2521 
2522  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2523  if (is_array($_POST["user_page"]))
2524  {
2525  foreach ($_POST["user_page"] as $i => $v)
2526  {
2528  if ($page->getUserId() == $ilUser->getId())
2529  {
2530  $page->delete();
2531  }
2532  }
2533  ilExtPublicProfilePage::fixOrdering($ilUser->getId());
2534  }
2535  ilUtil::sendSuccess($lng->txt("user_selected_pages_deleted"), true);
2536  $ilCtrl->redirect($this, "showExtendedProfile");
2537  }
2538 
2545  function saveExtProfilePagesOrdering()
2546  {
2547  global $ilCtrl, $ilUser, $lng;
2548 
2549  include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
2550 
2551  if (is_array($_POST["title"]))
2552  {
2553  foreach ($_POST["title"] as $k => $v)
2554  {
2556  if ($page->getUserId() == $ilUser->getId())
2557  {
2558  $page->setTitle(ilUtil::stripSlashes($v));
2559  $page->setOrderNr(ilUtil::stripSlashes($_POST["order"][$k]));
2560  $page->update();
2561  }
2562  }
2563  ilExtPublicProfilePage::fixOrdering($ilUser->getId());
2564  }
2565  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2566  $ilCtrl->redirect($this, "showExtendedProfile");
2567  }
2568 }
2569 ?>