ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPersonalProfileGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
35 {
36  var $tpl;
37  var $lng;
38  var $ilias;
39  var $ctrl;
40 
42 
43 
48  {
49  global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl;
50 
51  include_once './Services/User/classes/class.ilUserDefinedFields.php';
52  $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
53 
54  $this->tpl =& $tpl;
55  $this->lng =& $lng;
56  $this->ilias =& $ilias;
57  $this->ctrl =& $ilCtrl;
58  $this->settings = $ilias->getAllSettings();
59  $lng->loadLanguageModule("jsmath");
60  $this->upload_error = "";
61  $this->password_error = "";
62  }
63 
67  function &executeCommand()
68  {
69  $next_class = $this->ctrl->getNextClass();
70 
71  switch($next_class)
72  {
73  default:
74  //$this->setTabs();
75  $cmd = $this->ctrl->getCmd("showProfile");
76  $this->$cmd();
77  break;
78  }
79  return true;
80  }
81 
82 
83 
88  function workWithUserSetting($setting)
89  {
90  $result = TRUE;
91  if ($this->settings["usr_settings_hide_".$setting] == 1)
92  {
93  $result = FALSE;
94  }
95  if ($this->settings["usr_settings_disable_".$setting] == 1)
96  {
97  $result = FALSE;
98  }
99  return $result;
100  }
101 
106  function userSettingVisible($setting)
107  {
108  $result = TRUE;
109  if ($this->settings["usr_settings_hide_".$setting] == 1)
110  {
111  $result = FALSE;
112  }
113  return $result;
114  }
115 
120  function userSettingEnabled($setting)
121  {
122  $result = TRUE;
123  if ($this->settings["usr_settings_disable_".$setting] == 1)
124  {
125  $result = FALSE;
126  }
127  return $result;
128  }
129 
135  function uploadUserPicture()
136  {
137  global $ilUser;
138 
139  if ($this->workWithUserSetting("upload"))
140  {
141 
142  if ($_FILES["userfile"]["size"] == 0)
143  {
144  $this->upload_error = $this->lng->txt("msg_no_file");
145  }
146  else
147  {
148 
149  $webspace_dir = ilUtil::getWebspaceDir();
150  $image_dir = $webspace_dir."/usr_images";
151  $store_file = "usr_".$ilUser->getID()."."."jpg";
152 
153  // store filename
154  $ilUser->setPref("profile_image", $store_file);
155  $ilUser->update();
156 
157  // move uploaded file
158  $uploaded_file = $image_dir."/upload_".$ilUser->getId()."pic";
159 
160  if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
161  $uploaded_file, false))
162  {
163  ilUtil::sendInfo($this->lng->txt("upload_error", true));
164  $this->ctrl->redirect($this, "showProfile");
165  }
166  chmod($uploaded_file, 0770);
167 
168  // take quality 100 to avoid jpeg artefacts when uploading jpeg files
169  // taking only frame [0] to avoid problems with animated gifs
170  $show_file = "$image_dir/usr_".$ilUser->getId().".jpg";
171  $thumb_file = "$image_dir/usr_".$ilUser->getId()."_small.jpg";
172  $xthumb_file = "$image_dir/usr_".$ilUser->getId()."_xsmall.jpg";
173  $xxthumb_file = "$image_dir/usr_".$ilUser->getId()."_xxsmall.jpg";
174  $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
175  $show_file = ilUtil::escapeShellArg($show_file);
176  $thumb_file = ilUtil::escapeShellArg($thumb_file);
177  $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
178  $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
179 //echo "-".ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file"."-";
180  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file");
181  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
182  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
183  system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
184  }
185  }
186 
187  $this->saveProfile();
188  }
189 
193  function removeUserPicture()
194  {
195  global $ilUser;
196 
197  $ilUser->removeUserPicture();
198 
199  $this->saveProfile();
200  }
201 
202 
207  {
208  global $ilUser, $ilSetting;
209 
210  /*
211  include_once('Services/LDAP/classes/class.ilLDAPServer.php');
212  if($ilUser->getAuthMode(true) == AUTH_LDAP and ($server_ids = ilLDAPServer::_getPasswordServers()))
213  {
214  include_once('Services/LDAP/classes/class.ilLDAPPasswordSynchronization.php');
215  $pwd_sync = new ilLDAPPasswordSynchronization($server_ids[0]);
216  $pwd_sync->setOldPassword($_POST["current_password"]);
217  $pwd_sync->setNewPassword($_POST["desired_password"]);
218  $pwd_sync->setRetypePassword($_POST["retype_password"]);
219  if(!$pwd_sync->synchronize())
220  {
221  $this->password_error = $pwd_sync->getError();
222  }
223  $this->saveProfile();
224  return false;
225  }
226  */
227  // do nothing if auth mode is not local database
228  if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
229  ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
230  ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || !$ilSetting->get("shib_auth_allow_local")) &&
231  ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local"))
232  )
233  {
234  $this->password_error = $this->lng->txt("not_changeable_for_non_local_auth");
235  }
236 
237  // select password from auto generated passwords
238  if ($this->ilias->getSetting("passwd_auto_generate") == 1)
239  {
240  // The old password needs to be checked for verification
241  // unless the user uses Shibboleth authentication with additional
242  // local authentication for WebDAV.
243  if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
244  {
245  // check old password
246  if (md5($_POST["current_password"]) != $ilUser->getPasswd())
247  {
248  $this->password_error = $this->lng->txt("passwd_wrong");
249  }
250  }
251  // validate transmitted password
252  if (!ilUtil::isPassword($_POST["new_passwd"]))
253  {
254  $this->password_error = $this->lng->txt("passwd_not_selected");
255  }
256 
257  if (empty($this->password_error))
258  {
259  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
260  $ilUser->updatePassword($_POST["current_password"], $_POST["new_passwd"], $_POST["new_passwd"]);
261  }
262  }
263  else
264  {
265  // The old password needs to be checked for verification
266  // unless the user uses Shibboleth authentication with additional
267  // local authentication for WebDAV.
268  if (($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local")) &&
269  md5($_POST["current_password"]) != $ilUser->getPasswd())
270  {
271  $this->password_error = $this->lng->txt("passwd_wrong");
272  }
273 
274  // check new password
275  else if ($_POST["desired_password"] != $_POST["retype_password"])
276  {
277  $this->password_error = $this->lng->txt("passwd_not_match");
278  }
279  // validate password
280  else if (!ilUtil::isPassword($_POST["desired_password"],$custom_error))
281  {
282  if( $custom_error != '' )
283  $this->password_error = $custom_error;
284  else $this->password_error = $this->lng->txt("passwd_invalid");
285  }
286  else if ($ilUser->getAuthMode(true) == AUTH_SHIBBOLETH && $ilSetting->get("shib_auth_allow_local") && empty($this->password_error))
287  {
288  if( $ilUser->resetPassword($_POST["desired_password"], $_POST["retype_password"]) )
289  {
290  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
291  $ilUser->setLastPasswordChangeToNow();
292  }
293  else
294  {
295  $this->password_error = $this->lng->txt("passwd_invalid");
296  }
297  }
298  else if ($_POST["current_password"] != "" and empty($this->password_error))
299  {
300  if( $ilUser->isPasswordExpired() || $ilUser->isPasswordChangeDemanded() )
301  {
302  if( $_POST["current_password"] != $_POST["desired_password"] )
303  {
304  if( $ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]) )
305  {
306  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
307  $ilUser->setLastPasswordChangeToNow();
308  }
309  }
310  else
311  {
312  $this->password_error = $this->lng->txt("new_pass_equals_old_pass");
313  }
314  }
315  else
316  {
317  if ($ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]))
318  {
319  $ilUser->setLastPasswordChangeToNow();
320  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
321  }
322  else
323  {
324  $this->password_error = $this->lng->txt("new_pass_equals_old_pass");
325  }
326  }
327  }
328  }
329 
330  $this->saveProfile();
331  }
332 
333 
334 
338  function saveProfile()
339  {
340  global $ilUser;
341 
342  //init checking var
343  $form_valid = true;
344 
345  // testing by ratana ty:
346  // if people check on check box it will
347  // write some datata to table usr_pref
348  // if check on Public Profile
349  if (($_POST["chk_pub"])=="on")
350  {
351  $ilUser->setPref("public_profile","y");
352  }
353  else
354  {
355  $ilUser->setPref("public_profile","n");
356  }
357 
358  // if check on Institute
359  $val_array = array("institution", "department", "upload", "street",
360  "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
361  "fax", "email", "hobby", "matriculation");
362 
363  // set public profile preferences
364  foreach($val_array as $key => $value)
365  {
366  if (($_POST["chk_".$value]) == "on")
367  {
368  $ilUser->setPref("public_".$value,"y");
369  }
370  else
371  {
372  $ilUser->setPref("public_".$value,"n");
373  }
374  }
375 
376  $d_set = new ilSetting("delicious");
377  if ($d_set->get("user_profile"))
378  {
379  if (($_POST["chk_delicious"]) == "on")
380  {
381  $ilUser->setPref("public_delicious","y");
382  }
383  else
384  {
385  $ilUser->setPref("public_delicious","n");
386  }
387  }
388 
389 
390  // check dynamically required fields
391  foreach($this->settings as $key => $val)
392  {
393  if (substr($key,0,8) == "require_")
394  {
395  $require_keys[] = substr($key,8);
396  }
397  }
398 
399  foreach($require_keys as $key => $val)
400  {
401  // exclude required system and registration-only fields
402  $system_fields = array("login", "default_role", "passwd", "passwd2");
403  if (!in_array($val, $system_fields))
404  {
405  if ($this->workWithUserSetting($val))
406  {
407  if (isset($this->settings["require_" . $val]) && $this->settings["require_" . $val])
408  {
409  if (empty($_POST["usr_" . $val]))
410  {
411  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val));
412  $form_valid = false;
413  }
414  }
415  }
416  }
417  }
418 
419  // Check user defined required fields
420  if($form_valid and !$this->__checkUserDefinedRequiredFields())
421  {
422  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields"));
423  $form_valid = false;
424  }
425 
426  // check email
427  if ($this->workWithUserSetting("email"))
428  {
429  if (!ilUtil::is_email($_POST["usr_email"]) and !empty($_POST["usr_email"]) and $form_valid)
430  {
431  ilUtil::sendInfo($this->lng->txt("email_not_valid"));
432  $form_valid = false;
433  }
434  }
435 
436  //update user data (not saving!)
437  if ($this->workWithUserSetting("firstname"))
438  {
439  $ilUser->setFirstName(ilUtil::stripSlashes($_POST["usr_firstname"]));
440  }
441  if ($this->workWithUserSetting("lastname"))
442  {
443  $ilUser->setLastName(ilUtil::stripSlashes($_POST["usr_lastname"]));
444  }
445  if ($this->workWithUserSetting("gender"))
446  {
447  $ilUser->setGender($_POST["usr_gender"]);
448  }
449  if ($this->workWithUserSetting("title"))
450  {
451  $ilUser->setUTitle(ilUtil::stripSlashes($_POST["usr_title"]));
452  }
453  $ilUser->setFullname();
454  if ($this->workWithUserSetting("institution"))
455  {
456  $ilUser->setInstitution(ilUtil::stripSlashes($_POST["usr_institution"]));
457  }
458  if ($this->workWithUserSetting("department"))
459  {
460  $ilUser->setDepartment(ilUtil::stripSlashes($_POST["usr_department"]));
461  }
462  if ($this->workWithUserSetting("street"))
463  {
464  $ilUser->setStreet(ilUtil::stripSlashes($_POST["usr_street"]));
465  }
466  if ($this->workWithUserSetting("zipcode"))
467  {
468  $ilUser->setZipcode(ilUtil::stripSlashes($_POST["usr_zipcode"]));
469  }
470  if ($this->workWithUserSetting("city"))
471  {
472  $ilUser->setCity(ilUtil::stripSlashes($_POST["usr_city"]));
473  }
474  if ($this->workWithUserSetting("country"))
475  {
476  $ilUser->setCountry(ilUtil::stripSlashes($_POST["usr_country"]));
477  }
478  if ($this->workWithUserSetting("phone_office"))
479  {
480  $ilUser->setPhoneOffice(ilUtil::stripSlashes($_POST["usr_phone_office"]));
481  }
482  if ($this->workWithUserSetting("phone_home"))
483  {
484  $ilUser->setPhoneHome(ilUtil::stripSlashes($_POST["usr_phone_home"]));
485  }
486  if ($this->workWithUserSetting("phone_mobile"))
487  {
488  $ilUser->setPhoneMobile(ilUtil::stripSlashes($_POST["usr_phone_mobile"]));
489  }
490  if ($this->workWithUserSetting("fax"))
491  {
492  $ilUser->setFax(ilUtil::stripSlashes($_POST["usr_fax"]));
493  }
494  if ($this->workWithUserSetting("email"))
495  {
496  $ilUser->setEmail(ilUtil::stripSlashes($_POST["usr_email"]));
497  }
498  if ($this->workWithUserSetting("hobby"))
499  {
500  $ilUser->setHobby(ilUtil::stripSlashes($_POST["usr_hobby"]));
501  }
502  if ($this->workWithUserSetting("referral_comment"))
503  {
504  $ilUser->setComment(ilUtil::stripSlashes($_POST["usr_referral_comment"]));
505  }
506  if ($this->workWithUserSetting("matriculation"))
507  {
508  $ilUser->setMatriculation(ilUtil::stripSlashes($_POST["usr_matriculation"]));
509  }
510 
511  // delicious
512  $d_set = new ilSetting("delicious");
513  if ($d_set->get("user_profile"))
514  {
515  $ilUser->setDelicious(ilUtil::stripSlashes($_POST["usr_delicious"]));
516  }
517 
518  // set instant messengers
519  if ($this->workWithUserSetting("instant_messengers"))
520  {
521  $ilUser->setInstantMessengerId('icq',ilUtil::stripSlashes($_POST["usr_im_icq"]));
522  $ilUser->setInstantMessengerId('yahoo',ilUtil::stripSlashes($_POST["usr_im_yahoo"]));
523  $ilUser->setInstantMessengerId('msn',ilUtil::stripSlashes($_POST["usr_im_msn"]));
524  $ilUser->setInstantMessengerId('aim',ilUtil::stripSlashes($_POST["usr_im_aim"]));
525  $ilUser->setInstantMessengerId('skype',ilUtil::stripSlashes($_POST["usr_im_skype"]));
526  }
527 
528  // Set user defined data
529  $ilUser->setUserDefinedData($_POST['udf']);
530 
531  // everthing's ok. save form data
532  if ($form_valid)
533  {
534  // init reload var. page should only be reloaded if skin or style were changed
535  $reload = false;
536 
537  if ($this->workWithUserSetting("skin_style"))
538  {
539  //set user skin and style
540  if ($_POST["usr_skin_style"] != "")
541  {
542  $sknst = explode(":", $_POST["usr_skin_style"]);
543 
544  if ($ilUser->getPref("style") != $sknst[1] ||
545  $ilUser->getPref("skin") != $sknst[0])
546  {
547  $ilUser->setPref("skin", $sknst[0]);
548  $ilUser->setPref("style", $sknst[1]);
549  $reload = true;
550  }
551  }
552  }
553 
554  if ($this->workWithUserSetting("language"))
555  {
556  // reload page if language was changed
557  //if ($_POST["usr_language"] != "" and $_POST["usr_language"] != $_SESSION['lang'])
558  // (this didn't work as expected, alex)
559  if ($_POST["usr_language"] != $ilUser->getLanguage())
560  {
561  $reload = true;
562  }
563 
564  // set user language
565  $ilUser->setLanguage($_POST["usr_language"]);
566 
567  }
568  if ($this->workWithUserSetting("hits_per_page"))
569  {
570  // set user hits per page
571  if ($_POST["hits_per_page"] != "")
572  {
573  $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
574  }
575  }
576 
577  // set show users online
578  if ($this->workWithUserSetting("show_users_online"))
579  {
580  $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
581  }
582 
583  // set hide own online_status
584  if ($this->workWithUserSetting("hide_own_online_status"))
585  {
586  if ($_POST["chk_hide_own_online_status"] != "")
587  {
588  $ilUser->setPref("hide_own_online_status","y");
589  }
590  else
591  {
592  $ilUser->setPref("hide_own_online_status","n");
593  }
594  }
595 
596  // personal desktop items in news block
597 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
598  if ($_POST["pd_items_news"] != "")
599  {
600  $ilUser->setPref("pd_items_news","y");
601  }
602  else
603  {
604  $ilUser->setPref("pd_items_news","n");
605  }
606 */
607 
608  // profile ok
609  $ilUser->setProfileIncomplete(false);
610 
611  // save user data & object_data
612  $ilUser->setTitle($ilUser->getFullname());
613  $ilUser->setDescription($ilUser->getEmail());
614 
615  $ilUser->update();
616 
617  // reload page only if skin or style were changed
618  // feedback
619  if (!empty($this->password_error))
620  {
621  ilUtil::sendInfo($this->password_error,true);
622  }
623  elseif (!empty($this->upload_error))
624  {
625  ilUtil::sendInfo($this->upload_error,true);
626  }
627  else if ($reload)
628  {
629  // feedback
630  ilUtil::sendInfo($this->lng->txt("saved_successfully"),true);
631  $this->ctrl->redirect($this, "");
632  //$this->tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./start.php\";\n</script>\n");
633  }
634  else
635  {
636  ilUtil::sendInfo($this->lng->txt("saved_successfully"),true);
637  }
638  }
639 
640  $this->showProfile();
641  }
642 
646  function showProfile()
647  {
648  global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting;
649 
650  $this->__initSubTabs("showProfile");
651 
652  $settings = $ilias->getAllSettings();
653 
654  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
655 
656  // set locator
657 /*
658  $this->tpl->setVariable("TXT_LOCATOR", $this->lng->txt("locator"));
659  $this->tpl->touchBlock("locator_separator");
660  $this->tpl->touchBlock("locator_item");
661  //$this->tpl->setCurrentBlock("locator_item");
662  //$this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
663  //$this->tpl->setVariable("LINK_ITEM",
664  // $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui"));
665  //$this->tpl->parseCurrentBlock();
666 
667  $this->tpl->setCurrentBlock("locator_item");
668  $this->tpl->setVariable("ITEM", $this->lng->txt("personal_profile"));
669  $this->tpl->setVariable("LINK_ITEM",
670  $this->ctrl->getLinkTargetByClass("ilpersonalprofilegui", "showProfile"));
671  $this->tpl->parseCurrentBlock();
672 */
673 
674  // catch feedback message
675  if ($ilUser->getProfileIncomplete())
676  {
677  ilUtil::sendInfo($lng->txt("profile_incomplete"));
678  }
679  else
680  {
682  }
683 
684  // display infopanel if something happened
686 
687  if ($this->userSettingVisible("language"))
688  {
689  //get all languages
690  $languages = $this->lng->getInstalledLanguages();
691 
692  // preselect previous chosen language otherwise saved language
693  $selected_lang = (isset($_POST["usr_language"]))
694  ? $_POST["usr_language"]
695  : $ilUser->getLanguage();
696 
697  //go through languages
698  foreach($languages as $lang_key)
699  {
700  $this->tpl->setCurrentBlock("sel_lang");
701  //$tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
702  $this->tpl->setVariable("LANG", ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key));
703  $this->tpl->setVariable("LANGSHORT", $lang_key);
704 
705  if ($selected_lang == $lang_key)
706  {
707  $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
708  }
709 
710  $this->tpl->parseCurrentBlock();
711  }
712  }
713 
714  // get all templates
715  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
716  $templates = $styleDefinition->getAllTemplates();
717 
718  if ($this->userSettingVisible("skin_style"))
719  {
720  if (is_array($templates))
721  {
722 
723  foreach($templates as $template)
724  {
725  // get styles information of template
726  $styleDef =& new ilStyleDefinition($template["id"]);
727  $styleDef->startParsing();
728  $styles = $styleDef->getStyles();
729 
730  foreach($styles as $style)
731  {
732  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
733  {
734  continue;
735  }
736 
737  $this->tpl->setCurrentBlock("selectskin");
738  //echo "-".$ilUser->skin."-".$ilUser->prefs["style"]."-";
739  if ($ilUser->skin == $template["id"] &&
740  $ilUser->prefs["style"] == $style["id"])
741  {
742  $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
743  }
744 
745  $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
746  $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
747  $this->tpl->parseCurrentBlock();
748  }
749  }
750 
751  }
752  }
753 
754  // hits per page
755  if ($this->userSettingVisible("hits_per_page"))
756  {
757  $hits_options = array(2,10,15,20,30,40,50,100,9999);
758 
759  foreach($hits_options as $hits_option)
760  {
761  $this->tpl->setCurrentBlock("selecthits");
762 
763  if ($ilUser->prefs["hits_per_page"] == $hits_option)
764  {
765  $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
766  }
767 
768  $this->tpl->setVariable("HITSVALUE", $hits_option);
769 
770  if ($hits_option == 9999)
771  {
772  $hits_option = $this->lng->txt("no_limit");
773  }
774 
775  $this->tpl->setVariable("HITSOPTION", $hits_option);
776  $this->tpl->parseCurrentBlock();
777  }
778  }
779 
780  // Users Online
781  if ($this->userSettingVisible("show_users_online"))
782  {
783  $users_online_options = array("y","associated","n");
784  $selected_option = $ilUser->prefs["show_users_online"];
785  foreach($users_online_options as $an_option)
786  {
787  $this->tpl->setCurrentBlock("select_users_online");
788 
789  if ($selected_option == $an_option)
790  {
791  $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
792  }
793 
794  $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
795 
796  $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
797  $this->tpl->parseCurrentBlock();
798  }
799  }
800 
801  // hide_own_online_status
802  if ($this->userSettingVisible("hide_own_online_status")) {
803  if ($ilUser->prefs["hide_own_online_status"] == "y")
804  {
805  $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "checked");
806  }
807  }
808 
809  // personal desktop news
810 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
811  if ($ilUser->prefs["pd_items_news"] != "n")
812  {
813  $this->tpl->setVariable("PD_ITEMS_NEWS", "checked");
814  }
815  $this->tpl->setVariable("TXT_PD_ITEMS_NEWS",
816  $this->lng->txt("pd_items_news"));
817  $this->tpl->setVariable("TXT_PD_ITEMS_NEWS_INFO",
818  $this->lng->txt("pd_items_news_info"));
819 */
820 
821  if (($ilUser->getAuthMode(true) == AUTH_LOCAL ||
822  ($ilUser->getAuthMode(true) == AUTH_CAS && $ilSetting->get("cas_allow_local")) ||
823  ($ilUser->getAuthMode(true) == AUTH_SHIBBOLETH && $ilSetting->get("shib_auth_allow_local")) ||
824  ($ilUser->getAuthMode(true) == AUTH_SOAP && $ilSetting->get("soap_auth_allow_local"))
825  )
826  &&
827  $this->userSettingVisible('password'))
828  {
829  if($this->ilias->getSetting('usr_settings_disable_password'))
830  {
831  $this->tpl->setCurrentBlock("disabled_password");
832  $this->tpl->setVariable("TXT_DISABLED_PASSWORD", $this->lng->txt("chg_password"));
833  $this->tpl->setVariable("TXT_DISABLED_CURRENT_PASSWORD", $this->lng->txt("current_password"));
834  $this->tpl->parseCurrentBlock();
835  }
836  elseif ($settings["passwd_auto_generate"] == 1)
837  {
838  $passwd_list = ilUtil::generatePasswords(5);
839 
840  foreach ($passwd_list as $passwd)
841  {
842  $passwd_choice .= ilUtil::formRadioButton(0,"new_passwd",$passwd)." ".$passwd."<br/>";
843  }
844 
845  $this->tpl->setCurrentBlock("select_password");
846  switch ($ilUser->getAuthMode(true))
847  {
848  case AUTH_LOCAL :
849  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
850  break;
851  case AUTH_SHIBBOLETH :
852  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_and_webfolder_password"));
853  break;
854  default :
855  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_password"));
856  break;
857  }
858  // The old password needs to be checked for verification
859  // unless the user uses Shibboleth authentication with additional
860  // local authentication for WebDAV.
861  if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
862  {
863  $this->tpl->setVariable("TXT_CURRENT_PASSWORD", $this->lng->txt("current_password"));
864  }
865  $this->tpl->setVariable("TXT_SELECT_PASSWORD", $this->lng->txt("select_password"));
866  $this->tpl->setVariable("PASSWORD_CHOICE", $passwd_choice);
867  $this->tpl->setVariable("TXT_NEW_LIST_PASSWORD", $this->lng->txt("new_list_password"));
868  $this->tpl->parseCurrentBlock();
869  }
870  else
871  {
872  $this->tpl->setCurrentBlock("change_password");
873  switch ($ilUser->getAuthMode(true))
874  {
875  case AUTH_LOCAL :
876  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
877  break;
878  case AUTH_SHIBBOLETH :
879  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
881  {
882  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_and_webfolder_password"));
883  }
884  else
885  {
886  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_password"));
887  }
888  break;
889  default :
890  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_ilias_password"));
891  break;
892  }
893  // The old password needs to be checked for verification
894  // unless the user uses Shibboleth authentication with additional
895  // local authentication for WebDAV.
896  if ($ilUser->getAuthMode(true) != AUTH_SHIBBOLETH || ! $ilSetting->get("shib_auth_allow_local"))
897  {
898  $this->tpl->setVariable("TXT_CURRENT_PW", $this->lng->txt("current_password"));
899  }
900  $this->tpl->setVariable("TXT_DESIRED_PW", $this->lng->txt("desired_password"));
901  $this->tpl->setVariable("TXT_RETYPE_PW", $this->lng->txt("retype_password"));
902  $this->tpl->setVariable("CHANGE_PASSWORD", $this->lng->txt("chg_password"));
903  $this->tpl->parseCurrentBlock();
904  }
905  }
906 
907  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
908  $this->lng->txt("personal_desktop"));
909 
910  $this->tpl->setCurrentBlock("content");
911  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
912 
913  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
914  $this->tpl->setVariable("TXT_OF",strtolower($this->lng->txt("of")));
915  $this->tpl->setVariable("USR_FULLNAME",$ilUser->getFullname());
916 
917  $this->tpl->setVariable("TXT_USR_DATA", $this->lng->txt("userdata"));
918  switch ($ilUser->getAuthMode(true))
919  {
920  case AUTH_LOCAL :
921  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("username"));
922  break;
923  case AUTH_SHIBBOLETH :
924  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
926  {
927  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("ilias_and_webfolder_username"));
928  }
929  else
930  {
931  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("ilias_username"));
932  }
933  break;
934  default :
935  $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("ilias_username"));
936  break;
937  }
938  $this->tpl->setVariable("TXT_PUBLIC_PROFILE", $this->lng->txt("public_profile"));
939 
940  $data = array();
941  $data["fields"] = array();
942  $data["fields"]["gender"] = "";
943  $data["fields"]["firstname"] = "";
944  $data["fields"]["lastname"] = "";
945  $data["fields"]["title"] = "";
946  $data["fields"]["institution"] = "";
947  $data["fields"]["department"] = "";
948  $data["fields"]["street"] = "";
949  $data["fields"]["city"] = "";
950  $data["fields"]["zipcode"] = "";
951  $data["fields"]["country"] = "";
952  $data["fields"]["phone_office"] = "";
953  $data["fields"]["phone_home"] = "";
954  $data["fields"]["phone_mobile"] = "";
955  $data["fields"]["fax"] = "";
956  $data["fields"]["email"] = "";
957  $data["fields"]["hobby"] = "";
958  $data["fields"]["referral_comment"] = "";
959  $data["fields"]["matriculation"] = "";
960  $data["fields"]["create_date"] = "";
961  $data["fields"]["approve_date"] = "";
962  $data["fields"]["active"] = "";
963 
964  $data["fields"]["default_role"] = $role;
965  // fill presets
966  foreach($data["fields"] as $key => $val)
967  {
968  // note: general "title" is not as "title" for a person
969  if ($key != "title")
970  {
971  $str = $this->lng->txt($key);
972  }
973  else
974  {
975  $str = $this->lng->txt("person_title");
976  }
977 
978  // check to see if dynamically required
979  if (isset($this->settings["require_" . $key]) && $this->settings["require_" . $key])
980  {
981  $str = $str . '<span class="asterisk">*</span>';
982  }
983 
984  if ($this->userSettingVisible("$key"))
985  {
986  $this->tpl->setVariable("TXT_".strtoupper($key), $str);
987  }
988  }
989 
990  if ($this->userSettingVisible("gender"))
991  {
992  $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
993  $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
994  }
995 
996  $d_set = new ilSetting("delicious");
997  if ($d_set->get("user_profile"))
998  {
999  $this->tpl->setVariable("TXT_DELICIOUS", $lng->txt("delicious"));
1000  }
1001 
1002  if ($this->userSettingVisible("upload"))
1003  {
1004  $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("personal_picture"));
1005  $webspace_dir = ilUtil::getWebspaceDir("output");
1006  $full_img = $ilUser->getPref("profile_image");
1007  $last_dot = strrpos($full_img, ".");
1008  $small_img = substr($full_img, 0, $last_dot).
1009  "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
1010  $image_file = $webspace_dir."/usr_images/".$small_img;
1011 
1012  if (@is_file($image_file))
1013  {
1014  $this->tpl->setCurrentBlock("pers_image");
1015  $this->tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
1016  $this->tpl->setVariable("ALT_IMG_PERSONAL",$this->lng->txt("personal_picture"));
1017  $this->tpl->parseCurrentBlock();
1018  if ($this->userSettingEnabled("upload"))
1019  {
1020  $this->tpl->setCurrentBlock("remove_pic");
1021  $this->tpl->setVariable("TXT_REMOVE_PIC", $this->lng->txt("remove_personal_picture"));
1022  }
1023  $this->tpl->parseCurrentBlock();
1024  $this->tpl->setCurrentBlock("content");
1025  }
1026 
1027  if ($this->userSettingEnabled("upload"))
1028  {
1029  $this->tpl->setCurrentBlock("upload_pic");
1030  $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
1031  }
1032  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("userfile"));
1033  $this->tpl->setVariable("USER_FILE", $this->lng->txt("user_file"));
1034  }
1035  $this->tpl->setCurrentBlock("adm_content");
1036 
1037  // ilinc upload pic
1038  if ($this->userSettingVisible("upload") and $this->ilias->getSetting("ilinc_active"))
1039  {
1040  include_once ('./Modules/ILinc/classes/class.ilObjiLincUser.php');
1041  $ilinc_user = new ilObjiLincUser($ilUser);
1042 
1043  if ($ilinc_user->id)
1044  {
1045  include_once ('./Modules/ILinc/classes/class.ilnetucateXMLAPI.php');
1046  $ilincAPI = new ilnetucateXMLAPI();
1047 
1048  $ilincAPI->uploadPicture($ilinc_user);
1049  $response = $ilincAPI->sendRequest("uploadPicture");
1050 
1051  // return URL to user's personal page
1052  $url = trim($response->data['url']['cdata']);
1053  $this->tpl->setCurrentBlock("ilinc_upload_pic");
1054  $this->tpl->setVariable("TXT_ILINC_UPLOAD", $this->lng->txt("ilinc_upload_pic_text"));
1055  $this->tpl->setVariable("ILINC_UPLOAD_LINK", $url);
1056  $this->tpl->setVariable("ILINC_UPLOAD_LINKTXT", $this->lng->txt("ilinc_upload_pic_linktext"));
1057  $this->tpl->parseCurrentBlock();
1058  }
1059  }
1060 
1061 
1062  if ($this->userSettingVisible("language"))
1063  {
1064  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
1065  }
1066  if ($this->userSettingVisible("show_users_online"))
1067  {
1068  $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
1069  }
1070  if ($this->userSettingVisible("hide_own_online_status"))
1071  {
1072  $this->tpl->setVariable("TXT_HIDE_OWN_ONLINE_STATUS", $this->lng->txt("hide_own_online_status"));
1073  }
1074  if ($this->userSettingVisible("skin_style"))
1075  {
1076  $this->tpl->setVariable("TXT_USR_SKIN_STYLE", $this->lng->txt("usr_skin_style"));
1077  }
1078  if ($this->userSettingVisible("hits_per_page"))
1079  {
1080  $this->tpl->setVariable("TXT_HITS_PER_PAGE", $this->lng->txt("usr_hits_per_page"));
1081  }
1082  if ($this->userSettingVisible("show_users_online"))
1083  {
1084  $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
1085  }
1086  $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
1087  $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
1088  $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
1089 
1090  if($this->__showOtherInformations())
1091  {
1092  $this->tpl->setVariable("TXT_OTHER", $this->lng->txt("user_profile_other"));
1093  }
1094 
1095  $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
1096 
1097  //values
1098  $this->tpl->setVariable("NICKNAME", ilUtil::prepareFormOutput($ilUser->getLogin()));
1099 
1100  if ($this->userSettingVisible("firstname"))
1101  {
1102  $this->tpl->setVariable("FIRSTNAME", ilUtil::prepareFormOutput($ilUser->getFirstname()));
1103  }
1104  if ($this->userSettingVisible("lastname"))
1105  {
1106  $this->tpl->setVariable("LASTNAME", ilUtil::prepareFormOutput($ilUser->getLastname()));
1107  }
1108 
1109  if ($this->userSettingVisible("gender"))
1110  {
1111  // gender selection
1112  $gender = strtoupper($ilUser->getGender());
1113 
1114  if (!empty($gender))
1115  {
1116  $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
1117  }
1118  }
1119 
1120  $this->tpl->setVariable("CREATE_DATE", $ilUser->getCreateDate());
1121  $this->tpl->setVariable("APPROVE_DATE", $ilUser->getApproveDate());
1122 
1123  if ($ilUser->getActive())
1124  {
1125  $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
1126  }
1127 
1128  if ($this->userSettingVisible("title"))
1129  {
1130  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($ilUser->getUTitle()));
1131  }
1132  if ($this->userSettingVisible("institution"))
1133  {
1134  $this->tpl->setVariable("INSTITUTION", ilUtil::prepareFormOutput($ilUser->getInstitution()));
1135  }
1136  if ($this->userSettingVisible("department"))
1137  {
1138  $this->tpl->setVariable("DEPARTMENT", ilUtil::prepareFormOutput($ilUser->getDepartment()));
1139  }
1140  if ($this->userSettingVisible("street"))
1141  {
1142  $this->tpl->setVariable("STREET", ilUtil::prepareFormOutput($ilUser->getStreet()));
1143  }
1144  if ($this->userSettingVisible("zipcode"))
1145  {
1146  $this->tpl->setVariable("ZIPCODE", ilUtil::prepareFormOutput($ilUser->getZipcode()));
1147  }
1148  if ($this->userSettingVisible("city"))
1149  {
1150  $this->tpl->setVariable("CITY", ilUtil::prepareFormOutput($ilUser->getCity()));
1151  }
1152  if ($this->userSettingVisible("country"))
1153  {
1154  $this->tpl->setVariable("COUNTRY", ilUtil::prepareFormOutput($ilUser->getCountry()));
1155  }
1156  if ($this->userSettingVisible("phone_office"))
1157  {
1158  $this->tpl->setVariable("PHONE_OFFICE", ilUtil::prepareFormOutput($ilUser->getPhoneOffice()));
1159  }
1160  if ($this->userSettingVisible("phone_home"))
1161  {
1162  $this->tpl->setVariable("PHONE_HOME", ilUtil::prepareFormOutput($ilUser->getPhoneHome()));
1163  }
1164  if ($this->userSettingVisible("phone_mobile"))
1165  {
1166  $this->tpl->setVariable("PHONE_MOBILE", ilUtil::prepareFormOutput($ilUser->getPhoneMobile()));
1167  }
1168  if ($this->userSettingVisible("fax"))
1169  {
1170  $this->tpl->setVariable("FAX", ilUtil::prepareFormOutput($ilUser->getFax()));
1171  }
1172  if ($this->userSettingVisible("email"))
1173  {
1174  $this->tpl->setVariable("EMAIL", ilUtil::prepareFormOutput($ilUser->getEmail()));
1175  }
1176  if ($this->userSettingVisible("hobby"))
1177  {
1178  $this->tpl->setVariable("HOBBY", ilUtil::prepareFormOutput($ilUser->getHobby())); // here
1179  }
1180  if ($this->userSettingVisible("referral_comment"))
1181  {
1182  $this->tpl->setVariable("REFERRAL_COMMENT", ilUtil::prepareFormOutput($ilUser->getComment()));
1183  }
1184  if ($this->userSettingVisible("matriculation"))
1185  {
1186  $this->tpl->setVariable("MATRICULATION", ilUtil::prepareFormOutput($ilUser->getMatriculation()));
1187  }
1188 
1189  // instant messengers
1190  if ($this->userSettingVisible("instant_messengers"))
1191  {
1192  $this->tpl->setVariable("TXT_INSTANT_MESSENGERS", $this->lng->txt("user_profile_instant_messengers"));
1193 
1194  $im_arr = array("icq","yahoo","msn","aim","skype");
1195  $im_disabled = !$this->userSettingEnabled("instant_messengers") ? "disabled=\"disabled\"": "";
1196 
1197  foreach ($im_arr as $im_name)
1198  {
1199  $im_id = $ilUser->getInstantMessengerId($im_name);
1200  $this->tpl->setCurrentBlock("im_row");
1201  $this->tpl->setVariable("TXT_IM_NAME",$this->lng->txt("im_".$im_name));
1202  $this->tpl->setVariable("USR_IM_NAME","usr_im_".$im_name);
1203  $this->tpl->setVariable("IM_ID",$im_id);
1204  $this->tpl->setVariable("DISABLED_IM_NAME",$im_disabled);
1205  $this->tpl->setVariable("IMG_IM_ICON", ilUtil::getImagePath($im_name.'online.gif'));
1206  $this->tpl->setVariable("TXT_IM_ICON", $this->lng->txt("im_".$im_name."_icon"));
1207  $this->tpl->setVariable("CHK_IM", "checked=\"checked\" disabled=\"disabled\"");
1208  $this->tpl->parseCurrentBlock();
1209  }
1210  }
1211 
1212  $d_set = new ilSetting("delicious");
1213  if ($d_set->get("user_profile") == "1")
1214  {
1215  $this->tpl->setVariable("DELICIOUS", ilUtil::prepareFormOutput($ilUser->getDelicious()));
1216  }
1217 
1218  // show user defined visible fields
1219  $this->__showUserDefinedFields();
1220 
1221  // get assigned global roles (default roles)
1222  $global_roles = $rbacreview->getGlobalRoles();
1223 
1224  foreach($global_roles as $role_id)
1225  {
1226  if (in_array($role_id,$rbacreview->assignedRoles($ilUser->getId())))
1227  {
1228  $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1229  $role_names .= $roleObj->getTitle().", ";
1230  unset($roleObj);
1231  }
1232  }
1233 
1234  $this->tpl->setVariable("TXT_DEFAULT_ROLES", $this->lng->txt("default_roles"));
1235  $this->tpl->setVariable("DEFAULT_ROLES", substr($role_names,0,-2));
1236 
1237  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
1238 
1239  //button
1240  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1241 
1242  // addeding by ratana ty
1243  if ($this->userSettingEnabled("upload"))
1244  {
1245  $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
1246  }
1247 
1248  //
1249  if ($ilUser->prefs["public_profile"] == "y")
1250  {
1251  $this->tpl->setVariable("CHK_PUB","checked");
1252  }
1253  $val_array = array("institution", "department", "upload", "street",
1254  "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
1255  "fax", "email", "hobby", "matriculation", "show_users_online");
1256  foreach($val_array as $key => $value)
1257  {
1258  if ($this->userSettingVisible("$value"))
1259  {
1260  if ($ilUser->prefs["public_".$value] == "y")
1261  {
1262  $this->tpl->setVariable("CHK_".strtoupper($value), "checked");
1263  }
1264  }
1265  }
1266 
1267  $d_set = new ilSetting("delicious");
1268  if ($d_set->get("user_profile") == "1")
1269  {
1270  if ($ilUser->prefs["public_delicious"] == "y")
1271  {
1272  $this->tpl->setVariable("CHK_DELICIOUS", "checked");
1273  }
1274  }
1275 
1276 
1277  // End of showing
1278  // Testing by ratana ty
1279 
1280 
1281  $profile_fields = array(
1282  "gender",
1283  "firstname",
1284  "lastname",
1285  "title",
1286  "upload",
1287  "institution",
1288  "department",
1289  "street",
1290  "city",
1291  "zipcode",
1292  "country",
1293  "phone_office",
1294  "phone_home",
1295  "phone_mobile",
1296  "fax",
1297  "email",
1298  "hobby",
1299  "matriculation",
1300  "referral_comment",
1301  "language",
1302  "skin_style",
1303  "hits_per_page",
1304  "show_users_online",
1305  "hide_own_online_status"
1306  );
1307  foreach ($profile_fields as $field)
1308  {
1309  if (!$this->ilias->getSetting("usr_settings_hide_" . $field))
1310  {
1311  if ($this->ilias->getSetting("usr_settings_disable_" . $field))
1312  {
1313  $this->tpl->setVariable("DISABLED_" . strtoupper($field), " disabled=\"disabled\"");
1314  }
1315  }
1316  }
1317 
1318  $this->tpl->parseCurrentBlock();
1319  $this->tpl->show();
1320  }
1321 
1322  function saveMailOptions()
1323  {
1324  global $ilUser;
1325 
1326  require_once "Services/Mail/classes/class.ilMailOptions.php";
1327  $mailOptions = new ilMailOptions($ilUser->getId());
1328 
1329  $this->lng->loadLanguageModule("mail");
1330 
1331  $mailOptions->updateOptions($_POST["signature"],(int) $_POST["linebreak"],(int) $_POST["incoming_type"],(int) $_POST["cronjob_notification"]);
1332  ilUtil::sendInfo($this->lng->txt("mail_options_saved"),true);
1333 
1334  $this->showMailOptions();
1335  }
1336 
1337  function showMailOptions()
1338  {
1339  global $ilUser, $ilias;
1340 
1341  $this->__initSubTabs("showMailOptions");
1342 
1343  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile_mail.html");
1344 
1345  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
1346  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
1347 
1348  require_once "Services/Mail/classes/class.ilMailOptions.php";
1349  $mailOptions = new ilMailOptions($ilUser->getId());
1350 
1351  $this->lng->loadLanguageModule("mail");
1352 
1353  // BEGIN INCOMING
1354  $this->tpl->setCurrentBlock("option_inc_line");
1355 
1356  $inc = array($this->lng->txt("mail_incoming_local"),$this->lng->txt("mail_incoming_smtp"),$this->lng->txt("mail_incoming_both"));
1357  foreach($inc as $key => $option)
1358  {
1359  $this->tpl->setVariable("OPTION_INC_VALUE",$key);
1360  $this->tpl->setVariable("OPTION_INC_NAME",$option);
1361  $this->tpl->setVariable("OPTION_INC_SELECTED",$mailOptions->getIncomingType() == $key ? "selected=\"selected\"" : "");
1362  $this->tpl->parseCurrentBlock();
1363  }
1364  if(!strlen(ilObjUser::_lookupEmail($ilUser->getId())))
1365  {
1366  $this->tpl->setVariable('INC_DISABLED','disabled="disabled"');
1367  }
1368 
1369  // BEGIN LINEBREAK_OPTIONS
1370  $this->tpl->setCurrentBlock("option_line");
1371  $linebreak = $mailOptions->getLinebreak();
1372 
1373  for($i = 50; $i <= 80;$i++)
1374  {
1375  $this->tpl->setVariable("OPTION_VALUE",$i);
1376  $this->tpl->setVariable("OPTION_NAME",$i);
1377  if( $i == $linebreak)
1378  {
1379  $this->tpl->setVariable("OPTION_SELECTED","selected");
1380  }
1381  $this->tpl->parseCurrentBlock();
1382  }
1383  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1384  $this->tpl->setVariable("GLOBAL_OPTIONS",$this->lng->txt("mail_global_options"));
1385  $this->tpl->setVariable("TXT_INCOMING", $this->lng->txt("mail_incoming"));
1386  $this->tpl->setVariable("TXT_LINEBREAK", $this->lng->txt("linebreak"));
1387  $this->tpl->setVariable("TXT_SIGNATURE", $this->lng->txt("signature"));
1388  $this->tpl->setVariable("CONTENT",$mailOptions->getSignature());
1389  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1390 
1391  if ($ilias->getSetting("mail_notification"))
1392  {
1393  $this->tpl->setVariable("TXT_CRONJOB_NOTIFICATION", $this->lng->txt("cron_mail_notification"));
1394  $this->tpl->setVariable("TXT_CRONJOB_NOTIFICATION_INFO", $this->lng->txt("mail_cronjob_notification_info"));
1395  if ($mailOptions->getCronjobNotification())
1396  {
1397  $this->tpl->setVariable("CRONJOB_NOTIFICATION_SELECTED", " checked=\"checked\"");
1398  }
1399  }
1400 
1401  $this->tpl->show();
1402  }
1403 
1404  function showjsMath()
1405  {
1406  global $lng, $ilCtrl, $tpl, $ilUser;
1407 
1408  $this->__initSubTabs("showjsMath");
1409  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
1410  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
1411 
1412  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1413  $form = new ilPropertyFormGUI();
1414  $form->setFormAction($ilCtrl->getFormAction($this));
1415  $form->setTitle($lng->txt("jsmath_settings"));
1416 
1417  // Enable jsMath
1418  include_once "./Services/Administration/classes/class.ilSetting.php";
1419  $jsMathSetting = new ilSetting("jsMath");
1420  $enable = new ilCheckboxInputGUI($lng->txt("jsmath_enable_user"), "enable");
1421  $checked = ($ilUser->getPref("js_math") === FALSE) ? $jsMathSetting->get("makedefault") : $ilUser->getPref("js_math");
1422  $enable->setChecked($checked);
1423  $enable->setInfo($lng->txt("jsmath_enable_user_desc"));
1424  $form->addItem($enable);
1425 
1426  $form->addCommandButton("savejsMath", $lng->txt("save"));
1427  $form->addCommandButton("showjsMath", $lng->txt("cancel"));
1428 
1429  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1430  $this->tpl->show();
1431  }
1432 
1433  function savejsMath()
1434  {
1435  global $ilCtrl, $ilUser;
1436 
1437  include_once "./Services/Administration/classes/class.ilSetting.php";
1438  $jsMathSetting = new ilSetting("jsMath");
1439  if ($jsMathSetting->get("enable"))
1440  {
1441  if ($_POST["enable"])
1442  {
1443  $ilUser->writePref("js_math", "1");
1444  }
1445  else
1446  {
1447  $ilUser->writePref("js_math", "0");
1448  }
1449  }
1450  $ilCtrl->redirect($this, "showjsMath");
1451  }
1452 
1453  function showLocation()
1454  {
1455  global $ilUser, $ilCtrl, $ilUser, $lng;
1456 
1457  $lng->loadLanguageModule("gmaps");
1458 
1459  // check google map activation
1460  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1462  {
1463  return;
1464  }
1465 
1466  $this->__initSubTabs("showLocation");
1467 
1468  $latitude = $ilUser->getLatitude();
1469  $longitude = $ilUser->getLongitude();
1470  $zoom = $ilUser->getLocationZoom();
1471 
1472  // Get Default settings, when nothing is set
1473  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
1474  {
1476  $latitude = $def["latitude"];
1477  $longitude = $def["longitude"];
1478  $zoom = $def["zoom"];
1479  }
1480 
1481  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
1482  $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
1483 
1484  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1485  $form = new ilPropertyFormGUI();
1486  $form->setFormAction($ilCtrl->getFormAction($this));
1487 
1488  $form->setTitle($this->lng->txt("location")." ".
1489  strtolower($this->lng->txt("of"))." ".$ilUser->getFullname());
1490 
1491  // public profile
1492  $public = new ilCheckboxInputGUI($this->lng->txt("public_profile"),
1493  "public_location");
1494  $public->setValue("y");
1495  $public->setInfo($this->lng->txt("gmaps_public_profile_info"));
1496  $public->setChecked($ilUser->getPref("public_location"));
1497  $form->addItem($public);
1498 
1499  // location property
1500  $loc_prop = new ilLocationInputGUI($this->lng->txt("location"),
1501  "location");
1502  $loc_prop->setLatitude($latitude);
1503  $loc_prop->setLongitude($longitude);
1504  $loc_prop->setZoom($zoom);
1505  $form->addItem($loc_prop);
1506 
1507  $form->addCommandButton("saveLocation", $this->lng->txt("save"));
1508 
1509  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1510  $this->tpl->show();
1511  }
1512 
1513  function saveLocation()
1514  {
1515  global $ilCtrl, $ilUser;
1516 
1517  $ilUser->writePref("public_location", $_POST["public_location"]);
1518 
1519  $ilUser->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
1520  $ilUser->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
1521  $ilUser->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
1522  $ilUser->update();
1523 
1524  $ilCtrl->redirect($this, "showLocation");
1525  }
1526 
1527  // init sub tabs
1528  function __initSubTabs($a_cmd)
1529  {
1530  global $ilTabs;
1531 
1532  $showProfile = ($a_cmd == 'showProfile') ? true : false;
1533  $showMailOptions = ($a_cmd == 'showMailOptions') ? true : false;
1534  $showLocation = ($a_cmd == 'showLocation') ? true : false;
1535  $showjsMath = ($a_cmd == 'showjsMath') ? true : false;
1536 
1537  $ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showProfile"),
1538  "", "", "", $showProfile);
1539 
1540  /*$ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showProfile2"),
1541  "", "", "", $showProfile);
1542  */
1543 
1544  // check google map activation
1545  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1547  {
1548  $ilTabs->addSubTabTarget("location", $this->ctrl->getLinkTarget($this, "showLocation"),
1549  "", "", "", $showLocation);
1550  }
1551 
1552  $ilTabs->addSubTabTarget("mail_settings", $this->ctrl->getLinkTarget($this, "showMailOptions"),
1553  "", "", "", $showMailOptions);
1554  include_once "./Services/Administration/classes/class.ilSetting.php";
1555  $jsMathSetting = new ilSetting("jsMath");
1556  if ($jsMathSetting->get("enable"))
1557  {
1558  $ilTabs->addSubTabTarget("jsmath_extt_jsmath", $this->ctrl->getLinkTarget($this, "showjsMath"),
1559  "", "", "", $showjsMath);
1560  }
1561  }
1562 
1563 
1565  {
1566  $d_set = new ilSetting("delicous");
1567  if($this->userSettingVisible("matriculation") or count($this->user_defined_fields->getVisibleDefinitions())
1568  or $d_set->get("user_profile") == "1")
1569  {
1570  return true;
1571  }
1572  return false;
1573  }
1574 
1576  {
1577  global $ilUser;
1578 
1579  $user_defined_data = $ilUser->getUserDefinedData();
1580  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1581  {
1582  if($definition['field_type'] == UDF_TYPE_TEXT)
1583  {
1584  $this->tpl->setCurrentBlock("field_text");
1585  $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($user_defined_data[$field_id]));
1586  if(!$definition['changeable'])
1587  {
1588  $this->tpl->setVariable("DISABLED_FIELD",'disabled=\"disabled\"');
1589  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1590  }
1591  else
1592  {
1593  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
1594  }
1595  $this->tpl->parseCurrentBlock();
1596  }
1597  else
1598  {
1599  if($definition['changeable'])
1600  {
1601  $name = 'udf['.$definition['field_id'].']';
1602  $disabled = false;
1603  }
1604  else
1605  {
1606  $name = '';
1607  $disabled = true;
1608  }
1609  $this->tpl->setCurrentBlock("field_select");
1610  $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($user_defined_data[$field_id],
1611  $name,
1612  $this->user_defined_fields->fieldValuesToSelectArray(
1613  $definition['field_values']),
1614  false,
1615  true,0,'','',$disabled));
1616  $this->tpl->parseCurrentBlock();
1617  }
1618  $this->tpl->setCurrentBlock("user_defined");
1619 
1620  if($definition['required'])
1621  {
1622  $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
1623  }
1624  else
1625  {
1626  $name = $definition['field_name'];
1627  }
1628  $this->tpl->setVariable("TXT_FIELD_NAME",$name);
1629  $this->tpl->parseCurrentBlock();
1630  }
1631  return true;
1632  }
1633 
1635  {
1636  foreach($this->user_defined_fields->getVisibleDefinitions() as $definition)
1637  {
1638  $field_id = $definition['field_id'];
1639  if($definition['required'] and !strlen($_POST['udf'][$field_id]))
1640  {
1641  return false;
1642  }
1643  }
1644  return true;
1645  }
1646 
1650  function showProfile2()
1651  {
1652  global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting;
1653 exit; // comes later
1654  $this->__initSubTabs("showProfile");
1655 
1656  $settings = $ilias->getAllSettings();
1657 
1658  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
1659 
1660  // catch feedback message
1661  if ($ilUser->getProfileIncomplete())
1662  {
1663  ilUtil::sendInfo($lng->txt("profile_incomplete"));
1664  }
1665  else
1666  {
1667  ilUtil::sendInfo();
1668  }
1669  // display infopanel if something happened
1671 
1672  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
1673  $this->lng->txt("personal_desktop"));
1674  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
1675 
1676  $this->initForm();
1677  $this->tpl->setVariable("ADM_CONTENT", $this->form->getHTML());
1678 
1679  $this->tpl->show();
1680  }
1681 
1682 
1683  function initForm()
1684  {
1685  global $ilSetting, $lng, $ilUser, $styleDefinition, $rbacreview;
1686 
1687  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1688  $this->form = new ilPropertyFormGUI();
1689  $this->form->setFormAction($this->ctrl->getFormAction($this));
1690  $this->form->setSubformMode("right");
1691 
1692  // user data
1693  $sh = new ilFormSectionHeaderGUI();
1694  $sh->setTitle($this->lng->txt("userdata")." ".
1695  strtolower($this->lng->txt("of"))." ".$ilUser->getFullname());
1696  $this->form->addItem($sh);
1697 
1698  // user account name
1699  $val = new ilNonEditableValueGUI($this->lng->txt("username"));
1700  $val->setValue($ilUser->getLogin());
1701  $this->form->addItem($val);
1702 
1703  // default roles
1704  $global_roles = $rbacreview->getGlobalRoles();
1705  foreach($global_roles as $role_id)
1706  {
1707  if (in_array($role_id,$rbacreview->assignedRoles($ilUser->getId())))
1708  {
1709  $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1710  $role_names .= $roleObj->getTitle().", ";
1711  unset($roleObj);
1712  }
1713  }
1714  $dr = new ilNonEditableValueGUI($this->lng->txt("default_roles"));
1715  $dr->setValue(substr($role_names,0,-2));
1716  $this->form->addItem($dr);
1717 
1718  // personal data
1719  $sh = new ilFormSectionHeaderGUI();
1720  $sh->setTitle($this->lng->txt("personal_data"));
1721  $this->form->addItem($sh);
1722 
1723  // gender
1724  if ($this->userSettingVisible("gender"))
1725  {
1726  $this->input["gender"] =
1727  new ilRadioGroupInputGUI($lng->txt("gender"), "usr_gender");
1728  $this->input["gender"]->setValue($ilUser->getGender());
1729  $fem = new ilRadioOption($lng->txt("gender_f"), "f");
1730  $mal = new ilRadioOption($lng->txt("gender_m"), "m");
1731  $this->input["gender"]->addOption($fem);
1732  $this->input["gender"]->addOption($mal);
1733  $this->form->addItem($this->input["gender"]);
1734  }
1735 
1736  // first name
1737  if ($this->userSettingVisible("firstname"))
1738  {
1739  $this->input["firstname"] =
1740  new ilTextInputGUI($lng->txt("firstname"), "usr_firstname");
1741  $this->input["firstname"]->setValue($ilUser->getFirstname());
1742  $this->input["firstname"]->setMaxLength(32);
1743  $this->input["firstname"]->setSize(40);
1744  $this->form->addItem($this->input["firstname"]);
1745  }
1746 
1747  // last name
1748  if ($this->userSettingVisible("lastname"))
1749  {
1750  $this->input["lastname"] =
1751  new ilTextInputGUI($lng->txt("lastname"), "usr_lastname");
1752  $this->input["lastname"]->setValue($ilUser->getLastname());
1753  $this->input["lastname"]->setMaxLength(32);
1754  $this->input["lastname"]->setSize(40);
1755  $this->form->addItem($this->input["lastname"]);
1756  }
1757 
1758  // title
1759  if ($this->userSettingVisible("title"))
1760  {
1761  $this->input["title"] =
1762  new ilTextInputGUI($lng->txt("person_title"), "usr_title");
1763  $this->input["title"]->setValue($ilUser->getUTitle());
1764  $this->input["title"]->setMaxLength(32);
1765  $this->input["title"]->setSize(40);
1766  $this->form->addItem($this->input["title"]);
1767  }
1768 
1769  // personal picture
1770  if ($this->userSettingEnabled("upload"))
1771  {
1772  $this->input["image"] =
1773  new ilImageFileInputGUI($this->lng->txt("personal_picture"), "usr_image");
1774  $im = $ilUser->getPersonalPicturePath();
1775  if ($im != "")
1776  {
1777  $this->input["image"]->setImage($im);
1778  $this->input["image"]->setAlt($this->lng->txt("personal_picture"));
1779  }
1780 
1781  // ilinc link as info
1782  if ($this->userSettingVisible("upload") and $this->ilias->getSetting("ilinc_active"))
1783  {
1784  include_once ('./Modules/ILinc/classes/class.ilObjiLincUser.php');
1785  $ilinc_user = new ilObjiLincUser($ilUser);
1786 
1787  if ($ilinc_user->id)
1788  {
1789  include_once ('./Modules/ILinc/classes/class.ilnetucateXMLAPI.php');
1790  $ilincAPI = new ilnetucateXMLAPI();
1791  $ilincAPI->uploadPicture($ilinc_user);
1792  $response = $ilincAPI->sendRequest("uploadPicture");
1793 
1794  // return URL to user's personal page
1795  $url = trim($response->data['url']['cdata']);
1796  $desc =
1797  $this->lng->txt("ilinc_upload_pic_text")." ".
1798  '<a href="'.$url.'">'.$this->lng->txt("ilinc_upload_pic_linktext").'</a>';
1799  $this->input["image"]->setInfo($desc);
1800  }
1801  }
1802 
1803  $this->form->addItem($this->input["image"]);
1804  }
1805 
1806  // contact data
1807  $sh = new ilFormSectionHeaderGUI();
1808  $sh->setTitle($this->lng->txt("contact_data"));
1809  $this->form->addItem($sh);
1810 
1811  // institution
1812  if ($this->userSettingVisible("institution"))
1813  {
1814  $this->input["institution"] =
1815  new ilTextInputGUI($lng->txt("institution"), "usr_institution");
1816  $this->input["institution"]->setValue($ilUser->getInstitution());
1817  $this->input["institution"]->setMaxLength(80);
1818  $this->input["institution"]->setSize(40);
1819  $this->form->addItem($this->input["institution"]);
1820  }
1821 
1822  // department
1823  if ($this->userSettingVisible("department"))
1824  {
1825  $this->input["department"] =
1826  new ilTextInputGUI($lng->txt("department"), "usr_department");
1827  $this->input["department"]->setValue($ilUser->getDepartment());
1828  $this->input["department"]->setMaxLength(80);
1829  $this->input["department"]->setSize(40);
1830  $this->form->addItem($this->input["department"]);
1831  }
1832 
1833  // street
1834  if ($this->userSettingVisible("street"))
1835  {
1836  $this->input["street"] =
1837  new ilTextInputGUI($lng->txt("street"), "usr_street");
1838  $this->input["street"]->setValue($ilUser->getStreet());
1839  $this->input["street"]->setMaxLength(40);
1840  $this->input["street"]->setSize(40);
1841  $this->form->addItem($this->input["street"]);
1842  }
1843 
1844  // zipcode
1845  if ($this->userSettingVisible("zipcode"))
1846  {
1847  $this->input["zipcode"] =
1848  new ilTextInputGUI($lng->txt("zipcode"), "usr_zipcode");
1849  $this->input["zipcode"]->setValue($ilUser->getZipcode());
1850  $this->input["zipcode"]->setMaxLength(10);
1851  $this->input["zipcode"]->setSize(10);
1852  $this->form->addItem($this->input["zipcode"]);
1853  }
1854 
1855  // city
1856  if ($this->userSettingVisible("city"))
1857  {
1858  $this->input["city"] =
1859  new ilTextInputGUI($lng->txt("city"), "usr_city");
1860  $this->input["city"]->setValue($ilUser->getCity());
1861  $this->input["city"]->setMaxLength(40);
1862  $this->input["city"]->setSize(40);
1863  $this->form->addItem($this->input["city"]);
1864  }
1865 
1866  // country
1867  if ($this->userSettingVisible("country"))
1868  {
1869  $this->input["country"] =
1870  new ilTextInputGUI($lng->txt("country"), "usr_country");
1871  $this->input["country"]->setValue($ilUser->getCountry());
1872  $this->input["country"]->setMaxLength(40);
1873  $this->input["country"]->setSize(40);
1874  $this->form->addItem($this->input["country"]);
1875  }
1876 
1877  // phone office
1878  if ($this->userSettingVisible("phone_office"))
1879  {
1880  $this->input["phone_office"] =
1881  new ilTextInputGUI($lng->txt("phone_office"), "usr_phone_office");
1882  $this->input["phone_office"]->setValue($ilUser->getPhoneOffice());
1883  $this->input["phone_office"]->setMaxLength(40);
1884  $this->input["phone_office"]->setSize(40);
1885  $this->form->addItem($this->input["phone_office"]);
1886  }
1887 
1888  // phone home
1889  if ($this->userSettingVisible("phone_home"))
1890  {
1891  $this->input["phone_home"] =
1892  new ilTextInputGUI($lng->txt("phone_home"), "usr_phone_home");
1893  $this->input["phone_home"]->setValue($ilUser->getPhoneHome());
1894  $this->input["phone_home"]->setMaxLength(40);
1895  $this->input["phone_home"]->setSize(40);
1896  $this->form->addItem($this->input["phone_home"]);
1897  }
1898 
1899  // phone mobile
1900  if ($this->userSettingVisible("phone_mobile"))
1901  {
1902  $this->input["phone_mobile"] =
1903  new ilTextInputGUI($lng->txt("phone_mobile"), "usr_phone_mobile");
1904  $this->input["phone_mobile"]->setValue($ilUser->getPhoneMobile());
1905  $this->input["phone_mobile"]->setMaxLength(40);
1906  $this->input["phone_mobile"]->setSize(40);
1907  $this->form->addItem($this->input["phone_mobile"]);
1908  }
1909 
1910  // fax
1911  if ($this->userSettingVisible("fax"))
1912  {
1913  $this->input["fax"] =
1914  new ilTextInputGUI($lng->txt("fax"), "usr_fax");
1915  $this->input["fax"]->setValue($ilUser->getFax());
1916  $this->input["fax"]->setMaxLength(40);
1917  $this->input["fax"]->setSize(40);
1918  $this->form->addItem($this->input["fax"]);
1919  }
1920 
1921  // email
1922  if ($this->userSettingVisible("email"))
1923  {
1924  $this->input["email"] =
1925  new ilTextInputGUI($lng->txt("email"), "usr_email");
1926  $this->input["email"]->setValue($ilUser->getEmail());
1927  $this->input["email"]->setMaxLength(80);
1928  $this->input["email"]->setSize(40);
1929  $this->form->addItem($this->input["email"]);
1930  }
1931 
1932  // hobby
1933  if ($this->userSettingVisible("hobby"))
1934  {
1935  $this->input["hobby"] =
1936  new ilTextAreaInputGUI($lng->txt("hobby"), "usr_hobby");
1937  $this->input["hobby"]->setValue($ilUser->getHobby());
1938  $this->input["hobby"]->setRows(3);
1939  $this->input["hobby"]->setCols(45);
1940  $this->form->addItem($this->input["hobby"]);
1941  }
1942 
1943  // referral comment
1944  if ($this->userSettingVisible("referral_comment"))
1945  {
1946  $this->input["referral_comment"] =
1947  new ilTextAreaInputGUI($lng->txt("referral_comment"), "usr_referral_comment");
1948  $this->input["referral_comment"]->setValue($ilUser->getComment());
1949  $this->input["referral_comment"]->setRows(3);
1950  $this->input["referral_comment"]->setCols(45);
1951  $this->form->addItem($this->input["referral_comment"]);
1952  }
1953 
1954  // instant messengers
1955  if ($this->userSettingVisible("instant_messengers"))
1956  {
1957  $sh = new ilFormSectionHeaderGUI();
1958  $sh->setTitle($this->lng->txt("user_profile_instant_messengers"));
1959  $this->form->addItem($sh);
1960 
1961  $im_arr = array("icq","yahoo","msn","aim","skype");
1962  foreach ($im_arr as $im_name)
1963  {
1964  $this->input["im_".$im_name] =
1965  new ilTextInputGUI($lng->txt("im_".$im_name), "usr_im_".$im_name);
1966  $this->input["im_".$im_name]->setValue($ilUser->getInstantMessengerId($im_name));
1967  $this->input["im_".$im_name]->setMaxLength(40);
1968  $this->input["im_".$im_name]->setSize(40);
1969  $this->form->addItem($this->input["im_".$im_name]);
1970  }
1971  }
1972 
1973  // other information
1974  if($this->__showOtherInformations())
1975  {
1976  $sh = new ilFormSectionHeaderGUI();
1977  $sh->setTitle($this->lng->txt("user_profile_other"));
1978  $this->form->addItem($sh);
1979  }
1980 
1981  // matriculation number
1982  if ($this->userSettingVisible("matriculation"))
1983  {
1984  $this->input["matriculation"] =
1985  new ilTextInputGUI($lng->txt("matriculation"), "usr_matriculation");
1986  $this->input["matriculation"]->setValue($ilUser->getMatriculation());
1987  $this->input["matriculation"]->setMaxLength(40);
1988  $this->input["matriculation"]->setSize(40);
1989  $this->form->addItem($this->input["matriculation"]);
1990  }
1991 
1992  // delicious account
1993  $d_set = new ilSetting("delicious");
1994  if ($d_set->get("user_profile") == "1")
1995  {
1996  $this->input["delicious"] =
1997  new ilTextInputGUI($lng->txt("delicious"), "usr_delicious");
1998  $this->input["delicious"]->setValue($ilUser->getDelicious());
1999  $this->input["delicious"]->setMaxLength(40);
2000  $this->input["delicious"]->setSize(40);
2001  $this->form->addItem($this->input["delicious"]);
2002  }
2003 
2004  // user defined fields
2005  $user_defined_data = $ilUser->getUserDefinedData();
2006  foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
2007  {
2008  if($definition['field_type'] == UDF_TYPE_TEXT)
2009  {
2010  $this->input["udf_".$definition['field_id']] =
2011  new ilTextInputGUI($definition['field_name'], "udf_".$definition['field_id']);
2012  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data[$field_id]);
2013  $this->input["udf_".$definition['field_id']]->setMaxLength(255);
2014  $this->input["udf_".$definition['field_id']]->setSize(40);
2015  }
2016  else
2017  {
2018  $this->input["udf_".$definition['field_id']] =
2019  new ilSelectInputGUI($definition['field_name'], "udf_".$definition['field_id']);
2020  $this->input["udf_".$definition['field_id']]->setValue($user_defined_data[$field_id]);
2021  $this->input["udf_".$definition['field_id']]->setOptions(
2022  $this->user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
2023  }
2024  if(!$definition['changeable'])
2025  {
2026  $this->input["udf_".$definition['field_id']]->setDisabled(true);
2027  }
2028  if($definition['required'])
2029  {
2030  $this->input["udf_".$definition['field_id']]->setRequired(true);
2031  }
2032  $this->form->addItem($this->input["udf_".$definition['field_id']]);
2033  }
2034 
2035  // settings
2036  $sh = new ilFormSectionHeaderGUI();
2037  $sh->setTitle($lng->txt("settings"));
2038  $this->form->addItem($sh);
2039 
2040  // language
2041  if ($this->userSettingVisible("language"))
2042  {
2043  //get all languages
2044  $languages = $this->lng->getInstalledLanguages();
2045 
2046  // preselect previous chosen language otherwise saved language
2047  $selected_lang = (isset($_POST["usr_language"]))
2048  ? $_POST["usr_language"]
2049  : $ilUser->getLanguage();
2050 
2051  $this->input["language"] = new ilSelectInputGUI($lng->txt("language"), "usr_language");
2052 
2053  //go through languages
2054  $langs = array();
2055  foreach($languages as $lang_key)
2056  {
2057  $langs[$lang_key] = ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key);
2058  }
2059  $this->input["language"]->setValue($selected_lang);
2060  $this->input["language"]->setOptions($langs);
2061  $this->form->addItem($this->input["language"]);
2062  }
2063 
2064  // skin/style
2065  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
2066  $templates = $styleDefinition->getAllTemplates();
2067  if ($this->userSettingVisible("skin_style"))
2068  {
2069  if (is_array($templates))
2070  {
2071  $st_arr = array();
2072  foreach($templates as $template)
2073  {
2074  // get styles information of template
2075  $styleDef =& new ilStyleDefinition($template["id"]);
2076  $styleDef->startParsing();
2077  $styles = $styleDef->getStyles();
2078  $st_sel = $ilUser->skin.":".$ilUser->prefs["style"];
2079  foreach($styles as $style)
2080  {
2081  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
2082  {
2083  continue;
2084  }
2085  $st_arr[$template["id"].":".$style["id"]] =
2086  $styleDef->getTemplateName()." / ".$style["name"];
2087  }
2088  }
2089  $this->input["skin_style"] = new ilSelectInputGUI($lng->txt("usr_skin_style"), "usr_skin_style");
2090  $this->input["skin_style"]->setValue($st_sel);
2091  $this->input["skin_style"]->setOptions($st_arr);
2092  $this->form->addItem($this->input["skin_style"]);
2093  }
2094  }
2095 
2096  // hits per page
2097  if ($this->userSettingVisible("hits_per_page"))
2098  {
2099  $hits_options = array(2 => 2, 10 => 10, 15 => 15,
2100  20 => 20, 30 => 30, 40 => 40, 50 => 50,
2101  100 => 100, 9999 => $this->lng->txt("no_limit"));
2102  $this->input["hits_per_page"] = new ilSelectInputGUI($lng->txt("hits_per_page"), "hits_per_page");
2103  $this->input["hits_per_page"]->setValue($ilUser->prefs["hits_per_page"]);
2104  $this->input["hits_per_page"]->setOptions($hits_options);
2105  $this->form->addItem($this->input["hits_per_page"]);
2106  }
2107 
2108  // users online
2109  if ($this->userSettingVisible("show_users_online"))
2110  {
2111  $users_online_options = array(
2112  "y" => $this->lng->txt("users_online_show_y"),
2113  "associated" => $this->lng->txt("users_online_show_associated"),
2114  "n" => $this->lng->txt("users_online_show_n"));
2115  $this->input["show_users_online"] =
2116  new ilSelectInputGUI($lng->txt("show_users_online"), "show_users_online");
2117  $this->input["show_users_online"]->setValue($ilUser->prefs["show_users_online"]);
2118  $this->input["show_users_online"]->setOptions($users_online_options);
2119  $this->form->addItem($this->input["show_users_online"]);
2120  }
2121 
2122  // hide_own_online_status
2123  if ($this->userSettingVisible("hide_own_online_status"))
2124  {
2125  if ($ilUser->prefs["hide_own_online_status"] == "y")
2126  {
2127  $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "checked");
2128  }
2129  $this->input["hide_own_online_status"] =
2130  new ilCheckboxInputGUI($lng->txt("hide_own_online_status"), "hide_own_online_status");
2131  $this->input["hide_own_online_status"]->setValue("y");
2132  $this->input["hide_own_online_status"]->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
2133  $this->form->addItem($this->input["hide_own_online_status"]);
2134  }
2135 
2136 
2137  // disable disabled fields
2138  foreach ($this->input as $field => $val)
2139  {
2140  if (!$ilSetting->get("usr_settings_hide_" . $field))
2141  {
2142  if ($ilSetting->get("usr_settings_disable_" . $field))
2143  {
2144  $this->input[$field]->setDisabled(true);
2145  }
2146  }
2147  if (isset($this->settings["require_" . $field]) && $this->settings["require_" . $field])
2148  {
2149  $this->input[$field]->setRequired(true);
2150  }
2151  }
2152 
2153  // show in public profile?
2154  $val_array = array("institution", "department", "upload", "street",
2155  "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
2156  "fax", "email", "hobby", "matriculation");
2157  foreach ($val_array as $val)
2158  {
2159  if (is_object($this->input[$val]))
2160  {
2161  $this->input["chk_".$val] =
2162  new ilCheckboxInputGUI($lng->txt("public"), "chk_".$val);
2163  $this->input["chk_".$val]->setValue("y");
2164  $this->input["chk_".$val]->setChecked($ilUser->prefs["public_".$val] == "y");
2165  $this->input[$val]->addSubItem($this->input["chk_".$val]);
2166  $this->input[$val]->setSubformMode("right");
2167  }
2168  }
2169  }
2170 
2171 }
2172 ?>