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

usr_profile.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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 
00033 require_once "./include/inc.header.php";
00034 // catch hack attempts
00035 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00036 {
00037         $ilias->raiseError($lng->txt("msg_not_available_for_anon"),$ilias->error_obj->MESSAGE);
00038 }
00039 
00040 $strip = false;
00041 
00042 if (!empty($_POST))
00043 {
00044         $strip = true;
00045 }
00046 
00047 foreach($_POST as $key => $val)
00048 {
00049 //      $_POST[$key] = ilUtil::prepareFormOutput($val,$strip);
00050 }
00051 
00052 $webspace_dir = $ilias->ini->readVariable("server","webspace_dir");
00053 
00054 //load ILIAS settings
00055 $settings = $ilias->getAllSettings();
00056 
00057 //$image_dir = $webspace_dir."/usr_images";
00058 
00059 // Returns TRUE if working with the given
00060 // user setting is allowed, FALSE otherwise
00061 function workWithUserSetting($setting)
00062 {
00063         global $settings;
00064         $result = TRUE;
00065         if ($settings["usr_settings_hide_".$setting] == 1)
00066         {
00067                 $result = FALSE;
00068         }
00069         if ($settings["usr_settings_disable_".$setting] == 1)
00070         {
00071                 $result = FALSE;
00072         }
00073         return $result;
00074 }
00075 
00076 function userSettingVisible($setting)
00077 {
00078         global $settings;
00079         $result = TRUE;
00080         if ($settings["usr_settings_hide_".$setting] == 1)
00081         {
00082                 $result = FALSE;
00083         }
00084         return $result;
00085 }
00086 
00087 function userSettingEnabled($setting)
00088 {
00089         global $settings;
00090         $result = TRUE;
00091         if ($settings["usr_settings_disable_".$setting] == 1)
00092         {
00093                 $result = FALSE;
00094         }
00095         return $result;
00096 }
00097 
00098 // purpose is to upload file of user
00099 // function added by ratana ty
00100 function upload_file()
00101 {
00102         global $upload_error,$lng;
00103         global $userfile, $userfile_name, $userfile_size,
00104         $userfile_type, $archive_dir, $WINDIR,$ilias,$lng;
00105         global $target_file, $return_path;
00106 
00107         if ($_FILES["userfile"]["size"] == 0)
00108         {
00109                 $upload_error=$lng->txt("msg_no_file");
00110                 return;
00111         }
00112 
00113 // TODO
00114 // Check the type of file and then check the size
00115 // of the file whether we allow people to upload or not
00116 
00117         $webspace_dir = ilUtil::getWebspaceDir();
00118         $image_dir = $webspace_dir."/usr_images";
00119         $target_file = $image_dir."/usr_".$ilias->account->getId()."."."jpg";
00120         $store_file = "usr_".$ilias->account->getID()."."."jpg";
00121 
00122         // store filename
00123         $ilias->account->setPref("profile_image", $store_file);
00124         $ilias->account->update();
00125 
00126         //$tempfile = tempnam ("/tmp", "usr_profile_");
00127         //$pathinfo = pathinfo($tempfile);
00128         
00129         //
00130         $uploaded_file = $image_dir."/upload_".$ilias->account->getId();
00131 //echo ":".$uploaded_file.":";
00132         if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
00133                 $uploaded_file, false))
00134         {
00135                 ilUtil::redirect("usr_profile.php");
00136         }
00137         //move_uploaded_file($_FILES["userfile"]["tmp_name"],
00138         //      $uploaded_file);
00139         chmod($uploaded_file, 0770);
00140 
00141         // take quality 100 to avoid jpeg artefacts when uploading jpeg files
00142         // taking only frame [0] to avoid problems with animated gifs
00143         $show_file  = "$image_dir/usr_".$ilias->account->getId().".jpg"; 
00144         $thumb_file = "$image_dir/usr_".$ilias->account->getId()."_small.jpg";
00145         $xthumb_file = "$image_dir/usr_".$ilias->account->getId()."_xsmall.jpg"; 
00146         $xxthumb_file = "$image_dir/usr_".$ilias->account->getId()."_xxsmall.jpg";
00147 
00148         system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file");
00149         system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
00150         system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
00151         system(ilUtil::getConvertCmd()." $uploaded_file" . "[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
00152 
00153         if ($error)
00154         {
00155                 //$ilias->raiseError($lng->txt("image_gen_unsucc"), $ilias->error_obj->MESSAGE);
00156                 sendInfo($lng->txt("image_gen_unsucc"), true);
00157                 ilUtil::redirect("usr_profile.php");
00158         }
00159 
00160         return $target_file;
00161 }
00162 
00163 function removePicture()
00164 {
00165         global $ilias;
00166 
00167         $webspace_dir = ilUtil::getWebspaceDir();
00168         $image_dir = $webspace_dir."/usr_images";
00169         $file = $image_dir."/usr_".$ilias->account->getID()."."."jpg";
00170         $thumb_file = $image_dir."/usr_".$ilias->account->getID()."_small.jpg";
00171         $xthumb_file = $image_dir."/usr_".$ilias->account->getID()."_xsmall.jpg";
00172         $xxthumb_file = $image_dir."/usr_".$ilias->account->getID()."_xxsmall.jpg";
00173         $upload_file = $image_dir."/upload_".$ilias->account->getID();
00174 
00175         // remove user pref file name
00176         $ilias->account->setPref("profile_image", "");
00177         $ilias->account->update();
00178 
00179         if (@is_file($file))
00180         {
00181                 unlink($file);
00182         }
00183         if (@is_file($thumb_file))
00184         {
00185                 unlink($thumb_file);
00186         }
00187         if (@is_file($xthumb_file))
00188         {
00189                 unlink($xthumb_file);
00190         }
00191         if (@is_file($xxthumb_file))
00192         {
00193                 unlink($xxthumb_file);
00194         }
00195         if (@is_file($upload_file))
00196         {
00197                 unlink($upload_file);
00198         }
00199 
00200 }
00201 
00202 // End of function upload file
00203 
00204 // change user password
00205 function change_password()
00206 {
00207         global $ilias, $lng, $tpl, $password_error;
00208         
00209         // do nothing if auth mode is not local database
00210         if ($ilias->account->getAuthMode(true) != AUTH_LOCAL)
00211         {
00212                 return;
00213         }
00214 
00215     // select password from auto generated passwords
00216     if ($ilias->getSetting("passwd_auto_generate") == 1)
00217     {
00218         // check old password
00219         if (md5($_POST["current_password"]) != $ilias->account->getPasswd())
00220         {
00221             $password_error=$lng->txt("passwd_wrong");
00222             //$ilias->raiseError($lng->txt("passwd_wrong"),$ilias->error_obj->MESSAGE);
00223         }
00224 
00225         // validate transmitted password
00226         if (!ilUtil::isPassword($_POST["new_passwd"]))
00227         {
00228             $password_error=$lng->txt("passwd_not_selected");
00229             //$ilias->raiseError($lng->txt("passwd_not_selected"),$ilias->error_obj->MESSAGE);
00230         }
00231         
00232         if (empty($password_error))
00233         {
00234             $ilias->account->updatePassword($_POST["current_password"], $_POST["new_passwd"], $_POST["new_passwd"]);
00235         }
00236     }
00237     else
00238     {
00239 
00240         // check old password
00241         if (md5($_POST["current_password"]) != $ilias->account->getPasswd())
00242         {
00243                 $password_error=$lng->txt("passwd_wrong");
00244                 //$ilias->raiseError($lng->txt("passwd_wrong"),$ilias->error_obj->MESSAGE);
00245         }
00246 
00247         // check new password
00248         else if ($_POST["desired_password"] != $_POST["retype_password"])
00249         {
00250                 $password_error=$lng->txt("passwd_not_match");
00251                 //$ilias->raiseError($lng->txt("passwd_not_match"),$ilias->error_obj->MESSAGE);
00252         }
00253 
00254         // validate password
00255         else if (!ilUtil::isPassword($_POST["desired_password"]))
00256         {
00257                 $password_error=$lng->txt("passwd_invalid");
00258                 //$ilias->raiseError($lng->txt("passwd_invalid"),$ilias->error_obj->MESSAGE);
00259         }
00260 
00261         else if ($_POST["current_password"] != "" and empty($password_error))
00262         {
00263                 $ilias->account->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]);
00264 
00265                 /*if ($ilias->account->updatePassword($_POST["current_password"], $_POST["desired_password"], $_POST["retype_password"]))
00266                 {
00267                         sendInfo($lng->txt("msg_changes_ok"));
00268 
00269                 }
00270                 else
00271                 {
00272                         sendInfo($lng->txt("msg_failed"));
00273 
00274                 }*/
00275         }
00276     }
00277 }
00278 // End of function change_password
00279 
00280 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00281 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00282 $tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00283 //$tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00284 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_profile.html");
00285 
00286 // set locator
00287 $tpl->setVariable("TXT_LOCATOR",$lng->txt("locator"));
00288 $tpl->touchBlock("locator_separator");
00289 $tpl->setCurrentBlock("locator_item");
00290 $tpl->setVariable("ITEM", $lng->txt("personal_desktop"));
00291 $tpl->setVariable("LINK_ITEM", "usr_personaldesktop.php");
00292 $tpl->parseCurrentBlock();
00293 
00294 $tpl->setCurrentBlock("locator_item");
00295 $tpl->setVariable("ITEM", $lng->txt("personal_profile"));
00296 $tpl->setVariable("LINK_ITEM", "usr_profile.php");
00297 $tpl->parseCurrentBlock();
00298 
00299 // catch feedback message
00300 sendInfo();
00301 // display infopanel if something happened
00302 infoPanel();
00303 
00304 // display tabs
00305 include "./include/inc.personaldesktop_buttons.php";
00306 
00307 // To display picture after Uploaded
00308 //$tpl->setVariable("IMAGE_PATH","./".$webspace_dir."/usr_images/".$ilias->account->prefs["profile_image"]);
00309 
00310 // if data are posted check on upload button
00311 //if data are posted
00312 if ($_GET["cmd"] == "save" and empty($_POST["usr_reload"]))
00313 {
00314         $upload_error;
00315 
00316         if (workWithUserSetting("upload"))
00317         {
00318                 // upload usr_image
00319                 if (!empty($_POST["usr_upload"]))
00320                 {
00321                         upload_file();
00322                 }
00323         
00324                 // remove user image
00325                 if (!empty($_POST["removePicture"]))
00326                 {
00327                         removePicture();
00328                 }
00329         }
00330 
00331         // error content
00332         $password_error;
00333 
00334         //change password
00335         if (!empty($_POST["usr_change_password"]))
00336         {
00337                 change_password();
00338         }
00339 
00340         //init checking var
00341         $form_valid = true;
00342 
00343         // testing by ratana ty:
00344         // if people check on check box it will
00345         // write some datata to table usr_pref
00346         // if check on Public Profile
00347         if (($_POST["chk_pub"])=="on")
00348         {
00349                 $ilias->account->setPref("public_profile","y");
00350         }
00351         else
00352         {
00353                 $ilias->account->setPref("public_profile","n");
00354         }
00355 
00356         // if check on Institute
00357         $val_array = array("institution", "department", "upload", "street",
00358                 "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
00359                 "fax", "email", "hobby", "matriculation");
00360 
00361         foreach($val_array as $key => $value)
00362         {
00363                 if (($_POST["chk_".$value]) == "on")
00364                 {
00365                         $ilias->account->setPref("public_".$value,"y");
00366                 }
00367                 else
00368                 {
00369                         $ilias->account->setPref("public_".$value,"n");
00370                 }
00371         }
00372 
00373     // check dynamically required fields
00374     foreach($settings as $key => $val)
00375     {
00376         if (substr($key,0,8) == "require_")
00377         {
00378             $require_keys[] = substr($key,8);
00379         }
00380     }
00381 
00382     foreach($require_keys as $key => $val)
00383     {
00384         // exclude required system and registration-only fields
00385         $system_fields = array("login", "default_role", "passwd", "passwd2");
00386         if (!in_array($val, $system_fields))
00387         {
00388                                         if (workWithUserSetting($val))
00389                                         {
00390             if (isset($settings["require_" . $val]) && $settings["require_" . $val])
00391             {
00392                 if (empty($_POST["usr_" . $val]))
00393                 {
00394                     sendInfo($lng->txt("fill_out_all_required_fields") . ": " . $lng->txt($val));
00395                     $form_valid = false;
00396                 }
00397             }
00398                                         }
00399         }
00400     }
00401 
00402         if (workWithUserSetting("email"))
00403         {
00404                 // check email adress
00405                 if (!ilUtil::is_email($_POST["usr_email"]) and !empty($_POST["usr_email"]) and $form_valid)
00406                 {
00407                         sendInfo($lng->txt("email_not_valid"));
00408                         $form_valid = false;
00409                 }
00410         }
00411 
00412         //update user data (not saving!)
00413         if (workWithUserSetting("firstname"))
00414         {
00415           $ilias->account->setFirstName(ilUtil::stripSlashes($_POST["usr_firstname"]));
00416         }
00417         if (workWithUserSetting("lastname"))
00418         {
00419           $ilias->account->setLastName(ilUtil::stripSlashes($_POST["usr_lastname"]));
00420         }
00421         if (workWithUserSetting("gender"))
00422         {
00423                 $ilias->account->setGender($_POST["usr_gender"]);
00424         }
00425         if (workWithUserSetting("title"))
00426         {
00427                 $ilias->account->setUTitle(ilUtil::stripSlashes($_POST["usr_title"]));
00428         }
00429         $ilias->account->setFullname();
00430         // added for upload by ratana ty
00431         //$ilias->account->setFile($_POST["usr_file"]);
00432         if (workWithUserSetting("institution"))
00433         {
00434                 $ilias->account->setInstitution(ilUtil::stripSlashes($_POST["usr_institution"]));
00435         }
00436         if (workWithUserSetting("department"))
00437         {
00438                 $ilias->account->setDepartment(ilUtil::stripSlashes($_POST["usr_department"]));
00439         }
00440         if (workWithUserSetting("street"))
00441         {
00442                 $ilias->account->setStreet(ilUtil::stripSlashes($_POST["usr_street"]));
00443         }
00444         if (workWithUserSetting("zipcode"))
00445         {
00446                 $ilias->account->setZipcode(ilUtil::stripSlashes($_POST["usr_zipcode"]));
00447         }
00448         if (workWithUserSetting("city"))
00449         {
00450                 $ilias->account->setCity(ilUtil::stripSlashes($_POST["usr_city"]));
00451         }
00452         if (workWithUserSetting("country"))
00453         {
00454                 $ilias->account->setCountry(ilUtil::stripSlashes($_POST["usr_country"]));
00455         }
00456         if (workWithUserSetting("phone_office"))
00457         {
00458                 $ilias->account->setPhoneOffice(ilUtil::stripSlashes($_POST["usr_phone_office"]));
00459         }
00460         if (workWithUserSetting("phone_home"))
00461         {
00462                 $ilias->account->setPhoneHome(ilUtil::stripSlashes($_POST["usr_phone_home"]));
00463         }
00464         if (workWithUserSetting("phone_mobile"))
00465         {
00466                 $ilias->account->setPhoneMobile(ilUtil::stripSlashes($_POST["usr_phone_mobile"]));
00467         }
00468         if (workWithUserSetting("fax"))
00469         {
00470                 $ilias->account->setFax(ilUtil::stripSlashes($_POST["usr_fax"]));
00471         }
00472         if (workWithUserSetting("email"))
00473         {
00474                 $ilias->account->setEmail(ilUtil::stripSlashes($_POST["usr_email"]));
00475         }
00476         if (workWithUserSetting("hobby"))
00477         {
00478                 $ilias->account->setHobby(ilUtil::stripSlashes($_POST["usr_hobby"]));
00479         }
00480         if (workWithUserSetting("referral_comment"))
00481         {
00482                 $ilias->account->setComment(ilUtil::stripSlashes($_POST["usr_referral_comment"]));
00483         }
00484         if (workWithUserSetting("matriculation"))
00485         {
00486                 $ilias->account->setMatriculation(ilUtil::stripSlashes($_POST["usr_matriculation"]));
00487         }
00488 
00489         // everthing's ok. save form data
00490         if ($form_valid)
00491         {
00492                 // init reload var. page should only be reloaded if skin or style were changed
00493                 $reload = false;
00494 
00495                 if (workWithUserSetting("skin_style"))
00496                 {
00497                         //set user skin and style
00498                         if ($_POST["usr_skin_style"] != "")
00499                         {
00500                                 $sknst = explode(":", $_POST["usr_skin_style"]);
00501         
00502                                 if ($ilias->account->getPref("style") != $sknst[1] ||
00503                                         $ilias->account->getPref("skin") != $sknst[0])
00504                                 {
00505                                         $ilias->account->setPref("skin", $sknst[0]);
00506                                         $ilias->account->setPref("style", $sknst[1]);
00507                                         $reload = true;
00508                                 }
00509                         }
00510                 }
00511 
00512                 if (workWithUserSetting("language"))
00513                 {
00514                         // reload page if language was changed
00515                         if ($_POST["usr_language"] != "" && $_POST["usr_language"] != $ilias->account->getLanguage())
00516                         {
00517                                 $reload = true;
00518                         }
00519                         // set user language
00520                         $ilias->account->setLanguage($_POST["usr_language"]);
00521                 }
00522                 if (workWithUserSetting("hits_per_page"))
00523                 {
00524                         // set user hits per page
00525                         if ($_POST["hits_per_page"] != "")
00526                         {
00527                                 $ilias->account->setPref("hits_per_page",$_POST["hits_per_page"]);
00528                         }
00529                 }
00530 
00531                 // set show users online
00532                 if (workWithUserSetting("show_users_online"))
00533                 {
00534                         $ilias->account->setPref("show_users_online", $_POST["show_users_online"]);
00535                 }
00536 
00537                 // save user data & object_data
00538                 $ilias->account->setTitle($ilias->account->getFullname());
00539                 $ilias->account->setDescription($ilias->account->getEmail());
00540                 $ilias->account->update();
00541 
00542                 // reload page only if skin or style were changed
00543                 if ($reload && empty($password_error) && empty($upload_error))
00544                 {
00545                         // feedback
00546                         sendInfo($lng->txt("saved_successfully"),true);
00547                         $tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./start.php\";\n</script>\n");
00548                 }
00549                 else
00550                 {
00551                         // feedback
00552                         if (!empty($password_error))
00553                         {
00554                                 sendInfo($password_error,true);
00555                         }
00556                         elseif (!empty($upload_error))
00557                         {
00558                                 sendInfo($upload_error,true);
00559                         }
00560                         else
00561                         {
00562                                 sendInfo($lng->txt("saved_successfully"),true);
00563                         }
00564                         
00565                         ilUtil::redirect("usr_profile.php");
00566                 }
00567 
00568         }
00569 }
00570 
00571 if (userSettingVisible("language"))
00572 {
00573         //get all languages
00574         $languages = $lng->getInstalledLanguages();
00575         
00576         // preselect previous chosen language otherwise saved language
00577         $selected_lang = (isset($_POST["usr_language"])) ? $_POST["usr_language"] : $ilias->account->getLanguage();
00578         
00579         //go through languages
00580         foreach($languages as $lang_key)
00581         {
00582                 $tpl->setCurrentBlock("sel_lang");
00583                 //$tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00584                 $tpl->setVariable("LANG", ilLanguage::_lookupEntry($lang_key,"meta", "meta_l_".$lang_key));
00585                 $tpl->setVariable("LANGSHORT", $lang_key);
00586         
00587                 if ($selected_lang == $lang_key)
00588                 {
00589                         $tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00590                 }
00591         
00592                 $tpl->parseCurrentBlock();
00593         }
00594 }
00595 
00596 // get all templates
00597 include_once("classes/class.ilObjStyleSettings.php");
00598 $templates = $styleDefinition->getAllTemplates();
00599 
00600 if (userSettingVisible("skin_style"))
00601 {
00602         foreach($templates as $template)
00603         {
00604                 // get styles information of template
00605                 $styleDef =& new ilStyleDefinition($template["id"]);
00606                 $styleDef->startParsing();
00607                 $styles = $styleDef->getStyles();
00608         
00609                 foreach($styles as $style)
00610                 {
00611                         if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
00612                         {
00613                                 continue;
00614                         }
00615 
00616                         $tpl->setCurrentBlock("selectskin");
00617         
00618                         if ($ilias->account->skin == $template["id"] &&
00619                                 $ilias->account->prefs["style"] == $style["id"])
00620                         {
00621                                 $tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00622                         }
00623         
00624                         $tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00625                         $tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00626                         $tpl->parseCurrentBlock();
00627                 }
00628         }
00629 }
00630 
00631 // hits per page
00632 if (userSettingVisible("hits_per_page"))
00633 {
00634         $hits_options = array(2,10,15,20,30,40,50,100,9999);
00635 
00636         foreach($hits_options as $hits_option)
00637         {
00638                 $tpl->setCurrentBlock("selecthits");
00639 
00640                 if ($ilias->account->prefs["hits_per_page"] == $hits_option)
00641                 {
00642                         $tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
00643                 }
00644 
00645                 $tpl->setVariable("HITSVALUE", $hits_option);
00646 
00647                 if ($hits_option == 9999)
00648                 {
00649                         $hits_option = $lng->txt("no_limit");
00650                 }
00651 
00652                 $tpl->setVariable("HITSOPTION", $hits_option);
00653                 $tpl->parseCurrentBlock();
00654         }
00655 }
00656 
00657 // Users Online
00658 if (userSettingVisible("show_users_online"))
00659 {
00660         $users_online_options = array("y","associated","n");
00661         $selected_option = $ilias->account->prefs["show_users_online"];
00662         foreach($users_online_options as $an_option)
00663         {
00664                 $tpl->setCurrentBlock("select_users_online");
00665 
00666                 if ($selected_option == $an_option)
00667                 {
00668                         $tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
00669                 }
00670 
00671                 $tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
00672 
00673                 $tpl->setVariable("USERS_ONLINE_OPTION", $lng->txt("users_online_show_".$an_option));
00674                 $tpl->parseCurrentBlock();
00675         }
00676 }
00677 
00678 
00679 if ($ilias->account->getAuthMode(true) == AUTH_LOCAL and userSettingVisible('password'))
00680 {
00681         if($ilias->getSetting('usr_settings_disable_password'))
00682         {
00683         $tpl->setCurrentBlock("disabled_password");
00684         $tpl->setVariable("TXT_DISABLED_PASSWORD", $lng->txt("chg_password"));
00685         $tpl->setVariable("TXT_DISABLED_CURRENT_PASSWORD", $lng->txt("current_password"));
00686                 $tpl->parseCurrentBlock();
00687         }
00688         elseif ($settings["passwd_auto_generate"] == 1)
00689         {
00690             $passwd_list = ilUtil::generatePasswords(5);
00691      
00692         foreach ($passwd_list as $passwd)
00693         {
00694             $passwd_choice .= ilUtil::formRadioButton(0,"new_passwd",$passwd)." ".$passwd."<br/>";
00695         }
00696 
00697         $tpl->setCurrentBlock("select_password");
00698         $tpl->setVariable("TXT_CHANGE_PASSWORD", $lng->txt("chg_password"));
00699         $tpl->setVariable("TXT_CURRENT_PASSWORD", $lng->txt("current_password"));
00700         $tpl->setVariable("TXT_SELECT_PASSWORD", $lng->txt("select_password"));
00701         $tpl->setVariable("PASSWORD_CHOICE", $passwd_choice);
00702         $tpl->setVariable("TXT_NEW_LIST_PASSWORD", $lng->txt("new_list_password"));
00703         $tpl->parseCurrentBlock();
00704         }
00705         else
00706         {
00707         $tpl->setCurrentBlock("change_password");
00708         $tpl->setVariable("TXT_CHANGE_PASSWORD", $lng->txt("chg_password"));
00709         $tpl->setVariable("TXT_CURRENT_PW", $lng->txt("current_password"));
00710         $tpl->setVariable("TXT_DESIRED_PW", $lng->txt("desired_password"));
00711         $tpl->setVariable("TXT_RETYPE_PW", $lng->txt("retype_password"));
00712         $tpl->setVariable("CHANGE_PASSWORD",$lng->txt("chg_password"));
00713         $tpl->parseCurrentBlock();
00714         }
00715 }
00716 
00717 $tpl->setCurrentBlock("content");
00718 $tpl->setVariable("FORMACTION", "usr_profile.php?cmd=save");
00719 
00720 $tpl->setVariable("HEADER", $lng->txt("personal_desktop"));
00721 $tpl->setVariable("TXT_OF",strtolower($lng->txt("of")));
00722 $tpl->setVariable("USR_FULLNAME",$ilias->account->getFullname());
00723 
00724 $tpl->setVariable("TXT_USR_DATA", $lng->txt("userdata"));
00725 $tpl->setVariable("TXT_NICKNAME", $lng->txt("username"));
00726 $tpl->setVariable("TXT_PUBLIC_PROFILE", $lng->txt("public_profile"));
00727 
00728 $data = array();
00729 $data["fields"] = array();
00730 $data["fields"]["gender"] = "";
00731 $data["fields"]["firstname"] = "";
00732 $data["fields"]["lastname"] = "";
00733 $data["fields"]["title"] = "";
00734 $data["fields"]["institution"] = "";
00735 $data["fields"]["department"] = "";
00736 $data["fields"]["street"] = "";
00737 $data["fields"]["city"] = "";
00738 $data["fields"]["zipcode"] = "";
00739 $data["fields"]["country"] = "";
00740 $data["fields"]["phone_office"] = "";
00741 $data["fields"]["phone_home"] = "";
00742 $data["fields"]["phone_mobile"] = "";
00743 $data["fields"]["fax"] = "";
00744 $data["fields"]["email"] = "";
00745 $data["fields"]["hobby"] = "";
00746 $data["fields"]["referral_comment"] = "";
00747 $data["fields"]["matriculation"] = "";
00748 $data["fields"]["create_date"] = "";
00749 $data["fields"]["approve_date"] = "";
00750 $data["fields"]["active"] = "";
00751 
00752 $data["fields"]["default_role"] = $role;
00753 // fill presets
00754 foreach($data["fields"] as $key => $val)
00755 {
00756         // note: general "title" is not as "title" for a person
00757         if ($key != "title")
00758         {
00759                 $str = $lng->txt($key);
00760         }
00761         else
00762         {
00763                 $str = $lng->txt("person_title");
00764         }
00765 
00766         // check to see if dynamically required
00767         if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00768         {
00769                                 $str = $str . '<span class="asterisk">*</span>';
00770         }
00771 
00772         if (userSettingVisible("$key"))
00773         {
00774                 $tpl->setVariable("TXT_".strtoupper($key), $str);
00775         }
00776 }
00777 
00778 if (userSettingVisible("gender"))
00779 {
00780         $tpl->setVariable("TXT_GENDER_F",$lng->txt("gender_f"));
00781         $tpl->setVariable("TXT_GENDER_M",$lng->txt("gender_m"));
00782 }
00783 
00784 // todo
00785 // capture image name including path ($archive_dir/$filename)
00786 //$tpl->setVariable("IMAGE_PATH",$return_path);
00787 //$tpl->setVariable("IMAGE_PATH",'$archive_dir."/".$filename');
00788 
00789 if (userSettingVisible("upload"))
00790 {
00791         $tpl->setVariable("TXT_UPLOAD",$lng->txt("personal_picture"));
00792         $webspace_dir = ilUtil::getWebspaceDir("output");
00793         $full_img = $ilias->account->getPref("profile_image");
00794         $last_dot = strrpos($full_img, ".");
00795         $small_img = substr($full_img, 0, $last_dot).
00796                         "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
00797         $image_file = $webspace_dir."/usr_images/".$small_img;
00798         
00799         if (@is_file($image_file))
00800         {
00801                         $tpl->setCurrentBlock("pers_image");
00802                         $tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
00803                         $tpl->parseCurrentBlock();
00804                         if (userSettingEnabled("upload"))
00805                         {
00806                                 $tpl->setCurrentBlock("remove_pic");
00807                                 $tpl->setVariable("TXT_REMOVE_PIC",$lng->txt("remove_personal_picture"));
00808                         }
00809                         $tpl->parseCurrentBlock();
00810                         $tpl->setCurrentBlock("content");
00811         }
00812         
00813         if (userSettingEnabled("upload"))
00814         {
00815                 $tpl->setCurrentBlock("upload_pic");
00816                 $tpl->setVariable("UPLOAD",$lng->txt("upload"));
00817         }
00818         $tpl->setVariable("TXT_FILE", $lng->txt("userfile"));
00819         $tpl->setVariable("USER_FILE", $lng->txt("user_file"));
00820 }
00821 
00822 // ilinc upload pic
00823 if (userSettingVisible("upload") and $ilias->getSetting("ilinc_active"))
00824 {
00825         $ilinc_data = $ilias->account->getiLincData();
00826                 
00827         if ($ilinc_data["id"])
00828         {
00829                 include_once ('ilinc/classes/class.ilnetucateXMLAPI.php');
00830                 $ilincAPI = new ilnetucateXMLAPI();
00831                 
00832                 $ilincAPI->uploadPicture($ilias->account);
00833                 $response = $ilincAPI->sendRequest("uploadPicture");
00834         
00835                 // return URL to user's personal page
00836                 $url = trim($response->data['url']['cdata']);
00837 
00838                 $tpl->setCurrentBlock("ilinc_upload_pic");
00839                 $tpl->setVariable("TXT_ILINC_UPLOAD", $lng->txt("ilinc_upload_pic_text"));
00840                 $tpl->setVariable("ILINC_UPLOAD_LINK", $url);
00841                 $tpl->setVariable("ILINC_UPLOAD_LINKTXT", $lng->txt("ilinc_upload_pic_linktext"));
00842                 $tpl->parseCurrentBlock();
00843         }
00844 }
00845 
00846 
00847 if (userSettingVisible("language"))
00848 {
00849         $tpl->setVariable("TXT_LANGUAGE",$lng->txt("language"));
00850 }
00851 if (userSettingVisible("show_users_online"))
00852 {
00853         $tpl->setVariable("TXT_SHOW_USERS_ONLINE",$lng->txt("show_users_online"));
00854 }
00855 if (userSettingVisible("skin_style"))
00856 {
00857         $tpl->setVariable("TXT_USR_SKIN_STYLE",$lng->txt("usr_skin_style"));
00858 }
00859 if (userSettingVisible("hits_per_page"))
00860 {
00861         $tpl->setVariable("TXT_HITS_PER_PAGE",$lng->txt("usr_hits_per_page"));
00862 }
00863 if (userSettingVisible("show_users_online"))
00864 {
00865         $tpl->setVariable("TXT_SHOW_USERS_ONLINE",$lng->txt("show_users_online"));
00866 }
00867 $tpl->setVariable("TXT_PERSONAL_DATA", $lng->txt("personal_data"));
00868 $tpl->setVariable("TXT_SYSTEM_INFO", $lng->txt("system_information"));
00869 $tpl->setVariable("TXT_CONTACT_DATA", $lng->txt("contact_data"));
00870 if (userSettingVisible("matriculation"))
00871 {
00872         $tpl->setVariable("TXT_OTHER", $lng->txt("user_profile_other"));
00873 }
00874 $tpl->setVariable("TXT_SETTINGS", $lng->txt("settings"));
00875 
00876 //values
00877 $tpl->setVariable("NICKNAME", ilUtil::prepareFormOutput($ilias->account->getLogin()));
00878 //$tpl->setVariable("NICKNAME", ilUtil::prepareFormOutput($ilias->account->getLogin()." (#".$ilias->account->getId().")"));
00879 
00880 if (userSettingVisible("firstname"))
00881 {
00882         $tpl->setVariable("FIRSTNAME", ilUtil::prepareFormOutput($ilias->account->getFirstname()));
00883 }
00884 if (userSettingVisible("lastname"))
00885 {
00886         $tpl->setVariable("LASTNAME", ilUtil::prepareFormOutput($ilias->account->getLastname()));
00887 }
00888 
00889 if (userSettingVisible("gender"))
00890 {
00891         // gender selection
00892         $gender = strtoupper($ilias->account->getGender());
00893         
00894         if (!empty($gender))
00895         {
00896                 $tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00897         }
00898 }
00899 
00900 $tpl->setVariable("CREATE_DATE", $ilias->account->getCreateDate());
00901 $tpl->setVariable("APPROVE_DATE", $ilias->account->getApproveDate());
00902 
00903 if ($ilias->account->getActive())
00904 {
00905     $tpl->setVariable("ACTIVE", "checked=\"checked\"");
00906 }
00907 
00908 if (userSettingVisible("title"))
00909 {
00910         $tpl->setVariable("TITLE", ilUtil::prepareFormOutput($ilias->account->getUTitle()));
00911 }
00912 if (userSettingVisible("institution"))
00913 {
00914         $tpl->setVariable("INSTITUTION", ilUtil::prepareFormOutput($ilias->account->getInstitution()));
00915 }
00916 if (userSettingVisible("department"))
00917 {
00918         $tpl->setVariable("DEPARTMENT", ilUtil::prepareFormOutput($ilias->account->getDepartment()));
00919 }
00920 if (userSettingVisible("street"))
00921 {
00922         $tpl->setVariable("STREET", ilUtil::prepareFormOutput($ilias->account->getStreet()));
00923 }
00924 if (userSettingVisible("zipcode"))
00925 {
00926         $tpl->setVariable("ZIPCODE", ilUtil::prepareFormOutput($ilias->account->getZipcode()));
00927 }
00928 if (userSettingVisible("city"))
00929 {
00930         $tpl->setVariable("CITY", ilUtil::prepareFormOutput($ilias->account->getCity()));
00931 }
00932 if (userSettingVisible("country"))
00933 {
00934         $tpl->setVariable("COUNTRY", ilUtil::prepareFormOutput($ilias->account->getCountry()));
00935 }
00936 if (userSettingVisible("phone_office"))
00937 {
00938         $tpl->setVariable("PHONE_OFFICE", ilUtil::prepareFormOutput($ilias->account->getPhoneOffice()));
00939 }
00940 if (userSettingVisible("phone_home"))
00941 {
00942         $tpl->setVariable("PHONE_HOME", ilUtil::prepareFormOutput($ilias->account->getPhoneHome()));
00943 }
00944 if (userSettingVisible("phone_mobile"))
00945 {
00946         $tpl->setVariable("PHONE_MOBILE", ilUtil::prepareFormOutput($ilias->account->getPhoneMobile()));
00947 }
00948 if (userSettingVisible("fax"))
00949 {
00950         $tpl->setVariable("FAX", ilUtil::prepareFormOutput($ilias->account->getFax()));
00951 }
00952 if (userSettingVisible("email"))
00953 {
00954         $tpl->setVariable("EMAIL", ilUtil::prepareFormOutput($ilias->account->getEmail()));
00955 }
00956 if (userSettingVisible("hobby"))
00957 {
00958         $tpl->setVariable("HOBBY", ilUtil::prepareFormOutput($ilias->account->getHobby()));             // here
00959 }
00960 if (userSettingVisible("referral_comment"))
00961 {
00962         $tpl->setVariable("REFERRAL_COMMENT", ilUtil::prepareFormOutput($ilias->account->getComment()));
00963 }
00964 if (userSettingVisible("matriculation"))
00965 {
00966         $tpl->setVariable("MATRICULATION", ilUtil::prepareFormOutput($ilias->account->getMatriculation()));
00967 }
00968 
00969 // get assigned global roles (default roles)
00970 $global_roles = $rbacreview->getGlobalRoles();
00971 
00972 foreach($global_roles as $role_id)
00973 {
00974         if (in_array($role_id,$_SESSION["RoleId"]))
00975         {
00976                 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
00977                 $role_names .= $roleObj->getTitle().", ";
00978                 unset($roleObj);
00979         }
00980 }
00981 
00982 $tpl->setVariable("TXT_DEFAULT_ROLES",$lng->txt("default_roles"));
00983 $tpl->setVariable("DEFAULT_ROLES",substr($role_names,0,-2));
00984 
00985 $tpl->setVariable("TXT_REQUIRED_FIELDS",$lng->txt("required_field"));
00986 //button
00987 $tpl->setVariable("TXT_SAVE",$lng->txt("save"));
00988 // addeding by ratana ty
00989 if (userSettingEnabled("upload"))
00990 {
00991         $tpl->setVariable("UPLOAD", $lng->txt("upload"));
00992 }
00993 // end adding
00994 // Testing by ratana ty
00995 // Show check if value in table usr_pref is y
00996 //
00997 if ($ilias->account->prefs["public_profile"]=="y")
00998 {
00999         $tpl->setVariable("CHK_PUB","checked");
01000 }
01001 $val_array = array("institution", "department", "upload", "street",
01002         "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
01003         "fax", "email", "hobby", "matriculation", "show_users_online");
01004 foreach($val_array as $key => $value)
01005 {
01006         if (userSettingVisible("$value"))
01007         {
01008                 if ($ilias->account->prefs["public_".$value] == "y")
01009                 {
01010                         $tpl->setVariable("CHK_".strtoupper($value), "checked");
01011                 }
01012         }
01013 }
01014 // End of showing
01015 // Testing by ratana ty
01016 
01017 
01018 $profile_fields = array(
01019         "gender",
01020         "firstname",
01021         "lastname",
01022         "title",
01023         "upload",
01024         "institution",
01025         "department",
01026         "street",
01027         "city",
01028         "zipcode",
01029         "country",
01030         "phone_office",
01031         "phone_home",
01032         "phone_mobile",
01033         "fax",
01034         "email",
01035         "hobby",
01036         "matriculation",
01037         "referral_comment",
01038         "language",
01039         "skin_style",
01040         "hits_per_page",
01041         "show_users_online"
01042 );
01043 foreach ($profile_fields as $field)
01044 {
01045         if (!$ilias->getSetting("usr_settings_hide_" . $field))
01046         {
01047                 if ($ilias->getSetting("usr_settings_disable_" . $field))
01048                 {
01049                         $tpl->setVariable("DISABLED_" . strtoupper($field), " disabled=\"disabled\"");
01050                 }
01051         }
01052 }
01053 
01054 $tpl->parseCurrentBlock();
01055 $tpl->show();
01056 ?>

Generated on Fri Dec 13 2013 10:18:34 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1