ILIAS  Release_4_0_x_branch Revision 61816
 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  }
44 
48  function &executeCommand()
49  {
50  global $ilUser, $ilCtrl;
51 
52  $next_class = $this->ctrl->getNextClass();
53 
54  switch($next_class)
55  {
56  case "ilpublicuserprofilegui":
57  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
58  $pub_profile_gui = new ilPublicUserProfileGUI($ilUser->getId());
59  $ilCtrl->forwardCommand($pub_profile_gui);
60  break;
61 
62  default:
63  //$this->setTabs();
64 
65  $cmd = $this->ctrl->getCmd("showPersonalData");
66 
67  // check whether password of user have to be changed
68  // due to first login or password of user is expired
69  if( $ilUser->isPasswordChangeDemanded() && $cmd != 'savePassword' )
70  {
71  $cmd = 'showPassword';
72 
74  $this->lng->txt('password_change_on_first_login_demand'), true
75  );
76  }
77  elseif( $ilUser->isPasswordExpired() && $cmd != 'savePassword' )
78  {
79  $cmd = 'showPassword';
80 
81  $msg = $this->lng->txt('password_expired');
82  $password_age = $ilUser->getPasswordAge();
83 
84  ilUtil::sendInfo( sprintf($msg,$password_age), true );
85  }
86 
87  $this->$cmd();
88  break;
89  }
90  return true;
91  }
92 
93 
98  function workWithUserSetting($setting)
99  {
100  $result = TRUE;
101  if ($this->settings["usr_settings_hide_".$setting] == 1)
102  {
103  $result = FALSE;
104  }
105  if ($this->settings["usr_settings_disable_".$setting] == 1)
106  {
107  $result = FALSE;
108  }
109  return $result;
110  }
111 
116  function userSettingVisible($setting)
117  {
118  $result = TRUE;
119  if ($this->settings["usr_settings_hide_".$setting] == 1)
120  {
121  $result = FALSE;
122  }
123  return $result;
124  }
125 
130  function userSettingEnabled($setting)
131  {
132  $result = TRUE;
133  if ($this->settings["usr_settings_disable_".$setting] == 1)
134  {
135  $result = FALSE;
136  }
137  return $result;
138  }
139 
143  function uploadUserPicture()
144  {
145  global $ilUser;
146 
147  if ($this->workWithUserSetting("upload"))
148  {
149  $userfile_input = $this->form->getItemByPostVar("userfile");
150 
151  if ($_FILES["userfile"]["tmp_name"] == "")
152  {
153  if ($userfile_input->getDeletionFlag())
154  {
155  $ilUser->removeUserPicture();
156  }
157  return;
158  }
159 
160  if ($_FILES["userfile"]["size"] != 0)
161  {
162  $webspace_dir = ilUtil::getWebspaceDir();
163  $image_dir = $webspace_dir."/usr_images";
164  $store_file = "usr_".$ilUser->getID()."."."jpg";
165 
166  // store filename
167  $ilUser->setPref("profile_image", $store_file);
168  $ilUser->update();
169 
170  // move uploaded file
171  $uploaded_file = $image_dir."/upload_".$ilUser->getId()."pic";
172 
173  if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
174  $uploaded_file, false))
175  {
176  ilUtil::sendFailure($this->lng->txt("upload_error", true));
177  $this->ctrl->redirect($this, "showProfile");
178  }
179  chmod($uploaded_file, 0770);
180 
181  // take quality 100 to avoid jpeg artefacts when uploading jpeg files
182  // taking only frame [0] to avoid problems with animated gifs
183  $show_file = "$image_dir/usr_".$ilUser->getId().".jpg";
184  $thumb_file = "$image_dir/usr_".$ilUser->getId()."_small.jpg";
185  $xthumb_file = "$image_dir/usr_".$ilUser->getId()."_xsmall.jpg";
186  $xxthumb_file = "$image_dir/usr_".$ilUser->getId()."_xxsmall.jpg";
187  $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
188  $show_file = ilUtil::escapeShellArg($show_file);
189  $thumb_file = ilUtil::escapeShellArg($thumb_file);
190  $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
191  $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
192 //echo "-".ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file"."-";
193  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file");
194  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
195  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
196  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
197  }
198  }
199 
200 // $this->saveProfile();
201  }
202 
206  function removeUserPicture()
207  {
208  global $ilUser;
209 
210  $ilUser->removeUserPicture();
211 
212  $this->saveProfile();
213  }
214 
215 
220  {
221  global $ilUser, $ilSetting;
222 
223  /*
224  include_once('Services/LDAP/classes/class.ilLDAPServer.php');
225  if($ilUser->getAuthMode(true) == AUTH_LDAP and ($server_ids = ilLDAPServer::_getPasswordServers()))
226  {
227  include_once('Services/LDAP/classes/class.ilLDAPPasswordSynchronization.php');
228  $pwd_sync = new ilLDAPPasswordSynchronization($server_ids[0]);
229  $pwd_sync->setOldPassword($_POST["current_password"]);
230  $pwd_sync->setNewPassword($_POST["desired_password"]);
231  $pwd_sync->setRetypePassword($_POST["retype_password"]);
232  if(!$pwd_sync->synchronize())
233  {
234  $this->password_error = $pwd_sync->getError();
235  }
236  $this->saveProfile();
237  return false;
238  }
239  */
240  // do nothing if auth mode is not local database
241  if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
242  ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
243  ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local")) &&
244  ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local"))
245  )
246  {
247  $this->password_error = $this->lng->txt("not_changeable_for_non_local_auth");
248  }
249 
250  // select password from auto generated passwords
251  if ($this->ilias->getSetting("passwd_auto_generate") == 1)
252  {
253  // The old password needs to be checked for verification
254  // unless the user uses Shibboleth authentication with additional
255  // local authentication for WebDAV.
256  if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
257  {
258  // check old password
259  if (md5($_POST["current_password"]) != $ilUser->getPasswd())
260  {
261  $this->password_error = $this->lng->txt("passwd_wrong");
262  }
263  }
264  // validate transmitted password
265  if (!ilUtil::isPassword($_POST["new_passwd"]))
266  {
267  $this->password_error = $this->lng->txt("passwd_not_selected");
268  }
269 
270  if (empty($this->password_error))
271  {
272  ilUtil::sendSuccess($this->lng->txt("saved_successfully"));
273  $ilUser->updatePassword($_POST["current_password"], $_POST["new_passwd"], $_POST["new_passwd"]);
274  }
275  }
276  else
277  {
278  // check old password
279  if (md5($_POST["current_password"]) != $ilUser->getPasswd())
280  {
281  $this->password_error = $this->lng->txt("passwd_wrong");
282  }
283  // check new password
284  else if ($_POST["desired_password"] != $_POST["retype_password"])
285  {
286  $this->password_error = $this->lng->txt("passwd_not_match");
287  }
288  // validate password
289  else if (!ilUtil::isPassword($_POST["desired_password"],$custom_error))
290  {
291  if( $custom_error != '' )
292  $this->password_error = $custom_error;
293  else $this->password_error = $this->lng->txt("passwd_invalid");
294  }
295  else if ($_POST["current_password"] != "" and empty($this->password_error))
296  {
297  if( $ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded() )
298  {
299  if( $_POST["current_password"] != $_POST["desired_password"] )
300  {
301  if( $ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]) )
302  {
303  ilUtil::sendSuccess($this->lng->txt("saved_successfully"));
304  $ilUser->setLastPasswordChangeToNow();
305  }
306  }
307  else
308  {
309  $this->password_error = $this->lng->txt("new_pass_equals_old_pass");
310  }
311  }
312  else
313  {
314  ilUtil::sendSuccess($this->lng->txt("saved_successfully"));
315  $ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]);
316  $ilUser->setLastPasswordChangeToNow();
317  }
318  }
319  }
320 
321  $this->saveProfile();
322  }
323 
324 
325 
329  function saveProfile()
330  {
331  global $ilUser ,$ilSetting, $ilAuth;
332 
333  //init checking var
334  $form_valid = true;
335 
336  // testing by ratana ty:
337  // if people check on check box it will
338  // write some datata to table usr_pref
339  // if check on Public Profile
340  if (($_POST["chk_pub"])=="on")
341  {
342  $ilUser->setPref("public_profile","y");
343  }
344  else
345  {
346  $ilUser->setPref("public_profile","n");
347  }
348 
349  // if check on Institute
350  $val_array = array("institution", "department", "upload", "street",
351  "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
352  "fax", "email", "hobby", "matriculation");
353 
354  // set public profile preferences
355  foreach($val_array as $key => $value)
356  {
357  if (($_POST["chk_".$value]) == "on")
358  {
359  $ilUser->setPref("public_".$value,"y");
360  }
361  else
362  {
363  $ilUser->setPref("public_".$value,"n");
364  }
365  }
366 
367  $d_set = new ilSetting("delicious");
368  if ($d_set->get("user_profile"))
369  {
370  if (($_POST["chk_delicious"]) == "on")
371  {
372  $ilUser->setPref("public_delicious","y");
373  }
374  else
375  {
376  $ilUser->setPref("public_delicious","n");
377  }
378  }
379 
380 
381  // check dynamically required fields
382  foreach($this->settings as $key => $val)
383  {
384  if (substr($key,0,8) == "require_")
385  {
386  $require_keys[] = substr($key,8);
387  }
388  }
389 
390  foreach($require_keys as $key => $val)
391  {
392  // exclude required system and registration-only fields
393  $system_fields = array("login", "default_role", "passwd", "passwd2");
394  if (!in_array($val, $system_fields))
395  {
396  if ($this->workWithUserSetting($val))
397  {
398  if (isset($this->settings["require_" . $val]) && $this->settings["require_" . $val])
399  {
400  if (empty($_POST["usr_" . $val]))
401  {
402  ilUtil::sendFailure($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val));
403  $form_valid = false;
404  }
405  }
406  }
407  }
408  }
409 
410  // Check user defined required fields
411  if($form_valid and !$this->__checkUserDefinedRequiredFields())
412  {
413  ilUtil::sendFailure($this->lng->txt("fill_out_all_required_fields"));
414  $form_valid = false;
415  }
416 
417  // check email
418  if ($this->workWithUserSetting("email"))
419  {
420  if (!ilUtil::is_email($_POST["usr_email"]) and !empty($_POST["usr_email"]) and $form_valid)
421  {
422  ilUtil::sendFailure($this->lng->txt("email_not_valid"));
423  $form_valid = false;
424  }
425  }
426 
427  //update user data (not saving!)
428  if ($this->workWithUserSetting("firstname"))
429  {
430  $ilUser->setFirstName(ilUtil::stripSlashes($_POST["usr_firstname"]));
431  }
432  if ($this->workWithUserSetting("lastname"))
433  {
434  $ilUser->setLastName(ilUtil::stripSlashes($_POST["usr_lastname"]));
435  }
436  if ($this->workWithUserSetting("gender"))
437  {
438  $ilUser->setGender($_POST["usr_gender"]);
439  }
440  if ($this->workWithUserSetting("title"))
441  {
442  $ilUser->setUTitle(ilUtil::stripSlashes($_POST["usr_title"]));
443  }
444  $ilUser->setFullname();
445  if ($this->workWithUserSetting("institution"))
446  {
447  $ilUser->setInstitution(ilUtil::stripSlashes($_POST["usr_institution"]));
448  }
449  if ($this->workWithUserSetting("department"))
450  {
451  $ilUser->setDepartment(ilUtil::stripSlashes($_POST["usr_department"]));
452  }
453  if ($this->workWithUserSetting("street"))
454  {
455  $ilUser->setStreet(ilUtil::stripSlashes($_POST["usr_street"]));
456  }
457  if ($this->workWithUserSetting("zipcode"))
458  {
459  $ilUser->setZipcode(ilUtil::stripSlashes($_POST["usr_zipcode"]));
460  }
461  if ($this->workWithUserSetting("city"))
462  {
463  $ilUser->setCity(ilUtil::stripSlashes($_POST["usr_city"]));
464  }
465  if ($this->workWithUserSetting("country"))
466  {
467  $ilUser->setCountry(ilUtil::stripSlashes($_POST["usr_country"]));
468  }
469  if ($this->workWithUserSetting("phone_office"))
470  {
471  $ilUser->setPhoneOffice(ilUtil::stripSlashes($_POST["usr_phone_office"]));
472  }
473  if ($this->workWithUserSetting("phone_home"))
474  {
475  $ilUser->setPhoneHome(ilUtil::stripSlashes($_POST["usr_phone_home"]));
476  }
477  if ($this->workWithUserSetting("phone_mobile"))
478  {
479  $ilUser->setPhoneMobile(ilUtil::stripSlashes($_POST["usr_phone_mobile"]));
480  }
481  if ($this->workWithUserSetting("fax"))
482  {
483  $ilUser->setFax(ilUtil::stripSlashes($_POST["usr_fax"]));
484  }
485  if ($this->workWithUserSetting("email"))
486  {
487  $ilUser->setEmail(ilUtil::stripSlashes($_POST["usr_email"]));
488  }
489  if ($this->workWithUserSetting("hobby"))
490  {
491  $ilUser->setHobby(ilUtil::stripSlashes($_POST["usr_hobby"]));
492  }
493  if ($this->workWithUserSetting("referral_comment"))
494  {
495  $ilUser->setComment(ilUtil::stripSlashes($_POST["usr_referral_comment"]));
496  }
497  if ($this->workWithUserSetting("matriculation"))
498  {
499  $ilUser->setMatriculation(ilUtil::stripSlashes($_POST["usr_matriculation"]));
500  }
501 
502  // delicious
503  $d_set = new ilSetting("delicious");
504  if ($d_set->get("user_profile"))
505  {
506  $ilUser->setDelicious(ilUtil::stripSlashes($_POST["usr_delicious"]));
507  }
508 
509  // set instant messengers
510  if ($this->workWithUserSetting("instant_messengers"))
511  {
512  $ilUser->setInstantMessengerId('icq',ilUtil::stripSlashes($_POST["usr_im_icq"]));
513  $ilUser->setInstantMessengerId('yahoo',ilUtil::stripSlashes($_POST["usr_im_yahoo"]));
514  $ilUser->setInstantMessengerId('msn',ilUtil::stripSlashes($_POST["usr_im_msn"]));
515  $ilUser->setInstantMessengerId('aim',ilUtil::stripSlashes($_POST["usr_im_aim"]));
516  $ilUser->setInstantMessengerId('skype',ilUtil::stripSlashes($_POST["usr_im_skype"]));
517  $ilUser->setInstantMessengerId('jabber',ilUtil::stripSlashes($_POST["usr_im_jabber"]));
518  $ilUser->setInstantMessengerId('voip',ilUtil::stripSlashes($_POST["usr_im_voip"]));
519  }
520 
521  // Set user defined data
522  $ilUser->setUserDefinedData($_POST['udf']);
523 
524  // everthing's ok. save form data
525  if ($form_valid)
526  {
527  // init reload var. page should only be reloaded if skin or style were changed
528  $reload = false;
529 
530  if ($this->workWithUserSetting("skin_style"))
531  {
532  //set user skin and style
533  if ($_POST["usr_skin_style"] != "")
534  {
535  $sknst = explode(":", $_POST["usr_skin_style"]);
536 
537  if ($ilUser->getPref("style") != $sknst[1] ||
538  $ilUser->getPref("skin") != $sknst[0])
539  {
540  $ilUser->setPref("skin", $sknst[0]);
541  $ilUser->setPref("style", $sknst[1]);
542  $reload = true;
543  }
544  }
545  }
546 
547  if ($this->workWithUserSetting("language"))
548  {
549  // reload page if language was changed
550  //if ($_POST["usr_language"] != "" and $_POST["usr_language"] != $_SESSION['lang'])
551  // (this didn't work as expected, alex)
552  if ($_POST["usr_language"] != $ilUser->getLanguage())
553  {
554  $reload = true;
555  }
556 
557  // set user language
558  $ilUser->setLanguage($_POST["usr_language"]);
559 
560  }
561  if ($this->workWithUserSetting("hits_per_page"))
562  {
563  // set user hits per page
564  if ($_POST["hits_per_page"] != "")
565  {
566  $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
567  }
568  }
569 
570  // set show users online
571  if ($this->workWithUserSetting("show_users_online"))
572  {
573  $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
574  }
575 
576  // set hide own online_status
577  if ($this->workWithUserSetting("hide_own_online_status"))
578  {
579  if ($_POST["chk_hide_own_online_status"] != "")
580  {
581  $ilUser->setPref("hide_own_online_status","y");
582  }
583  else
584  {
585  $ilUser->setPref("hide_own_online_status","n");
586  }
587  }
588 
589  // personal desktop items in news block
590 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
591  if ($_POST["pd_items_news"] != "")
592  {
593  $ilUser->setPref("pd_items_news","y");
594  }
595  else
596  {
597  $ilUser->setPref("pd_items_news","n");
598  }
599 */
600 
601  // profile ok
602  $ilUser->setProfileIncomplete(false);
603 
604  // save user data & object_data
605  $ilUser->setTitle($ilUser->getFullname());
606  $ilUser->setDescription($ilUser->getEmail());
607 
608  $ilUser->update();
609 
610  // reload page only if skin or style were changed
611  // feedback
612  if (!empty($this->password_error))
613  {
614  ilUtil::sendFailure($this->password_error,true);
615  }
616  elseif (!empty($this->upload_error))
617  {
618  ilUtil::sendFailure($this->upload_error,true);
619  }
620  else if ($reload)
621  {
622  // feedback
623  ilUtil::sendSuccess($this->lng->txt("saved_successfully"),true);
624  $this->ctrl->redirect($this, "");
625  //$this->tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./start.php\";\n</script>\n");
626  }
627  else
628  {
629  ilUtil::sendSuccess($this->lng->txt("saved_successfully"),true);
630  }
631  }
632 
633  $this->showProfile();
634  }
635 
641  function showProfile()
642  {
643 $this->showPersonalData();
644 return;
645  global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting;
646 
647  $this->__initSubTabs("showProfile");
648 
649  $settings = $ilias->getAllSettings();
650 
651  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html",
652  "Services/User");
653 
654  // catch feedback message
655  if ($ilUser->getProfileIncomplete())
656  {
657  ilUtil::sendInfo($lng->txt("profile_incomplete"));
658  }
659 
660  // display infopanel if something happened
662 
663  if ($this->userSettingVisible("language"))
664  {
665  //get all languages
666  $languages = $this->lng->getInstalledLanguages();
667 
668  // preselect previous chosen language otherwise saved language
669  $selected_lang = (isset($_POST["usr_language"]))
670  ? $_POST["usr_language"]
671  : $ilUser->getLanguage();
672 
673  //go through languages
674  foreach($languages as $lang_key)
675  {
676  $this->tpl->setCurrentBlock("sel_lang");
677  //$tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
678  $this->tpl->setVariable("LANG", ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key));
679  $this->tpl->setVariable("LANGSHORT", $lang_key);
680 
681  if ($selected_lang == $lang_key)
682  {
683  $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
684  }
685 
686  $this->tpl->parseCurrentBlock();
687  }
688  }
689 
690  // get all templates
691  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
692  $templates = $styleDefinition->getAllTemplates();
693 
694  if ($this->userSettingVisible("skin_style"))
695  {
696  if (is_array($templates))
697  {
698 
699  foreach($templates as $template)
700  {
701  // get styles information of template
702  $styleDef =& new ilStyleDefinition($template["id"]);
703  $styleDef->startParsing();
704  $styles = $styleDef->getStyles();
705 
706  foreach($styles as $style)
707  {
708  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
709  {
710  continue;
711  }
712 
713  $this->tpl->setCurrentBlock("selectskin");
714  //echo "-".$ilUser->skin."-".$ilUser->prefs["style"]."-";
715  if ($ilUser->skin == $template["id"] &&
716  $ilUser->prefs["style"] == $style["id"])
717  {
718  $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
719  }
720 
721  $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
722  $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
723  $this->tpl->parseCurrentBlock();
724  }
725  }
726 
727  }
728  }
729 
730  // hits per page
731  if ($this->userSettingVisible("hits_per_page"))
732  {
733  $hits_options = array(2,10,15,20,30,40,50,100,9999);
734 
735  foreach($hits_options as $hits_option)
736  {
737  $this->tpl->setCurrentBlock("selecthits");
738 
739  if ($ilUser->prefs["hits_per_page"] == $hits_option)
740  {
741  $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
742  }
743 
744  $this->tpl->setVariable("HITSVALUE", $hits_option);
745 
746  if ($hits_option == 9999)
747  {
748  $hits_option = $this->lng->txt("no_limit");
749  }
750 
751  $this->tpl->setVariable("HITSOPTION", $hits_option);
752  $this->tpl->parseCurrentBlock();
753  }
754  }
755 
756  // Users Online
757  if ($this->userSettingVisible("show_users_online"))
758  {
759  $users_online_options = array("y","associated","n");
760  $selected_option = $ilUser->prefs["show_users_online"];
761  foreach($users_online_options as $an_option)
762  {
763  $this->tpl->setCurrentBlock("select_users_online");
764 
765  if ($selected_option == $an_option)
766  {
767  $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
768  }
769 
770  $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
771 
772  $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
773  $this->tpl->parseCurrentBlock();
774  }
775  }
776 
777  // hide_own_online_status
778  if ($this->userSettingVisible("hide_own_online_status")) {
779  if ($ilUser->prefs["hide_own_online_status"] == "y")
780  {
781  $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "checked");
782  }
783  }
784 
785  // personal desktop news
786 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
787  if ($ilUser->prefs["pd_items_news"] != "n")
788  {
789  $this->tpl->setVariable("PD_ITEMS_NEWS", "checked");
790  }
791  $this->tpl->setVariable("TXT_PD_ITEMS_NEWS",
792  $this->lng->txt("pd_items_news"));
793  $this->tpl->setVariable("TXT_PD_ITEMS_NEWS_INFO",
794  $this->lng->txt("pd_items_news_info"));
795 */
796 
797  if (($ilUser->getAuthMode(true) == AUTH_LOCAL ||
798  ($ilUser->getAuthMode(true) == AUTH_CAS && $ilSetting->get("cas_allow_local")) ||
799  ($ilUser->getAuthMode(true) == AUTH_SHIBBOLETH && $ilSetting->get("shib_auth_allow_local")) ||
800  ($ilUser->getAuthMode(true) == AUTH_SOAP && $ilSetting->get("soap_auth_allow_local"))
801  )
802  &&
803  $this->userSettingVisible('password'))
804  {
805  if($this->ilias->getSetting('usr_settings_disable_password'))
806  {
807  $this->tpl->setCurrentBlock("disabled_password");
808  $this->tpl->setVariable("TXT_DISABLED_PASSWORD", $this->lng->txt("chg_password"));
809  $this->tpl->setVariable("TXT_DISABLED_CURRENT_PASSWORD", $this->lng->txt("current_password"));
810  $this->tpl->parseCurrentBlock();
811  }
812  elseif ($settings["passwd_auto_generate"] == 1)
813  {
814  $passwd_list = ilUtil::generatePasswords(5);
815 
816  foreach ($passwd_list as $passwd)
817  {
818  $passwd_choice .= ilUtil::formRadioButton(0,"new_passwd",$passwd)." ".$passwd."<br/>";
819  }
820 
821  $this->tpl->setCurrentBlock("select_password");
822  switch ($ilUser->getAuthMode(true))
823  {
824  case AUTH_LOCAL :
825  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
826  break;
827  case AUTH_SHIBBOLETH :
828  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_and_webfolder_password"));
829  break;
830  default :
831  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_password"));
832  break;
833  }
834  $this->tpl->setVariable("TXT_CURRENT_PASSWORD", $this->lng->txt("current_password"));
835  $this->tpl->setVariable("TXT_SELECT_PASSWORD", $this->lng->txt("select_password"));
836  $this->tpl->setVariable("PASSWORD_CHOICE", $passwd_choice);
837  $this->tpl->setVariable("TXT_NEW_LIST_PASSWORD", $this->lng->txt("new_list_password"));
838  $this->tpl->parseCurrentBlock();
839  }
840  else
841  {
842  $this->tpl->setCurrentBlock("change_password");
843  switch ($ilUser->getAuthMode(true))
844  {
845  case AUTH_LOCAL :
846  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
847  break;
848  case AUTH_SHIBBOLETH :
849  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
851  {
852  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_and_webfolder_password"));
853  }
854  else
855  {
856  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_password"));
857  }
858  break;
859  default :
860  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_password"));
861  break;
862  }
863  $this->tpl->setVariable("TXT_CURRENT_PW", $this->lng->txt("current_password"));
864  $this->tpl->setVariable("TXT_DESIRED_PW", $this->lng->txt("desired_password"));
865  $this->tpl->setVariable("TXT_RETYPE_PW", $this->lng->txt("retype_password"));
866  $this->tpl->setVariable("CHANGE_PASSWORD", $this->lng->txt("chg_password"));
867  $this->tpl->parseCurrentBlock();
868  }
869  }
870 
871  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
872  // $this->lng->txt("personal_desktop"));
873  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
874  "");
875 
876  $this->tpl->setCurrentBlock("content");
877  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
878 
879  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
880  $this->tpl->setVariable("TXT_OF",strtolower($this->lng->txt("of")));
881  $this->tpl->setVariable("USR_FULLNAME",$ilUser->getFullname());
882 
883  $this->tpl->setVariable("TXT_USR_DATA", $this->lng->txt("userdata"));
884  switch ($ilUser->getAuthMode(true))
885  {
886  case AUTH_LOCAL :
887  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("username"));
888 
889  break;
890  case AUTH_SHIBBOLETH :
891  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
893  {
894  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("ilias_and_webfolder_username"));
895  }
896  else
897  {
898  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("ilias_username"));
899  }
900  break;
901  default :
902  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("ilias_username"));
903  break;
904 
905  }
906 
907  $this->tpl->setVariable("TXT_PUBLIC_PROFILE", $this->lng->txt("public_profile"));
908 
909  $data = array();
910  $data["fields"] = array();
911  $data["fields"]["gender"] = "";
912  $data["fields"]["firstname"] = "";
913  $data["fields"]["lastname"] = "";
914  $data["fields"]["title"] = "";
915  $data["fields"]["birthday"] = "";
916  $data["fields"]["institution"] = "";
917  $data["fields"]["department"] = "";
918  $data["fields"]["street"] = "";
919  $data["fields"]["city"] = "";
920  $data["fields"]["zipcode"] = "";
921  $data["fields"]["country"] = "";
922  $data["fields"]["phone_office"] = "";
923  $data["fields"]["phone_home"] = "";
924  $data["fields"]["phone_mobile"] = "";
925  $data["fields"]["fax"] = "";
926  $data["fields"]["email"] = "";
927  $data["fields"]["hobby"] = "";
928  $data["fields"]["referral_comment"] = "";
929  $data["fields"]["matriculation"] = "";
930  $data["fields"]["create_date"] = "";
931  $data["fields"]["approve_date"] = "";
932  $data["fields"]["active"] = "";
933 
934  $data["fields"]["default_role"] = $role;
935  // fill presets
936  foreach($data["fields"] as $key => $val)
937  {
938  // note: general "title" is not as "title" for a person
939  if ($key != "title")
940  {
941  $str = $this->lng->txt($key);
942  }
943  else
944  {
945  $str = $this->lng->txt("person_title");
946  }
947 
948  // check to see if dynamically required
949  if (isset($this->settings["require_" . $key]) && $this->settings["require_" . $key])
950  {
951  $str = $str . '<span class="asterisk">*</span>';
952  }
953 
954  if ($this->userSettingVisible("$key"))
955  {
956  $this->tpl->setVariable("TXT_".strtoupper($key), $str);
957  }
958  }
959 
960  if ($this->userSettingVisible("gender"))
961  {
962  $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
963  $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
964  }
965 
966  $d_set = new ilSetting("delicious");
967  if ($d_set->get("user_profile"))
968  {
969  $this->tpl->setVariable("TXT_DELICIOUS", $lng->txt("delicious"));
970  }
971 
972  if ($this->userSettingVisible("upload"))
973  {
974  $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("personal_picture"));
975  $webspace_dir = ilUtil::getWebspaceDir("output");
976  $full_img = $ilUser->getPref("profile_image");
977  $last_dot = strrpos($full_img, ".");
978  $small_img = substr($full_img, 0, $last_dot).
979  "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
980  $image_file = $webspace_dir."/usr_images/".$small_img;
981 
982  if (@is_file($image_file))
983  {
984  $this->tpl->setCurrentBlock("pers_image");
985  $this->tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
986  $this->tpl->setVariable("ALT_IMG_PERSONAL",$this->lng->txt("personal_picture"));
987  $this->tpl->parseCurrentBlock();
988  if ($this->userSettingEnabled("upload"))
989  {
990  $this->tpl->setCurrentBlock("remove_pic");
991  $this->tpl->setVariable("TXT_REMOVE_PIC", $this->lng->txt("remove_personal_picture"));
992  }
993  $this->tpl->parseCurrentBlock();
994  $this->tpl->setCurrentBlock("content");
995  }
996 
997  if ($this->userSettingEnabled("upload"))
998  {
999  $this->tpl->setCurrentBlock("upload_pic");
1000  $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
1001  }
1002  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("userfile"));
1003  $this->tpl->setVariable("USER_FILE", $this->lng->txt("user_file"));
1004  }
1005  $this->tpl->setCurrentBlock("adm_content");
1006 
1007  // ilinc upload pic
1008  if ($this->userSettingVisible("upload") and $this->ilias->getSetting("ilinc_active"))
1009  {
1010  include_once ('./Modules/ILinc/classes/class.ilObjiLincUser.php');
1011  $ilinc_user = new ilObjiLincUser($ilUser);
1012 
1013  if ($ilinc_user->id)
1014  {
1015  include_once ('./Modules/ILinc/classes/class.ilnetucateXMLAPI.php');
1016  $ilincAPI = new ilnetucateXMLAPI();
1017 
1018  $ilincAPI->uploadPicture($ilinc_user);
1019  $response = $ilincAPI->sendRequest("uploadPicture");
1020 
1021  // return URL to user's personal page
1022  $url = trim($response->data['url']['cdata']);
1023  $this->tpl->setCurrentBlock("ilinc_upload_pic");
1024  $this->tpl->setVariable("TXT_ILINC_UPLOAD", $this->lng->txt("ilinc_upload_pic_text"));
1025  $this->tpl->setVariable("ILINC_UPLOAD_LINK", $url);
1026  $this->tpl->setVariable("ILINC_UPLOAD_LINKTXT", $this->lng->txt("ilinc_upload_pic_linktext"));
1027  $this->tpl->parseCurrentBlock();
1028  }
1029  }
1030 
1031 
1032  if ($this->userSettingVisible("language"))
1033  {
1034  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
1035  }
1036  if ($this->userSettingVisible("show_users_online"))
1037  {
1038  $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
1039  }
1040  if ($this->userSettingVisible("hide_own_online_status"))
1041  {
1042  $this->tpl->setVariable("TXT_HIDE_OWN_ONLINE_STATUS", $this->lng->txt("hide_own_online_status"));
1043  }
1044  if ($this->userSettingVisible("skin_style"))
1045  {
1046  $this->tpl->setVariable("TXT_USR_SKIN_STYLE", $this->lng->txt("usr_skin_style"));
1047  }
1048  if ($this->userSettingVisible("hits_per_page"))
1049  {
1050  $this->tpl->setVariable("TXT_HITS_PER_PAGE", $this->lng->txt("usr_hits_per_page"));
1051  }
1052  if ($this->userSettingVisible("show_users_online"))
1053  {
1054  $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
1055  }
1056  $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
1057  $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
1058  $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
1059 
1060  if($this->__showOtherInformations())
1061  {
1062  $this->tpl->setVariable("TXT_OTHER", $this->lng->txt("user_profile_other"));
1063  }
1064 
1065  $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
1066 
1067  //values
1068  if((int)$ilSetting->get('allow_change_loginname'))
1069  {
1070  $this->tpl->setCurrentBlock('nickname_req');
1071  $this->tpl->touchBlock('nickname_req');
1072  $this->tpl->parseCurrentBlock();
1073 
1074  $this->tpl->setVariable('NICKNAME_CHANGEABLE', ilUtil::prepareFormOutput($ilUser->getLogin()));
1075  }
1076  else
1077  {
1078  $this->tpl->setVariable('NICKNAME_FIX', ilUtil::prepareFormOutput($ilUser->getLogin()));
1079  }
1080 
1081  if ($this->userSettingVisible("firstname"))
1082  {
1083  $this->tpl->setVariable("FIRSTNAME", ilUtil::prepareFormOutput($ilUser->getFirstname()));
1084  }
1085  if ($this->userSettingVisible("lastname"))
1086  {
1087  $this->tpl->setVariable("LASTNAME", ilUtil::prepareFormOutput($ilUser->getLastname()));
1088  }
1089 
1090  if ($this->userSettingVisible("gender"))
1091  {
1092  // gender selection
1093  $gender = strtoupper($ilUser->getGender());
1094 
1095  if (!empty($gender))
1096  {
1097  $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
1098  }
1099  }
1100 
1101  $this->tpl->setVariable("CREATE_DATE", $ilUser->getCreateDate());
1102  $this->tpl->setVariable("APPROVE_DATE", $ilUser->getApproveDate());
1103 
1104  if ($ilUser->getActive())
1105  {
1106  $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
1107  }
1108 
1109  if ($this->userSettingVisible("title"))
1110  {
1111  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($ilUser->getUTitle()));
1112  }
1113  if ($this->userSettingVisible("institution"))
1114  {
1115  $this->tpl->setVariable("INSTITUTION", ilUtil::prepareFormOutput($ilUser->getInstitution()));
1116  }
1117  if ($this->userSettingVisible("department"))
1118  {
1119  $this->tpl->setVariable("DEPARTMENT", ilUtil::prepareFormOutput($ilUser->getDepartment()));
1120  }
1121  if ($this->userSettingVisible("street"))
1122  {
1123  $this->tpl->setVariable("STREET", ilUtil::prepareFormOutput($ilUser->getStreet()));
1124  }
1125  if ($this->userSettingVisible("zipcode"))
1126  {
1127  $this->tpl->setVariable("ZIPCODE", ilUtil::prepareFormOutput($ilUser->getZipcode()));
1128  }
1129  if ($this->userSettingVisible("city"))
1130  {
1131  $this->tpl->setVariable("CITY", ilUtil::prepareFormOutput($ilUser->getCity()));
1132  }
1133  if ($this->userSettingVisible("country"))
1134  {
1135  $this->tpl->setVariable("COUNTRY", ilUtil::prepareFormOutput($ilUser->getCountry()));
1136  }
1137  if ($this->userSettingVisible("phone_office"))
1138  {
1139  $this->tpl->setVariable("PHONE_OFFICE", ilUtil::prepareFormOutput($ilUser->getPhoneOffice()));
1140  }
1141  if ($this->userSettingVisible("phone_home"))
1142  {
1143  $this->tpl->setVariable("PHONE_HOME", ilUtil::prepareFormOutput($ilUser->getPhoneHome()));
1144  }
1145  if ($this->userSettingVisible("phone_mobile"))
1146  {
1147  $this->tpl->setVariable("PHONE_MOBILE", ilUtil::prepareFormOutput($ilUser->getPhoneMobile()));
1148  }
1149  if ($this->userSettingVisible("fax"))
1150  {
1151  $this->tpl->setVariable("FAX", ilUtil::prepareFormOutput($ilUser->getFax()));
1152  }
1153  if ($this->userSettingVisible("email"))
1154  {
1155  $this->tpl->setVariable("EMAIL", ilUtil::prepareFormOutput($ilUser->getEmail()));
1156  }
1157  if ($this->userSettingVisible("hobby"))
1158  {
1159  $this->tpl->setVariable("HOBBY", ilUtil::prepareFormOutput($ilUser->getHobby())); // here
1160  }
1161  if ($this->userSettingVisible("referral_comment"))
1162  {
1163  $this->tpl->setVariable("REFERRAL_COMMENT", ilUtil::prepareFormOutput($ilUser->getComment()));
1164  }
1165  if ($this->userSettingVisible("matriculation"))
1166  {
1167  $this->tpl->setVariable("MATRICULATION", ilUtil::prepareFormOutput($ilUser->getMatriculation()));
1168  }
1169 
1170  // instant messengers
1171  if ($this->userSettingVisible("instant_messengers"))
1172  {
1173  $this->tpl->setVariable("TXT_INSTANT_MESSENGERS", $this->lng->txt("user_profile_instant_messengers"));
1174 
1175  $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
1176  $im_disabled = !$this->userSettingEnabled("instant_messengers") ? "disabled=\"disabled\"": "";
1177 
1178  foreach ($im_arr as $im_name)
1179  {
1180  $im_id = $ilUser->getInstantMessengerId($im_name);
1181  $this->tpl->setCurrentBlock("im_row");
1182  $this->tpl->setVariable("TXT_IM_NAME",$this->lng->txt("im_".$im_name));
1183  $this->tpl->setVariable("USR_IM_NAME","usr_im_".$im_name);
1184  $this->tpl->setVariable("IM_ID",$im_id);
1185  $this->tpl->setVariable("DISABLED_IM_NAME",$im_disabled);
1186  $this->tpl->setVariable("IMG_IM_ICON", ilUtil::getImagePath($im_name.'online.gif'));
1187  $this->tpl->setVariable("TXT_IM_ICON", $this->lng->txt("im_".$im_name."_icon"));
1188  $this->tpl->setVariable("CHK_IM", "checked=\"checked\" disabled=\"disabled\"");
1189  $this->tpl->parseCurrentBlock();
1190  }
1191  }
1192 
1193  $d_set = new ilSetting("delicious");
1194  if ($d_set->get("user_profile") == "1")
1195  {
1196  $this->tpl->setVariable("DELICIOUS", ilUtil::prepareFormOutput($ilUser->getDelicious()));
1197  }
1198 
1199  // show user defined visible fields
1200  $this->__showUserDefinedFields();
1201 
1202  // get assigned global roles (default roles)
1203  $global_roles = $rbacreview->getGlobalRoles();
1204 
1205  foreach($global_roles as $role_id)
1206  {
1207  if (in_array($role_id,$rbacreview->assignedRoles($ilUser->getId())))
1208  {
1209  $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1210  $role_names .= $roleObj->getTitle().", ";
1211  unset($roleObj);
1212  }
1213  }
1214 
1215  $this->tpl->setVariable("TXT_DEFAULT_ROLES", $this->lng->txt("default_roles"));
1216  $this->tpl->setVariable("DEFAULT_ROLES", substr($role_names,0,-2));
1217 
1218  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
1219 
1220  //button
1221  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1222 
1223  // addeding by ratana ty
1224  if ($this->userSettingEnabled("upload"))
1225  {
1226  $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
1227  }
1228 
1229  //
1230  if ($ilUser->prefs["public_profile"] == "y")
1231  {
1232  $this->tpl->setVariable("CHK_PUB","checked");
1233  }
1234  $val_array = array("institution", "department", "upload", "street",
1235  "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
1236  "fax", "email", "hobby", "matriculation", "show_users_online");
1237  foreach($val_array as $key => $value)
1238  {
1239  if ($this->userSettingVisible("$value"))
1240  {
1241  if ($ilUser->prefs["public_".$value] == "y")
1242  {
1243  $this->tpl->setVariable("CHK_".strtoupper($value), "checked");
1244  }
1245  }
1246  }
1247 
1248  $d_set = new ilSetting("delicious");
1249  if ($d_set->get("user_profile") == "1")
1250  {
1251  if ($ilUser->prefs["public_delicious"] == "y")
1252  {
1253  $this->tpl->setVariable("CHK_DELICIOUS", "checked");
1254  }
1255  }
1256 
1257 
1258  // End of showing
1259  // Testing by ratana ty
1260 
1261 
1262  $profile_fields = array(
1263  "gender",
1264  "firstname",
1265  "lastname",
1266  "title",
1267  "upload",
1268  "institution",
1269  "department",
1270  "street",
1271  "city",
1272  "zipcode",
1273  "country",
1274  "phone_office",
1275  "phone_home",
1276  "phone_mobile",
1277  "fax",
1278  "email",
1279  "hobby",
1280  "matriculation",
1281  "referral_comment",
1282  "language",
1283  "skin_style",
1284  "hits_per_page",
1285  "show_users_online",
1286  "hide_own_online_status"
1287  );
1288  foreach ($profile_fields as $field)
1289  {
1290  if (!$this->ilias->getSetting("usr_settings_hide_" . $field))
1291  {
1292  if ($this->ilias->getSetting("usr_settings_disable_" . $field))
1293  {
1294  $this->tpl->setVariable("DISABLED_" . strtoupper($field), " disabled=\"disabled\"");
1295  }
1296  }
1297  }
1298 
1299  $this->tpl->parseCurrentBlock();
1300  $this->tpl->show();
1301  }
1302 
1310  public function saveMailOptions()
1311  {
1312  global $ilUser, $lng, $ilTabs, $ilSetting;
1313 
1314  $lng->loadLanguageModule('mail');
1315 
1316  $this->__initSubTabs('showMailOptions');
1317  $ilTabs->setSubTabActive('mail_settings');
1318 
1319  //$this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
1320  // $lng->txt('personal_desktop'));
1321  $this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
1322  "");
1323  $this->tpl->setTitle($lng->txt('personal_desktop'));
1324 
1325  require_once 'Services/Mail/classes/class.ilMailOptions.php';
1326  $mailOptions = new ilMailOptions($ilUser->getId());
1327  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1' &&
1328  $ilSetting->get('usr_settings_disable_mail_incoming_mail') != '1')
1329  {
1330  $incoming_type = (int)$_POST['incoming_type'];
1331  }
1332  else
1333  {
1334  $incoming_type = $mailOptions->getIncomingType();
1335  }
1336 
1337  $this->initMailOptionsForm();
1338  if($this->form->checkInput())
1339  {
1340  $mailOptions->updateOptions(
1341  ilUtil::stripSlashes($_POST['signature']),
1342  (int)$_POST['linebreak'],
1343  $incoming_type,
1344  (int)$_POST['cronjob_notification']
1345  );
1346 
1347  ilUtil::sendSuccess($lng->txt('mail_options_saved'));
1348  }
1349 
1350  if(!isset($_POST['incoming_type']))
1351  {
1352  $_POST['incoming_type'] = $mailOptions->getIncomingType();
1353  }
1354 
1355  $this->form->setValuesByPost();
1356 
1357  $this->tpl->setContent($this->form->getHTML());
1358  $this->tpl->show();
1359  }
1360 
1367  private function initMailOptionsForm()
1368  {
1369  global $ilCtrl, $ilSetting, $lng, $ilUser;
1370 
1371  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1372  $this->form = new ilPropertyFormGUI();
1373 
1374  $this->form->setFormAction($ilCtrl->getFormAction($this, 'saveMailOptions'));
1375  $this->form->setTitle($lng->txt('mail_settings'));
1376 
1377  // BEGIN INCOMING
1378  include_once 'Services/Mail/classes/class.ilMailOptions.php';
1379  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1')
1380  {
1381  $options = array(
1382  IL_MAIL_LOCAL => $this->lng->txt('mail_incoming_local'),
1383  IL_MAIL_EMAIL => $this->lng->txt('mail_incoming_smtp'),
1384  IL_MAIL_BOTH => $this->lng->txt('mail_incoming_both')
1385  );
1386  $si = new ilSelectInputGUI($lng->txt('mail_incoming'), 'incoming_type');
1387  $si->setOptions($options);
1388  if(!strlen(ilObjUser::_lookupEmail($ilUser->getId())) ||
1389  $ilSetting->get('usr_settings_disable_mail_incoming_mail') == '1')
1390  {
1391  $si->setDisabled(true);
1392  }
1393  $this->form->addItem($si);
1394  }
1395 
1396  // BEGIN LINEBREAK_OPTIONS
1397  $options = array();
1398  for($i = 50; $i <= 80; $i++)
1399  {
1400  $options[$i] = $i;
1401  }
1402  $si = new ilSelectInputGUI($lng->txt('linebreak'), 'linebreak');
1403  $si->setOptions($options);
1404  $this->form->addItem($si);
1405 
1406  // BEGIN SIGNATURE
1407  $ta = new ilTextAreaInputGUI($lng->txt('signature'), 'signature');
1408  $ta->setRows(10);
1409  $ta->setCols(60);
1410  $this->form->addItem($ta);
1411 
1412  // BEGIN CRONJOB NOTIFICATION
1413  if($ilSetting->get('mail_notification'))
1414  {
1415  $cb = new ilCheckboxInputGUI($lng->txt('cron_mail_notification'), 'cronjob_notification');
1416  $cb->setInfo($lng->txt('mail_cronjob_notification_info'));
1417  $cb->setValue(1);
1418  $this->form->addItem($cb);
1419  }
1420 
1421  $this->form->addCommandButton('saveMailOptions', $lng->txt('save'));
1422  }
1423 
1430  private function setMailOptionsValuesByDB()
1431  {
1432  global $ilUser, $ilSetting;
1433 
1434  require_once 'Services/Mail/classes/class.ilMailOptions.php';
1435  $mailOptions = new ilMailOptions($ilUser->getId());
1436 
1437  $data = array(
1438  'linebreak' => $mailOptions->getLinebreak(),
1439  'signature' => $mailOptions->getSignature(),
1440  'cronjob_notification' => $mailOptions->getCronjobNotification()
1441  );
1442 
1443  if($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1')
1444  {
1445  $data['incoming_type'] = $mailOptions->getIncomingType();
1446  }
1447 
1448  $this->form->setValuesByArray($data);
1449  }
1450 
1457  public function showMailOptions()
1458  {
1459  global $ilTabs, $lng;
1460 
1461  $lng->loadLanguageModule('mail');
1462 
1463  $this->__initSubTabs('showMailOptions');
1464  $ilTabs->setSubTabActive('mail_settings');
1465 
1466  //$this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
1467  // $lng->txt('personal_desktop'));
1468  $this->tpl->setTitleIcon(ilUtil::getImagePath('icon_pd_b.gif'),
1469  "");
1470  $this->tpl->setTitle($lng->txt('personal_desktop'));
1471 
1472  $this->initMailOptionsForm();
1473  $this->setMailOptionsValuesByDB();
1474 
1475  $this->tpl->setContent($this->form->getHTML());
1476  $this->tpl->show();
1477  }
1478 
1479  function showjsMath()
1480  {
1481  global $lng, $ilCtrl, $tpl, $ilUser;
1482 
1483  $this->__initSubTabs("showjsMath");
1484  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
1485  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), "");
1486  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
1487 
1488  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1489  $form = new ilPropertyFormGUI();
1490  $form->setFormAction($ilCtrl->getFormAction($this));
1491  $form->setTitle($lng->txt("jsmath_settings"));
1492 
1493  // Enable jsMath
1494  include_once "./Services/Administration/classes/class.ilSetting.php";
1495  $jsMathSetting = new ilSetting("jsMath");
1496  $enable = new ilCheckboxInputGUI($lng->txt("jsmath_enable_user"), "enable");
1497  $checked = ($ilUser->getPref("js_math") === FALSE) ? $jsMathSetting->get("makedefault") : $ilUser->getPref("js_math");
1498  $enable->setChecked($checked);
1499  $enable->setInfo($lng->txt("jsmath_enable_user_desc"));
1500  $form->addItem($enable);
1501 
1502  $form->addCommandButton("savejsMath", $lng->txt("save"));
1503  $form->addCommandButton("showjsMath", $lng->txt("cancel"));
1504 
1505  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1506  $this->tpl->show();
1507  }
1508 
1509  function savejsMath()
1510  {
1511  global $ilCtrl, $ilUser;
1512 
1513  include_once "./Services/Administration/classes/class.ilSetting.php";
1514  $jsMathSetting = new ilSetting("jsMath");
1515  if ($jsMathSetting->get("enable"))
1516  {
1517  if ($_POST["enable"])
1518  {
1519  $ilUser->writePref("js_math", "1");
1520  }
1521  else
1522  {
1523  $ilUser->writePref("js_math", "0");
1524  }
1525  }
1526  $ilCtrl->redirect($this, "showjsMath");
1527  }
1528 
1529  function showLocation()
1530  {
1531  global $ilUser, $ilCtrl, $ilUser, $lng;
1532 
1533  $lng->loadLanguageModule("gmaps");
1534 
1535  // check google map activation
1536  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1538  {
1539  return;
1540  }
1541 
1542  $this->__initSubTabs("showLocation");
1543 
1544  $latitude = $ilUser->getLatitude();
1545  $longitude = $ilUser->getLongitude();
1546  $zoom = $ilUser->getLocationZoom();
1547 
1548  // Get Default settings, when nothing is set
1549  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
1550  {
1552  $latitude = $def["latitude"];
1553  $longitude = $def["longitude"];
1554  $zoom = $def["zoom"];
1555  }
1556 
1557  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
1558  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), "");
1559  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
1560 
1561  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1562  $form = new ilPropertyFormGUI();
1563  $form->setFormAction($ilCtrl->getFormAction($this));
1564 
1565  $form->setTitle($this->lng->txt("location")." ".
1566  strtolower($this->lng->txt("of"))." ".$ilUser->getFullname());
1567 
1568  // public profile
1569  $public = new ilCheckboxInputGUI($this->lng->txt("public_profile"),
1570  "public_location");
1571  $public->setValue("y");
1572  $public->setInfo($this->lng->txt("gmaps_public_profile_info"));
1573  $public->setChecked($ilUser->getPref("public_location"));
1574  $form->addItem($public);
1575 
1576  // location property
1577  $loc_prop = new ilLocationInputGUI($this->lng->txt("location"),
1578  "location");
1579  $loc_prop->setLatitude($latitude);
1580  $loc_prop->setLongitude($longitude);
1581  $loc_prop->setZoom($zoom);
1582 
1583  $street = $ilUser->getStreet();
1584  if (!$street)
1585  {
1586  $street = $this->lng->txt("street");
1587  }
1588 
1589  $city = $ilUser->getCity();
1590  if (!$city)
1591  {
1592  $city = $this->lng->txt("city");
1593  }
1594 
1595  $country = $ilUser->getCountry();
1596  if (!$country)
1597  {
1598  $country = $this->lng->txt("country");
1599  }
1600 
1601  $loc_prop->setAddress($street.",".$city.",".$country);
1602 
1603  $form->addItem($loc_prop);
1604 
1605  $form->addCommandButton("saveLocation", $this->lng->txt("save"));
1606 
1607  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1608  $this->tpl->show();
1609  }
1610 
1611  function saveLocation()
1612  {
1613  global $ilCtrl, $ilUser, $lng;
1614 
1615  $ilUser->writePref("public_location", $_POST["public_location"]);
1616 
1617  $ilUser->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
1618  $ilUser->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
1619  $ilUser->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
1620  $ilUser->update();
1621  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1622 
1623  $ilCtrl->redirect($this, "showLocation");
1624  }
1625 
1626  // init sub tabs
1627  function __initSubTabs($a_cmd)
1628  {
1629  global $ilTabs, $ilSetting;
1630 
1631  $showProfile = ($a_cmd == 'showProfile') ? true : false;
1632  $showPersonalData = ($a_cmd == 'showPersonalData') ? true : false;
1633  $showPublicProfile = ($a_cmd == 'showPublicProfile') ? true : false;
1634  $showPassword = ($a_cmd == 'showPassword') ? true : false;
1635  $showGeneralSettings = ($a_cmd == 'showGeneralSettings') ? true : false;
1636  $showMailOptions = ($a_cmd == 'showMailOptions') ? true : false;
1637  $showLocation = ($a_cmd == 'showLocation') ? true : false;
1638  $showjsMath = ($a_cmd == 'showjsMath') ? true : false;
1639  $showChatOptions = ($a_cmd == 'showChatOptions') ? true : false;
1640 
1641  // old profile
1642 /*
1643  $ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showProfile"),
1644  "", "", "", $showProfile);
1645 */
1646 
1647  // personal data
1648  $ilTabs->addSubTabTarget("personal_data", $this->ctrl->getLinkTarget($this, "showPersonalData"));
1649 
1650  // public profile
1651  $ilTabs->addSubTabTarget("public_profile", $this->ctrl->getLinkTarget($this, "showPublicProfile"));
1652 
1653  // password
1654  if ($this->allowPasswordChange())
1655  {
1656  $ilTabs->addSubTabTarget("password", $this->ctrl->getLinkTarget($this, "showPassword"),
1657  "", "", "", $showPassword);
1658  }
1659 
1660  // general settings
1661  $ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
1662  "", "", "", $showGeneralSettings);
1663 
1664 
1665  // check google map activation
1666  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1668  {
1669  $ilTabs->addSubTabTarget("location", $this->ctrl->getLinkTarget($this, "showLocation"),
1670  "", "", "", $showLocation);
1671  }
1672 
1673  $ilTabs->addSubTabTarget("mail_settings", $this->ctrl->getLinkTarget($this, "showMailOptions"),
1674  "", "", "", $showMailOptions);
1675 
1676  if(((int)$ilSetting->get('chat_sound_status') &&
1677  ((int)$ilSetting->get('chat_new_invitation_sound_status') ||
1678  (int)$ilSetting->get('chat_new_message_sound_status'))) ||
1679  (int)$ilSetting->get('chat_message_notify_status') == 1)
1680  {
1681  $ilTabs->addSubTabTarget("chat_settings", $this->ctrl->getLinkTarget($this, "showChatOptions"),
1682  "", "", "", $showChatOptions);
1683  }
1684 
1685  include_once "./Services/Administration/classes/class.ilSetting.php";
1686  $jsMathSetting = new ilSetting("jsMath");
1687  if ($jsMathSetting->get("enable"))
1688  {
1689  $ilTabs->addSubTabTarget("jsmath_extt_jsmath", $this->ctrl->getLinkTarget($this, "showjsMath"),
1690  "", "", "", $showjsMath);
1691  }
1692  }
1693 
1694 
1696  {
1697  $d_set = new ilSetting("delicous");
1698  if($this->userSettingVisible("matriculation") or count($this->user_defined_fields->getVisibleDefinitions())
1699  or $d_set->get("user_profile") == "1")
1700  {
1701  return true;
1702  }
1703  return false;
1704  }
1705 
1707  {
1708  global $ilUser;
1709 
1710  $user_defined_data = $ilUser->getUserDefinedData();
1711  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1712  {
1713  if($definition['field_type'] == UDF_TYPE_TEXT)
1714  {
1715  $this->tpl->setCurrentBlock("field_text");
1716  $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($user_defined_data[$field_id]));
1717  if(!$definition['changeable'])
1718  {
1719  $this->tpl->setVariable("DISABLED_FIELD",'disabled=\"disabled\"');
1720  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1721  }
1722  else
1723  {
1724  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1725  }
1726  $this->tpl->parseCurrentBlock();
1727  }
1728  else
1729  {
1730  if($definition['changeable'])
1731  {
1732  $name = 'udf['.$definition['field_id'].']';
1733  $disabled = false;
1734  }
1735  else
1736  {
1737  $name = '';
1738  $disabled = true;
1739  }
1740  $this->tpl->setCurrentBlock("field_select");
1741  $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($user_defined_data[$field_id],
1742  $name,
1743  $this->user_defined_fields->fieldValuesToSelectArray(
1744  $definition['field_values']),
1745  false,
1746  true,0,'','',$disabled));
1747  $this->tpl->parseCurrentBlock();
1748  }
1749  $this->tpl->setCurrentBlock("user_defined");
1750 
1751  if($definition['required'])
1752  {
1753  $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
1754  }
1755  else
1756  {
1757  $name = $definition['field_name'];
1758  }
1759  $this->tpl->setVariable("TXT_FIELD_NAME",$name);
1760  $this->tpl->parseCurrentBlock();
1761  }
1762  return true;
1763  }
1764 
1766  {
1767  foreach($this->user_defined_fields->getVisibleDefinitions() as $definition)
1768  {
1769  $field_id = $definition['field_id'];
1770  if($definition['required'] and !strlen($_POST['udf'][$field_id]))
1771  {
1772  return false;
1773  }
1774  }
1775  return true;
1776  }
1777 
1778 
1779  private function getChatSettingsForm()
1780  {
1781  global $ilCtrl, $ilSetting, $lng;
1782 
1783  $lng->loadLanguageModule('chat');
1784 
1785  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1786  $form = new ilPropertyFormGUI();
1787 
1788  $form->setFormAction($this->ctrl->getFormAction($this, 'saveChatOptions'));
1789  $form->setTitle($lng->txt("chat_settings"));
1790 
1791  if((int)$ilSetting->get('chat_message_notify_status'))
1792  {
1793  // chat message notification in ilias
1794  //$rg_parent = new ilRadioGroupInputGUI($this->lng->txt('chat_message_notify'), 'chat_message_notify_status');
1795  //$rg_parent->setValue(0);
1796 
1797  $ro_parent = new ilCheckboxInputGUI($this->lng->txt('chat_message_notify_activate'), 'chat_message_notify_activate');
1798  $ro_parent->setOptionTitle($this->lng->txt('chat_activate_status_notification'));
1799  //$rg_parent->addOption($ro_parent);
1800  #$ro_parent->setValue(0);
1801 
1802  if((int)$ilSetting->get('chat_sound_status') &&
1803  ((int)$ilSetting->get('chat_new_invitation_sound_status') ||
1804  (int)$ilSetting->get('chat_new_message_sound_status')))
1805  {
1806  // sound activation/deactivation for new chat invitations and messages
1807  #$rg = new ilRadioGroupInputGUI($this->lng->txt('chat_sounds'), 'chat_sound_status');
1808  #$rg->setValue(0);
1809  #$ro = new ilCheckboxInputGUI($this->lng->txt('chat_sound_status_activate'), 1);
1810  if((int)$ilSetting->get('chat_new_invitation_sound_status'))
1811  {
1812  $chb = new ilCheckboxInputGUI('', 'chat_new_invitation_sound_status');
1813  $chb->setOptionTitle($this->lng->txt('chat_new_invitation_sound_status'));
1814  $chb->setChecked(false);
1815  $ro_parent->addSubItem($chb);
1816  }
1817 
1818  if((int)$ilSetting->get('chat_new_message_sound_status'))
1819  {
1820  $chb = new ilCheckBoxInputGUI('','chat_new_message_sound_status');
1821  $chb->setOptionTitle($this->lng->txt('chat_new_message_sound_status'));
1822  $chb->setChecked(false);
1823  $ro_parent->addSubItem($chb);
1824  }
1825  #$rg->addOption($ro);
1826 
1827  //$ro = new ilRadioOption($this->lng->txt('chat_sound_status_deactivate'), 0);
1828  //$rg->addOption($ro);
1829 
1830  #$ro_parent->addSubItem($rg);
1831  //$form->addItem($rg);
1832  }
1833 
1834 
1835  #$ro_parent = new ilRadioOption($this->lng->txt('chat_message_notify_deactivate'), 0);
1836  #$rg_parent->addOption($ro_parent);
1837  $form->addItem($ro_parent);
1838  }
1839 
1840  $form->addCommandButton("saveChatOptions", $lng->txt("save"));
1841  return $form;
1842  }
1843 
1844  public function saveChatOptions()
1845  {
1846  global $ilUser, $ilSetting, $lng;
1847 
1848  if((int)$ilSetting->get('chat_message_notify_status'))
1849  {
1850  $ilUser->setPref('chat_message_notify_status', (int)$_POST['chat_message_notify_activate']);
1851  }
1852 
1853  if((int)$ilSetting->get('chat_sound_status') &&
1854  ((int)$ilSetting->get('chat_new_invitation_sound_status') ||
1855  (int)$ilSetting->get('chat_new_message_sound_status')))
1856  {
1857  $ilUser->setPref('chat_sound_status', (int)$_POST['chat_sound_status']);
1858  if((int)$ilSetting->get('chat_new_invitation_sound_status'))
1859  {
1860  $ilUser->setPref('chat_new_invitation_sound_status', (int)$_POST['chat_new_invitation_sound_status']);
1861  }
1862  if((int)$ilSetting->get('chat_new_message_sound_status'))
1863  {
1864  $ilUser->setPref('chat_new_message_sound_status', (int)$_POST['chat_new_message_sound_status']);
1865  }
1866  }
1867 
1868  $ilUser->writePrefs();
1869 
1870  ilUtil::sendSuccess($lng->txt('saved'));
1871 
1872  $this->showChatOptions(true);
1873  }
1874 
1878  public function showChatOptions($by_post = false)
1879  {
1880  global $ilCtrl, $ilSetting, $lng, $ilUser;
1881 
1882  $this->__initSubTabs('showChatOptions');
1883 
1884  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
1885  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), "");
1886  $this->tpl->setVariable('HEADER', $this->lng->txt('personal_desktop'));
1887 
1888  $form = false;
1889  if($by_post)
1890  {
1891  $form = $this->getChatSettingsForm();
1892  $form->setValuesByPost();
1893  }
1894  else
1895  {
1896  $values = array();
1897  $values['chat_message_notify_status'] = $ilUser->getPref('chat_message_notify_status');
1898  $values['chat_message_notify_activate'] = $ilUser->getPref('chat_message_notify_status');
1899 
1900  $values['chat_sound_status'] = $ilUser->getPref('chat_sound_status');
1901  $values['chat_new_invitation_sound_status'] = $ilUser->getPref('chat_new_invitation_sound_status');
1902  $values['chat_new_message_sound_status'] = $ilUser->getPref('chat_new_message_sound_status');
1903 
1904  $form = $this->getChatSettingsForm();
1905  $form->setValuesByArray($values);
1906 
1907  }
1908  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1909  $this->tpl->show();
1910  }
1911 
1912  //
1913  //
1914  // PERSONAL DATA FORM
1915  //
1916  //
1917 
1921  function showPersonalData($a_no_init = false)
1922  {
1923  global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting, $ilTabs;
1924  $this->__initSubTabs("showPersonalData");
1925  $ilTabs->setSubTabActive("personal_data");
1926 
1927  $settings = $ilias->getAllSettings();
1928 
1929  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
1930 
1931 
1932  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1933  // $this->lng->txt("personal_desktop"));
1934  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1935  "");
1936  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1937 
1938  if (!$a_no_init)
1939  {
1940  $this->initPersonalDataForm();
1941  // catch feedback message
1942  if ($ilUser->getProfileIncomplete())
1943  {
1944  ilUtil::sendInfo($lng->txt("profile_incomplete"));
1945  }
1946  }
1947  $this->tpl->setContent($this->form->getHTML());
1948 
1949  $this->tpl->show();
1950  }
1951 
1956  {
1957  global $ilSetting, $lng, $ilUser, $styleDefinition, $rbacreview;
1958 
1959  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1960  $this->form = new ilPropertyFormGUI();
1961  $this->form->setFormAction($this->ctrl->getFormAction($this));
1962 
1963  // standard fields
1964  include_once("./Services/User/classes/class.ilUserProfile.php");
1965  $up = new ilUserProfile();
1966  $up->skipField("password");
1967  $up->skipGroup("settings");
1968  $up->skipGroup("preferences");
1969 
1970  // standard fields
1971  $up->addStandardFieldsToForm($this->form, $ilUser);
1972 
1973  // user defined fields
1974  $user_defined_data = $ilUser->getUserDefinedData();
1975 
1976  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1977  {
1978  if($definition['field_type'] == UDF_TYPE_TEXT)
1979  {
1980  $this->input["udf_".$definition['field_id']] =
1981  new ilTextInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1982  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
1983  $this->input["udf_".$definition['field_id']]->setMaxLength(255);
1984  $this->input["udf_".$definition['field_id']]->setSize(40);
1985  }
1986  else if($definition['field_type'] == UDF_TYPE_WYSIWYG)
1987  {
1988  $this->input["udf_".$definition['field_id']] =
1989  new ilTextAreaInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1990  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
1991  $this->input["udf_".$definition['field_id']]->setUseRte(true);
1992  }
1993  else
1994  {
1995  $this->input["udf_".$definition['field_id']] =
1996  new ilSelectInputGUI($definition['field_name'], "udf_".$definition['field_id']);
1997  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
1998  $this->input["udf_".$definition['field_id']]->setOptions(
1999  $this->user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
2000  }
2001  if(!$definition['changeable'])
2002  {
2003  $this->input["udf_".$definition['field_id']]->setDisabled(true);
2004  }
2005  if($definition['required'])
2006  {
2007  $this->input["udf_".$definition['field_id']]->setRequired(true);
2008  }
2009  $this->form->addItem($this->input["udf_".$definition['field_id']]);
2010  }
2011 
2012  $this->form->addCommandButton("savePersonalData", $lng->txt("save"));
2013 
2014  }
2015 
2020  public function savePersonalData()
2021  {
2022  global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting, $ilAuth;
2023 
2024  $this->initPersonalDataForm();
2025  if ($this->form->checkInput())
2026  {
2027  $form_valid = true;
2028 
2029  if ($this->workWithUserSetting("firstname"))
2030  {
2031  $ilUser->setFirstName($_POST["usr_firstname"]);
2032  }
2033  if ($this->workWithUserSetting("lastname"))
2034  {
2035  $ilUser->setLastName($_POST["usr_lastname"]);
2036  }
2037  if ($this->workWithUserSetting("gender"))
2038  {
2039  $ilUser->setGender($_POST["usr_gender"]);
2040  }
2041  if ($this->workWithUserSetting("title"))
2042  {
2043  $ilUser->setUTitle($_POST["usr_title"]);
2044  }
2045  if ($this->workWithUserSetting("birthday"))
2046  {
2047  if (is_array($_POST['usr_birthday']))
2048  {
2049  if (is_array($_POST['usr_birthday']['date']))
2050  {
2051  if (($_POST['usr_birthday']['d'] > 0) && ($_POST['usr_birthday']['m'] > 0) && ($_POST['usr_birthday']['y'] > 0))
2052  {
2053  $ilUser->setBirthday(sprintf("%04d-%02d-%02d", $_POST['user_birthday']['y'], $_POST['user_birthday']['m'], $_POST['user_birthday']['d']));
2054  }
2055  else
2056  {
2057  $ilUser->setBirthday("");
2058  }
2059  }
2060  else
2061  {
2062  $ilUser->setBirthday($_POST['usr_birthday']['date']);
2063  }
2064  }
2065  }
2066  $ilUser->setFullname();
2067  if ($this->workWithUserSetting("institution"))
2068  {
2069  $ilUser->setInstitution($_POST["usr_institution"]);
2070  }
2071  if ($this->workWithUserSetting("department"))
2072  {
2073  $ilUser->setDepartment($_POST["usr_department"]);
2074  }
2075  if ($this->workWithUserSetting("street"))
2076  {
2077  $ilUser->setStreet($_POST["usr_street"]);
2078  }
2079  if ($this->workWithUserSetting("zipcode"))
2080  {
2081  $ilUser->setZipcode($_POST["usr_zipcode"]);
2082  }
2083  if ($this->workWithUserSetting("city"))
2084  {
2085  $ilUser->setCity($_POST["usr_city"]);
2086  }
2087  if ($this->workWithUserSetting("country"))
2088  {
2089  $ilUser->setCountry($_POST["usr_country"]);
2090  }
2091  if ($this->workWithUserSetting("phone_office"))
2092  {
2093  $ilUser->setPhoneOffice($_POST["usr_phone_office"]);
2094  }
2095  if ($this->workWithUserSetting("phone_home"))
2096  {
2097  $ilUser->setPhoneHome($_POST["usr_phone_home"]);
2098  }
2099  if ($this->workWithUserSetting("phone_mobile"))
2100  {
2101  $ilUser->setPhoneMobile($_POST["usr_phone_mobile"]);
2102  }
2103  if ($this->workWithUserSetting("fax"))
2104  {
2105  $ilUser->setFax($_POST["usr_fax"]);
2106  }
2107  if ($this->workWithUserSetting("email"))
2108  {
2109  $ilUser->setEmail($_POST["usr_email"]);
2110  }
2111  if ($this->workWithUserSetting("hobby"))
2112  {
2113  $ilUser->setHobby($_POST["usr_hobby"]);
2114  }
2115  if ($this->workWithUserSetting("referral_comment"))
2116  {
2117  $ilUser->setComment($_POST["usr_referral_comment"]);
2118  }
2119  if ($this->workWithUserSetting("matriculation"))
2120  {
2121  $ilUser->setMatriculation($_POST["usr_matriculation"]);
2122  }
2123  if ($this->workWithUserSetting("delicious"))
2124  {
2125  $ilUser->setDelicious($_POST["usr_delicious"]);
2126  }
2127 
2128  // delicious
2129  $d_set = new ilSetting("delicious");
2130  if ($d_set->get("user_profile"))
2131  {
2132  $ilUser->setDelicious($_POST["usr_delicious"]);
2133  }
2134 
2135  // set instant messengers
2136  if ($this->workWithUserSetting("instant_messengers"))
2137  {
2138  $ilUser->setInstantMessengerId('icq',$_POST["usr_im_icq"]);
2139  $ilUser->setInstantMessengerId('yahoo',$_POST["usr_im_yahoo"]);
2140  $ilUser->setInstantMessengerId('msn',$_POST["usr_im_msn"]);
2141  $ilUser->setInstantMessengerId('aim',$_POST["usr_im_aim"]);
2142  $ilUser->setInstantMessengerId('skype',$_POST["usr_im_skype"]);
2143  $ilUser->setInstantMessengerId('jabber',$_POST["usr_im_jabber"]);
2144  $ilUser->setInstantMessengerId('voip',$_POST["usr_im_voip"]);
2145  }
2146 
2147  // Set user defined data
2148  $defs = $this->user_defined_fields->getVisibleDefinitions();
2149  $udf = array();
2150  foreach ($_POST as $k => $v)
2151  {
2152  if (substr($k, 0, 4) == "udf_")
2153  {
2154  $f = substr($k, 4);
2155  if ($defs[$f]["changeable"] && $defs[$f]["visible"])
2156  {
2157  $udf[$f] = $v;
2158  }
2159  }
2160  }
2161 
2162  $ilUser->setUserDefinedData($udf);
2163 
2164  // if loginname is changeable -> validate
2165  $un = $this->form->getInput('username');
2166  if((int)$ilSetting->get('allow_change_loginname') &&
2167  $un != $ilUser->getLogin())
2168  {
2169  if(!strlen($un) || !ilUtil::isLogin($un))
2170  {
2171  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
2172  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('login_invalid'));
2173  $form_valid = false;
2174  }
2175  else if(ilObjUser::_loginExists($un, $ilUser->getId()))
2176  {
2177  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
2178  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('loginname_already_exists'));
2179  $form_valid = false;
2180  }
2181  else
2182  {
2183  $ilUser->setLogin($un);
2184 
2185  try
2186  {
2187  $ilUser->updateLogin($ilUser->getLogin());
2188  $ilAuth->setAuth($ilUser->getLogin());
2189  $ilAuth->start();
2190  }
2191  catch (ilUserException $e)
2192  {
2193  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
2194  $this->form->getItemByPostVar('username')->setAlert($e->getMessage());
2195  $form_valid = false;
2196  }
2197  }
2198  }
2199 
2200  // everthing's ok. save form data
2201  if ($form_valid)
2202  {
2203  $this->uploadUserPicture();
2204 
2205  // profile ok
2206  $ilUser->setProfileIncomplete(false);
2207 
2208  // save user data & object_data
2209  $ilUser->setTitle($ilUser->getFullname());
2210  $ilUser->setDescription($ilUser->getEmail());
2211 
2212  $ilUser->update();
2213  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2214  $ilCtrl->redirect($this, "showPersonalData");
2215  }
2216  }
2217 
2218  $this->form->setValuesByPost();
2219  $this->showPersonalData(true);
2220  }
2221 
2222  //
2223  //
2224  // PUBLIC PROFILE FORM
2225  //
2226  //
2227 
2231  function showPublicProfile($a_no_init = false)
2232  {
2233  global $ilUser, $lng, $ilSetting, $ilTabs;
2234 
2235  $this->__initSubTabs("showPersonalData");
2236  $ilTabs->setSubTabActive("public_profile");
2237 
2238  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2239  // $this->lng->txt("personal_desktop"));
2240  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2241  "");
2242  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
2243 
2244  if (!$a_no_init)
2245  {
2246  $this->initPublicProfileForm();
2247  }
2248 
2249  $ptpl = new ilTemplate("tpl.edit_personal_profile.html", true, true, "Services/User");
2250  $ptpl->setVariable("FORM", $this->form->getHTML());
2251  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
2252  $pub_profile = new ilPublicUserProfileGUI($ilUser->getId());
2253  $ptpl->setVariable("PREVIEW", $pub_profile->getHTML());
2254  $this->tpl->setContent($ptpl->get());
2255  $this->tpl->show();
2256  }
2257 
2263  public function initPublicProfileForm()
2264  {
2265  global $lng, $ilUser, $ilSetting;
2266 
2267  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2268  $this->form = new ilPropertyFormGUI();
2269 
2270  // Activate public profile
2271  $radg = new ilRadioGroupInputGUI($lng->txt("user_activate_public_profile"), "public_profile");
2272  $radg->setInfo($this->lng->txt("user_activate_public_profile_info"));
2273  $pub_prof = in_array($ilUser->prefs["public_profile"], array("y", "n", "g"))
2274  ? $ilUser->prefs["public_profile"]
2275  : "n";
2276  if (!$ilSetting->get('enable_global_profiles') && $pub_prof == "g")
2277  {
2278  $pub_prof = "y";
2279  }
2280  $radg->setValue($pub_prof);
2281  $op1 = new ilRadioOption($lng->txt("usr_public_profile_disabled"), "n",$lng->txt("usr_public_profile_disabled_info"));
2282  $radg->addOption($op1);
2283  $op2 = new ilRadioOption($lng->txt("usr_public_profile_logged_in"), "y",$lng->txt("usr_public_profile_logged_in_info"));
2284  $radg->addOption($op2);
2285  if ($ilSetting->get('enable_global_profiles'))
2286  {
2287  $op3 = new ilRadioOption($lng->txt("usr_public_profile_global"), "g",$lng->txt("usr_public_profile_global_info"));
2288  $radg->addOption($op3);
2289  }
2290  $this->form->addItem($radg);
2291  /*$cb = new ilCheckboxInputGUI($this->lng->txt("user_activate_public_profile"), "public_profile");
2292 
2293  if ($ilUser->prefs["public_profile"] == "y")
2294  {
2295  $cb->setChecked(true);
2296  }
2297  $this->form->addItem($cb);*/
2298 
2299  // personal data
2300  $val_array = array(
2301  "institution" => $ilUser->getInstitution(),
2302  "department" => $ilUser->getDepartment(),
2303  "upload" => "",
2304  "street" => $ilUser->getStreet(),
2305  "zipcode" => $ilUser->getZipcode(),
2306  "city" => $ilUser->getCity(),
2307  "country" => $ilUser->getCountry(),
2308  "phone_office" => $ilUser->getPhoneOffice(),
2309  "phone_home" => $ilUser->getPhoneHome(),
2310  "phone_mobile" => $ilUser->getPhoneMobile(),
2311  "fax" => $ilUser->getFax(),
2312  "email" => $ilUser->getEmail(),
2313  "hobby" => $ilUser->getHobby(),
2314  "matriculation" => $ilUser->getMatriculation(),
2315  "delicious" => $ilUser->getDelicious()
2316  );
2317  foreach($val_array as $key => $value)
2318  {
2319  if ($this->userSettingVisible($key))
2320  {
2321  // public setting
2322  if ($key == "upload")
2323  {
2324  $cb = new ilCheckboxInputGUI($this->lng->txt("personal_picture"), "chk_".$key);
2325  }
2326  else
2327  {
2328  $cb = new ilCheckboxInputGUI($this->lng->txt($key), "chk_".$key);
2329  }
2330  if ($ilUser->prefs["public_".$key] == "y")
2331  {
2332  $cb->setChecked(true);
2333  }
2334  //$cb->setInfo($value);
2335  $cb->setOptionTitle($value);
2336  $this->form->addItem($cb);
2337  }
2338  }
2339 
2340  $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
2341  if ($this->userSettingVisible("instant_messengers"))
2342  {
2343  foreach ($im_arr as $im)
2344  {
2345  // public setting
2346  $cb = new ilCheckboxInputGUI($this->lng->txt("im_".$im), "chk_im_".$im);
2347  //$cb->setInfo($ilUser->getInstantMessengerId($im));
2348  $cb->setOptionTitle($ilUser->getInstantMessengerId($im));
2349  if ($ilUser->prefs["public_im_".$im] != "n")
2350  {
2351  $cb->setChecked(true);
2352  }
2353  $this->form->addItem($cb);
2354  }
2355  }
2356 
2357  // additional defined user data fields
2358  $user_defined_data = $ilUser->getUserDefinedData();
2359  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
2360  {
2361  // public setting
2362  $cb = new ilCheckboxInputGUI($definition["field_name"], "chk_udf_".$definition["field_id"]);
2363  $cb->setOptionTitle($user_defined_data["f_".$definition["field_id"]]);
2364  if ($ilUser->prefs["public_udf_".$definition["field_id"]] == "y")
2365  {
2366  $cb->setChecked(true);
2367  }
2368  $this->form->addItem($cb);
2369  }
2370 
2371 
2372  // save and cancel commands
2373  $this->form->addCommandButton("savePublicProfile", $lng->txt("save"));
2374 
2375  $this->form->setTitle($lng->txt("public_profile"));
2376  $this->form->setDescription($lng->txt("user_public_profile_info"));
2377  $this->form->setFormAction($this->ctrl->getFormAction($this));
2378  }
2379 
2384  public function savePublicProfile()
2385  {
2386  global $tpl, $lng, $ilCtrl, $ilUser;
2387 
2388  $this->initPublicProfileForm();
2389  if ($this->form->checkInput())
2390  {
2391  /*if (($_POST["public_profile"]))
2392  {
2393  $ilUser->setPref("public_profile","y");
2394  }
2395  else
2396  {
2397  $ilUser->setPref("public_profile","n");
2398  }*/
2399  $ilUser->setPref("public_profile", $_POST["public_profile"]);
2400 
2401  // if check on Institute
2402  $val_array = array("institution", "department", "upload", "street",
2403  "zipcode", "city", "country", "phone_office", "phone_home", "phone_mobile",
2404  "fax", "email", "hobby", "matriculation");
2405 
2406  // set public profile preferences
2407  foreach($val_array as $key => $value)
2408  {
2409  if (($_POST["chk_".$value]))
2410  {
2411  $ilUser->setPref("public_".$value,"y");
2412  }
2413  else
2414  {
2415  $ilUser->setPref("public_".$value,"n");
2416  }
2417  }
2418 
2419  $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
2420  if ($this->userSettingVisible("instant_messengers"))
2421  {
2422  foreach ($im_arr as $im)
2423  {
2424  if (($_POST["chk_im_".$im]))
2425  {
2426  $ilUser->setPref("public_im_".$im,"y");
2427  }
2428  else
2429  {
2430  $ilUser->setPref("public_im_".$im,"n");
2431  }
2432  }
2433  }
2434 
2435 // $d_set = new ilSetting("delicious");
2436 // if ($d_set->get("user_profile"))
2437 // {
2438  if (($_POST["chk_delicious"]))
2439  {
2440  $ilUser->setPref("public_delicious","y");
2441  }
2442  else
2443  {
2444  $ilUser->setPref("public_delicious","n");
2445  }
2446 // }
2447 
2448  // additional defined user data fields
2449  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
2450  {
2451  if (($_POST["chk_udf_".$definition["field_id"]]))
2452  {
2453  $ilUser->setPref("public_udf_".$definition["field_id"], "y");
2454  }
2455  else
2456  {
2457  $ilUser->setPref("public_udf_".$definition["field_id"], "n");
2458  }
2459  }
2460 
2461  $ilUser->update();
2462  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2463  $ilCtrl->redirect($this, "showPublicProfile");
2464  }
2465  $this->form->setValuesByPost();
2466  $tpl->showPublicProfile(true);
2467  }
2468 
2469 
2470  //
2471  //
2472  // PASSWORD FORM
2473  //
2474  //
2475 
2479  function showPassword($a_no_init = false)
2480  {
2481  global $ilTabs;
2482 
2483  $this->__initSubTabs("showPersonalData");
2484  $ilTabs->setSubTabActive("password");
2485 
2486  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2487  // $this->lng->txt("personal_desktop"));
2488  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2489  "");
2490  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
2491 
2492  if (!$a_no_init)
2493  {
2494  $this->initPasswordForm();
2495  }
2496  $this->tpl->setContent($this->form->getHTML());
2497  $this->tpl->show();
2498  }
2499 
2505  public function initPasswordForm()
2506  {
2507  global $lng, $ilUser, $ilSetting;
2508 
2509  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2510  $this->form = new ilPropertyFormGUI();
2511 
2512  // Check whether password change is allowed
2513  if ($this->allowPasswordChange())
2514  {
2515  // The current password needs to be checked for verification
2516  // unless the user uses Shibboleth authentication with additional
2517  // local authentication for WebDAV.
2518  if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
2519  {
2520  // current password
2521  $cpass = new ilPasswordInputGUI($lng->txt("current_password"), "current_password");
2522  $cpass->setRetype(false);
2523  $cpass->setSkipSyntaxCheck(true);
2524  // only if a password exists.
2525  if($ilUser->getPasswd())
2526  {
2527  $cpass->setRequired(true);
2528  }
2529  $this->form->addItem($cpass);
2530  }
2531 
2532  // new password
2533  $ipass = new ilPasswordInputGUI($lng->txt("desired_password"), "new_password");
2534  $ipass->setRequired(true);
2535  $ipass->setInfo(ilUtil::getPasswordRequirementsInfo());
2536 
2537  if ($ilSetting->get("passwd_auto_generate") == 1) // auto generation list
2538  {
2539  $ipass->setPreSelection(true);
2540 
2541  $this->form->addItem($ipass);
2542  $this->form->addCommandButton("savePassword", $lng->txt("save"));
2543  $this->form->addCommandButton("showPassword", $lng->txt("new_list_password"));
2544  }
2545  else // user enters password
2546  {
2547  $this->form->addItem($ipass);
2548  $this->form->addCommandButton("savePassword", $lng->txt("save"));
2549  }
2550 
2551  switch ($ilUser->getAuthMode(true))
2552  {
2553  case AUTH_LOCAL :
2554  $this->form->setTitle($lng->txt("chg_password"));
2555  break;
2556 
2557  case AUTH_SHIBBOLETH :
2558  case AUTH_CAS:
2559  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
2560  if (ilDAVServer::_isActive())
2561  {
2562  $this->form->setTitle($lng->txt("chg_ilias_and_webfolder_password"));
2563  }
2564  else
2565  {
2566  $this->form->setTitle($lng->txt("chg_ilias_password"));
2567  }
2568  break;
2569  default :
2570  $this->form->setTitle($lng->txt("chg_ilias_password"));
2571  break;
2572  }
2573  $this->form->setFormAction($this->ctrl->getFormAction($this));
2574  }
2575  }
2576 
2581  {
2582  global $ilUser, $ilSetting;
2583 
2584  // do nothing if auth mode is not local database
2585  if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
2586  ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
2587  ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local")) &&
2588  ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local"))
2589  )
2590  {
2591  return false;
2592  }
2593  if (!$this->userSettingVisible('password') ||
2594  $this->ilias->getSetting('usr_settings_disable_password'))
2595  {
2596  return false;
2597  }
2598  return true;
2599  }
2600 
2605  public function savePassword()
2606  {
2607  global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting;
2608 
2609  // normally we should not end up here
2610  if (!$this->allowPasswordChange())
2611  {
2612  $ilCtrl->redirect($this, "showPersonalData");
2613  return;
2614  }
2615 
2616  $this->initPasswordForm();
2617  if ($this->form->checkInput())
2618  {
2619  $cp = $this->form->getItemByPostVar("current_password");
2620  $np = $this->form->getItemByPostVar("new_password");
2621  $error = false;
2622 
2623  // The old password needs to be checked for verification
2624  // unless the user uses Shibboleth authentication with additional
2625  // local authentication for WebDAV.
2626  if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
2627  {
2628  // check current password
2629  if (md5($_POST["current_password"]) != $ilUser->getPasswd() and
2630  $ilUser->getPasswd())
2631  {
2632  $error = true;
2633  $cp->setAlert($this->lng->txt("passwd_wrong"));
2634  }
2635  }
2636 
2637  // select password from auto generated passwords
2638  if ($this->ilias->getSetting("passwd_auto_generate") == 1 &&
2639  (!ilUtil::isPassword($_POST["new_password"])))
2640  {
2641  $error = true;
2642  $np->setAlert($this->lng->txt("passwd_not_selected"));
2643  }
2644 
2645 
2646  if ($this->ilias->getSetting("passwd_auto_generate") != 1 &&
2647  !ilUtil::isPassword($_POST["new_password"],$custom_error))
2648  {
2649  $error = true;
2650  if ($custom_error != '')
2651  {
2652  $np->setAlert($custom_error);
2653  }
2654  else
2655  {
2656  $np->setAlert($this->lng->txt("passwd_invalid"));
2657  }
2658  }
2659  if ($this->ilias->getSetting("passwd_auto_generate") != 1 &&
2660  ($ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded()) &&
2661  ($_POST["current_password"] == $_POST["new_password"]))
2662  {
2663  $error = true;
2664  $np->setAlert($this->lng->txt("new_pass_equals_old_pass"));
2665  }
2666 
2667  if (!$error)
2668  {
2669  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
2670  $ilUser->resetPassword($_POST["new_password"], $_POST["new_password"]);
2671  if ($_POST["current_password"] != $_POST["new_password"])
2672  {
2673  $ilUser->setLastPasswordChangeToNow();
2674  }
2675  $ilCtrl->redirect($this, "showPassword");
2676  }
2677  }
2678  $this->form->setValuesByPost();
2679  $this->showPassword(true);
2680  }
2681 
2682  //
2683  //
2684  // GENERAL SETTINGS FORM
2685  //
2686  //
2687 
2691  function showGeneralSettings($a_no_init = false)
2692  {
2693  global $ilTabs;
2694 
2695  $this->__initSubTabs("showPersonalData");
2696  $ilTabs->setSubTabActive("general_settings");
2697 
2698  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2699  // $this->lng->txt("personal_desktop"));
2700  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
2701  "");
2702  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
2703 
2704  if (!$a_no_init)
2705  {
2706  $this->initGeneralSettingsForm();
2707  }
2708  $this->tpl->setContent($this->form->getHTML());
2709  $this->tpl->show();
2710  }
2711 
2716  public function initGeneralSettingsForm()
2717  {
2718  global $lng, $ilUser, $styleDefinition, $ilSetting;
2719 
2720 
2721  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2722  $this->form = new ilPropertyFormGUI();
2723 
2724  // language
2725  if ($this->userSettingVisible("language"))
2726  {
2727  $languages = $this->lng->getInstalledLanguages();
2728  $options = array();
2729  foreach($languages as $lang_key)
2730  {
2731  $options[$lang_key] = ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key);
2732  }
2733 
2734  $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
2735  $si->setOptions($options);
2736  $si->setValue($ilUser->getLanguage());
2737  $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
2738  $this->form->addItem($si);
2739  }
2740 
2741  // skin/style
2742  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
2743  if ($this->userSettingVisible("skin_style"))
2744  {
2745  $templates = $styleDefinition->getAllTemplates();
2746  if (is_array($templates))
2747  {
2748  $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
2749 
2750  $options = array();
2751  foreach($templates as $template)
2752  {
2753  // get styles information of template
2754  $styleDef =& new ilStyleDefinition($template["id"]);
2755  $styleDef->startParsing();
2756  $styles = $styleDef->getStyles();
2757 
2758  foreach($styles as $style)
2759  {
2760  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
2761  {
2762  continue;
2763  }
2764 
2765  $options[$template["id"].":".$style["id"]] =
2766  $styleDef->getTemplateName()." / ".$style["name"];
2767  }
2768  }
2769  $si->setOptions($options);
2770  $si->setValue($ilUser->skin.":".$ilUser->prefs["style"]);
2771  $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
2772  $this->form->addItem($si);
2773  }
2774  }
2775 
2776  // screen reader optimization
2777  if ($this->userSettingVisible("screen_reader_optimization"))
2778  {
2779  $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
2780  $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
2781  $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
2782  $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
2783  $this->form->addItem($cb);
2784  }
2785 
2786  // hits per page
2787  if ($this->userSettingVisible("hits_per_page"))
2788  {
2789  $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
2790 
2791  $hits_options = array(10,15,20,30,40,50,100,9999);
2792  $options = array();
2793 
2794  foreach($hits_options as $hits_option)
2795  {
2796  $hstr = ($hits_option == 9999)
2797  ? $this->lng->txt("no_limit")
2798  : $hits_option;
2799  $options[$hits_option] = $hstr;
2800  }
2801  $si->setOptions($options);
2802  $si->setValue($ilUser->prefs["hits_per_page"]);
2803  $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
2804  $this->form->addItem($si);
2805  }
2806 
2807  // Users Online
2808  if ($this->userSettingVisible("show_users_online"))
2809  {
2810  $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
2811 
2812  $options = array(
2813  "y" => $this->lng->txt("users_online_show_y"),
2814  "associated" => $this->lng->txt("users_online_show_associated"),
2815  "n" => $this->lng->txt("users_online_show_n"));
2816  $si->setOptions($options);
2817  $si->setValue($ilUser->prefs["show_users_online"]);
2818  $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
2819  $this->form->addItem($si);
2820  }
2821 
2822  // hide_own_online_status
2823  if ($this->userSettingVisible("hide_own_online_status"))
2824  {
2825  $cb = new ilCheckboxInputGUI($this->lng->txt("hide_own_online_status"), "hide_own_online_status");
2826  $cb->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
2827  $cb->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
2828  $this->form->addItem($cb);
2829  }
2830 
2831  // session reminder
2832  if((int)$ilSetting->get('session_reminder_enabled'))
2833  {
2834  $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
2835  $cb->setInfo($this->lng->txt('session_reminder_info'));
2836  $cb->setValue(1);
2837  $cb->setChecked((int)$ilUser->getPref('session_reminder_enabled'));
2838 
2839  global $ilClientIniFile;
2840 
2841  $lead_time_gui = new ilTextInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
2842  $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilFormat::_secondsToString($ilClientIniFile->readVariable('session', 'expire'))));
2843  $lead_time_gui->setValue($ilUser->getPref('session_reminder_lead_time'));
2844  $lead_time_gui->setMaxLength(10);
2845  $lead_time_gui->setSize(10);
2846  $cb->addSubItem($lead_time_gui);
2847 
2848  $this->form->addItem($cb);
2849  }
2850 
2851  $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
2852  $this->form->setTitle($lng->txt("general_settings"));
2853  $this->form->setFormAction($this->ctrl->getFormAction($this));
2854 
2855  }
2856 
2861  public function saveGeneralSettings()
2862  {
2863  global $tpl, $lng, $ilCtrl, $ilUser;
2864 
2865  $this->initGeneralSettingsForm();
2866  if ($this->form->checkInput())
2867  {
2868  if ($this->workWithUserSetting("skin_style"))
2869  {
2870  //set user skin and style
2871  if ($_POST["skin_style"] != "")
2872  {
2873  $sknst = explode(":", $_POST["skin_style"]);
2874 
2875  if ($ilUser->getPref("style") != $sknst[1] ||
2876  $ilUser->getPref("skin") != $sknst[0])
2877  {
2878  $ilUser->setPref("skin", $sknst[0]);
2879  $ilUser->setPref("style", $sknst[1]);
2880  }
2881  }
2882  }
2883 
2884  // language
2885  if ($this->workWithUserSetting("language"))
2886  {
2887  $ilUser->setLanguage($_POST["language"]);
2888  }
2889 
2890  // hits per page
2891  if ($this->workWithUserSetting("hits_per_page"))
2892  {
2893  if ($_POST["hits_per_page"] != "")
2894  {
2895  $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
2896  }
2897  }
2898 
2899  // set show users online
2900  if ($this->workWithUserSetting("show_users_online"))
2901  {
2902  $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
2903  }
2904 
2905  // set hide own online_status
2906  if ($this->workWithUserSetting("hide_own_online_status"))
2907  {
2908  if ($_POST["hide_own_online_status"] == 1)
2909  {
2910  $ilUser->setPref("hide_own_online_status","y");
2911  }
2912  else
2913  {
2914  $ilUser->setPref("hide_own_online_status","n");
2915  }
2916  }
2917 
2918  // set show users online
2919  if ($this->workWithUserSetting("screen_reader_optimization"))
2920  {
2921  $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
2922  }
2923 
2924  // session reminder
2925  global $ilSetting;
2926  if((int)$ilSetting->get('session_reminder_enabled'))
2927  {
2928  $ilUser->setPref('session_reminder_enabled', (int)$_POST['session_reminder_enabled']);
2929 
2930  if(!preg_match('/^([0]|([1-9][0-9]*))([\.,][0-9][0-9]*)?$/', (int)$_POST['session_reminder_lead_time']))
2931  $_POST['session_reminder_lead_time'] = 0;
2932  $ilUser->setPref('session_reminder_lead_time', (int)$_POST['session_reminder_lead_time']);
2933  }
2934 
2935  $ilUser->update();
2936  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2937  $ilCtrl->redirect($this, "showGeneralSettings");
2938  }
2939 
2940  $this->form->setValuesByPost();
2941  $tpl->showGeneralSettings(true);
2942  }
2943 
2944 }
2945 ?>