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

Generated on Fri Dec 13 2013 11:58:04 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1