• 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                         $ilias->account->setLanguage($_POST["usr_language"]);
00504 
00505                         // reload page if language was changed
00506                         if ($_POST["usr_language"] != "" and $_POST["usr_language"] != $_SESSION['lang'])
00507                         {
00508                                 $reload = true;
00509                         }
00510                 }
00511                 
00512                 // set user hits per page
00513                 if ($_POST["usr_hits_per_page"] != "")
00514                 {
00515                         $ilias->account->setPref("hits_per_page",$_POST["usr_hits_per_page"]);
00516                 }
00517 
00518                 // set user hits per page
00519                 if ($_POST["show_users_online"] == "y")
00520                 {
00521                         $ilias->account->setPref("show_users_online", "y");
00522                 }
00523                 else
00524                 {
00525                         $ilias->account->setPref("show_users_online", "n");
00526                 }
00527 
00528                 // save user data & object_data
00529                 $ilias->account->setTitle($ilias->account->getFullname());
00530                 $ilias->account->setDescription($ilias->account->getEmail());
00531                 $ilias->account->update();
00532 
00533                 // reload page only if skin or style were changed
00534                 if ($reload)
00535                 {
00536                         // feedback
00537                         sendInfo($lng->txt("saved_successfully"),true);
00538                         $tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./start.php\";\n</script>\n");
00539                 }
00540                 else
00541                 {
00542                         // feedback
00543                         if (!empty($password_error))
00544                         {
00545                                 sendInfo($password_error,true);
00546                         }
00547                         elseif (!empty($upload_error))
00548                         {
00549                                 sendInfo($upload_error,true);
00550                         }
00551                         else
00552                         {
00553                                 sendInfo($lng->txt("saved_successfully"),true);
00554                         }
00555                         
00556                         ilUtil::redirect("usr_profile.php");
00557                 }
00558 
00559         }
00560 }
00561 
00562 if (userSettingVisible("language"))
00563 {
00564         //get all languages
00565         $languages = $lng->getInstalledLanguages();
00566         
00567         // preselect previous chosen language otherwise saved language
00568         $selected_lang = (isset($_POST["usr_language"])) ? $_POST["usr_language"] : $ilias->account->getLanguage();
00569         
00570         //go through languages
00571         foreach($languages as $lang_key)
00572         {
00573                 $tpl->setCurrentBlock("sel_lang");
00574                 $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00575                 $tpl->setVariable("LANGSHORT", $lang_key);
00576         
00577                 if ($selected_lang == $lang_key)
00578                 {
00579                         $tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00580                 }
00581         
00582                 $tpl->parseCurrentBlock();
00583         }
00584 }
00585 
00586 // get all templates
00587 include_once("classes/class.ilObjStyleSettings.php");
00588 $templates = $styleDefinition->getAllTemplates();
00589 
00590 if (userSettingVisible("skin_style"))
00591 {
00592         foreach($templates as $template)
00593         {
00594                 // get styles information of template
00595                 $styleDef =& new ilStyleDefinition($template["id"]);
00596                 $styleDef->startParsing();
00597                 $styles = $styleDef->getStyles();
00598         
00599                 foreach($styles as $style)
00600                 {
00601                         if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
00602                         {
00603                                 continue;
00604                         }
00605                         
00606                         $tpl->setCurrentBlock("selectskin");
00607         
00608                         if ($ilias->account->skin == $template["id"] &&
00609                                 $ilias->account->prefs["style"] == $style["id"])
00610                         {
00611                                 $tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00612                         }
00613         
00614                         $tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00615                         $tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00616                         $tpl->parseCurrentBlock();
00617                 }
00618         }
00619 }
00620 
00621 // hits per page
00622 $hits_options = array(2,10,15,20,30,40,50,100,9999);
00623 
00624 foreach($hits_options as $hits_option)
00625 {
00626         $tpl->setCurrentBlock("selecthits");
00627 
00628         if ($ilias->account->prefs["hits_per_page"] == $hits_option)
00629         {
00630                 $tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
00631         }
00632 
00633         $tpl->setVariable("HITSVALUE", $hits_option);
00634 
00635         if ($hits_option == 9999)
00636         {
00637                 $hits_option = $lng->txt("no_limit");
00638         }
00639 
00640         $tpl->setVariable("HITSOPTION", $hits_option);
00641         $tpl->parseCurrentBlock();
00642 }
00643 
00644 if (AUTH_CURRENT == AUTH_LOCAL and userSettingVisible('password'))
00645 {
00646         if($ilias->getSetting('usr_settings_disable_password'))
00647         {
00648         $tpl->setCurrentBlock("disabled_password");
00649         $tpl->setVariable("TXT_DISABLED_PASSWORD", $lng->txt("chg_password"));
00650         $tpl->setVariable("TXT_DISABLED_CURRENT_PASSWORD", $lng->txt("current_password"));
00651                 $tpl->parseCurrentBlock();
00652         }
00653         elseif ($settings["passwd_auto_generate"] == 1)
00654         {
00655             $passwd_list = ilUtil::generatePasswords(5);
00656      
00657         foreach ($passwd_list as $passwd)
00658         {
00659             $passwd_choice .= ilUtil::formRadioButton(0,"new_passwd",$passwd)." ".$passwd."<br/>";
00660         }
00661 
00662         $tpl->setCurrentBlock("select_password");
00663         $tpl->setVariable("TXT_CHANGE_PASSWORD", $lng->txt("chg_password"));
00664         $tpl->setVariable("TXT_CURRENT_PASSWORD", $lng->txt("current_password"));
00665         $tpl->setVariable("TXT_SELECT_PASSWORD", $lng->txt("select_password"));
00666         $tpl->setVariable("PASSWORD_CHOICE", $passwd_choice);
00667         $tpl->setVariable("TXT_NEW_LIST_PASSWORD", $lng->txt("new_list_password"));
00668         $tpl->parseCurrentBlock();
00669         }
00670         else
00671         {
00672         $tpl->setCurrentBlock("change_password");
00673         $tpl->setVariable("TXT_CHANGE_PASSWORD", $lng->txt("chg_password"));
00674         $tpl->setVariable("TXT_CURRENT_PW", $lng->txt("current_password"));
00675         $tpl->setVariable("TXT_DESIRED_PW", $lng->txt("desired_password"));
00676         $tpl->setVariable("TXT_RETYPE_PW", $lng->txt("retype_password"));
00677         $tpl->setVariable("CHANGE_PASSWORD",$lng->txt("chg_password"));
00678         $tpl->parseCurrentBlock();
00679         }
00680 }
00681 
00682 $tpl->setCurrentBlock("content");
00683 $tpl->setVariable("FORMACTION", "usr_profile.php?cmd=save");
00684 
00685 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("personal_desktop"));
00686 $tpl->setVariable("TXT_OF",strtolower($lng->txt("of")));
00687 $tpl->setVariable("USR_FULLNAME",$ilias->account->getFullname());
00688 
00689 $tpl->setVariable("TXT_USR_DATA", $lng->txt("userdata"));
00690 $tpl->setVariable("TXT_NICKNAME", $lng->txt("username"));
00691 $tpl->setVariable("TXT_PUBLIC_PROFILE", $lng->txt("public_profile"));
00692 
00693 $data = array();
00694 $data["fields"] = array();
00695 $data["fields"]["gender"] = "";
00696 $data["fields"]["firstname"] = "";
00697 $data["fields"]["lastname"] = "";
00698 $data["fields"]["title"] = "";
00699 $data["fields"]["institution"] = "";
00700 $data["fields"]["department"] = "";
00701 $data["fields"]["street"] = "";
00702 $data["fields"]["city"] = "";
00703 $data["fields"]["zipcode"] = "";
00704 $data["fields"]["country"] = "";
00705 $data["fields"]["phone_office"] = "";
00706 $data["fields"]["phone_home"] = "";
00707 $data["fields"]["phone_mobile"] = "";
00708 $data["fields"]["fax"] = "";
00709 $data["fields"]["email"] = "";
00710 $data["fields"]["hobby"] = "";
00711 $data["fields"]["referral_comment"] = "";
00712 $data["fields"]["matriculation"] = "";
00713 $data["fields"]["create_date"] = "";
00714 $data["fields"]["approve_date"] = "";
00715 $data["fields"]["active"] = "";
00716 
00717 $data["fields"]["default_role"] = $role;
00718 // fill presets
00719 foreach($data["fields"] as $key => $val)
00720 {
00721         // note: general "title" is not as "title" for a person
00722         if ($key != "title")
00723         {
00724                 $str = $lng->txt($key);
00725         }
00726         else
00727         {
00728                 $str = $lng->txt("person_title");
00729         }
00730 
00731         // check to see if dynamically required
00732         if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00733         {
00734                                 $str = $str . '<span class="asterisk">*</span>';
00735         }
00736 
00737         if (userSettingVisible("$key"))
00738         {
00739                 $tpl->setVariable("TXT_".strtoupper($key), $str);
00740         }
00741 }
00742 
00743 if (userSettingVisible("gender"))
00744 {
00745         $tpl->setVariable("TXT_GENDER_F",$lng->txt("gender_f"));
00746         $tpl->setVariable("TXT_GENDER_M",$lng->txt("gender_m"));
00747 }
00748 
00749 // todo
00750 // capture image name including path ($archive_dir/$filename)
00751 //$tpl->setVariable("IMAGE_PATH",$return_path);
00752 //$tpl->setVariable("IMAGE_PATH",'$archive_dir."/".$filename');
00753 
00754 if (userSettingVisible("upload"))
00755 {
00756         $tpl->setVariable("TXT_UPLOAD",$lng->txt("personal_picture"));
00757         $webspace_dir = ilUtil::getWebspaceDir("output");
00758         $full_img = $ilias->account->getPref("profile_image");
00759         $last_dot = strrpos($full_img, ".");
00760         $small_img = substr($full_img, 0, $last_dot).
00761                         "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
00762         $image_file = $webspace_dir."/usr_images/".$small_img;
00763         
00764         if (@is_file($image_file))
00765         {
00766                         $tpl->setCurrentBlock("pers_image");
00767                         $tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
00768                         $tpl->parseCurrentBlock();
00769                         $tpl->setCurrentBlock("remove_pic");
00770                         $tpl->setVariable("TXT_REMOVE_PIC",$lng->txt("remove_personal_picture"));
00771                         $tpl->parseCurrentBlock();
00772                         $tpl->setCurrentBlock("content");
00773         }
00774         
00775         $tpl->setVariable("UPLOAD",$lng->txt("upload"));
00776         $tpl->setVariable("TXT_FILE", $lng->txt("userfile"));
00777         $tpl->setVariable("USER_FILE", $lng->txt("user_file"));
00778 }
00779 
00780 if (userSettingVisible("language"))
00781 {
00782         $tpl->setVariable("TXT_LANGUAGE",$lng->txt("language"));
00783 }
00784 if (userSettingVisible("skin_style"))
00785 {
00786         $tpl->setVariable("TXT_USR_SKIN_STYLE",$lng->txt("usr_skin_style"));
00787 }
00788 $tpl->setVariable("TXT_USR_HITS_PER_PAGE",$lng->txt("usr_hits_per_page"));
00789 $tpl->setVariable("TXT_SHOW_USERS_ONLINE",$lng->txt("show_users_online"));
00790 $tpl->setVariable("TXT_PERSONAL_DATA", $lng->txt("personal_data"));
00791 $tpl->setVariable("TXT_SYSTEM_INFO", $lng->txt("system_information"));
00792 $tpl->setVariable("TXT_CONTACT_DATA", $lng->txt("contact_data"));
00793 if (userSettingVisible("matriculation"))
00794 {
00795         $tpl->setVariable("TXT_OTHER", $lng->txt("user_profile_other"));
00796 }
00797 $tpl->setVariable("TXT_SETTINGS", $lng->txt("settings"));
00798 
00799 //values
00800 $tpl->setVariable("NICKNAME", ilUtil::prepareFormOutput($ilias->account->getLogin()));
00801 if (userSettingVisible("firstname"))
00802 {
00803         $tpl->setVariable("FIRSTNAME", ilUtil::prepareFormOutput($ilias->account->getFirstname()));
00804 }
00805 if (userSettingVisible("lastname"))
00806 {
00807         $tpl->setVariable("LASTNAME", ilUtil::prepareFormOutput($ilias->account->getLastname()));
00808 }
00809 
00810 if (userSettingVisible("gender"))
00811 {
00812         // gender selection
00813         $gender = strtoupper($ilias->account->getGender());
00814         
00815         if (!empty($gender))
00816         {
00817                 $tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00818         }
00819 }
00820 
00821 $tpl->setVariable("CREATE_DATE", $ilias->account->getCreateDate());
00822 $tpl->setVariable("APPROVE_DATE", $ilias->account->getApproveDate());
00823 
00824 if ($ilias->account->getActive())
00825 {
00826     $tpl->setVariable("ACTIVE", "checked=\"checked\"");
00827 }
00828 
00829 if (userSettingVisible("title"))
00830 {
00831         $tpl->setVariable("TITLE", ilUtil::prepareFormOutput($ilias->account->getUTitle()));
00832 }
00833 if (userSettingVisible("institution"))
00834 {
00835         $tpl->setVariable("INSTITUTION", ilUtil::prepareFormOutput($ilias->account->getInstitution()));
00836 }
00837 if (userSettingVisible("department"))
00838 {
00839         $tpl->setVariable("DEPARTMENT", ilUtil::prepareFormOutput($ilias->account->getDepartment()));
00840 }
00841 if (userSettingVisible("street"))
00842 {
00843         $tpl->setVariable("STREET", ilUtil::prepareFormOutput($ilias->account->getStreet()));
00844 }
00845 if (userSettingVisible("zipcode"))
00846 {
00847         $tpl->setVariable("ZIPCODE", $ilias->account->getZipcode());
00848 }
00849 if (userSettingVisible("city"))
00850 {
00851         $tpl->setVariable("CITY", ilUtil::prepareFormOutput($ilias->account->getCity()));
00852 }
00853 if (userSettingVisible("country"))
00854 {
00855         $tpl->setVariable("COUNTRY", ilUtil::prepareFormOutput($ilias->account->getCountry()));
00856 }
00857 if (userSettingVisible("phone_office"))
00858 {
00859         $tpl->setVariable("PHONE_OFFICE", $ilias->account->getPhoneOffice());
00860 }
00861 if (userSettingVisible("phone_home"))
00862 {
00863         $tpl->setVariable("PHONE_HOME", $ilias->account->getPhoneHome());
00864 }
00865 if (userSettingVisible("phone_mobile"))
00866 {
00867         $tpl->setVariable("PHONE_MOBILE", $ilias->account->getPhoneMobile());
00868 }
00869 if (userSettingVisible("fax"))
00870 {
00871         $tpl->setVariable("FAX", $ilias->account->getFax());
00872 }
00873 if (userSettingVisible("email"))
00874 {
00875         $tpl->setVariable("EMAIL", $ilias->account->getEmail());
00876 }
00877 if (userSettingVisible("hobby"))
00878 {
00879         $tpl->setVariable("HOBBY", ilUtil::stripSlashes($ilias->account->getHobby()));          // here
00880 }
00881 if (userSettingVisible("referral_comment"))
00882 {
00883         $tpl->setVariable("REFERRAL_COMMENT", ilUtil::stripSlashes($ilias->account->getComment()));
00884 }
00885 if (userSettingVisible("matriculation"))
00886 {
00887         $tpl->setVariable("MATRICULATION", $ilias->account->getMatriculation());
00888 }
00889 
00890 // get assigned global roles (default roles)
00891 $global_roles = $rbacreview->getGlobalRoles();
00892 
00893 foreach($global_roles as $role_id)
00894 {
00895         if (in_array($role_id,$_SESSION["RoleId"]))
00896         {
00897                 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
00898                 $role_names .= $roleObj->getTitle().", ";
00899                 unset($roleObj);
00900         }
00901 }
00902 
00903 $tpl->setVariable("TXT_DEFAULT_ROLES",$lng->txt("default_roles"));
00904 $tpl->setVariable("DEFAULT_ROLES",substr($role_names,0,-2));
00905 
00906 $tpl->setVariable("TXT_REQUIRED_FIELDS",$lng->txt("required_field"));
00907 //button
00908 $tpl->setVariable("TXT_SAVE",$lng->txt("save"));
00909 // addeding by ratana ty
00910 if (userSettingVisible("upload"))
00911 {
00912         $tpl->setVariable("UPLOAD", $lng->txt("upload"));
00913 }
00914 // end adding
00915 // Testing by ratana ty
00916 // Show check if value in table usr_pref is y
00917 //
00918 if ($ilias->account->prefs["public_profile"]=="y")
00919 {
00920         $tpl->setVariable("CHK_PUB","checked");
00921 }
00922 
00923 $val_array = array("institution", "department", "upload", "street",
00924         "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
00925         "fax", "email", "hobby", "matriculation");
00926 
00927 foreach($val_array as $key => $value)
00928 {
00929         if (userSettingVisible("$value"))
00930         {
00931                 if ($ilias->account->prefs["public_".$value] == "y")
00932                 {
00933                         $tpl->setVariable("CHK_".strtoupper($value), "checked");
00934                 }
00935         }
00936 }
00937 // End of showing
00938 // Testing by ratana ty
00939 
00940 if ($ilias->account->prefs["show_users_online"] == "y")
00941 {
00942         $tpl->setVariable("CHK_SHOW_USERS_ONLINE", "checked");
00943 }
00944 
00945 $profile_fields = array(
00946         "gender",
00947         "firstname",
00948         "lastname",
00949         "title",
00950         "upload",
00951         "institution",
00952         "department",
00953         "street",
00954         "city",
00955         "zipcode",
00956         "country",
00957         "phone_office",
00958         "phone_home",
00959         "phone_mobile",
00960         "fax",
00961         "email",
00962         "hobby",
00963         "matriculation",
00964         "referral_comment",
00965         "language",
00966         "skin_style"
00967 );
00968 foreach ($profile_fields as $field)
00969 {
00970         if (!$ilias->getSetting("usr_settings_hide_" . $field))
00971         {
00972                 if ($ilias->getSetting("usr_settings_disable_" . $field))
00973                 {
00974                         $tpl->setVariable("DISABLED_" . strtoupper($field), " disabled=\"disabled\"");
00975                 }
00976         }
00977 }
00978 
00979 $tpl->parseCurrentBlock();
00980 $tpl->show();
00981 ?>

Generated on Fri Dec 13 2013 09:06:40 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1