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

Generated on Fri Dec 13 2013 08:00:20 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1