• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/User/classes/class.ilPersonalProfileGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00034 class ilPersonalProfileGUI
00035 {
00036     var $tpl;
00037     var $lng;
00038     var $ilias;
00039         var $ctrl;
00040 
00041         var $user_defined_fields = null;
00042 
00043 
00047     function ilPersonalProfileGUI()
00048     {
00049         global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl;
00050 
00051                 include_once './Services/User/classes/class.ilUserDefinedFields.php';
00052                 $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
00053 
00054         $this->tpl =& $tpl;
00055         $this->lng =& $lng;
00056         $this->ilias =& $ilias;
00057                 $this->ctrl =& $ilCtrl;
00058                 $this->settings = $ilias->getAllSettings();
00059                 $lng->loadLanguageModule("jsmath");
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                                 //$this->setTabs();
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                                 // store filename
00154                                 $ilUser->setPref("profile_image", $store_file);
00155                                 $ilUser->update();
00156                                         
00157                                 // move uploaded file
00158                                 $uploaded_file = $image_dir."/upload_".$ilUser->getId()."pic";
00159 
00160                                 if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
00161                                         $uploaded_file, false))
00162                                 {
00163                                         ilUtil::sendInfo($this->lng->txt("upload_error", true));
00164                                         $this->ctrl->redirect($this, "showProfile");
00165                                 }
00166                                 chmod($uploaded_file, 0770);
00167                         
00168                                 // take quality 100 to avoid jpeg artefacts when uploading jpeg files
00169                                 // taking only frame [0] to avoid problems with animated gifs
00170                                 $show_file  = "$image_dir/usr_".$ilUser->getId().".jpg"; 
00171                                 $thumb_file = "$image_dir/usr_".$ilUser->getId()."_small.jpg";
00172                                 $xthumb_file = "$image_dir/usr_".$ilUser->getId()."_xsmall.jpg"; 
00173                                 $xxthumb_file = "$image_dir/usr_".$ilUser->getId()."_xxsmall.jpg";
00174                                 $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
00175                                 $show_file = ilUtil::escapeShellArg($show_file);
00176                                 $thumb_file = ilUtil::escapeShellArg($thumb_file);
00177                                 $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
00178                                 $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
00179 //echo "-".ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file"."-";
00180                                 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file");
00181                                 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
00182                                 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
00183                                 system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
00184                         }
00185                 }
00186                 
00187                 $this->saveProfile();
00188         }
00189 
00193         function removeUserPicture()
00194         {
00195                 global $ilUser;
00196         
00197                 $webspace_dir = ilUtil::getWebspaceDir();
00198                 $image_dir = $webspace_dir."/usr_images";
00199                 $file = $image_dir."/usr_".$ilUser->getID()."."."jpg";
00200                 $thumb_file = $image_dir."/usr_".$ilUser->getID()."_small.jpg";
00201                 $xthumb_file = $image_dir."/usr_".$ilUser->getID()."_xsmall.jpg";
00202                 $xxthumb_file = $image_dir."/usr_".$ilUser->getID()."_xxsmall.jpg";
00203                 $upload_file = $image_dir."/upload_".$ilUser->getID();
00204         
00205                 // remove user pref file name
00206                 $ilUser->setPref("profile_image", "");
00207                 $ilUser->update();
00208         
00209                 if (@is_file($file))
00210                 {
00211                         unlink($file);
00212                 }
00213                 if (@is_file($thumb_file))
00214                 {
00215                         unlink($thumb_file);
00216                 }
00217                 if (@is_file($xthumb_file))
00218                 {
00219                         unlink($xthumb_file);
00220                 }
00221                 if (@is_file($xxthumb_file))
00222                 {
00223                         unlink($xxthumb_file);
00224                 }
00225                 if (@is_file($upload_file))
00226                 {
00227                         unlink($upload_file);
00228                 }
00229         
00230                 $this->saveProfile();
00231         }
00232 
00233 
00237         function changeUserPassword()
00238         {
00239                 global $ilUser, $ilSetting;
00240                 
00241                 /*
00242                 include_once('Services/LDAP/classes/class.ilLDAPServer.php');
00243                 if($ilUser->getAuthMode(true) == AUTH_LDAP and ($server_ids = ilLDAPServer::_getPasswordServers()))
00244                 {
00245                         include_once('Services/LDAP/classes/class.ilLDAPPasswordSynchronization.php');
00246                         $pwd_sync = new ilLDAPPasswordSynchronization($server_ids[0]);
00247                         $pwd_sync->setOldPassword($_POST["current_password"]);
00248                         $pwd_sync->setNewPassword($_POST["desired_password"]);
00249                         $pwd_sync->setRetypePassword($_POST["retype_password"]);
00250                         if(!$pwd_sync->synchronize())
00251                         {
00252                                 $this->password_error = $pwd_sync->getError();
00253                         }
00254                         $this->saveProfile();
00255                         return false;
00256                 }
00257                 */
00258                 // do nothing if auth mode is not local database
00259                 if ($ilUser->getAuthMode(true) != AUTH_LOCAL &&
00260                         ($ilUser->getAuthMode(true) != AUTH_CAS || !$ilSetting->get("cas_allow_local")) &&
00261                         ($ilUser->getAuthMode(true) != AUTH_SOAP || !$ilSetting->get("soap_auth_allow_local"))
00262                         )
00263                 {
00264                         $this->password_error = $this->lng->txt("not_changeable_for_non_local_auth");
00265                 }
00266 
00267                 // select password from auto generated passwords
00268                 if ($this->ilias->getSetting("passwd_auto_generate") == 1)
00269                 {
00270                         // check old password
00271                         if (md5($_POST["current_password"]) != $ilUser->getPasswd())
00272                         {
00273                                 $this->password_error = $this->lng->txt("passwd_wrong");
00274                         }
00275                         // validate transmitted password
00276                         if (!ilUtil::isPassword($_POST["new_passwd"]))
00277                         {
00278                                 $this->password_error = $this->lng->txt("passwd_not_selected");
00279                         }
00280 
00281                         if (empty($this->password_error))
00282                         {
00283                                 ilUtil::sendInfo($this->lng->txt("saved_successfully"));
00284                                 $ilUser->updatePassword($_POST["current_password"], $_POST["new_passwd"], $_POST["new_passwd"]);
00285                         }
00286                 }
00287                 else
00288                 {
00289                         // check old password
00290                         if (md5($_POST["current_password"]) != $ilUser->getPasswd())
00291                         {
00292                                 $this->password_error = $this->lng->txt("passwd_wrong");
00293                         }
00294                         // check new password
00295                         else if ($_POST["desired_password"] != $_POST["retype_password"])
00296                         {
00297                                 $this->password_error = $this->lng->txt("passwd_not_match");
00298                         }
00299                         // validate password
00300                         else if (!ilUtil::isPassword($_POST["desired_password"]))
00301                         {
00302                                 $this->password_error = $this->lng->txt("passwd_invalid");
00303                         }
00304                         else if ($_POST["current_password"] != "" and empty($this->password_error))
00305                         {
00306                                 ilUtil::sendInfo($this->lng->txt("saved_successfully"));
00307                                 $ilUser->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]);
00308                         }
00309                 }
00310 
00311                 $this->saveProfile();
00312         }
00313 
00314 
00315 
00319         function saveProfile()
00320         {
00321                 global $ilUser;
00322                 
00323                 //init checking var
00324                 $form_valid = true;
00325 
00326                 // testing by ratana ty:
00327                 // if people check on check box it will
00328                 // write some datata to table usr_pref
00329                 // if check on Public Profile
00330                 if (($_POST["chk_pub"])=="on")
00331                 {
00332                         $ilUser->setPref("public_profile","y");
00333                 }
00334                 else
00335                 {
00336                         $ilUser->setPref("public_profile","n");
00337                 }
00338 
00339                 // if check on Institute
00340                 $val_array = array("institution", "department", "upload", "street",
00341                         "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
00342                         "fax", "email", "hobby", "matriculation");
00343         
00344                 // set public profile preferences
00345                 foreach($val_array as $key => $value)
00346                 {
00347                         if (($_POST["chk_".$value]) == "on")
00348                         {
00349                                 $ilUser->setPref("public_".$value,"y");
00350                         }
00351                         else
00352                         {
00353                                 $ilUser->setPref("public_".$value,"n");
00354                         }
00355                 }
00356                 
00357                 $d_set = new ilSetting("delicious");
00358                 if ($d_set->get("user_profile"))
00359                 {
00360                         if (($_POST["chk_delicious"]) == "on")
00361                         {
00362                                 $ilUser->setPref("public_delicious","y");
00363                         }
00364                         else
00365                         {
00366                                 $ilUser->setPref("public_delicious","n");
00367                         }
00368                 }
00369 
00370 
00371                 // check dynamically required fields
00372                 foreach($this->settings as $key => $val)
00373                 {
00374                         if (substr($key,0,8) == "require_")
00375                         {
00376                                 $require_keys[] = substr($key,8);
00377                         }
00378                 }
00379 
00380                 foreach($require_keys as $key => $val)
00381                 {
00382                         // exclude required system and registration-only fields
00383                         $system_fields = array("login", "default_role", "passwd", "passwd2");
00384                         if (!in_array($val, $system_fields))
00385                         {
00386                                 if ($this->workWithUserSetting($val))
00387                                 {
00388                                         if (isset($this->settings["require_" . $val]) && $this->settings["require_" . $val])
00389                                         {
00390                                                 if (empty($_POST["usr_" . $val]))
00391                                                 {
00392                                                         ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val));
00393                                                         $form_valid = false;
00394                                                 }
00395                                         }
00396                                 }
00397                         }
00398                 }
00399 
00400                 // Check user defined required fields
00401                 if($form_valid and !$this->__checkUserDefinedRequiredFields())
00402                 {
00403                         ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields"));
00404                         $form_valid = false;
00405                 }
00406 
00407                 // check email
00408                 if ($this->workWithUserSetting("email"))
00409                 {
00410                         if (!ilUtil::is_email($_POST["usr_email"]) and !empty($_POST["usr_email"]) and $form_valid)
00411                         {
00412                                 ilUtil::sendInfo($this->lng->txt("email_not_valid"));
00413                                 $form_valid = false;
00414                         }
00415                 }
00416 
00417                 //update user data (not saving!)
00418                 if ($this->workWithUserSetting("firstname"))
00419                 {
00420                         $ilUser->setFirstName(ilUtil::stripSlashes($_POST["usr_firstname"]));
00421                 }
00422                 if ($this->workWithUserSetting("lastname"))
00423                 {
00424                         $ilUser->setLastName(ilUtil::stripSlashes($_POST["usr_lastname"]));
00425                 }
00426                 if ($this->workWithUserSetting("gender"))
00427                 {
00428                         $ilUser->setGender($_POST["usr_gender"]);
00429                 }
00430                 if ($this->workWithUserSetting("title"))
00431                 {
00432                         $ilUser->setUTitle(ilUtil::stripSlashes($_POST["usr_title"]));
00433                 }
00434                 $ilUser->setFullname();
00435                 if ($this->workWithUserSetting("institution"))
00436                 {
00437                         $ilUser->setInstitution(ilUtil::stripSlashes($_POST["usr_institution"]));
00438                 }
00439                 if ($this->workWithUserSetting("department"))
00440                 {
00441                         $ilUser->setDepartment(ilUtil::stripSlashes($_POST["usr_department"]));
00442                 }
00443                 if ($this->workWithUserSetting("street"))
00444                 {
00445                         $ilUser->setStreet(ilUtil::stripSlashes($_POST["usr_street"]));
00446                 }
00447                 if ($this->workWithUserSetting("zipcode"))
00448                 {
00449                         $ilUser->setZipcode(ilUtil::stripSlashes($_POST["usr_zipcode"]));
00450                 }
00451                 if ($this->workWithUserSetting("city"))
00452                 {
00453                         $ilUser->setCity(ilUtil::stripSlashes($_POST["usr_city"]));
00454                 }
00455                 if ($this->workWithUserSetting("country"))
00456                 {
00457                         $ilUser->setCountry(ilUtil::stripSlashes($_POST["usr_country"]));
00458                 }
00459                 if ($this->workWithUserSetting("phone_office"))
00460                 {
00461                         $ilUser->setPhoneOffice(ilUtil::stripSlashes($_POST["usr_phone_office"]));
00462                 }
00463                 if ($this->workWithUserSetting("phone_home"))
00464                 {
00465                         $ilUser->setPhoneHome(ilUtil::stripSlashes($_POST["usr_phone_home"]));
00466                 }
00467                 if ($this->workWithUserSetting("phone_mobile"))
00468                 {
00469                         $ilUser->setPhoneMobile(ilUtil::stripSlashes($_POST["usr_phone_mobile"]));
00470                 }
00471                 if ($this->workWithUserSetting("fax"))
00472                 {
00473                         $ilUser->setFax(ilUtil::stripSlashes($_POST["usr_fax"]));
00474                 }
00475                 if ($this->workWithUserSetting("email"))
00476                 {
00477                         $ilUser->setEmail(ilUtil::stripSlashes($_POST["usr_email"]));
00478                 }
00479                 if ($this->workWithUserSetting("hobby"))
00480                 {
00481                         $ilUser->setHobby(ilUtil::stripSlashes($_POST["usr_hobby"]));
00482                 }
00483                 if ($this->workWithUserSetting("referral_comment"))
00484                 {
00485                         $ilUser->setComment(ilUtil::stripSlashes($_POST["usr_referral_comment"]));
00486                 }
00487                 if ($this->workWithUserSetting("matriculation"))
00488                 {
00489                         $ilUser->setMatriculation(ilUtil::stripSlashes($_POST["usr_matriculation"]));
00490                 }
00491                 
00492                 // delicious
00493                 $d_set = new ilSetting("delicious");
00494                 if ($d_set->get("user_profile"))
00495                 {
00496                         $ilUser->setDelicious(ilUtil::stripSlashes($_POST["usr_delicious"]));
00497                 }
00498 
00499                 // set instant messengers
00500                 if ($this->workWithUserSetting("instant_messengers"))
00501                 {
00502                         $ilUser->setInstantMessengerId('icq',ilUtil::stripSlashes($_POST["usr_im_icq"]));
00503                         $ilUser->setInstantMessengerId('yahoo',ilUtil::stripSlashes($_POST["usr_im_yahoo"]));
00504                         $ilUser->setInstantMessengerId('msn',ilUtil::stripSlashes($_POST["usr_im_msn"]));
00505                         $ilUser->setInstantMessengerId('aim',ilUtil::stripSlashes($_POST["usr_im_aim"]));
00506                         $ilUser->setInstantMessengerId('skype',ilUtil::stripSlashes($_POST["usr_im_skype"]));
00507                 }
00508 
00509                 // Set user defined data
00510                 $ilUser->setUserDefinedData($_POST['udf']);
00511 
00512                 // everthing's ok. save form data
00513                 if ($form_valid)
00514                 {
00515                         // init reload var. page should only be reloaded if skin or style were changed
00516                         $reload = false;
00517         
00518                         if ($this->workWithUserSetting("skin_style"))
00519                         {
00520                                 //set user skin and style
00521                                 if ($_POST["usr_skin_style"] != "")
00522                                 {
00523                                         $sknst = explode(":", $_POST["usr_skin_style"]);
00524                 
00525                                         if ($ilUser->getPref("style") != $sknst[1] ||
00526                                                 $ilUser->getPref("skin") != $sknst[0])
00527                                         {
00528                                                 $ilUser->setPref("skin", $sknst[0]);
00529                                                 $ilUser->setPref("style", $sknst[1]);
00530                                                 $reload = true;
00531                                         }
00532                                 }
00533                         }
00534         
00535                         if ($this->workWithUserSetting("language"))
00536                         {       
00537                                 // reload page if language was changed
00538                                 //if ($_POST["usr_language"] != "" and $_POST["usr_language"] != $_SESSION['lang'])
00539                                 // (this didn't work as expected, alex)
00540                                 if ($_POST["usr_language"] != $ilUser->getLanguage())
00541                                 {
00542                                         $reload = true;
00543                                 }
00544 
00545                                 // set user language
00546                                 $ilUser->setLanguage($_POST["usr_language"]);
00547 
00548                         }
00549                         if ($this->workWithUserSetting("hits_per_page"))
00550                         {
00551                                 // set user hits per page
00552                                 if ($_POST["hits_per_page"] != "")
00553                                 {
00554                                         $ilUser->setPref("hits_per_page",$_POST["hits_per_page"]);
00555                                 }
00556                         }
00557         
00558                         // set show users online
00559                         if ($this->workWithUserSetting("show_users_online"))
00560                         {
00561                                 $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
00562                         }
00563                         
00564                         // set hide own online_status
00565                         if ($this->workWithUserSetting("hide_own_online_status"))
00566                         {
00567                                 if ($_POST["chk_hide_own_online_status"] != "")
00568                                 {
00569                                         $ilUser->setPref("hide_own_online_status","y");
00570                                 }
00571                                 else
00572                                 {
00573                                         $ilUser->setPref("hide_own_online_status","n");
00574                                 }                                       
00575                         }
00576 
00577                         // personal desktop items in news block
00578 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
00579                         if ($_POST["pd_items_news"] != "")
00580                         {
00581                                 $ilUser->setPref("pd_items_news","y");
00582                         }
00583                         else
00584                         {
00585                                 $ilUser->setPref("pd_items_news","n");
00586                         }
00587 */
00588 
00589                         // profile ok
00590                         $ilUser->setProfileIncomplete(false);
00591                         
00592                         // save user data & object_data
00593                         $ilUser->setTitle($ilUser->getFullname());
00594                         $ilUser->setDescription($ilUser->getEmail());
00595                         $ilUser->update();
00596         
00597                         // reload page only if skin or style were changed
00598                         // feedback
00599                         if (!empty($this->password_error))
00600                         {
00601                                 ilUtil::sendInfo($this->password_error,true);
00602                         }
00603                         elseif (!empty($this->upload_error))
00604                         {
00605                                 ilUtil::sendInfo($this->upload_error,true);
00606                         }
00607                         else if ($reload)
00608                         {
00609                                 // feedback
00610                                 ilUtil::sendInfo($this->lng->txt("saved_successfully"),true);
00611                                 $this->ctrl->redirect($this, "");
00612                                 //$this->tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./start.php\";\n</script>\n");
00613                         }
00614                         else
00615                         {
00616                                 ilUtil::sendInfo($this->lng->txt("saved_successfully"),true);
00617                         }
00618                 }
00619                 
00620                 $this->showProfile();
00621         }
00622 
00626         function showProfile()
00627         {
00628                 global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting;
00629                 
00630                 $this->__initSubTabs("showProfile");
00631 
00632                 $settings = $ilias->getAllSettings();
00633                 
00634                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
00635                 
00636                 // set locator
00637 /*
00638                 $this->tpl->setVariable("TXT_LOCATOR", $this->lng->txt("locator"));
00639                 $this->tpl->touchBlock("locator_separator");
00640                 $this->tpl->touchBlock("locator_item");
00641                 //$this->tpl->setCurrentBlock("locator_item");
00642                 //$this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
00643                 //$this->tpl->setVariable("LINK_ITEM",
00644                 //      $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui"));
00645                 //$this->tpl->parseCurrentBlock();
00646                 
00647                 $this->tpl->setCurrentBlock("locator_item");
00648                 $this->tpl->setVariable("ITEM", $this->lng->txt("personal_profile"));
00649                 $this->tpl->setVariable("LINK_ITEM",
00650                         $this->ctrl->getLinkTargetByClass("ilpersonalprofilegui", "showProfile"));
00651                 $this->tpl->parseCurrentBlock();
00652 */
00653                 
00654                 // catch feedback message
00655                 if ($ilUser->getProfileIncomplete())
00656                 {
00657                         ilUtil::sendInfo($lng->txt("profile_incomplete"));
00658                 }
00659                 else
00660                 {
00661                         ilUtil::sendInfo();
00662                 }
00663                 
00664                 
00665                 // display infopanel if something happened
00666                 ilUtil::infoPanel();
00667 
00668                 if ($this->userSettingVisible("language"))
00669                 {
00670                         //get all languages
00671                         $languages = $this->lng->getInstalledLanguages();
00672                         
00673                         // preselect previous chosen language otherwise saved language
00674                         $selected_lang = (isset($_POST["usr_language"]))
00675                                 ? $_POST["usr_language"]
00676                                 : $ilUser->getLanguage();
00677                         
00678                         //go through languages
00679                         foreach($languages as $lang_key)
00680                         {
00681                                 $this->tpl->setCurrentBlock("sel_lang");
00682                                 //$tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00683                                 $this->tpl->setVariable("LANG", ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key));
00684                                 $this->tpl->setVariable("LANGSHORT", $lang_key);
00685                         
00686                                 if ($selected_lang == $lang_key)
00687                                 {
00688                                         $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00689                                 }
00690                         
00691                                 $this->tpl->parseCurrentBlock();
00692                         }
00693                 }
00694                 
00695                 // get all templates
00696                 include_once("classes/class.ilObjStyleSettings.php");
00697                 $templates = $styleDefinition->getAllTemplates();
00698                 
00699                 if ($this->userSettingVisible("skin_style"))
00700                 {
00701                         if (is_array($templates))
00702                         {
00703                         
00704                                 foreach($templates as $template)
00705                                 {
00706                                         // get styles information of template
00707                                         $styleDef =& new ilStyleDefinition($template["id"]);
00708                                         $styleDef->startParsing();
00709                                         $styles = $styleDef->getStyles();
00710                                 
00711                                         foreach($styles as $style)
00712                                         {
00713                                                 if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
00714                                                 {
00715                                                         continue;
00716                                                 }
00717                         
00718                                                 $this->tpl->setCurrentBlock("selectskin");
00719         //echo "-".$ilUser->skin."-".$ilUser->prefs["style"]."-";
00720                                                 if ($ilUser->skin == $template["id"] &&
00721                                                         $ilUser->prefs["style"] == $style["id"])
00722                                                 {
00723                                                         $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00724                                                 }
00725                                 
00726                                                 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00727                                                 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00728                                                 $this->tpl->parseCurrentBlock();
00729                                         }
00730                                 }
00731                                 
00732                         }
00733                 }
00734                 
00735                 // hits per page
00736                 if ($this->userSettingVisible("hits_per_page"))
00737                 {
00738                         $hits_options = array(2,10,15,20,30,40,50,100,9999);
00739                 
00740                         foreach($hits_options as $hits_option)
00741                         {
00742                                 $this->tpl->setCurrentBlock("selecthits");
00743                 
00744                                 if ($ilUser->prefs["hits_per_page"] == $hits_option)
00745                                 {
00746                                         $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
00747                                 }
00748                 
00749                                 $this->tpl->setVariable("HITSVALUE", $hits_option);
00750                 
00751                                 if ($hits_option == 9999)
00752                                 {
00753                                         $hits_option = $this->lng->txt("no_limit");
00754                                 }
00755                 
00756                                 $this->tpl->setVariable("HITSOPTION", $hits_option);
00757                                 $this->tpl->parseCurrentBlock();
00758                         }
00759                 }
00760                 
00761                 // Users Online
00762                 if ($this->userSettingVisible("show_users_online"))
00763                 {
00764                         $users_online_options = array("y","associated","n");
00765                         $selected_option = $ilUser->prefs["show_users_online"];
00766                         foreach($users_online_options as $an_option)
00767                         {
00768                                 $this->tpl->setCurrentBlock("select_users_online");
00769                 
00770                                 if ($selected_option == $an_option)
00771                                 {
00772                                         $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
00773                                 }
00774                 
00775                                 $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
00776                 
00777                                 $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
00778                                 $this->tpl->parseCurrentBlock();
00779                         }
00780                 }
00781                 
00782                 // hide_own_online_status
00783                 if ($this->userSettingVisible("hide_own_online_status")) {                      
00784                         if ($ilUser->prefs["hide_own_online_status"] == "y")
00785                         {
00786                                 $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "checked");
00787                         }
00788                 }                               
00789 
00790                 // personal desktop news
00791 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
00792                 if ($ilUser->prefs["pd_items_news"] != "n")
00793                 {
00794                         $this->tpl->setVariable("PD_ITEMS_NEWS", "checked");
00795                 }
00796                 $this->tpl->setVariable("TXT_PD_ITEMS_NEWS",
00797                         $this->lng->txt("pd_items_news"));
00798                 $this->tpl->setVariable("TXT_PD_ITEMS_NEWS_INFO",
00799                         $this->lng->txt("pd_items_news_info"));
00800 */
00801                 
00802                 if (($ilUser->getAuthMode(true) == AUTH_LOCAL ||
00803                         ($ilUser->getAuthMode(true) == AUTH_CAS && $ilSetting->get("cas_allow_local")) ||
00804                         ($ilUser->getAuthMode(true) == AUTH_SOAP && $ilSetting->get("soap_auth_allow_local"))
00805                         )
00806                         &&
00807                         $this->userSettingVisible('password'))
00808                 {
00809                         if($this->ilias->getSetting('usr_settings_disable_password'))
00810                         {
00811                                 $this->tpl->setCurrentBlock("disabled_password");
00812                                 $this->tpl->setVariable("TXT_DISABLED_PASSWORD", $this->lng->txt("chg_password"));
00813                                 $this->tpl->setVariable("TXT_DISABLED_CURRENT_PASSWORD", $this->lng->txt("current_password"));
00814                                 $this->tpl->parseCurrentBlock();
00815                         }
00816                         elseif ($settings["passwd_auto_generate"] == 1)
00817                         {
00818                                 $passwd_list = ilUtil::generatePasswords(5);
00819                          
00820                                 foreach ($passwd_list as $passwd)
00821                                 {
00822                                         $passwd_choice .= ilUtil::formRadioButton(0,"new_passwd",$passwd)." ".$passwd."<br/>";
00823                                 }
00824                 
00825                                 $this->tpl->setCurrentBlock("select_password");
00826                                 $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
00827                                 $this->tpl->setVariable("TXT_CURRENT_PASSWORD", $this->lng->txt("current_password"));
00828                                 $this->tpl->setVariable("TXT_SELECT_PASSWORD", $this->lng->txt("select_password"));
00829                                 $this->tpl->setVariable("PASSWORD_CHOICE", $passwd_choice);
00830                                 $this->tpl->setVariable("TXT_NEW_LIST_PASSWORD", $this->lng->txt("new_list_password"));
00831                                 $this->tpl->parseCurrentBlock();
00832                         }
00833                         else
00834                         {
00835                                 $this->tpl->setCurrentBlock("change_password");
00836                                 $this->tpl->setVariable("TXT_CHANGE_PASSWORD", $this->lng->txt("chg_password"));
00837                                 $this->tpl->setVariable("TXT_CURRENT_PW", $this->lng->txt("current_password"));
00838                                 $this->tpl->setVariable("TXT_DESIRED_PW", $this->lng->txt("desired_password"));
00839                                 $this->tpl->setVariable("TXT_RETYPE_PW", $this->lng->txt("retype_password"));
00840                                 $this->tpl->setVariable("CHANGE_PASSWORD", $this->lng->txt("chg_password"));
00841                                 $this->tpl->parseCurrentBlock();
00842                         }
00843                 }
00844                 
00845                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
00846                         $this->lng->txt("personal_desktop"));
00847 
00848                 $this->tpl->setCurrentBlock("content");
00849                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00850 
00851                 $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
00852                 $this->tpl->setVariable("TXT_OF",strtolower($this->lng->txt("of")));
00853                 $this->tpl->setVariable("USR_FULLNAME",$ilUser->getFullname());
00854                 
00855                 $this->tpl->setVariable("TXT_USR_DATA", $this->lng->txt("userdata"));
00856                 $this->tpl->setVariable("TXT_NICKNAME", $this->lng->txt("username"));
00857                 $this->tpl->setVariable("TXT_PUBLIC_PROFILE", $this->lng->txt("public_profile"));
00858                 
00859                 $data = array();
00860                 $data["fields"] = array();
00861                 $data["fields"]["gender"] = "";
00862                 $data["fields"]["firstname"] = "";
00863                 $data["fields"]["lastname"] = "";
00864                 $data["fields"]["title"] = "";
00865                 $data["fields"]["institution"] = "";
00866                 $data["fields"]["department"] = "";
00867                 $data["fields"]["street"] = "";
00868                 $data["fields"]["city"] = "";
00869                 $data["fields"]["zipcode"] = "";
00870                 $data["fields"]["country"] = "";
00871                 $data["fields"]["phone_office"] = "";
00872                 $data["fields"]["phone_home"] = "";
00873                 $data["fields"]["phone_mobile"] = "";
00874                 $data["fields"]["fax"] = "";
00875                 $data["fields"]["email"] = "";
00876                 $data["fields"]["hobby"] = "";
00877                 $data["fields"]["referral_comment"] = "";
00878                 $data["fields"]["matriculation"] = "";
00879                 $data["fields"]["create_date"] = "";
00880                 $data["fields"]["approve_date"] = "";
00881                 $data["fields"]["active"] = "";
00882                 
00883                 $data["fields"]["default_role"] = $role;
00884                 // fill presets
00885                 foreach($data["fields"] as $key => $val)
00886                 {
00887                         // note: general "title" is not as "title" for a person
00888                         if ($key != "title")
00889                         {
00890                                 $str = $this->lng->txt($key);
00891                         }
00892                         else
00893                         {
00894                                 $str = $this->lng->txt("person_title");
00895                         }
00896                 
00897                         // check to see if dynamically required
00898                         if (isset($this->settings["require_" . $key]) && $this->settings["require_" . $key])
00899                         {
00900                                                 $str = $str . '<span class="asterisk">*</span>';
00901                         }
00902                 
00903                         if ($this->userSettingVisible("$key"))
00904                         {
00905                                 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00906                         }
00907                 }
00908                 
00909                 if ($this->userSettingVisible("gender"))
00910                 {
00911                         $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
00912                         $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
00913                 }
00914                 
00915                 $d_set = new ilSetting("delicious");
00916                 if ($d_set->get("user_profile"))
00917                 {
00918                         $this->tpl->setVariable("TXT_DELICIOUS", $lng->txt("delicious"));
00919                 }
00920                 
00921                 if ($this->userSettingVisible("upload"))
00922                 {
00923                         $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("personal_picture"));
00924                         $webspace_dir = ilUtil::getWebspaceDir("output");
00925                         $full_img = $ilUser->getPref("profile_image");
00926                         $last_dot = strrpos($full_img, ".");
00927                         $small_img = substr($full_img, 0, $last_dot).
00928                                         "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
00929                         $image_file = $webspace_dir."/usr_images/".$small_img;
00930                         
00931                         if (@is_file($image_file))
00932                         {
00933                                 $this->tpl->setCurrentBlock("pers_image");
00934                                 $this->tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
00935                                 $this->tpl->setVariable("ALT_IMG_PERSONAL",$this->lng->txt("personal_picture"));
00936                                 $this->tpl->parseCurrentBlock();
00937                                 if ($this->userSettingEnabled("upload"))
00938                                 {
00939                                         $this->tpl->setCurrentBlock("remove_pic");
00940                                         $this->tpl->setVariable("TXT_REMOVE_PIC", $this->lng->txt("remove_personal_picture"));
00941                                 }
00942                                 $this->tpl->parseCurrentBlock();
00943                                 $this->tpl->setCurrentBlock("content");
00944                         }
00945                         
00946                         if ($this->userSettingEnabled("upload"))
00947                         {
00948                                 $this->tpl->setCurrentBlock("upload_pic");
00949                                 $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
00950                         }
00951                         $this->tpl->setVariable("TXT_FILE", $this->lng->txt("userfile"));
00952                         $this->tpl->setVariable("USER_FILE", $this->lng->txt("user_file"));
00953                 }
00954                 $this->tpl->setCurrentBlock("adm_content");
00955                 
00956                 // ilinc upload pic
00957                 if ($this->userSettingVisible("upload") and $this->ilias->getSetting("ilinc_active"))
00958                 {
00959                         include_once ('ilinc/classes/class.ilObjiLincUser.php');
00960                         $ilinc_user = new ilObjiLincUser($ilUser);
00961                                 
00962                         if ($ilinc_user->id)
00963                         {
00964                                 include_once ('ilinc/classes/class.ilnetucateXMLAPI.php');
00965                                 $ilincAPI = new ilnetucateXMLAPI();
00966                                 
00967                                 $ilincAPI->uploadPicture($ilinc_user);
00968                                 $response = $ilincAPI->sendRequest("uploadPicture");
00969                         
00970                                 // return URL to user's personal page
00971                                 $url = trim($response->data['url']['cdata']);
00972                                 $this->tpl->setCurrentBlock("ilinc_upload_pic");
00973                                 $this->tpl->setVariable("TXT_ILINC_UPLOAD", $this->lng->txt("ilinc_upload_pic_text"));
00974                                 $this->tpl->setVariable("ILINC_UPLOAD_LINK", $url);
00975                                 $this->tpl->setVariable("ILINC_UPLOAD_LINKTXT", $this->lng->txt("ilinc_upload_pic_linktext"));
00976                                 $this->tpl->parseCurrentBlock();
00977                         }
00978                 }
00979                 
00980                 
00981                 if ($this->userSettingVisible("language"))
00982                 {
00983                         $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00984                 }
00985                 if ($this->userSettingVisible("show_users_online"))
00986                 {
00987                         $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
00988                 }
00989                 if ($this->userSettingVisible("hide_own_online_status"))
00990                 {
00991                         $this->tpl->setVariable("TXT_HIDE_OWN_ONLINE_STATUS", $this->lng->txt("hide_own_online_status"));
00992                 }
00993                 if ($this->userSettingVisible("skin_style"))
00994                 {
00995                         $this->tpl->setVariable("TXT_USR_SKIN_STYLE", $this->lng->txt("usr_skin_style"));
00996                 }
00997                 if ($this->userSettingVisible("hits_per_page"))
00998                 {
00999                         $this->tpl->setVariable("TXT_HITS_PER_PAGE", $this->lng->txt("usr_hits_per_page"));
01000                 }
01001                 if ($this->userSettingVisible("show_users_online"))
01002                 {
01003                         $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE", $this->lng->txt("show_users_online"));
01004                 }
01005                 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
01006                 $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
01007                 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
01008 
01009                 if($this->__showOtherInformations())
01010                 {
01011                         $this->tpl->setVariable("TXT_OTHER", $this->lng->txt("user_profile_other"));
01012                 }
01013                 
01014                 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
01015                 
01016                 //values
01017                 $this->tpl->setVariable("NICKNAME", ilUtil::prepareFormOutput($ilUser->getLogin()));
01018                 
01019                 if ($this->userSettingVisible("firstname"))
01020                 {
01021                         $this->tpl->setVariable("FIRSTNAME", ilUtil::prepareFormOutput($ilUser->getFirstname()));
01022                 }
01023                 if ($this->userSettingVisible("lastname"))
01024                 {
01025                         $this->tpl->setVariable("LASTNAME", ilUtil::prepareFormOutput($ilUser->getLastname()));
01026                 }
01027                 
01028                 if ($this->userSettingVisible("gender"))
01029                 {
01030                         // gender selection
01031                         $gender = strtoupper($ilUser->getGender());
01032                         
01033                         if (!empty($gender))
01034                         {
01035                                 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
01036                         }
01037                 }
01038                 
01039                 $this->tpl->setVariable("CREATE_DATE", $ilUser->getCreateDate());
01040                 $this->tpl->setVariable("APPROVE_DATE", $ilUser->getApproveDate());
01041                 
01042                 if ($ilUser->getActive())
01043                 {
01044                         $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
01045                 }
01046                 
01047                 if ($this->userSettingVisible("title"))
01048                 {
01049                         $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($ilUser->getUTitle()));
01050                 }
01051                 if ($this->userSettingVisible("institution"))
01052                 {
01053                         $this->tpl->setVariable("INSTITUTION", ilUtil::prepareFormOutput($ilUser->getInstitution()));
01054                 }
01055                 if ($this->userSettingVisible("department"))
01056                 {
01057                         $this->tpl->setVariable("DEPARTMENT", ilUtil::prepareFormOutput($ilUser->getDepartment()));
01058                 }
01059                 if ($this->userSettingVisible("street"))
01060                 {
01061                         $this->tpl->setVariable("STREET", ilUtil::prepareFormOutput($ilUser->getStreet()));
01062                 }
01063                 if ($this->userSettingVisible("zipcode"))
01064                 {
01065                         $this->tpl->setVariable("ZIPCODE", ilUtil::prepareFormOutput($ilUser->getZipcode()));
01066                 }
01067                 if ($this->userSettingVisible("city"))
01068                 {
01069                         $this->tpl->setVariable("CITY", ilUtil::prepareFormOutput($ilUser->getCity()));
01070                 }
01071                 if ($this->userSettingVisible("country"))
01072                 {
01073                         $this->tpl->setVariable("COUNTRY", ilUtil::prepareFormOutput($ilUser->getCountry()));
01074                 }
01075                 if ($this->userSettingVisible("phone_office"))
01076                 {
01077                         $this->tpl->setVariable("PHONE_OFFICE", ilUtil::prepareFormOutput($ilUser->getPhoneOffice()));
01078                 }
01079                 if ($this->userSettingVisible("phone_home"))
01080                 {
01081                         $this->tpl->setVariable("PHONE_HOME", ilUtil::prepareFormOutput($ilUser->getPhoneHome()));
01082                 }
01083                 if ($this->userSettingVisible("phone_mobile"))
01084                 {
01085                         $this->tpl->setVariable("PHONE_MOBILE", ilUtil::prepareFormOutput($ilUser->getPhoneMobile()));
01086                 }
01087                 if ($this->userSettingVisible("fax"))
01088                 {
01089                         $this->tpl->setVariable("FAX", ilUtil::prepareFormOutput($ilUser->getFax()));
01090                 }
01091                 if ($this->userSettingVisible("email"))
01092                 {
01093                         $this->tpl->setVariable("EMAIL", ilUtil::prepareFormOutput($ilUser->getEmail()));
01094                 }
01095                 if ($this->userSettingVisible("hobby"))
01096                 {
01097                         $this->tpl->setVariable("HOBBY", ilUtil::prepareFormOutput($ilUser->getHobby()));               // here
01098                 }
01099                 if ($this->userSettingVisible("referral_comment"))
01100                 {
01101                         $this->tpl->setVariable("REFERRAL_COMMENT", ilUtil::prepareFormOutput($ilUser->getComment()));
01102                 }
01103                 if ($this->userSettingVisible("matriculation"))
01104                 {
01105                         $this->tpl->setVariable("MATRICULATION", ilUtil::prepareFormOutput($ilUser->getMatriculation()));
01106                 }
01107                 
01108                 // instant messengers
01109                 if ($this->userSettingVisible("instant_messengers"))
01110                 {
01111                         $this->tpl->setVariable("TXT_INSTANT_MESSENGERS", $this->lng->txt("user_profile_instant_messengers"));
01112 
01113                         $im_arr = array("icq","yahoo","msn","aim","skype");
01114                         
01115                         foreach ($im_arr as $im_name)
01116                         {
01117                                 $im_id = $ilUser->getInstantMessengerId($im_name);
01118                                 $this->tpl->setCurrentBlock("im_row");
01119                                 $this->tpl->setVariable("TXT_IM_NAME",$this->lng->txt("im_".$im_name));
01120                                 $this->tpl->setVariable("USR_IM_NAME","usr_im_".$im_name);
01121                                 $this->tpl->setVariable("IM_ID",$im_id);
01122                                 $this->tpl->setVariable("IMG_IM_ICON", ilUtil::getImagePath($im_name.'online.gif'));
01123                                 $this->tpl->setVariable("TXT_IM_ICON", $this->lng->txt("im_".$im_name."_icon"));
01124                                 $this->tpl->setVariable("CHK_IM", "checked=\"checked\" disabled=\"disabled\"");
01125                                 $this->tpl->parseCurrentBlock();        
01126                         }
01127                 }
01128                 
01129                 $d_set = new ilSetting("delicious");
01130                 if ($d_set->get("user_profile") == "1")
01131                 {
01132                         $this->tpl->setVariable("DELICIOUS", ilUtil::prepareFormOutput($ilUser->getDelicious()));
01133                 }
01134 
01135                 // show user defined visible fields
01136                 $this->__showUserDefinedFields();
01137 
01138                 // get assigned global roles (default roles)
01139                 $global_roles = $rbacreview->getGlobalRoles();
01140                 
01141                 foreach($global_roles as $role_id)
01142                 {
01143                         if (in_array($role_id,$rbacreview->assignedRoles($ilUser->getId())))
01144                         {
01145                                 $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
01146                                 $role_names .= $roleObj->getTitle().", ";
01147                                 unset($roleObj);
01148                         }
01149                 }
01150                 
01151                 $this->tpl->setVariable("TXT_DEFAULT_ROLES", $this->lng->txt("default_roles"));
01152                 $this->tpl->setVariable("DEFAULT_ROLES", substr($role_names,0,-2));
01153                 
01154                 $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
01155                 
01156                 //button
01157                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01158                 
01159                 // addeding by ratana ty
01160                 if ($this->userSettingEnabled("upload"))
01161                 {
01162                         $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
01163                 }
01164 
01165                 // 
01166                 if ($ilUser->prefs["public_profile"] == "y")
01167                 {
01168                         $this->tpl->setVariable("CHK_PUB","checked");
01169                 }
01170                 $val_array = array("institution", "department", "upload", "street",
01171                         "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
01172                         "fax", "email", "hobby", "matriculation", "show_users_online");
01173                 foreach($val_array as $key => $value)
01174                 {
01175                         if ($this->userSettingVisible("$value"))
01176                         {
01177                                 if ($ilUser->prefs["public_".$value] == "y")
01178                                 {
01179                                         $this->tpl->setVariable("CHK_".strtoupper($value), "checked");
01180                                 }
01181                         }
01182                 }
01183                 
01184                 $d_set = new ilSetting("delicious");
01185                 if ($d_set->get("user_profile") == "1")
01186                 {
01187                         if ($ilUser->prefs["public_delicious"] == "y")
01188                         {
01189                                 $this->tpl->setVariable("CHK_DELICIOUS", "checked");
01190                         }
01191                 }
01192 
01193                 
01194                 // End of showing
01195                 // Testing by ratana ty
01196                 
01197                 
01198                 $profile_fields = array(
01199                         "gender",
01200                         "firstname",
01201                         "lastname",
01202                         "title",
01203                         "upload",
01204                         "institution",
01205                         "department",
01206                         "street",
01207                         "city",
01208                         "zipcode",
01209                         "country",
01210                         "phone_office",
01211                         "phone_home",
01212                         "phone_mobile",
01213                         "fax",
01214                         "email",
01215                         "hobby",
01216                         "matriculation",
01217                         "referral_comment",
01218                         "language",
01219                         "skin_style",
01220                         "hits_per_page",
01221                         "show_users_online",
01222                         "hide_own_online_status"
01223                 );
01224                 foreach ($profile_fields as $field)
01225                 {
01226                         if (!$this->ilias->getSetting("usr_settings_hide_" . $field))
01227                         {
01228                                 if ($this->ilias->getSetting("usr_settings_disable_" . $field))
01229                                 {
01230                                         $this->tpl->setVariable("DISABLED_" . strtoupper($field), " disabled=\"disabled\"");
01231                                 }
01232                         }
01233                 }
01234                 
01235                 $this->tpl->parseCurrentBlock();
01236                 $this->tpl->show();
01237         }
01238 
01239         function saveMailOptions()
01240         {
01241                 global $ilUser;
01242 
01243                 require_once "Services/Mail/classes/class.ilMailOptions.php";
01244                 $mailOptions = new ilMailOptions($ilUser->getId());
01245 
01246                 $this->lng->loadLanguageModule("mail");
01247 
01248                 $mailOptions->updateOptions($_POST["signature"],(int) $_POST["linebreak"],(int) $_POST["incoming_type"],(int) $_POST["cronjob_notification"]);
01249                 ilUtil::sendInfo($this->lng->txt("mail_options_saved"),true);
01250 
01251                 $this->showMailOptions();
01252         }
01253 
01254         function showMailOptions()
01255         {
01256                 global $ilUser, $ilias;
01257 
01258                 $this->__initSubTabs("showMailOptions");
01259 
01260                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile_mail.html");
01261 
01262                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
01263                 $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
01264 
01265                 require_once "Services/Mail/classes/class.ilMailOptions.php";
01266                 $mailOptions = new ilMailOptions($ilUser->getId());
01267 
01268                 $this->lng->loadLanguageModule("mail");
01269 
01270                 // BEGIN INCOMING
01271                 $this->tpl->setCurrentBlock("option_inc_line");
01272         
01273                 $inc = array($this->lng->txt("mail_incoming_local"),$this->lng->txt("mail_incoming_smtp"),$this->lng->txt("mail_incoming_both"));
01274                 foreach($inc as $key => $option)
01275                 {
01276                         $this->tpl->setVariable("OPTION_INC_VALUE",$key);
01277                         $this->tpl->setVariable("OPTION_INC_NAME",$option);
01278                         $this->tpl->setVariable("OPTION_INC_SELECTED",$mailOptions->getIncomingType() == $key ? "selected=\"selected\"" : "");
01279                         $this->tpl->parseCurrentBlock();
01280                 }
01281                 if(!strlen(ilObjUser::_lookupEmail($ilUser->getId())))
01282                 {
01283                         $this->tpl->setVariable('INC_DISABLED','disabled="disabled"');
01284                 }                                       
01285         
01286                 // BEGIN LINEBREAK_OPTIONS
01287                 $this->tpl->setCurrentBlock("option_line");
01288                 $linebreak = $mailOptions->getLinebreak();
01289                 
01290                 for($i = 50; $i <= 80;$i++)
01291                 {
01292                         $this->tpl->setVariable("OPTION_VALUE",$i);
01293                         $this->tpl->setVariable("OPTION_NAME",$i);
01294                         if( $i == $linebreak)
01295                         {
01296                                 $this->tpl->setVariable("OPTION_SELECTED","selected");
01297                         }
01298                         $this->tpl->parseCurrentBlock();
01299                 }
01300                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01301                 $this->tpl->setVariable("GLOBAL_OPTIONS",$this->lng->txt("mail_global_options"));
01302                 $this->tpl->setVariable("TXT_INCOMING", $this->lng->txt("mail_incoming"));
01303                 $this->tpl->setVariable("TXT_LINEBREAK", $this->lng->txt("linebreak"));
01304                 $this->tpl->setVariable("TXT_SIGNATURE", $this->lng->txt("signature"));
01305                 $this->tpl->setVariable("CONTENT",$mailOptions->getSignature());
01306                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01307                 
01308                 if ($ilias->getSetting("mail_notification"))
01309                 {
01310                         $this->tpl->setVariable("TXT_CRONJOB_NOTIFICATION", $this->lng->txt("cron_mail_notification"));
01311                         $this->tpl->setVariable("TXT_CRONJOB_NOTIFICATION_INFO", $this->lng->txt("mail_cronjob_notification_info"));
01312                         if ($mailOptions->getCronjobNotification())
01313                         {
01314                                 $this->tpl->setVariable("CRONJOB_NOTIFICATION_SELECTED", " checked=\"checked\"");
01315                         }
01316                 }
01317 
01318                 $this->tpl->show();
01319         }
01320         
01321         function showjsMath()
01322         {
01323                 global $lng, $ilCtrl, $tpl, $ilUser;
01324                 
01325                 $this->__initSubTabs("showjsMath");
01326                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
01327                 $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
01328 
01329                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
01330                 $form = new ilPropertyFormGUI();
01331                 $form->setFormAction($ilCtrl->getFormAction($this));
01332                 $form->setTitle($lng->txt("jsmath_settings"));
01333                 
01334                 // Enable jsMath
01335                 include_once "./Services/Administration/classes/class.ilSetting.php";
01336                 $jsMathSetting = new ilSetting("jsMath");
01337                 $enable = new ilCheckboxInputGUI($lng->txt("jsmath_enable_user"), "enable");
01338                 $checked = ($ilUser->getPref("js_math") === FALSE) ? $jsMathSetting->get("makedefault") : $ilUser->getPref("js_math");
01339                 $enable->setChecked($checked);
01340                 $enable->setInfo($lng->txt("jsmath_enable_user_desc"));
01341                 $form->addItem($enable);
01342 
01343                 $form->addCommandButton("savejsMath", $lng->txt("save"));
01344                 $form->addCommandButton("showjsMath", $lng->txt("cancel"));
01345                 
01346                 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
01347                 $this->tpl->show();
01348         }
01349         
01350         function savejsMath()
01351         {
01352                 global $ilCtrl, $ilUser;
01353                 
01354                 include_once "./Services/Administration/classes/class.ilSetting.php";
01355                 $jsMathSetting = new ilSetting("jsMath");
01356                 if ($jsMathSetting->get("enable"))
01357                 {
01358                         if ($_POST["enable"])
01359                         {
01360                                 $ilUser->writePref("js_math", "1");
01361                         }
01362                         else
01363                         {
01364                                 $ilUser->writePref("js_math", "0");
01365                         }
01366                 }
01367                 $ilCtrl->redirect($this, "showjsMath");
01368         }
01369         
01370         function showLocation()
01371         {
01372                 global $ilUser, $ilCtrl, $ilUser, $lng;
01373                 
01374                 $lng->loadLanguageModule("gmaps");
01375 
01376                 // check google map activation
01377                 include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
01378                 if (!ilGoogleMapUtil::isActivated())
01379                 {
01380                         return;
01381                 }
01382                 
01383                 $this->__initSubTabs("showLocation");
01384                 
01385                 $latitude = $ilUser->getLatitude();
01386                 $longitude = $ilUser->getLongitude();
01387                 $zoom = $ilUser->getLocationZoom();
01388                 
01389                 // Get Default settings, when nothing is set
01390                 if ($latitude == 0 && $longitude == 0 && $zoom == 0)
01391                 {
01392                         $def = ilGoogleMapUtil::getDefaultSettings();
01393                         $latitude = $def["latitude"];
01394                         $longitude = $def["longitude"];
01395                         $zoom =  $def["zoom"];
01396                 }
01397 
01398                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
01399                 $this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
01400 
01401                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
01402                 $form = new ilPropertyFormGUI();
01403                 $form->setFormAction($ilCtrl->getFormAction($this));
01404                 
01405                 $form->setTitle($this->lng->txt("location")." ".
01406                         strtolower($this->lng->txt("of"))." ".$ilUser->getFullname());
01407                         
01408                 // public profile
01409                 $public = new ilCheckboxInputGUI($this->lng->txt("public_profile"),
01410                         "public_location");
01411                 $public->setValue("y");
01412                 $public->setInfo($this->lng->txt("gmaps_public_profile_info"));
01413                 $public->setChecked($ilUser->getPref("public_location"));
01414                 $form->addItem($public);
01415 
01416                 // location property
01417                 $loc_prop = new ilLocationInputGUI($this->lng->txt("location"),
01418                         "location");
01419                 $loc_prop->setLatitude($latitude);
01420                 $loc_prop->setLongitude($longitude);
01421                 $loc_prop->setZoom($zoom);
01422                 $form->addItem($loc_prop);
01423                 
01424                 $form->addCommandButton("saveLocation", $this->lng->txt("save"));
01425                 
01426                 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
01427                 $this->tpl->show();
01428         }
01429 
01430         function saveLocation()
01431         {
01432                 global $ilCtrl, $ilUser;
01433                 
01434                 $ilUser->writePref("public_location", $_POST["public_location"]);
01435                 
01436                 $ilUser->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
01437                 $ilUser->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
01438                 $ilUser->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
01439                 $ilUser->update();
01440                 
01441                 $ilCtrl->redirect($this, "showLocation");
01442         }
01443         
01444         // init sub tabs
01445         function __initSubTabs($a_cmd)
01446         {
01447                 global $ilTabs;
01448 
01449                 $showProfile = ($a_cmd == 'showProfile') ? true : false;
01450                 $showMailOptions = ($a_cmd == 'showMailOptions') ? true : false;
01451                 $showLocation = ($a_cmd == 'showLocation') ? true : false;
01452                 $showjsMath = ($a_cmd == 'showjsMath') ? true : false;
01453 
01454                 $ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showProfile"),
01455                                                                  "", "", "", $showProfile);
01456 
01457                 /*$ilTabs->addSubTabTarget("general_settings", $this->ctrl->getLinkTarget($this, "showProfile2"),
01458                                                                  "", "", "", $showProfile);
01459                 */
01460                                                                  
01461                 // check google map activation
01462                 include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
01463                 if (ilGoogleMapUtil::isActivated())
01464                 {
01465                         $ilTabs->addSubTabTarget("location", $this->ctrl->getLinkTarget($this, "showLocation"),
01466                                                                  "", "", "", $showLocation);
01467                 }
01468                 
01469                 $ilTabs->addSubTabTarget("mail_settings", $this->ctrl->getLinkTarget($this, "showMailOptions"),
01470                                                                  "", "", "", $showMailOptions);
01471                 include_once "./Services/Administration/classes/class.ilSetting.php";
01472                 $jsMathSetting = new ilSetting("jsMath");
01473                 if ($jsMathSetting->get("enable"))
01474                 {
01475                         $ilTabs->addSubTabTarget("jsmath_extt_jsmath", $this->ctrl->getLinkTarget($this, "showjsMath"),
01476                                                                          "", "", "", $showjsMath);
01477                 }
01478         }
01479 
01480 
01481         function __showOtherInformations()
01482         {
01483                 $d_set = new ilSetting("delicous");
01484                 if($this->userSettingVisible("matriculation") or count($this->user_defined_fields->getVisibleDefinitions())
01485                         or $d_set->get("user_profile") == "1")
01486                 {
01487                         return true;
01488                 }
01489                 return false;
01490         }
01491 
01492         function __showUserDefinedFields()
01493         {
01494                 global $ilUser;
01495 
01496                 $user_defined_data = $ilUser->getUserDefinedData();
01497                 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
01498                 {
01499                         if($definition['field_type'] == UDF_TYPE_TEXT)
01500                         {
01501                                 $this->tpl->setCurrentBlock("field_text");
01502                                 $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($user_defined_data[$field_id]));
01503                                 if(!$definition['changeable'])
01504                                 {
01505                                         $this->tpl->setVariable("DISABLED_FIELD",'disabled=\"disabled\"');
01506                                         $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
01507                                 }
01508                                 else
01509                                 {
01510                                         $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
01511                                 }
01512                                 $this->tpl->parseCurrentBlock();
01513                         }
01514                         else
01515                         {
01516                                 if($definition['changeable'])
01517                                 {
01518                                         $name = 'udf['.$definition['field_id'].']';
01519                                         $disabled = false;
01520                                 }
01521                                 else
01522                                 {
01523                                         $name = '';
01524                                         $disabled = true;
01525                                 }
01526                                 $this->tpl->setCurrentBlock("field_select");
01527                                 $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($user_defined_data[$field_id],
01528                                                                                                                                                 $name,
01529                                                                                                                                                 $this->user_defined_fields->fieldValuesToSelectArray(
01530                                                                                                                                                         $definition['field_values']),
01531                                                                                                                                                 false,
01532                                                                                                                                                 true,0,'','',$disabled));
01533                                 $this->tpl->parseCurrentBlock();
01534                         }
01535                         $this->tpl->setCurrentBlock("user_defined");
01536 
01537                         if($definition['required'])
01538                         {
01539                                 $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
01540                         }
01541                         else
01542                         {
01543                                 $name = $definition['field_name'];
01544                         }
01545                         $this->tpl->setVariable("TXT_FIELD_NAME",$name);
01546                         $this->tpl->parseCurrentBlock();
01547                 }
01548                 return true;
01549         }
01550 
01551         function __checkUserDefinedRequiredFields()
01552         {
01553                 foreach($this->user_defined_fields->getVisibleDefinitions() as $definition)
01554                 {
01555                         $field_id = $definition['field_id'];
01556                         if($definition['required'] and !strlen($_POST['udf'][$field_id]))
01557                         {
01558                                 return false;
01559                         }
01560                 }
01561                 return true;
01562         }
01563         
01567         function showProfile2()
01568         {
01569                 global $ilUser, $styleDefinition, $rbacreview, $ilias, $lng, $ilSetting;
01570 exit; // comes later
01571                 $this->__initSubTabs("showProfile");
01572 
01573                 $settings = $ilias->getAllSettings();
01574                 
01575                 //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
01576                 
01577                 // catch feedback message
01578                 if ($ilUser->getProfileIncomplete())
01579                 {
01580                         ilUtil::sendInfo($lng->txt("profile_incomplete"));
01581                 }
01582                 else
01583                 {
01584                         ilUtil::sendInfo();
01585                 }
01586                 // display infopanel if something happened
01587                 ilUtil::infoPanel();
01588 
01589                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
01590                         $this->lng->txt("personal_desktop"));
01591                 $this->tpl->setTitle($this->lng->txt("personal_desktop"));
01592 
01593                 $this->initForm();
01594                 $this->tpl->setVariable("ADM_CONTENT", $this->form->getHTML());
01595                 
01596                 $this->tpl->show();
01597         }
01598                 
01599         
01600         function initForm()
01601         {
01602                 global $ilSetting, $lng, $ilUser, $styleDefinition, $rbacreview;
01603                 
01604                 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
01605                 $this->form = new ilPropertyFormGUI();
01606                 $this->form->setFormAction($this->ctrl->getFormAction($this));
01607                 $this->form->setSubformMode("right");
01608                 
01609                 // user data
01610                 $sh = new ilFormSectionHeaderGUI();
01611                 $sh->setTitle($this->lng->txt("userdata")." ".
01612                         strtolower($this->lng->txt("of"))." ".$ilUser->getFullname());
01613                 $this->form->addItem($sh);
01614                 
01615                 // user account name
01616                 $val = new ilNonEditableValueGUI($this->lng->txt("username"));
01617                 $val->setValue($ilUser->getLogin());
01618                 $this->form->addItem($val);
01619                 
01620                 // default roles
01621                 $global_roles = $rbacreview->getGlobalRoles();
01622                 foreach($global_roles as $role_id)
01623                 {
01624                         if (in_array($role_id,$rbacreview->assignedRoles($ilUser->getId())))
01625                         {
01626                                 $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
01627                                 $role_names .= $roleObj->getTitle().", ";
01628                                 unset($roleObj);
01629                         }
01630                 }
01631                 $dr = new ilNonEditableValueGUI($this->lng->txt("default_roles"));
01632                 $dr->setValue(substr($role_names,0,-2));
01633                 $this->form->addItem($dr);
01634                 
01635                 // personal data
01636                 $sh = new ilFormSectionHeaderGUI();
01637                 $sh->setTitle($this->lng->txt("personal_data"));
01638                 $this->form->addItem($sh);
01639 
01640                 // gender
01641                 if ($this->userSettingVisible("gender"))
01642                 {
01643                         $this->input["gender"] =
01644                                 new ilRadioGroupInputGUI($lng->txt("gender"), "usr_gender");
01645                         $this->input["gender"]->setValue($ilUser->getGender());
01646                         $fem = new ilRadioOption($lng->txt("gender_f"), "f");
01647                         $mal = new ilRadioOption($lng->txt("gender_m"), "m");
01648                         $this->input["gender"]->addOption($fem);
01649                         $this->input["gender"]->addOption($mal);
01650                         $this->form->addItem($this->input["gender"]);
01651                 }
01652                 
01653                 // first name
01654                 if ($this->userSettingVisible("firstname"))
01655                 {
01656                         $this->input["firstname"] =
01657                                 new ilTextInputGUI($lng->txt("firstname"), "usr_firstname");
01658                         $this->input["firstname"]->setValue($ilUser->getFirstname());
01659                         $this->input["firstname"]->setMaxLength(32);
01660                         $this->input["firstname"]->setSize(40);
01661                         $this->form->addItem($this->input["firstname"]);
01662                 }
01663 
01664                 // last name
01665                 if ($this->userSettingVisible("lastname"))
01666                 {
01667                         $this->input["lastname"] =
01668                                 new ilTextInputGUI($lng->txt("lastname"), "usr_lastname");
01669                         $this->input["lastname"]->setValue($ilUser->getLastname());
01670                         $this->input["lastname"]->setMaxLength(32);
01671                         $this->input["lastname"]->setSize(40);
01672                         $this->form->addItem($this->input["lastname"]);
01673                 }
01674 
01675                 // title
01676                 if ($this->userSettingVisible("title"))
01677                 {
01678                         $this->input["title"] =
01679                                 new ilTextInputGUI($lng->txt("person_title"), "usr_title");
01680                         $this->input["title"]->setValue($ilUser->getUTitle());
01681                         $this->input["title"]->setMaxLength(32);
01682                         $this->input["title"]->setSize(40);
01683                         $this->form->addItem($this->input["title"]);
01684                 }
01685 
01686                 // personal picture
01687                 if ($this->userSettingEnabled("upload"))
01688                 {
01689                         $this->input["image"] =
01690                                 new ilImageFileInputGUI($this->lng->txt("personal_picture"), "usr_image");
01691                         $im = $ilUser->getPersonalPicturePath();
01692                         if ($im != "")
01693                         {
01694                                 $this->input["image"]->setImage($im);
01695                                 $this->input["image"]->setAlt($this->lng->txt("personal_picture"));
01696                         }
01697                         
01698                         // ilinc link as info
01699                         if ($this->userSettingVisible("upload") and $this->ilias->getSetting("ilinc_active"))
01700                         {
01701                                 include_once ('ilinc/classes/class.ilObjiLincUser.php');
01702                                 $ilinc_user = new ilObjiLincUser($ilUser);
01703                                         
01704                                 if ($ilinc_user->id)
01705                                 {
01706                                         include_once ('ilinc/classes/class.ilnetucateXMLAPI.php');
01707                                         $ilincAPI = new ilnetucateXMLAPI();
01708                                         $ilincAPI->uploadPicture($ilinc_user);
01709                                         $response = $ilincAPI->sendRequest("uploadPicture");
01710                                 
01711                                         // return URL to user's personal page
01712                                         $url = trim($response->data['url']['cdata']);
01713                                         $desc = 
01714                                                 $this->lng->txt("ilinc_upload_pic_text")." ".
01715                                                 '<a href="'.$url.'">'.$this->lng->txt("ilinc_upload_pic_linktext").'</a>';
01716                                         $this->input["image"]->setInfo($desc);
01717                                 }
01718                         }
01719 
01720                         $this->form->addItem($this->input["image"]);
01721                 }
01722                 
01723                 // contact data
01724                 $sh = new ilFormSectionHeaderGUI();
01725                 $sh->setTitle($this->lng->txt("contact_data"));
01726                 $this->form->addItem($sh);
01727 
01728                 // institution
01729                 if ($this->userSettingVisible("institution"))
01730                 {
01731                         $this->input["institution"] =
01732                                 new ilTextInputGUI($lng->txt("institution"), "usr_institution");
01733                         $this->input["institution"]->setValue($ilUser->getInstitution());
01734                         $this->input["institution"]->setMaxLength(80);
01735                         $this->input["institution"]->setSize(40);
01736                         $this->form->addItem($this->input["institution"]);
01737                 }
01738 
01739                 // department
01740                 if ($this->userSettingVisible("department"))
01741                 {
01742                         $this->input["department"] =
01743                                 new ilTextInputGUI($lng->txt("department"), "usr_department");
01744                         $this->input["department"]->setValue($ilUser->getDepartment());
01745                         $this->input["department"]->setMaxLength(80);
01746                         $this->input["department"]->setSize(40);
01747                         $this->form->addItem($this->input["department"]);
01748                 }
01749 
01750                 // street
01751                 if ($this->userSettingVisible("street"))
01752                 {
01753                         $this->input["street"] =
01754                                 new ilTextInputGUI($lng->txt("street"), "usr_street");
01755                         $this->input["street"]->setValue($ilUser->getStreet());
01756                         $this->input["street"]->setMaxLength(40);
01757                         $this->input["street"]->setSize(40);
01758                         $this->form->addItem($this->input["street"]);
01759                 }
01760 
01761                 // zipcode
01762                 if ($this->userSettingVisible("zipcode"))
01763                 {
01764                         $this->input["zipcode"] =
01765                                 new ilTextInputGUI($lng->txt("zipcode"), "usr_zipcode");
01766                         $this->input["zipcode"]->setValue($ilUser->getZipcode());
01767                         $this->input["zipcode"]->setMaxLength(10);
01768                         $this->input["zipcode"]->setSize(10);
01769                         $this->form->addItem($this->input["zipcode"]);
01770                 }
01771 
01772                 // city
01773                 if ($this->userSettingVisible("city"))
01774                 {
01775                         $this->input["city"] =
01776                                 new ilTextInputGUI($lng->txt("city"), "usr_city");
01777                         $this->input["city"]->setValue($ilUser->getCity());
01778                         $this->input["city"]->setMaxLength(40);
01779                         $this->input["city"]->setSize(40);
01780                         $this->form->addItem($this->input["city"]);
01781                 }
01782 
01783                 // country
01784                 if ($this->userSettingVisible("country"))
01785                 {
01786                         $this->input["country"] =
01787                                 new ilTextInputGUI($lng->txt("country"), "usr_country");
01788                         $this->input["country"]->setValue($ilUser->getCountry());
01789                         $this->input["country"]->setMaxLength(40);
01790                         $this->input["country"]->setSize(40);
01791                         $this->form->addItem($this->input["country"]);
01792                 }
01793 
01794                 // phone office
01795                 if ($this->userSettingVisible("phone_office"))
01796                 {
01797                         $this->input["phone_office"] =
01798                                 new ilTextInputGUI($lng->txt("phone_office"), "usr_phone_office");
01799                         $this->input["phone_office"]->setValue($ilUser->getPhoneOffice());
01800                         $this->input["phone_office"]->setMaxLength(40);
01801                         $this->input["phone_office"]->setSize(40);
01802                         $this->form->addItem($this->input["phone_office"]);
01803                 }
01804 
01805                 // phone home
01806                 if ($this->userSettingVisible("phone_home"))
01807                 {
01808                         $this->input["phone_home"] =
01809                                 new ilTextInputGUI($lng->txt("phone_home"), "usr_phone_home");
01810                         $this->input["phone_home"]->setValue($ilUser->getPhoneHome());
01811                         $this->input["phone_home"]->setMaxLength(40);
01812                         $this->input["phone_home"]->setSize(40);
01813                         $this->form->addItem($this->input["phone_home"]);
01814                 }
01815 
01816                 // phone mobile
01817                 if ($this->userSettingVisible("phone_mobile"))
01818                 {
01819                         $this->input["phone_mobile"] =
01820                                 new ilTextInputGUI($lng->txt("phone_mobile"), "usr_phone_mobile");
01821                         $this->input["phone_mobile"]->setValue($ilUser->getPhoneMobile());
01822                         $this->input["phone_mobile"]->setMaxLength(40);
01823                         $this->input["phone_mobile"]->setSize(40);
01824                         $this->form->addItem($this->input["phone_mobile"]);
01825                 }
01826 
01827                 // fax
01828                 if ($this->userSettingVisible("fax"))
01829                 {
01830                         $this->input["fax"] =
01831                                 new ilTextInputGUI($lng->txt("fax"), "usr_fax");
01832                         $this->input["fax"]->setValue($ilUser->getFax());
01833                         $this->input["fax"]->setMaxLength(40);
01834                         $this->input["fax"]->setSize(40);
01835                         $this->form->addItem($this->input["fax"]);
01836                 }
01837 
01838                 // email
01839                 if ($this->userSettingVisible("email"))
01840                 {
01841                         $this->input["email"] =
01842                                 new ilTextInputGUI($lng->txt("email"), "usr_email");
01843                         $this->input["email"]->setValue($ilUser->getEmail());
01844                         $this->input["email"]->setMaxLength(80);
01845                         $this->input["email"]->setSize(40);
01846                         $this->form->addItem($this->input["email"]);
01847                 }
01848 
01849                 // hobby
01850                 if ($this->userSettingVisible("hobby"))
01851                 {
01852                         $this->input["hobby"] =
01853                                 new ilTextAreaInputGUI($lng->txt("hobby"), "usr_hobby");
01854                         $this->input["hobby"]->setValue($ilUser->getHobby());
01855                         $this->input["hobby"]->setRows(3);
01856                         $this->input["hobby"]->setCols(45);
01857                         $this->form->addItem($this->input["hobby"]);
01858                 }
01859 
01860                 // referral comment
01861                 if ($this->userSettingVisible("referral_comment"))
01862                 {
01863                         $this->input["referral_comment"] =
01864                                 new ilTextAreaInputGUI($lng->txt("referral_comment"), "usr_referral_comment");
01865                         $this->input["referral_comment"]->setValue($ilUser->getComment());
01866                         $this->input["referral_comment"]->setRows(3);
01867                         $this->input["referral_comment"]->setCols(45);
01868                         $this->form->addItem($this->input["referral_comment"]);
01869                 }
01870 
01871                 // instant messengers
01872                 if ($this->userSettingVisible("instant_messengers"))
01873                 {
01874                         $sh = new ilFormSectionHeaderGUI();
01875                         $sh->setTitle($this->lng->txt("user_profile_instant_messengers"));
01876                         $this->form->addItem($sh);
01877                         
01878                         $im_arr = array("icq","yahoo","msn","aim","skype");
01879                         foreach ($im_arr as $im_name)
01880                         {
01881                                 $this->input["im_".$im_name] =
01882                                         new ilTextInputGUI($lng->txt("im_".$im_name), "usr_im_".$im_name);
01883                                 $this->input["im_".$im_name]->setValue($ilUser->getInstantMessengerId($im_name));
01884                                 $this->input["im_".$im_name]->setMaxLength(40);
01885                                 $this->input["im_".$im_name]->setSize(40);
01886                                 $this->form->addItem($this->input["im_".$im_name]);
01887                         }
01888                 }
01889                 
01890                 // other information
01891                 if($this->__showOtherInformations())
01892                 {
01893                         $sh = new ilFormSectionHeaderGUI();
01894                         $sh->setTitle($this->lng->txt("user_profile_other"));
01895                         $this->form->addItem($sh);
01896                 }
01897                 
01898                 // matriculation number
01899                 if ($this->userSettingVisible("matriculation"))
01900                 {
01901                         $this->input["matriculation"] =
01902                                 new ilTextInputGUI($lng->txt("matriculation"), "usr_matriculation");
01903                         $this->input["matriculation"]->setValue($ilUser->getMatriculation());
01904                         $this->input["matriculation"]->setMaxLength(40);
01905                         $this->input["matriculation"]->setSize(40);
01906                         $this->form->addItem($this->input["matriculation"]);
01907                 }
01908 
01909                 // delicious account
01910                 $d_set = new ilSetting("delicious");
01911                 if ($d_set->get("user_profile") == "1")
01912                 {
01913                         $this->input["delicious"] =
01914                                 new ilTextInputGUI($lng->txt("delicious"), "usr_delicious");
01915                         $this->input["delicious"]->setValue($ilUser->getDelicious());
01916                         $this->input["delicious"]->setMaxLength(40);
01917                         $this->input["delicious"]->setSize(40);
01918                         $this->form->addItem($this->input["delicious"]);
01919                 }
01920                 
01921                 // user defined fields
01922                 $user_defined_data = $ilUser->getUserDefinedData();
01923                 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
01924                 {
01925                         if($definition['field_type'] == UDF_TYPE_TEXT)
01926                         {
01927                                 $this->input["udf_".$definition['field_id']] =
01928                                         new ilTextInputGUI($definition['field_name'], "udf_".$definition['field_id']);
01929                                 $this->input["udf_".$definition['field_id']]->setValue($user_defined_data[$field_id]);
01930                                 $this->input["udf_".$definition['field_id']]->setMaxLength(255);
01931                                 $this->input["udf_".$definition['field_id']]->setSize(40);
01932                         }
01933                         else
01934                         {
01935                                 $this->input["udf_".$definition['field_id']] =
01936                                         new ilSelectInputGUI($definition['field_name'], "udf_".$definition['field_id']);
01937                                 $this->input["udf_".$definition['field_id']]->setValue($user_defined_data[$field_id]);
01938                                 $this->input["udf_".$definition['field_id']]->setOptions(
01939                                         $this->user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
01940                         }
01941                         if(!$definition['changeable'])
01942                         {
01943                                 $this->input["udf_".$definition['field_id']]->setDisabled(true);
01944                         }
01945                         if($definition['required'])
01946                         {
01947                                 $this->input["udf_".$definition['field_id']]->setRequired(true);
01948                         }
01949                         $this->form->addItem($this->input["udf_".$definition['field_id']]);
01950                 }
01951                 
01952                 // settings
01953                 $sh = new ilFormSectionHeaderGUI();
01954                 $sh->setTitle($lng->txt("settings"));
01955                 $this->form->addItem($sh);
01956                 
01957                 // language
01958                 if ($this->userSettingVisible("language"))
01959                 {
01960                         //get all languages
01961                         $languages = $this->lng->getInstalledLanguages();
01962                         
01963                         // preselect previous chosen language otherwise saved language
01964                         $selected_lang = (isset($_POST["usr_language"]))
01965                                 ? $_POST["usr_language"]
01966                                 : $ilUser->getLanguage();
01967                         
01968                         $this->input["language"] = new ilSelectInputGUI($lng->txt("language"), "usr_language");
01969                                 
01970                         //go through languages
01971                         $langs = array();
01972                         foreach($languages as $lang_key)
01973                         {
01974                                 $langs[$lang_key] = ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key);
01975                         }
01976                         $this->input["language"]->setValue($selected_lang);
01977                         $this->input["language"]->setOptions($langs);
01978                         $this->form->addItem($this->input["language"]);
01979                 }
01980 
01981                 // skin/style
01982                 include_once("classes/class.ilObjStyleSettings.php");
01983                 $templates = $styleDefinition->getAllTemplates();
01984                 if ($this->userSettingVisible("skin_style"))
01985                 {
01986                         if (is_array($templates))
01987                         {
01988                                 $st_arr = array();
01989                                 foreach($templates as $template)
01990                                 {
01991                                         // get styles information of template
01992                                         $styleDef =& new ilStyleDefinition($template["id"]);
01993                                         $styleDef->startParsing();
01994                                         $styles = $styleDef->getStyles();
01995                                         $st_sel = $ilUser->skin.":".$ilUser->prefs["style"];
01996                                         foreach($styles as $style)
01997                                         {
01998                                                 if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
01999                                                 {
02000                                                         continue;
02001                                                 }
02002                                                 $st_arr[$template["id"].":".$style["id"]] =
02003                                                         $styleDef->getTemplateName()." / ".$style["name"];
02004                                         }
02005                                 }
02006                                 $this->input["skin_style"] = new ilSelectInputGUI($lng->txt("usr_skin_style"), "usr_skin_style");
02007                                 $this->input["skin_style"]->setValue($st_sel);
02008                                 $this->input["skin_style"]->setOptions($st_arr);
02009                                 $this->form->addItem($this->input["skin_style"]);
02010                         }
02011                 }
02012                                 
02013                 // hits per page
02014                 if ($this->userSettingVisible("hits_per_page"))
02015                 {
02016                         $hits_options = array(2 => 2, 10 => 10, 15 => 15,
02017                                 20 => 20, 30 => 30, 40 => 40, 50 => 50,
02018                                 100 => 100, 9999 => $this->lng->txt("no_limit"));
02019                         $this->input["hits_per_page"] = new ilSelectInputGUI($lng->txt("hits_per_page"), "hits_per_page");
02020                         $this->input["hits_per_page"]->setValue($ilUser->prefs["hits_per_page"]);
02021                         $this->input["hits_per_page"]->setOptions($hits_options);
02022                         $this->form->addItem($this->input["hits_per_page"]);
02023                 }
02024                 
02025                 // users online
02026                 if ($this->userSettingVisible("show_users_online"))
02027                 {
02028                         $users_online_options = array(
02029                                 "y" => $this->lng->txt("users_online_show_y"),
02030                                 "associated" => $this->lng->txt("users_online_show_associated"),
02031                                 "n" => $this->lng->txt("users_online_show_n"));
02032                         $this->input["show_users_online"] =
02033                                 new ilSelectInputGUI($lng->txt("show_users_online"), "show_users_online");
02034                         $this->input["show_users_online"]->setValue($ilUser->prefs["show_users_online"]);
02035                         $this->input["show_users_online"]->setOptions($users_online_options);
02036                         $this->form->addItem($this->input["show_users_online"]);
02037                 }
02038 
02039                 // hide_own_online_status
02040                 if ($this->userSettingVisible("hide_own_online_status"))
02041                 {                       
02042                         if ($ilUser->prefs["hide_own_online_status"] == "y")
02043                         {
02044                                 $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "checked");
02045                         }
02046                         $this->input["hide_own_online_status"] =
02047                                 new ilCheckboxInputGUI($lng->txt("hide_own_online_status"), "hide_own_online_status");
02048                         $this->input["hide_own_online_status"]->setValue("y");
02049                         $this->input["hide_own_online_status"]->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
02050                         $this->form->addItem($this->input["hide_own_online_status"]);
02051                 }
02052                 
02053                 
02054                 // disable disabled fields
02055                 foreach ($this->input as $field => $val)
02056                 {
02057                         if (!$ilSetting->get("usr_settings_hide_" . $field))
02058                         {
02059                                 if ($ilSetting->get("usr_settings_disable_" . $field))
02060                                 {
02061                                         $this->input[$field]->setDisabled(true);
02062                                 }
02063                         }
02064                         if (isset($this->settings["require_" . $field]) && $this->settings["require_" . $field])
02065                         {
02066                                 $this->input[$field]->setRequired(true);
02067                         }
02068                 }
02069 
02070                 // show in public profile?
02071                 $val_array = array("institution", "department", "upload", "street",
02072                         "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
02073                         "fax", "email", "hobby", "matriculation");
02074                 foreach ($val_array as $val)
02075                 {
02076                         if (is_object($this->input[$val]))
02077                         {
02078                                 $this->input["chk_".$val] =
02079                                         new ilCheckboxInputGUI($lng->txt("public"), "chk_".$val);
02080                                 $this->input["chk_".$val]->setValue("y");
02081                                 $this->input["chk_".$val]->setChecked($ilUser->prefs["public_".$val] == "y");
02082                                 $this->input[$val]->addSubItem($this->input["chk_".$val]);
02083                                 $this->input[$val]->setSubformMode("right");
02084                         }
02085                 }
02086         }
02087 
02088 }
02089 ?>

Generated on Fri Dec 13 2013 17:57:02 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1