00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00035 class ilPersonalProfileGUI
00036 {
00037 var $tpl;
00038 var $lng;
00039 var $ilias;
00040 var $ctrl;
00041
00042 var $user_defined_fields = null;
00043
00044
00048 function ilPersonalProfileGUI()
00049 {
00050 global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl;
00051
00052 include_once './classes/class.ilUserDefinedFields.php';
00053 $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
00054
00055 $this->tpl =& $tpl;
00056 $this->lng =& $lng;
00057 $this->ilias =& $ilias;
00058 $this->ctrl =& $ilCtrl;
00059 $this->settings = $ilias->getAllSettings();
00060 $this->upload_error = "";
00061 $this->password_error = "";
00062 }
00063
00067 function &executeCommand()
00068 {
00069 $next_class = $this->ctrl->getNextClass();
00070
00071 switch($next_class)
00072 {
00073 default:
00074
00075 $cmd = $this->ctrl->getCmd("showProfile");
00076 $this->$cmd();
00077 break;
00078 }
00079 return true;
00080 }
00081
00082
00083
00088 function workWithUserSetting($setting)
00089 {
00090 $result = TRUE;
00091 if ($this->settings["usr_settings_hide_".$setting] == 1)
00092 {
00093 $result = FALSE;
00094 }
00095 if ($this->settings["usr_settings_disable_".$setting] == 1)
00096 {
00097 $result = FALSE;
00098 }
00099 return $result;
00100 }
00101
00106 function userSettingVisible($setting)
00107 {
00108 $result = TRUE;
00109 if ($this->settings["usr_settings_hide_".$setting] == 1)
00110 {
00111 $result = FALSE;
00112 }
00113 return $result;
00114 }
00115
00120 function userSettingEnabled($setting)
00121 {
00122 $result = TRUE;
00123 if ($this->settings["usr_settings_disable_".$setting] == 1)
00124 {
00125 $result = FALSE;
00126 }
00127 return $result;
00128 }
00129
00135 function uploadUserPicture()
00136 {
00137 global $ilUser;
00138
00139 if ($this->workWithUserSetting("upload"))
00140 {
00141
00142 if ($_FILES["userfile"]["size"] == 0)
00143 {
00144 $this->upload_error = $this->lng->txt("msg_no_file");
00145 }
00146 else
00147 {
00148
00149 $webspace_dir = ilUtil::getWebspaceDir();
00150 $image_dir = $webspace_dir."/usr_images";
00151 $store_file = "usr_".$ilUser->getID()."."."jpg";
00152
00153
00154 $ilUser->setPref("profile_image", $store_file);
00155 $ilUser->update();
00156
00157
00158 $uploaded_file = $image_dir."/upload_".$ilUser->getId()."pic";
00159 if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
00160 $uploaded_file, false))
00161 {
00162 sendInfo($this->lng->txt("upload_error", true));
00163 $this->ctrl->redirect($this, "showProfile");
00164 }
00165 chmod($uploaded_file, 0770);
00166
00167
00168
00169 $show_file = "$image_dir/usr_".$ilUser->getId().".jpg";
00170 $thumb_file = "$image_dir/usr_".$ilUser->getId()."_small.jpg";
00171 $xthumb_file = "$image_dir/usr_".$ilUser->getId()."_xsmall.jpg";
00172 $xxthumb_file = "$image_dir/usr_".$ilUser->getId()."_xxsmall.jpg";
00173 $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
00174 $show_file = ilUtil::escapeShellArg($show_file);
00175 $thumb_file = ilUtil::escapeShellArg($thumb_file);
00176 $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
00177 $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
00178
00179 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file");
00180 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
00181 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
00182 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
00183 }
00184 }
00185
00186 $this->saveProfile();
00187 }
00188
00192 function removeUserPicture()
00193 {
00194 global $ilUser;
00195
00196 $webspace_dir = ilUtil::getWebspaceDir();
00197 $image_dir = $webspace_dir."/usr_images";
00198 $file = $image_dir."/usr_".$ilUser->getID()."."."jpg";
00199 $thumb_file = $image_dir."/usr_".$ilUser->getID()."_small.jpg";
00200 $xthumb_file = $image_dir."/usr_".$ilUser->getID()."_xsmall.jpg";
00201 $xxthumb_file = $image_dir."/usr_".$ilUser->getID()."_xxsmall.jpg";
00202 $upload_file = $image_dir."/upload_".$ilUser->getID();
00203
00204
00205 $ilUser->setPref("profile_image", "");
00206 $ilUser->update();
00207
00208 if (@is_file($file))
00209 {
00210 unlink($file);
00211 }
00212 if (@is_file($thumb_file))
00213 {
00214 unlink($thumb_file);
00215 }
00216 if (@is_file($xthumb_file))
00217 {
00218 unlink($xthumb_file);
00219 }
00220 if (@is_file($xxthumb_file))
00221 {
00222 unlink($xxthumb_file);
00223 }
00224 if (@is_file($upload_file))
00225 {
00226 unlink($upload_file);
00227 }
00228
00229 $this->saveProfile();
00230 }
00231
00232
00236 function changeUserPassword()
00237 {
00238 global $ilUser, $ilSetting;
00239
00240
00241 if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
00242 ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
00243 ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local"))
00244 )
00245 {
00246 $this->password_error = $this->lng->txt("not_changeable_for_non_local_auth");
00247 }
00248
00249
00250 if ($this->ilias->getSetting("passwd_auto_generate") == 1)
00251 {
00252
00253 if (md5($_POST["current_password"]) != $ilUser->getPasswd())
00254 {
00255 $this->password_error = $this->lng->txt("passwd_wrong");
00256 }
00257
00258 if (!ilUtil::isPassword($_POST["new_passwd"]))
00259 {
00260 $this->password_error = $this->lng->txt("passwd_not_selected");
00261 }
00262
00263 if (empty($this->password_error))
00264 {
00265 sendInfo($this->lng->txt("saved_successfully"));
00266 $ilUser->updatePassword($_POST["current_password"], $_POST["new_passwd"], $_POST["new_passwd"]);
00267 }
00268 }
00269 else
00270 {
00271
00272 if (md5($_POST["current_password"]) != $ilUser->getPasswd())
00273 {
00274 $this->password_error = $this->lng->txt("passwd_wrong");
00275 }
00276
00277 else if ($_POST["desired_password"] != $_POST["retype_password"])
00278 {
00279 $this->password_error = $this->lng->txt("passwd_not_match");
00280 }
00281
00282 else if (!ilUtil::isPassword($_POST["desired_password"]))
00283 {
00284 $this->password_error = $this->lng->txt("passwd_invalid");
00285 }
00286 else if ($_POST["current_password"] != "" and empty($this->password_error))
00287 {
00288 sendInfo($this->lng->txt("saved_successfully"));
00289 $ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]);
00290 }
00291 }
00292
00293 $this->saveProfile();
00294 }
00295
00296
00297
00301 function saveProfile()
00302 {
00303 global $ilUser;
00304
00305
00306 $form_valid = true;
00307
00308
00309
00310
00311
00312 if (($_POST["chk_pub"])=="on")
00313 {
00314 $ilUser->setPref("public_profile","y");
00315 }
00316 else
00317 {
00318 $ilUser->setPref("public_profile","n");
00319 }
00320
00321
00322 $val_array = array("institution", "department", "upload", "street",
00323 "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
00324 "fax", "email", "hobby", "matriculation");
00325
00326
00327 foreach($val_array as $key => $value)
00328 {
00329 if (($_POST["chk_".$value]) == "on")
00330 {
00331 $ilUser->setPref("public_".$value,"y");
00332 }
00333 else
00334 {
00335 $ilUser->setPref("public_".$value,"n");
00336 }
00337 }
00338
00339
00340 foreach($this->settings as $key => $val)
00341 {
00342 if (substr($key,0,8) == "require_")
00343 {
00344 $require_keys[] = substr($key,8);
00345 }
00346 }
00347
00348 foreach($require_keys as $key => $val)
00349 {
00350
00351 $system_fields = array("login", "default_role", "passwd", "passwd2");
00352 if (!in_array($val, $system_fields))
00353 {
00354 if ($this->workWithUserSetting($val))
00355 {
00356 if (isset($this->settings["require_" . $val]) && $this->settings["require_" . $val])
00357 {
00358 if (empty($_POST["usr_" . $val]))
00359 {
00360 sendInfo($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val));
00361 $form_valid = false;
00362 }
00363 }
00364 }
00365 }
00366 }
00367
00368
00369 if($form_valid and !$this->__checkUserDefinedRequiredFields())
00370 {
00371 sendInfo($this->lng->txt("fill_out_all_required_fields"));
00372 $form_valid = false;
00373 }
00374
00375
00376 if ($this->workWithUserSetting("email"))
00377 {
00378 if (!ilUtil::is_email($_POST["usr_email"]) and !empty($_POST["usr_email"]) and $form_valid)
00379 {
00380 sendInfo($this->lng->txt("email_not_valid"));
00381 $form_valid = false;
00382 }
00383 }
00384
00385
00386 if ($this->workWithUserSetting("firstname"))
00387 {
00388 $ilUser->setFirstName(ilUtil::stripSlashes($_POST["usr_firstname"]));
00389 }
00390 if ($this->workWithUserSetting("lastname"))
00391 {
00392 $ilUser->setLastName(ilUtil::stripSlashes($_POST["usr_lastname"]));
00393 }
00394 if ($this->workWithUserSetting("gender"))
00395 {
00396 $ilUser->setGender($_POST["usr_gender"]);
00397 }
00398 if ($this->workWithUserSetting("title"))
00399 {
00400 $ilUser->setUTitle(ilUtil::stripSlashes($_POST["usr_title"]));
00401 }
00402 $ilUser->setFullname();
00403 if ($this->workWithUserSetting("institution"))
00404 {
00405 $ilUser->setInstitution(ilUtil::stripSlashes($_POST["usr_institution"]));
00406 }
00407 if ($this->workWithUserSetting("department"))
00408 {
00409 $ilUser->setDepartment(ilUtil::stripSlashes($_POST["usr_department"]));
00410 }
00411 if ($this->workWithUserSetting("street"))
00412 {
00413 $ilUser->setStreet(ilUtil::stripSlashes($_POST["usr_street"]));
00414 }
00415 if ($this->workWithUserSetting("zipcode"))
00416 {
00417 $ilUser->setZipcode(ilUtil::stripSlashes($_POST["usr_zipcode"]));
00418 }
00419 if ($this->workWithUserSetting("city"))
00420 {
00421 $ilUser->setCity(ilUtil::stripSlashes($_POST["usr_city"]));
00422 }
00423 if ($this->workWithUserSetting("country"))
00424 {
00425 $ilUser->setCountry(ilUtil::stripSlashes($_POST["usr_country"]));
00426 }
00427 if ($this->workWithUserSetting("phone_office"))
00428 {
00429 $ilUser->setPhoneOffice(ilUtil::stripSlashes($_POST["usr_phone_office"]));
00430 }
00431 if ($this->workWithUserSetting("phone_home"))
00432 {
00433 $ilUser->setPhoneHome(ilUtil::stripSlashes($_POST["usr_phone_home"]));
00434 }
00435 if ($this->workWithUserSetting("phone_mobile"))
00436 {
00437 $ilUser->setPhoneMobile(ilUtil::stripSlashes($_POST["usr_phone_mobile"]));
00438 }
00439 if ($this->workWithUserSetting("fax"))
00440 {
00441 $ilUser->setFax(ilUtil::stripSlashes($_POST["usr_fax"]));
00442 }
00443 if ($this->workWithUserSetting("email"))
00444 {
00445 $ilUser->setEmail(ilUtil::stripSlashes($_POST["usr_email"]));
00446 }
00447 if ($this->workWithUserSetting("hobby"))
00448 {
00449 $ilUser->setHobby(ilUtil::stripSlashes($_POST["usr_hobby"]));
00450 }
00451 if ($this->workWithUserSetting("referral_comment"))
00452 {
00453 $ilUser->setComment(ilUtil::stripSlashes($_POST["usr_referral_comment"]));
00454 }
00455 if ($this->workWithUserSetting("matriculation"))
00456 {
00457 $ilUser->setMatriculation(ilUtil::stripSlashes($_POST["usr_matriculation"]));
00458 }
00459
00460 $ilUser->setUserDefinedData($_POST['udf']);
00461
00462
00463 if ($form_valid)
00464 {
00465
00466 $reload = false;
00467
00468 if ($this->workWithUserSetting("skin_style"))
00469 {
00470
00471 if ($_POST["usr_skin_style"] != "")
00472 {
00473 $sknst = explode(":", $_POST["usr_skin_style"]);
00474
00475 if ($ilUser->getPref("style") != $sknst[1] ||
00476 $ilUser->getPref("skin") != $sknst[0])
00477 {
00478 $ilUser->setPref("skin", $sknst[0]);
00479 $ilUser->setPref("style", $sknst[1]);
00480 $reload = true;
00481 }
00482 }
00483 }
00484
00485 if ($this->workWithUserSetting("language"))
00486 {
00487
00488
00489
00490 if ($_POST["usr_language"] != $ilUser->getLanguage())
00491 {
00492 $reload = true;
00493 }
00494
00495
00496 $ilUser->setLanguage($_POST["usr_language"]);
00497
00498 }
00499 if ($this->workWithUserSetting("hits_per_page"))
00500 {
00501
00502 if ($_POST["hits_per_page"] != "")
00503 {
00504 $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
00505 }
00506 }
00507
00508
00509 if ($this->workWithUserSetting("show_users_online"))
00510 {
00511 $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
00512 }
00513
00514
00515 if ($_POST["chk_notes"] != "")
00516 {
00517 $ilUser->setPref("show_notes","y");
00518 }
00519 else
00520 {
00521 $ilUser->setPref("show_notes","n");
00522 }
00523
00524
00525 $ilUser->setProfileIncomplete(false);
00526
00527
00528 $ilUser->setTitle($ilUser->getFullname());
00529 $ilUser->setDescription($ilUser->getEmail());
00530 $ilUser->update();
00531
00532
00533
00534 if (!empty($this->password_error))
00535 {
00536 sendInfo($this->password_error,true);
00537 }
00538 elseif (!empty($this->upload_error))
00539 {
00540 sendInfo($this->upload_error,true);
00541 }
00542 else if ($reload)
00543 {
00544
00545 sendInfo($this->lng->txt("saved_successfully"),true);
00546 $this->ctrl->redirect($this, "");
00547
00548 }
00549 else
00550 {
00551 sendInfo($this->lng->txt("saved_successfully"),true);
00552 }
00553 }
00554
00555 $this->showProfile();
00556 }
00557
00561 function showProfile()
00562 {
00563 global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting;
00564
00565 $settings = $ilias->getAllSettings();
00566
00567 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588 if ($ilUser->getProfileIncomplete())
00589 {
00590 sendInfo($lng->txt("profile_incomplete"));
00591 }
00592 else
00593 {
00594 sendInfo();
00595 }
00596
00597
00598
00599 infoPanel();
00600
00601 if ($this->userSettingVisible("language"))
00602 {
00603
00604 $languages = $this->lng->getInstalledLanguages();
00605
00606
00607 $selected_lang = (isset($_POST["usr_language"]))
00608 ? $_POST["usr_language"]
00609 : $ilUser->getLanguage();
00610
00611
00612 foreach($languages as $lang_key)
00613 {
00614 $this->tpl->setCurrentBlock("sel_lang");
00615
00616 $this->tpl->setVariable("LANG", ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key));
00617 $this->tpl->setVariable("LANGSHORT", $lang_key);
00618
00619 if ($selected_lang == $lang_key)
00620 {
00621 $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00622 }
00623
00624 $this->tpl->parseCurrentBlock();
00625 }
00626 }
00627
00628
00629 include_once("classes/class.ilObjStyleSettings.php");
00630 $templates = $styleDefinition->getAllTemplates();
00631
00632 if ($this->userSettingVisible("skin_style"))
00633 {
00634 foreach($templates as $template)
00635 {
00636
00637 $styleDef =& new ilStyleDefinition($template["id"]);
00638 $styleDef->startParsing();
00639 $styles = $styleDef->getStyles();
00640
00641 foreach($styles as $style)
00642 {
00643 if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
00644 {
00645 continue;
00646 }
00647
00648 $this->tpl->setCurrentBlock("selectskin");
00649
00650 if ($ilUser->skin == $template["id"] &&
00651 $ilUser->prefs["style"] == $style["id"])
00652 {
00653 $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00654 }
00655
00656 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00657 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00658 $this->tpl->parseCurrentBlock();
00659 }
00660 }
00661 }
00662
00663
00664 if ($this->userSettingVisible("hits_per_page"))
00665 {
00666 $hits_options = array(2,10,15,20,30,40,50,100,9999);
00667
00668 foreach($hits_options as $hits_option)
00669 {
00670 $this->tpl->setCurrentBlock("selecthits");
00671
00672 if ($ilUser->prefs["hits_per_page"] == $hits_option)
00673 {
00674 $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
00675 }
00676
00677 $this->tpl->setVariable("HITSVALUE", $hits_option);
00678
00679 if ($hits_option == 9999)
00680 {
00681 $hits_option = $this->lng->txt("no_limit");
00682 }
00683
00684 $this->tpl->setVariable("HITSOPTION", $hits_option);
00685 $this->tpl->parseCurrentBlock();
00686 }
00687 }
00688
00689
00690 if ($this->userSettingVisible("show_users_online"))
00691 {
00692 $users_online_options = array("y","associated","n");
00693 $selected_option = $ilUser->prefs["show_users_online"];
00694 foreach($users_online_options as $an_option)
00695 {
00696 $this->tpl->setCurrentBlock("select_users_online");
00697
00698 if ($selected_option == $an_option)
00699 {
00700 $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
00701 }
00702
00703 $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
00704
00705 $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
00706 $this->tpl->parseCurrentBlock();
00707 }
00708 }
00709
00710
00711 if ($ilUser->prefs["show_notes"] != "n")
00712 {
00713 $this->tpl->setVariable("CHK_NOTES", "checked");
00714 }
00715 $this->tpl->setVariable("TXT_SHOW_NOTES", $this->lng->txt("show_notes_on_pd"));
00716
00717 if (($ilUser->getAuthMode(true) == AUTH_LOCAL ||
00718 ($ilUser->getAuthMode(true) == AUTH_CAS && $ilSetting->get("cas_allow_local")) ||
00719 ($ilUser->getAuthMode(true) == AUTH_SOAP && $ilSetting->get("soap_auth_allow_local"))
00720 )
00721 &&
00722 $this->userSettingVisible('password'))
00723 {
00724 if($this->ilias->getSetting('usr_settings_disable_password'))
00725 {
00726 $this->tpl->setCurrentBlock("disabled_password");
00727 $this->tpl->setVariable("TXT_DISABLED_PASSWORD", $this->lng->txt("chg_password"));
00728 $this->tpl->setVariable("TXT_DISABLED_CURRENT_PASSWORD", $this->lng->txt("current_password"));
00729 $this->tpl->parseCurrentBlock();
00730 }
00731 elseif ($settings["passwd_auto_generate"] == 1)
00732 {
00733 $passwd_list = ilUtil::generatePasswords(5);
00734
00735 foreach ($passwd_list as $passwd)
00736 {
00737 $passwd_choice .= ilUtil::formRadioButton(0,"new_passwd",$passwd)." ".$passwd."<br/>";
00738 }
00739
00740 $this->tpl->setCurrentBlock("select_password");
00741 $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
00742 $this->tpl->setVariable("TXT_CURRENT_PASSWORD", $this->lng->txt("current_password"));
00743 $this->tpl->setVariable("TXT_SELECT_PASSWORD", $this->lng->txt("select_password"));
00744 $this->tpl->setVariable("PASSWORD_CHOICE", $passwd_choice);
00745 $this->tpl->setVariable("TXT_NEW_LIST_PASSWORD", $this->lng->txt("new_list_password"));
00746 $this->tpl->parseCurrentBlock();
00747 }
00748 else
00749 {
00750 $this->tpl->setCurrentBlock("change_password");
00751 $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
00752 $this->tpl->setVariable("TXT_CURRENT_PW", $this->lng->txt("current_password"));
00753 $this->tpl->setVariable("TXT_DESIRED_PW", $this->lng->txt("desired_password"));
00754 $this->tpl->setVariable("TXT_RETYPE_PW", $this->lng->txt("retype_password"));
00755 $this->tpl->setVariable("CHANGE_PASSWORD", $this->lng->txt("chg_password"));
00756 $this->tpl->parseCurrentBlock();
00757 }
00758 }
00759
00760 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
00761 $this->lng->txt("personal_desktop"));
00762
00763 $this->tpl->setCurrentBlock("content");
00764 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00765
00766 $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
00767 $this->tpl->setVariable("TXT_OF",strtolower($this->lng->txt("of")));
00768 $this->tpl->setVariable("USR_FULLNAME",$ilUser->getFullname());
00769
00770 $this->tpl->setVariable("TXT_USR_DATA", $this->lng->txt("userdata"));
00771 $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("username"));
00772 $this->tpl->setVariable("TXT_PUBLIC_PROFILE", $this->lng->txt("public_profile"));
00773
00774 $data = array();
00775 $data["fields"] = array();
00776 $data["fields"]["gender"] = "";
00777 $data["fields"]["firstname"] = "";
00778 $data["fields"]["lastname"] = "";
00779 $data["fields"]["title"] = "";
00780 $data["fields"]["institution"] = "";
00781 $data["fields"]["department"] = "";
00782 $data["fields"]["street"] = "";
00783 $data["fields"]["city"] = "";
00784 $data["fields"]["zipcode"] = "";
00785 $data["fields"]["country"] = "";
00786 $data["fields"]["phone_office"] = "";
00787 $data["fields"]["phone_home"] = "";
00788 $data["fields"]["phone_mobile"] = "";
00789 $data["fields"]["fax"] = "";
00790 $data["fields"]["email"] = "";
00791 $data["fields"]["hobby"] = "";
00792 $data["fields"]["referral_comment"] = "";
00793 $data["fields"]["matriculation"] = "";
00794 $data["fields"]["create_date"] = "";
00795 $data["fields"]["approve_date"] = "";
00796 $data["fields"]["active"] = "";
00797
00798 $data["fields"]["default_role"] = $role;
00799
00800 foreach($data["fields"] as $key => $val)
00801 {
00802
00803 if ($key != "title")
00804 {
00805 $str = $this->lng->txt($key);
00806 }
00807 else
00808 {
00809 $str = $this->lng->txt("person_title");
00810 }
00811
00812
00813 if (isset($this->settings["require_" . $key]) && $this->settings["require_" . $key])
00814 {
00815 $str = $str . '<span class="asterisk">*</span>';
00816 }
00817
00818 if ($this->userSettingVisible("$key"))
00819 {
00820 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00821 }
00822 }
00823
00824 if ($this->userSettingVisible("gender"))
00825 {
00826 $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
00827 $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
00828 }
00829
00830
00831 if ($this->userSettingVisible("upload"))
00832 {
00833 $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("personal_picture"));
00834 $webspace_dir = ilUtil::getWebspaceDir("output");
00835 $full_img = $ilUser->getPref("profile_image");
00836 $last_dot = strrpos($full_img, ".");
00837 $small_img = substr($full_img, 0, $last_dot).
00838 "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
00839 $image_file = $webspace_dir."/usr_images/".$small_img;
00840
00841 if (@is_file($image_file))
00842 {
00843 $this->tpl->setCurrentBlock("pers_image");
00844 $this->tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
00845 $this->tpl->setVariable("ALT_IMG_PERSONAL",$this->lng->txt("personal_picture"));
00846 $this->tpl->parseCurrentBlock();
00847 if ($this->userSettingEnabled("upload"))
00848 {
00849 $this->tpl->setCurrentBlock("remove_pic");
00850 $this->tpl->setVariable("TXT_REMOVE_PIC", $this->lng->txt("remove_personal_picture"));
00851 }
00852 $this->tpl->parseCurrentBlock();
00853 $this->tpl->setCurrentBlock("content");
00854 }
00855
00856 if ($this->userSettingEnabled("upload"))
00857 {
00858 $this->tpl->setCurrentBlock("upload_pic");
00859 $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
00860 }
00861 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("userfile"));
00862 $this->tpl->setVariable("USER_FILE", $this->lng->txt("user_file"));
00863 }
00864 $this->tpl->setCurrentBlock("adm_content");
00865
00866
00867 if ($this->userSettingVisible("upload") and $this->ilias->getSetting("ilinc_active"))
00868 {
00869 include_once ('ilinc/classes/class.ilObjiLincUser.php');
00870 $ilinc_user = new ilObjiLincUser($ilUser);
00871
00872 if ($ilinc_user->id)
00873 {
00874 include_once ('ilinc/classes/class.ilnetucateXMLAPI.php');
00875 $ilincAPI = new ilnetucateXMLAPI();
00876
00877 $ilincAPI->uploadPicture($ilinc_user);
00878 $response = $ilincAPI->sendRequest("uploadPicture");
00879
00880
00881 $url = trim($response->data['url']['cdata']);
00882
00883 $this->tpl->setCurrentBlock("ilinc_upload_pic");
00884 $this->tpl->setVariable("TXT_ILINC_UPLOAD", $this->lng->txt("ilinc_upload_pic_text"));
00885 $this->tpl->setVariable("ILINC_UPLOAD_LINK", $url);
00886 $this->tpl->setVariable("ILINC_UPLOAD_LINKTXT", $this->lng->txt("ilinc_upload_pic_linktext"));
00887 $this->tpl->parseCurrentBlock();
00888 }
00889 }
00890
00891
00892 if ($this->userSettingVisible("language"))
00893 {
00894 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00895 }
00896 if ($this->userSettingVisible("show_users_online"))
00897 {
00898 $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
00899 }
00900 if ($this->userSettingVisible("skin_style"))
00901 {
00902 $this->tpl->setVariable("TXT_USR_SKIN_STYLE", $this->lng->txt("usr_skin_style"));
00903 }
00904 if ($this->userSettingVisible("hits_per_page"))
00905 {
00906 $this->tpl->setVariable("TXT_HITS_PER_PAGE", $this->lng->txt("usr_hits_per_page"));
00907 }
00908 if ($this->userSettingVisible("show_users_online"))
00909 {
00910 $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
00911 }
00912 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
00913 $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
00914 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
00915
00916 if($this->__showOtherInformations())
00917 {
00918 $this->tpl->setVariable("TXT_OTHER", $this->lng->txt("user_profile_other"));
00919 }
00920 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
00921
00922
00923 $this->tpl->setVariable("NICKNAME", ilUtil::prepareFormOutput($ilUser->getLogin()));
00924
00925 if ($this->userSettingVisible("firstname"))
00926 {
00927 $this->tpl->setVariable("FIRSTNAME", ilUtil::prepareFormOutput($ilUser->getFirstname()));
00928 }
00929 if ($this->userSettingVisible("lastname"))
00930 {
00931 $this->tpl->setVariable("LASTNAME", ilUtil::prepareFormOutput($ilUser->getLastname()));
00932 }
00933
00934 if ($this->userSettingVisible("gender"))
00935 {
00936
00937 $gender = strtoupper($ilUser->getGender());
00938
00939 if (!empty($gender))
00940 {
00941 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00942 }
00943 }
00944
00945 $this->tpl->setVariable("CREATE_DATE", $ilUser->getCreateDate());
00946 $this->tpl->setVariable("APPROVE_DATE", $ilUser->getApproveDate());
00947
00948 if ($ilUser->getActive())
00949 {
00950 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00951 }
00952
00953 if ($this->userSettingVisible("title"))
00954 {
00955 $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($ilUser->getUTitle()));
00956 }
00957 if ($this->userSettingVisible("institution"))
00958 {
00959 $this->tpl->setVariable("INSTITUTION", ilUtil::prepareFormOutput($ilUser->getInstitution()));
00960 }
00961 if ($this->userSettingVisible("department"))
00962 {
00963 $this->tpl->setVariable("DEPARTMENT", ilUtil::prepareFormOutput($ilUser->getDepartment()));
00964 }
00965 if ($this->userSettingVisible("street"))
00966 {
00967 $this->tpl->setVariable("STREET", ilUtil::prepareFormOutput($ilUser->getStreet()));
00968 }
00969 if ($this->userSettingVisible("zipcode"))
00970 {
00971 $this->tpl->setVariable("ZIPCODE", ilUtil::prepareFormOutput($ilUser->getZipcode()));
00972 }
00973 if ($this->userSettingVisible("city"))
00974 {
00975 $this->tpl->setVariable("CITY", ilUtil::prepareFormOutput($ilUser->getCity()));
00976 }
00977 if ($this->userSettingVisible("country"))
00978 {
00979 $this->tpl->setVariable("COUNTRY", ilUtil::prepareFormOutput($ilUser->getCountry()));
00980 }
00981 if ($this->userSettingVisible("phone_office"))
00982 {
00983 $this->tpl->setVariable("PHONE_OFFICE", ilUtil::prepareFormOutput($ilUser->getPhoneOffice()));
00984 }
00985 if ($this->userSettingVisible("phone_home"))
00986 {
00987 $this->tpl->setVariable("PHONE_HOME", ilUtil::prepareFormOutput($ilUser->getPhoneHome()));
00988 }
00989 if ($this->userSettingVisible("phone_mobile"))
00990 {
00991 $this->tpl->setVariable("PHONE_MOBILE", ilUtil::prepareFormOutput($ilUser->getPhoneMobile()));
00992 }
00993 if ($this->userSettingVisible("fax"))
00994 {
00995 $this->tpl->setVariable("FAX", ilUtil::prepareFormOutput($ilUser->getFax()));
00996 }
00997 if ($this->userSettingVisible("email"))
00998 {
00999 $this->tpl->setVariable("EMAIL", ilUtil::prepareFormOutput($ilUser->getEmail()));
01000 }
01001 if ($this->userSettingVisible("hobby"))
01002 {
01003 $this->tpl->setVariable("HOBBY", ilUtil::prepareFormOutput($ilUser->getHobby()));
01004 }
01005 if ($this->userSettingVisible("referral_comment"))
01006 {
01007 $this->tpl->setVariable("REFERRAL_COMMENT", ilUtil::prepareFormOutput($ilUser->getComment()));
01008 }
01009 if ($this->userSettingVisible("matriculation"))
01010 {
01011 $this->tpl->setVariable("MATRICULATION", ilUtil::prepareFormOutput($ilUser->getMatriculation()));
01012 }
01013
01014
01015 $this->__showUserDefinedFields();
01016
01017
01018 $global_roles = $rbacreview->getGlobalRoles();
01019
01020 foreach($global_roles as $role_id)
01021 {
01022 if (in_array($role_id, $_SESSION["RoleId"]))
01023 {
01024 $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
01025 $role_names .= $roleObj->getTitle().", ";
01026 unset($roleObj);
01027 }
01028 }
01029
01030 $this->tpl->setVariable("TXT_DEFAULT_ROLES", $this->lng->txt("default_roles"));
01031 $this->tpl->setVariable("DEFAULT_ROLES", substr($role_names,0,-2));
01032
01033 $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
01034
01035
01036 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01037
01038
01039 if ($this->userSettingEnabled("upload"))
01040 {
01041 $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
01042 }
01043
01044
01045 if ($ilUser->prefs["public_profile"] == "y")
01046 {
01047 $this->tpl->setVariable("CHK_PUB","checked");
01048 }
01049 $val_array = array("institution", "department", "upload", "street",
01050 "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
01051 "fax", "email", "hobby", "matriculation", "show_users_online");
01052 foreach($val_array as $key => $value)
01053 {
01054 if ($this->userSettingVisible("$value"))
01055 {
01056 if ($ilUser->prefs["public_".$value] == "y")
01057 {
01058 $this->tpl->setVariable("CHK_".strtoupper($value), "checked");
01059 }
01060 }
01061 }
01062
01063
01064
01065
01066 $profile_fields = array(
01067 "gender",
01068 "firstname",
01069 "lastname",
01070 "title",
01071 "upload",
01072 "institution",
01073 "department",
01074 "street",
01075 "city",
01076 "zipcode",
01077 "country",
01078 "phone_office",
01079 "phone_home",
01080 "phone_mobile",
01081 "fax",
01082 "email",
01083 "hobby",
01084 "matriculation",
01085 "referral_comment",
01086 "language",
01087 "skin_style",
01088 "hits_per_page",
01089 "show_users_online"
01090 );
01091 foreach ($profile_fields as $field)
01092 {
01093 if (!$this->ilias->getSetting("usr_settings_hide_" . $field))
01094 {
01095 if ($this->ilias->getSetting("usr_settings_disable_" . $field))
01096 {
01097 $this->tpl->setVariable("DISABLED_" . strtoupper($field), " disabled=\"disabled\"");
01098 }
01099 }
01100 }
01101
01102 $this->tpl->parseCurrentBlock();
01103 $this->tpl->show();
01104 }
01105
01106
01107 function __showOtherInformations()
01108 {
01109 if($this->userSettingVisible("matriculation") or count($this->user_defined_fields->getVisibleDefinitions()))
01110 {
01111 return true;
01112 }
01113 return false;
01114 }
01115
01116 function __showUserDefinedFields()
01117 {
01118 global $ilUser;
01119
01120 $user_defined_data = $ilUser->getUserDefinedData();
01121 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
01122 {
01123 if($definition['field_type'] == UDF_TYPE_TEXT)
01124 {
01125 $this->tpl->setCurrentBlock("field_text");
01126 $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
01127 $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($user_defined_data[$field_id]));
01128 if(!$definition['changeable'])
01129 {
01130 $this->tpl->setVariable("DISABLED_FIELD",'disabled=\"disabled\"');
01131 }
01132 $this->tpl->parseCurrentBlock();
01133 }
01134 else
01135 {
01136 $this->tpl->setCurrentBlock("field_select");
01137 $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($user_defined_data[$field_id],
01138 'udf['.$definition['field_id'].']',
01139 $this->user_defined_fields->fieldValuesToSelectArray(
01140 $definition['field_values']),
01141 false,
01142 true));
01143 $this->tpl->parseCurrentBlock();
01144 }
01145 $this->tpl->setCurrentBlock("user_defined");
01146
01147 if($definition['required'])
01148 {
01149 $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
01150 }
01151 else
01152 {
01153 $name = $definition['field_name'];
01154 }
01155 $this->tpl->setVariable("TXT_FIELD_NAME",$name);
01156 $this->tpl->parseCurrentBlock();
01157 }
01158 return true;
01159 }
01160
01161 function __checkUserDefinedRequiredFields()
01162 {
01163 foreach($this->user_defined_fields->getVisibleDefinitions() as $definition)
01164 {
01165 $field_id = $definition['field_id'];
01166 if($definition['required'] and !strlen($_POST['udf'][$field_id]))
01167 {
01168 return false;
01169 }
01170 }
01171 return true;
01172 }
01173
01174 }
01175 ?>