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

classes/class.ilObjUserGUI.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 
00036 require_once "class.ilObjectGUI.php";
00037 
00038 class ilObjUserGUI extends ilObjectGUI
00039 {
00040         var $ilCtrl;
00041 
00047         var $gender;
00048 
00054         var $type;
00055 
00061         var $user_ref_id;
00062 
00067         function ilObjUserGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
00068         {
00069                 global $ilCtrl;
00070 
00071                 define('USER_FOLDER_ID',7);
00072 
00073                 $this->type = "usr";
00074                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output);
00075                 $this->usrf_ref_id =& $this->ref_id;
00076 
00077                 $this->ctrl =& $ilCtrl;
00078                 $this->ctrl->saveParameter($this,'obj_id');
00079 
00080                 // for gender selection. don't change this
00081                 // maybe deprecated
00082                 $this->gender = array(
00083                                                           'm'    => "salutation_m",
00084                                                           'f'    => "salutation_f"
00085                                                           );
00086         }
00087 
00088         function &executeCommand()
00089         {
00090                 global $rbacsystem;
00091 
00092                 $next_class = $this->ctrl->getNextClass($this);
00093                 $cmd = $this->ctrl->getCmd();
00094                 switch($next_class)
00095                 {
00096                         default:
00097                                 if(!$cmd)
00098                                 {
00099                                         $cmd = "view";
00100                                 }
00101                                 $cmd .= "Object";
00102                                 $this->$cmd();
00103                                         
00104                                 break;
00105                 }
00106                 return true;
00107         }
00108 
00109 
00110         function cancelObject()
00111         {
00112                 session_unregister("saved_post");
00113 
00114                 sendInfo($this->lng->txt("msg_cancel"),true);
00115 
00116                 if($this->ctrl->getTargetScript() == 'adm_object.php')
00117                 {
00118                         $return_location = $_GET["cmd_return_location"];
00119                         ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
00120                 }
00121                 else
00122                 {
00123                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
00124                 }
00125         }
00126 
00130         function createObject()
00131         {
00132                 global $ilias, $rbacsystem, $rbacreview, $styleDefinition;
00133                 //load ILIAS settings
00134                 $settings = $ilias->getAllSettings();
00135                 
00136                 if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
00137                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
00138                 {
00139                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00140                 }
00141                 
00142                 // role selection
00143                 $obj_list = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
00144                 $rol = array();
00145                 foreach ($obj_list as $obj_data)
00146                 {
00147                         // allow only 'assign_users' marked roles if called from category
00148                         if($this->object->getRefId() != USER_FOLDER_ID and !in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00149                         {
00150                                 include_once './classes/class.ilObjRole.php';
00151                 
00152                                 if(!ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
00153                                 {
00154                                         continue;
00155                                 }
00156                         }
00157                         // exclude anonymous role from list
00158                         if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
00159                         {
00160                                 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
00161                                 if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00162                                 {
00163                                         $rol[$obj_data["obj_id"]] = $obj_data["title"];
00164                                 }
00165                         }
00166                 }
00167                 
00168                 // raise error if there is no global role user can be assigned to
00169                 if(!count($rol))
00170                 {
00171                         $this->ilias->raiseError($this->lng->txt("msg_no_roles_users_can_be_assigned_to"),$this->ilias->error_obj->MESSAGE);
00172                 }
00173                 
00174                 $keys = array_keys($rol);
00175                 
00176                 // set pre defined user role to default
00177                 if (in_array(4,$keys))
00178                 {
00179                         $default_role = 4;
00180                 }
00181                 else
00182                 {
00183                         if (count($keys) > 1 and in_array(2,$keys))
00184                         {
00185                                 // remove admin role as preselectable role
00186                                 foreach ($keys as $key => $val)
00187                                 {
00188                                         if ($val == 2)
00189                                         {
00190                                                 unset($keys[$key]);
00191                                                 break;
00192                                         }
00193                                 }
00194                         }
00195                 
00196                         $default_role = array_shift($keys);
00197                 }
00198                 
00199                 $pre_selected_role = (isset($_SESSION["error_post_vars"]["Fobject"]["default_role"])) ? $_SESSION["error_post_vars"]["Fobject"]["default_role"] : $default_role;
00200                 
00201                 $roles = ilUtil::formSelect($pre_selected_role,"Fobject[default_role]",$rol,false,true);
00202                 
00203                 $data = array();
00204                 $data["fields"] = array();
00205                 $data["fields"]["login"] = "";
00206                 $data["fields"]["passwd"] = "";
00207                 $data["fields"]["passwd2"] = "";
00208                 $data["fields"]["title"] = "";
00209                 $data["fields"]["gender"] = "";
00210                 $data["fields"]["firstname"] = "";
00211                 $data["fields"]["lastname"] = "";
00212                 $data["fields"]["institution"] = "";
00213                 $data["fields"]["department"] = "";
00214                 $data["fields"]["street"] = "";
00215                 $data["fields"]["city"] = "";
00216                 $data["fields"]["zipcode"] = "";
00217                 $data["fields"]["country"] = "";
00218                 $data["fields"]["phone_office"] = "";
00219                 $data["fields"]["phone_home"] = "";
00220                 $data["fields"]["phone_mobile"] = "";
00221                 $data["fields"]["fax"] = "";
00222                 $data["fields"]["email"] = "";
00223                 $data["fields"]["hobby"] = "";
00224                 $data["fields"]["matriculation"] = "";
00225                 $data["fields"]["client_ip"] = "";
00226                 $data["fields"]["referral_comment"] = "";
00227                 $data["fields"]["create_date"] = "";
00228                 $data["fields"]["approve_date"] = "";
00229                 $data["fields"]["active"] = " checked=\"checked\"";
00230                 $data["fields"]["default_role"] = $roles;
00231                 $data["fields"]["auth_mode"] = "";
00232                 
00233                 $this->getTemplateFile("edit","usr");
00234                 
00235                 // fill presets
00236                 foreach ($data["fields"] as $key => $val)
00237                 {
00238                         $str = $this->lng->txt($key);
00239                         if ($key == "title")
00240                         {
00241                                 $str = $this->lng->txt("person_title");
00242                         }
00243                 
00244                         // check to see if dynamically required
00245                         if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00246                         {
00247                                 $str = $str . '<span class="asterisk">*</span>';
00248                         }
00249                 
00250                         $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00251                 
00252                         if ($key == "default_role")
00253                         {
00254                                 $this->tpl->setVariable(strtoupper($key), $val);
00255                         }
00256                         else
00257                         {
00258                                 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00259                         }
00260                 
00261                         if ($this->prepare_output)
00262                         {
00263                                 $this->tpl->parseCurrentBlock();
00264                         }
00265                 }
00266                 
00267                 $this->ctrl->setParameter($this,'new_type',$this->type);
00268                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));                
00269                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->type."_new"));
00270                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00271                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($this->type."_add"));
00272                 $this->tpl->setVariable("CMD_SUBMIT", "save");
00273                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00274                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00275                 
00276                 $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
00277                 $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
00278                 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
00279                 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
00280                 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
00281                 $this->tpl->setVariable("TXT_PASSWD2", $this->lng->txt("retype_password"));
00282                 $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
00283                 $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
00284                 $this->tpl->setVariable("TXT_HITS_PER_PAGE",$this->lng->txt("usr_hits_per_page"));
00285                 $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE",$this->lng->txt("show_users_online"));
00286                 $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
00287                 $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
00288                 $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
00289                 
00290                 //$this->tpl->setVariable("TXT_CURRENT_IP",$this->lng->txt("current_ip").
00291                 //      $_SERVER["REMOTE_ADDR"]);
00292                 $this->tpl->setVariable("TXT_CURRENT_IP_ALERT",$this->lng->txt("current_ip_alert"));
00293 
00294                 // FILL SAVED VALUES IN CASE OF ERROR
00295                 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00296                 {
00297                         if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
00298                         {
00299                                 $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
00300                         }
00301                 
00302                         foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
00303                         {
00304                                 if ($key != "default_role" and $key != "language" 
00305                                         and $key != "skin_style" and $key != "hits_per_page"
00306                                         and $key != "show_users_online")
00307                                 {
00308                                         $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00309                                 }
00310                         }
00311                 
00312                         // gender selection
00313                         $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00314                 
00315                         if (!empty($gender))
00316                         {
00317                                 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00318                         }
00319 
00320                         $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
00321                         if ($active)
00322                         {
00323                                 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00324                         }
00325                 }
00326                 
00327                 // auth mode selection
00328                 include_once('classes/class.ilAuthUtils.php');
00329                 $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
00330 
00331                 // preselect previous chosen auth mode otherwise default auth mode
00332                 $selected_auth_mode = (isset($_SESSION["error_post_vars"]["Fobject"]["auth_mode"])) ? $_SESSION["error_post_vars"]["Fobject"]["auth_mode"] : 'default';
00333 
00334                 foreach ($active_auth_modes as $auth_name => $auth_key)
00335                 {
00336                         $this->tpl->setCurrentBlock("auth_mode_selection");
00337 
00338                         if ($auth_name == 'default')
00339                         {
00340                                 $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
00341                         }
00342                         else
00343                         {
00344                                 $name = $this->lng->txt('auth_'.$auth_name);
00345                         }
00346                         
00347                         $this->tpl->setVariable("AUTH_MODE_NAME", $name);
00348 
00349                         $this->tpl->setVariable("AUTH_MODE", $auth_name);
00350 
00351                         if ($selected_auth_mode == $auth_name)
00352                         {
00353                                 $this->tpl->setVariable("SELECTED_AUTH_MODE", "selected=\"selected\"");
00354                         }
00355 
00356                         $this->tpl->parseCurrentBlock();
00357                 } // END auth_mode selection
00358                 
00359                 // language selection
00360                 $languages = $this->lng->getInstalledLanguages();
00361                 
00362                 // preselect previous chosen language otherwise default language
00363                 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->ilias->getSetting("language");
00364                 
00365                 foreach ($languages as $lang_key)
00366                 {
00367                         $this->tpl->setCurrentBlock("language_selection");
00368                         $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
00369                         $this->tpl->setVariable("LANGSHORT", $lang_key);
00370                 
00371                         if ($selected_lang == $lang_key)
00372                         {
00373                                 $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00374                         }
00375                 
00376                         $this->tpl->parseCurrentBlock();
00377                 } // END language selection
00378                 
00379                 // skin & style selection
00380                 $templates = $styleDefinition->getAllTemplates();
00381                 //$this->ilias->getSkins();
00382 
00383                 // preselect previous chosen skin/style otherwise default skin/style
00384                 if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
00385                 {
00386                         $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
00387                 
00388                         $selected_style = $sknst[1];
00389                         $selected_skin = $sknst[0];
00390                 }
00391                 else
00392                 {
00393                         $selected_style = $this->ilias->ini->readVariable("layout","style");;
00394                         $selected_skin = $this->ilias->ini->readVariable("layout","skin");;
00395                 }
00396                 include_once("classes/class.ilObjStyleSettings.php");
00397                 foreach ($templates as $template)
00398                 {
00399                         // get styles for skin
00400                         //$this->ilias->getStyles($template["id"]);
00401                         $styleDef =& new ilStyleDefinition($template["id"]);
00402                         $styleDef->startParsing();
00403                         $styles = $styleDef->getStyles();
00404                 
00405                         foreach($styles as $style)
00406                         {
00407                                 if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
00408                                 {
00409                                         continue;
00410                                 }
00411 
00412                                 $this->tpl->setCurrentBlock("selectskin");
00413                 
00414                                 if ($selected_skin == $template["id"] &&
00415                                         $selected_style == $style["id"])
00416                                 {
00417                                         $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00418                                 }
00419                 
00420                                 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00421                                 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00422                                 $this->tpl->parseCurrentBlock();
00423                         }
00424                 } // END skin & style selection
00425 
00426                 // BEGIN hits per page
00427                 $hits_options = array(2,10,15,20,30,40,50,100,9999);
00428                 // preselect previous chosen option otherwise default option
00429                 if (isset($_SESSION["error_post_vars"]["Fobject"]["hits_per_page"]))
00430                 {
00431                         $selected_option = $_SESSION["error_post_vars"]["Fobject"]["hits_per_page"];
00432                 }
00433                 else
00434                 {
00435                         $selected_option = $this->ilias->getSetting("hits_per_page");
00436                 }
00437                 foreach($hits_options as $hits_option)
00438                 {
00439                         $this->tpl->setCurrentBlock("selecthits");
00440 
00441                         if ($hits_option == $selected_option)
00442                         {
00443                                 $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
00444                         }
00445 
00446                         $this->tpl->setVariable("HITSVALUE", $hits_option);
00447 
00448                         if ($hits_option == 9999)
00449                         {
00450                                 $hits_option = $this->lng->txt("no_limit");
00451                         }
00452 
00453                         $this->tpl->setVariable("HITSOPTION", $hits_option);
00454                         $this->tpl->parseCurrentBlock();
00455                 }
00456                 // END hits per page
00457 
00458                 // BEGIN show users online
00459                 // preselect previous chosen option otherwise default option
00460                 if (isset($_SESSION["error_post_vars"]["Fobject"]["show_users_online"]))
00461                 {
00462                         $selected_option = $_SESSION["error_post_vars"]["Fobject"]["show_users_online"];
00463                 }
00464                 else
00465                 {
00466                         $selected_option = $this->ilias->getSetting("show_users_online");
00467                 }
00468                 $users_online_options = array("y","associated","n");
00469                 foreach($users_online_options as $an_option)
00470                 {
00471                         $this->tpl->setCurrentBlock("show_users_online");
00472                         
00473                         if ($selected_option == $an_option)
00474                         {
00475                                 $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
00476                         }
00477 
00478                         $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
00479 
00480                         $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
00481                         $this->tpl->parseCurrentBlock();
00482                 }
00483                 // END show users online
00484                 
00485                 // time limit
00486                 if (is_array($_SESSION["error_post_vars"]))
00487                 {
00488                         $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"];
00489                 }
00490                 else
00491                 {
00492                         $time_limit_unlimited = 1;
00493                 }
00494                 
00495                 $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
00496                         $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
00497                         time();
00498                 
00499                 $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
00500                         $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
00501                         time();
00502                 
00503                 $this->lng->loadLanguageModule('crs');
00504                 
00505                 $this->tpl->setCurrentBlock("time_limit");
00506                 $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
00507                 $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
00508                 $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
00509                 $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
00510                 $this->tpl->setVariable("TXT_TIME_LIMIT_CLOCK", $this->lng->txt("clock"));
00511                 $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
00512                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
00513                         date("i",$time_limit_from)));
00514                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
00515                                                                                                                                                                          date("G",$time_limit_from)));
00516                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
00517                                                                                                                                                                         date("d",$time_limit_from)));
00518                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
00519                                                                                                                                                                           date("m",$time_limit_from)));
00520                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
00521                                                                                                                                                                          date("Y",$time_limit_from)));
00522                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
00523                                                                                                                                                                                 date("i",$time_limit_until)));
00524                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
00525                                                                                                                                                                           date("G",$time_limit_until)));
00526                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
00527                                                                                                                                                                          date("d",$time_limit_until)));
00528                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
00529                                                                                                                                                                            date("m",$time_limit_until)));
00530                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
00531                                                                                                                                                                           date("Y",$time_limit_until)));
00532                 $this->tpl->parseCurrentBlock();
00533 
00534 
00535         }
00536         
00661     function editObject()
00662     {
00663         global $ilias, $rbacsystem, $rbacreview, $rbacadmin, $styleDefinition, $ilUser;
00664 
00665         //load ILIAS settings
00666         $settings = $ilias->getAllSettings();
00667 
00668                 // deactivated:
00669                 // or ($this->id != $_SESSION["AccountId"])
00670                 if (!$rbacsystem->checkAccess('visible,read', $this->usrf_ref_id) and
00671                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
00672                 {
00673                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
00674                 }
00675 
00676                 $data = array();
00677                 $data["fields"] = array();
00678                 $data["fields"]["login"] = $this->object->getLogin();
00679                 $data["fields"]["passwd"] = "********"; // will not be saved
00680                 $data["fields"]["passwd2"] = "********";        // will not be saved
00681                 $data["fields"]["title"] = $this->object->getUTitle();
00682                 $data["fields"]["gender"] = $this->object->getGender();
00683                 $data["fields"]["firstname"] = $this->object->getFirstname();
00684                 $data["fields"]["lastname"] = $this->object->getLastname();
00685                 $data["fields"]["institution"] = $this->object->getInstitution();
00686                 $data["fields"]["department"] = $this->object->getDepartment();
00687                 $data["fields"]["street"] = $this->object->getStreet();
00688                 $data["fields"]["city"] = $this->object->getCity();
00689                 $data["fields"]["zipcode"] = $this->object->getZipcode();
00690                 $data["fields"]["country"] = $this->object->getCountry();
00691                 $data["fields"]["phone_office"] = $this->object->getPhoneOffice();
00692                 $data["fields"]["phone_home"] = $this->object->getPhoneHome();
00693                 $data["fields"]["phone_mobile"] = $this->object->getPhoneMobile();
00694                 $data["fields"]["fax"] = $this->object->getFax();
00695                 $data["fields"]["email"] = $this->object->getEmail();
00696                 $data["fields"]["hobby"] = $this->object->getHobby();
00697                 $data["fields"]["matriculation"] = $this->object->getMatriculation();
00698                 $data["fields"]["client_ip"] = $this->object->getClientIP();
00699                 $data["fields"]["referral_comment"] = $this->object->getComment();
00700                 $data["fields"]["create_date"] = $this->object->getCreateDate();
00701                 $data["fields"]["approve_date"] = $this->object->getApproveDate();
00702                 $data["fields"]["active"] = $this->object->getActive();
00703                 $data["fields"]["auth_mode"] = $this->object->getAuthMode();
00704 
00705                 if (!count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
00706                 {
00707                         $user_is_online = false;
00708                 }
00709                 else
00710                 {
00711                         $user_is_online = true;
00712 
00713                         // extract serialized role Ids from session data
00714                         preg_match("/RoleId.*?;\}/",$user_online[$this->object->getId()]["data"],$matches);
00715 
00716                         $active_roles = unserialize(substr($matches[0],7));
00717 
00718                         // gather data for active roles
00719                         $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
00720 
00721                         foreach ($assigned_roles as $key => $role)
00722                         {
00723                                 $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role);
00724 
00725                                 // fetch context path of role
00726                                 $rolf = $rbacreview->getFoldersAssignedToRole($role,true);
00727 
00728                                 // only list roles that are not set to status "deleted"
00729                                 if (count($rolf) > 0)
00730                                 {
00731                                         if (!$rbacreview->isDeleted($rolf[0]))
00732                                         {
00733                                                 $path = "";
00734 
00735                                                 if ($this->tree->isInTree($rolf[0]))
00736                                                 {
00737                                                         $tmpPath = $this->tree->getPathFull($rolf[0]);
00738 
00739                                                         // count -1, to exclude the role folder itself
00740                                                         for ($i = 0; $i < (count($tmpPath)-1); $i++)
00741                                                         {
00742                                                                 if ($path != "")
00743                                                                 {
00744                                                                         $path .= " > ";
00745                                                                 }
00746 
00747                                                                 $path .= $tmpPath[$i]["title"];
00748                                                         }
00749                                                 }
00750                                                 else
00751                                                 {
00752                                                         $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role.")</b>";
00753                                                 }
00754 
00755                                                 if (in_array($role,$active_roles))
00756                                                 {
00757                                                         $data["active_role"][$role]["active"] = true;
00758                                                 }
00759 
00760                                                 $data["active_role"][$role]["title"] = $roleObj->getTitle();
00761                                                 $data["active_role"][$role]["context"] = $path;
00762 
00763                                                 unset($roleObj);
00764                                         }
00765                                 }
00766                                 else
00767                                 {
00768                                         $path = "<b>No role folder found for role ".$role."!</b>";
00769                                 }
00770                         }
00771                 }
00772 
00773                 $this->getTemplateFile("edit","usr");
00774 
00775                 // FILL SAVED VALUES IN CASE OF ERROR
00776                 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00777                 {
00778             if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
00779             {
00780                 $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
00781             }
00782 
00783                         foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
00784                         {
00785                                 $str = $this->lng->txt($key);
00786                                 if ($key == "title")
00787                                 {
00788                                         $str = $this->lng->txt("person_title");
00789                                 }
00790 
00791                 // check to see if dynamically required
00792                 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00793                 {
00794                     $str = $str . '<span class="asterisk">*</span>';
00795                 }
00796 
00797                                 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00798 
00799                                 if ($key != "default_role" and $key != "language" 
00800                                         and $key != "skin_style" and $key != "hits_per_page"
00801                                         and $key != "show_users_online")
00802                                 {
00803                                         $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
00804                                 }
00805                         }
00806 
00807                         // gender selection
00808                         $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00809                         
00810 
00811                         if (!empty($gender))
00812                         {
00813                                 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00814                         }
00815 
00816             $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
00817             if ($active)
00818             {
00819                 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00820             }
00821                 }
00822                 else
00823                 {
00824             if (!isset($data["fields"]["active"]))
00825             {
00826                 $data["fields"]["active"] = 0;
00827             }
00828 
00829                         foreach ($data["fields"] as $key => $val)
00830                         {
00831                                 $str = $this->lng->txt($key);
00832                                 if ($key == "title")
00833                                 {
00834                                         $str = $this->lng->txt("person_title");
00835                                 }
00836 
00837                 // check to see if dynamically required
00838                 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00839                 {
00840                     $str = $str . '<span class="asterisk">*</span>';
00841                 }
00842 
00843                                 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00844 
00845                                 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00846                                 #$this->tpl->parseCurrentBlock();
00847                         }
00848                         
00849                         // gender selection
00850                         $gender = strtoupper($data["fields"]["gender"]);
00851                 
00852                         if (!empty($gender))
00853                         {
00854                                 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00855                         }
00856 
00857                         $active = $data["fields"]["active"];
00858                         if ($active)
00859                         {
00860                                 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00861                         }
00862                 }
00863 
00864                 if ($this->object->getAuthMode(true) != AUTH_LOCAL)
00865                 {
00866                         $this->tpl->setVariable("OPTION_DISABLED", "\"disabled=disabled\"");
00867                 }
00868 
00869                 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00870                 
00871                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00872                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
00873                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00874                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00875                 $this->tpl->setVariable("CMD_SUBMIT", "update");
00876                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00877                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00878 
00879                 $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
00880         $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
00881                 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
00882                 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
00883                 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
00884                 $this->tpl->setVariable("TXT_PASSWD2", $this->lng->txt("retype_password"));
00885                 $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
00886                 $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
00887                 $this->tpl->setVariable("TXT_HITS_PER_PAGE",$this->lng->txt("hits_per_page"));
00888                 $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE",$this->lng->txt("show_users_online"));
00889                 $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
00890                 $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
00891                 $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
00892                 if ($this->object->getId() == $ilUser->getId())
00893                 {
00894                         $this->tpl->setVariable("TXT_CURRENT_IP","(".$this->lng->txt("current_ip")." ".$_SERVER["REMOTE_ADDR"].")");
00895                 }
00896                 $this->tpl->setVariable("TXT_CURRENT_IP_ALERT",$this->lng->txt("current_ip_alert"));
00897                 
00898                 // auth mode selection
00899                 include_once('classes/class.ilAuthUtils.php');
00900                 $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
00901 
00902                 // preselect previous chosen auth mode otherwise default auth mode
00903                 $selected_auth_mode = (isset($_SESSION["error_post_vars"]["Fobject"]["auth_mode"])) ? $_SESSION["error_post_vars"]["Fobject"]["auth_mode"] : $this->object->getAuthMode();
00904 
00905                 foreach ($active_auth_modes as $auth_name => $auth_key)
00906                 {
00907                         $this->tpl->setCurrentBlock("auth_mode_selection");
00908 
00909                         if ($auth_name == 'default')
00910                         {
00911                                 $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
00912                         }
00913                         else
00914                         {
00915                                 $name = $this->lng->txt('auth_'.$auth_name);
00916                         }
00917                         
00918                         $this->tpl->setVariable("AUTH_MODE_NAME", $name);
00919 
00920                         $this->tpl->setVariable("AUTH_MODE", $auth_name);
00921 
00922                         if ($selected_auth_mode == $auth_name)
00923                         {
00924                                 $this->tpl->setVariable("SELECTED_AUTH_MODE", "selected=\"selected\"");
00925                         }
00926 
00927                         $this->tpl->parseCurrentBlock();
00928                 } // END auth_mode selection
00929                 
00930                 
00931                 // language selection
00932                 $languages = $this->lng->getInstalledLanguages();
00933 
00934                 // preselect previous chosen language otherwise default language
00935                 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->object->getLanguage();
00936 
00937                 foreach ($languages as $lang_key)
00938                 {
00939                         $this->tpl->setCurrentBlock("language_selection");
00940                         $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
00941                         $this->tpl->setVariable("LANGSHORT", $lang_key);
00942 
00943                         if ($selected_lang == $lang_key)
00944                         {
00945                                 $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00946                         }
00947 
00948                         $this->tpl->parseCurrentBlock();
00949                 } // END language selection
00950                 
00951                 // BEGIN skin & style selection
00952                 //$this->ilias->getSkins();
00953                 $templates = $styleDefinition->getAllTemplates();
00954                 
00955                 // preselect previous chosen skin/style otherwise default skin/style
00956                 if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
00957                 {
00958                         $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
00959                         
00960                         $selected_style = $sknst[1];
00961                         $selected_skin = $sknst[0];     
00962                 }
00963                 else
00964                 {
00965                         $selected_style = $this->object->prefs["style"];
00966                         $selected_skin = $this->object->skin;   
00967                 }
00968                 
00969                 include("classes/class.ilObjStyleSettings.php");
00970                 foreach ($templates as $template)
00971                 {
00972                         // get styles for skin
00973                         //$this->ilias->getStyles($skin["name"]);
00974                         $styleDef =& new ilStyleDefinition($template["id"]);
00975                         $styleDef->startParsing();
00976                         $styles = $styleDef->getStyles();
00977                         foreach ($styles as $style)
00978                         {
00979                                 if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
00980                                 {
00981                                         continue;
00982                                 }
00983 
00984                                 $this->tpl->setCurrentBlock("selectskin");
00985 
00986                                 if ($selected_skin == $template["id"] &&
00987                                         $selected_style == $style["id"])
00988                                 {
00989                                         $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00990                                 }
00991 
00992                                 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00993                                 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00994                                 $this->tpl->parseCurrentBlock();
00995                         }
00996                 } // END skin & style selection
00997 
00998                 // BEGIN hits per page
00999                 $hits_options = array(2,10,15,20,30,40,50,100,9999);
01000                 // preselect previous chosen option otherwise default option
01001                 if (isset($_SESSION["error_post_vars"]["Fobject"]["hits_per_page"]))
01002                 {
01003                         $selected_option = $_SESSION["error_post_vars"]["Fobject"]["hits_per_page"];
01004                 }
01005                 else
01006                 {
01007                         $selected_option = $this->object->prefs["hits_per_page"];
01008                 }
01009                 foreach($hits_options as $hits_option)
01010                 {
01011                         $this->tpl->setCurrentBlock("selecthits");
01012 
01013                         if ($selected_option == $hits_option)
01014                         {
01015                                 $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
01016                         }
01017 
01018                         $this->tpl->setVariable("HITSVALUE", $hits_option);
01019 
01020                         if ($hits_option == 9999)
01021                         {
01022                                 $hits_option = $this->lng->txt("no_limit");
01023                         }
01024 
01025                         $this->tpl->setVariable("HITSOPTION", $hits_option);
01026                         $this->tpl->parseCurrentBlock();
01027                 }
01028                 // END hits per page
01029 
01030                 // BEGIN show users online
01031                 $users_online_options = array("y","associated","n");
01032                 // preselect previous chosen option otherwise default option
01033                 if (isset($_SESSION["error_post_vars"]["Fobject"]["show_users_online"]))
01034                 {
01035                         $selected_option = $_SESSION["error_post_vars"]["Fobject"]["show_users_online"];
01036                 }
01037                 else
01038                 {
01039                         $selected_option = $this->object->prefs["show_users_online"];
01040                 }
01041                 foreach($users_online_options as $an_option)
01042                 {
01043                         $this->tpl->setCurrentBlock("show_users_online");
01044 
01045                         if ($selected_option == $an_option)
01046                         {
01047                                 $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
01048                         }
01049 
01050                         $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
01051 
01052                         $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
01053                         $this->tpl->parseCurrentBlock();
01054                 }
01055                 // END show users online
01056 
01057                 // inform user about changes option
01058                 $this->tpl->setCurrentBlock("inform_user");
01059 
01060 
01061                 if (true)
01062                 {
01063                         $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
01064                 }
01065 
01066                 $this->tpl->setVariable("TXT_INFORM_USER_MAIL", $this->lng->txt("inform_user_mail"));
01067                 $this->tpl->parseCurrentBlock();
01068 
01069                 $this->lng->loadLanguageModule('crs');
01070 
01071                 $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"] ?
01072             $_SESSION["error_post_vars"]["time_limit"]["unlimited"] :
01073             $this->object->getTimeLimitUnlimited();
01074         $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
01075             $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
01076             $this->object->getTimeLimitFrom();
01077 
01078         $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
01079             $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
01080             $this->object->getTimeLimitUntil();
01081 
01082                 $this->tpl->setCurrentBlock("time_limit");
01083         $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
01084         $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
01085         $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
01086         $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
01087 
01088         $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
01089         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
01090                                                                                      date("i",$time_limit_from)));
01091         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
01092                                                                                      date("G",$time_limit_from)));
01093         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
01094                                                                                      date("d",$time_limit_from)));
01095         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
01096                                                                                        date("m",$time_limit_from)));
01097         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
01098                                                                                       date("Y",$time_limit_from)));
01099         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
01100                                                                                      date("i",$time_limit_until)));
01101         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
01102                                                                                      date("G",$time_limit_until)));
01103         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
01104                                                                                    date("d",$time_limit_until)));
01105         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
01106                                                                                      date("m",$time_limit_until)));
01107         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
01108                                                                                     date("Y",$time_limit_until)));
01109                 $this->tpl->parseCurrentBlock();
01110 
01111 
01112                 if ($user_is_online)
01113                 {
01114                         // BEGIN TABLE ROLES
01115                         $this->tpl->setCurrentBlock("TABLE_ROLES");
01116 
01117                         $counter = 0;
01118 
01119                         foreach ($data["active_role"] as $role_id => $role)
01120                         {
01121                                 ++$counter;
01122                                 $css_row = ilUtil::switchColor($counter,"tblrow2","tblrow1");
01123                                 ($role["active"]) ? $checked = "checked=\"checked\"" : $checked = "";
01124 
01125                                 $this->tpl->setVariable("ACTIVE_ROLE_CSS_ROW",$css_row);
01126                                 $this->tpl->setVariable("ROLECONTEXT",$role["context"]);
01127                                 $this->tpl->setVariable("ROLENAME",$role["title"]);
01128                                 $this->tpl->setVariable("CHECKBOX_ID", $role_id);
01129                                 $this->tpl->setVariable("CHECKED", $checked);
01130                                 $this->tpl->parseCurrentBlock();
01131                         }
01132                         // END TABLE ROLES
01133 
01134                         // BEGIN ACTIVE ROLES
01135                         $this->tpl->setCurrentBlock("ACTIVE_ROLE");
01136                         $this->tpl->setVariable("ACTIVE_ROLE_FORMACTION","adm_object.php?cmd=activeRoleSave&ref_id=".
01137                                                                         $this->usrf_ref_id."&obj_id=".$this->obj_id);
01138                         $this->tpl->setVariable("TXT_ACTIVE_ROLES",$this->lng->txt("active_roles"));
01139                         $this->tpl->setVariable("TXT_ASSIGN",$this->lng->txt("change_active_assignment"));
01140                         $this->tpl->parseCurrentBlock();
01141                         // END ACTIVE ROLES
01142                 }
01143         }
01144 
01149         function saveObject()
01150         {
01151         global $ilias, $rbacsystem, $rbacadmin;
01152 
01153         //load ILIAS settings
01154         $settings = $ilias->getAllSettings();
01155 
01156                 if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
01157                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
01158                 {
01159                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
01160                 }
01161 
01162         // check dynamically required fields
01163         foreach ($settings as $key => $val)
01164         {
01165             if (substr($key,0,8) == "require_")
01166             {
01167                 $require_keys[] = substr($key,8);
01168             }
01169         }
01170 
01171         foreach ($require_keys as $key => $val)
01172         {
01173             if (isset($settings["require_" . $val]) && $settings["require_" . $val])
01174             {
01175                 if (empty($_POST["Fobject"][$val]))
01176                 {
01177                     $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
01178                                                                                          $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
01179                 }
01180             }
01181         }
01182 
01183                 // validate login
01184                 if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
01185                 {
01186                         $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
01187                 }
01188 
01189                 // check loginname
01190                 if (loginExists($_POST["Fobject"]["login"]))
01191                 {
01192                         $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
01193                 }
01194 
01195                 // check passwords
01196                 if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
01197                 {
01198                         $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
01199                 }
01200 
01201                 // validate password
01202                 if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
01203                 {
01204                         $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
01205                 }
01206                 // The password type is not passed in the post data.  Therefore we
01207                 // append it here manually.
01208                 require_once "class.ilObjUser.php";
01209             $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
01210 
01211                 // validate email
01212                 if (!ilUtil::is_email($_POST["Fobject"]["email"]))
01213                 {
01214                         $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
01215                 }
01216 
01217                 // validate time limit
01218         if ($_POST["time_limit"]["unlimited"] != 1 and
01219             ($this->__toUnix($_POST["time_limit"]["until"]) < $this->__toUnix($_POST["time_limit"]["from"])))
01220         {
01221             $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
01222         }
01223                 if(!$this->ilias->account->getTimeLimitUnlimited())
01224                 {
01225                         if($this->__toUnix($_POST["time_limit"]["from"]) < $this->ilias->account->getTimeLimitFrom() or
01226                            $this->__toUnix($_POST["time_limit"]["until"])> $this->ilias->account->getTimeLimitUntil() or
01227                            $_POST['time_limit']['unlimited'])
01228                         {
01229                                 $this->ilias->raiseError($this->lng->txt("time_limit_not_within_owners"),$this->ilias->error_obj->MESSAGE);
01230                         }
01231                 }
01232 
01233 
01234 
01235                 // TODO: check if login or passwd already exists
01236                 // TODO: check length of login and passwd
01237 
01238                 // checks passed. save user
01239                 $userObj = new ilObjUser();
01240                 $userObj->assignData($_POST["Fobject"]);
01241                 $userObj->setTitle($userObj->getFullname());
01242                 $userObj->setDescription($userObj->getEmail());
01243 
01244                 $userObj->setTimeLimitOwner($this->object->getRefId());
01245         $userObj->setTimeLimitUnlimited($_POST["time_limit"]["unlimited"]);
01246         $userObj->setTimeLimitFrom($this->__toUnix($_POST["time_limit"]["from"]));
01247         $userObj->setTimeLimitUntil($this->__toUnix($_POST["time_limit"]["until"]));
01248 
01249                 $userObj->create();
01250 
01251                 //$user->setId($userObj->getId());
01252 
01253                 //insert user data in table user_data
01254                 $userObj->saveAsNew();
01255 
01256                 // setup user preferences
01257                 $userObj->setLanguage($_POST["Fobject"]["language"]);
01258 
01259                 //set user skin and style
01260                 $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
01261 
01262                 if ($userObj->getPref("style") != $sknst[1] ||
01263                         $userObj->getPref("skin") != $sknst[0])
01264                 {
01265                         $userObj->setPref("skin", $sknst[0]);
01266                         $userObj->setPref("style", $sknst[1]);
01267                 }
01268 
01269                 // set hits per pages
01270                 $userObj->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
01271                 // set show users online
01272                 $userObj->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
01273 
01274                 $userObj->writePrefs();
01275 
01276                 //set role entries
01277                 $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
01278 
01279                 /* moved the following to ObjUser->saveasNew
01280                 // CREATE ENTRIES FOR MAIL BOX
01281                 include_once ("classes/class.ilMailbox.php");
01282                 $mbox = new ilMailbox($userObj->getId());
01283                 $mbox->createDefaultFolder();
01284 
01285                 include_once "classes/class.ilMailOptions.php";
01286                 $mail_options = new ilMailOptions($userObj->getId());
01287                 $mail_options->createMailOptionsEntry();
01288 
01289                 // create personal bookmark folder tree
01290                 include_once "classes/class.ilBookmarkFolder.php";
01291                 $bmf = new ilBookmarkFolder(0, $userObj->getId());
01292                 $bmf->createNewBookmarkTree();*/
01293 
01294                 sendInfo($this->lng->txt("user_added"),true);
01295 
01296                 
01297                 if($this->ctrl->getTargetScript() == 'adm_object.php')
01298                 {
01299                         ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$this->usrf_ref_id));
01300                 }
01301                 else
01302                 {
01303                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01304                 }
01305         }
01306 
01311         function updateObject()
01312         {
01313         global $ilias, $rbacsystem, $rbacadmin;
01314 
01315         //load ILIAS settings
01316         $settings = $ilias->getAllSettings();
01317 
01318                 // check write access
01319                 if (!$rbacsystem->checkAccess('write', $this->usrf_ref_id) and
01320                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
01321                 {
01322                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
01323                 }
01324 
01325                 foreach ($_POST["Fobject"] as $key => $val)
01326                 {
01327                         $_POST["Fobject"][$key] = ilUtil::stripSlashes($val);
01328                 }
01329 
01330                 // do not validate required fields, login & passwd if auth mode ist not 'local'
01331                 if ($this->object->getAuthMode(true) == AUTH_LOCAL)
01332                 {
01333             // check dynamically required fields
01334             foreach ($settings as $key => $val)
01335             {
01336                 if (substr($key,0,8) == "require_")
01337                 {
01338                     $require_keys[] = substr($key,8);
01339                 }
01340             }
01341 
01342             foreach ($require_keys as $key => $val)
01343             {
01344                 // exclude required system and registration-only fields
01345                 $system_fields = array("default_role");
01346                 if (!in_array($val, $system_fields))
01347                 {
01348                     if (isset($settings["require_" . $val]) && $settings["require_" . $val])
01349                     {
01350                         if (empty($_POST["Fobject"][$val]))
01351                         {
01352                             $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
01353                         }
01354                     }
01355                 }
01356             }
01357             
01358                         // validate login
01359                         if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
01360                         {
01361                                 $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
01362                         }
01363 
01364                         // check loginname
01365                         if (loginExists($_POST["Fobject"]["login"],$this->id))
01366                         {
01367                                 $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
01368                         }
01369 
01370                         // check passwords
01371                         if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
01372                         {
01373                                 $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
01374                         }
01375 
01376                         // validate password
01377                         if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
01378                         {
01379                                 $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
01380                         }
01381 
01382                         if ($_POST["Fobject"]["passwd"] != "********")
01383                         {
01384                                 $this->object->resetPassword($_POST["Fobject"]["passwd"],$_POST["Fobject"]["passwd2"]);
01385                         }
01386                 }
01387                 // The password type is not passed with the post data.  Therefore we
01388                 // append it here manually.
01389                 include_once ('classes/class.ilObjUser.php');
01390             $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
01391 
01392                 // validate email
01393                 if (!ilUtil::is_email($_POST["Fobject"]["email"]))
01394                 {
01395                         $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
01396                 }
01397 
01398                 $start = $this->__toUnix($_POST["time_limit"]["from"]);
01399                 $end = $this->__toUnix($_POST["time_limit"]["until"]);
01400 
01401                 // validate time limit
01402                 if (!$_POST["time_limit"]["unlimited"] and 
01403                         ( $start > $end))
01404         {
01405             $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
01406         }
01407 
01408                 if(!$this->ilias->account->getTimeLimitUnlimited())
01409                 {
01410                         if($start < $this->ilias->account->getTimeLimitFrom() or
01411                            $end > $this->ilias->account->getTimeLimitUntil() or
01412                            $_POST['time_limit']['unlimited'])
01413                         {
01414                                 $_SESSION['error_post_vars'] = $_POST;
01415 
01416                                 sendInfo($this->lng->txt('time_limit_not_within_owners'));
01417                                 $this->editObject();
01418 
01419                                 return false;
01420                         }
01421                 }
01422 
01423                 // TODO: check length of login and passwd
01424 
01425                 // checks passed. save user
01426                 $_POST['Fobject']['time_limit_owner'] = $this->object->getTimeLimitOwner();
01427 
01428                 $_POST['Fobject']['time_limit_unlimited'] = (int) $_POST['time_limit']['unlimited'];
01429                 $_POST['Fobject']['time_limit_from'] = $this->__toUnix($_POST['time_limit']['from']);
01430                 $_POST['Fobject']['time_limit_until'] = $this->__toUnix($_POST['time_limit']['until']);
01431 
01432                 if($_POST['Fobject']['time_limit_unlimited'] != $this->object->getTimeLimitUnlimited() or
01433                    $_POST['Fobject']['time_limit_from'] != $this->object->getTimeLimitFrom() or
01434                    $_POST['Fobject']['time_limit_until'] != $this->object->getTimeLimitUntil())
01435                 {
01436                         $_POST['Fobject']['time_limit_message'] = 0;
01437                 }
01438                 else
01439                 {
01440                         $_POST['Fobject']['time_limit_message'] = $this->object->getTimeLimitMessage();
01441                 }
01442 
01443                 // don't save login & passwd if auth mode is not 'local'
01444                 if ($this->object->getAuthMode(true) != AUTH_LOCAL)
01445                 {
01446                         $_POST['Fobject']['login'] = $this->object->getLogin();
01447                         $_POST['Fobject']['passwd'] = "********";
01448                 }
01449                 
01450                 $this->object->assignData($_POST["Fobject"]);
01451                 
01452                 if ($this->object->getAuthMode(true) == AUTH_LOCAL)
01453                 {
01454                         $this->object->updateLogin($_POST["Fobject"]["login"]);
01455                 }
01456 
01457                 $this->object->setTitle($this->object->getFullname());
01458                 $this->object->setDescription($this->object->getEmail());
01459                 $this->object->setLanguage($_POST["Fobject"]["language"]);
01460 
01461                 //set user skin and style
01462                 $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
01463 
01464                 if ($this->object->getPref("style") != $sknst[1] ||
01465                         $this->object->getPref("skin") != $sknst[0])
01466                 {
01467                         $this->object->setPref("skin", $sknst[0]);
01468                         $this->object->setPref("style", $sknst[1]);
01469                 }
01470 
01471                 // set hits per pages
01472                 $this->object->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
01473                 // set show users online
01474                 $this->object->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
01475 
01476                 $this->update = $this->object->update();
01477                 //$rbacadmin->updateDefaultRole($_POST["Fobject"]["default_role"], $this->object->getId());
01478 
01479                 // send email
01480                 if ($_POST["send_mail"] == "y")
01481                 {
01482                         $this->lng->loadLanguageModule('crs');
01483 
01484                         include_once "classes/class.ilFormatMail.php";
01485 
01486                         $umail = new ilFormatMail($_SESSION["AccountId"]);
01487 
01488                         // mail body
01489                         $body = $this->lng->txt("login").": ".$this->object->getLogin()."\n\r".
01490                         $this->lng->txt("passwd").": ".$_POST["Fobject"]["passwd"]."\n\r".
01491                         $this->lng->txt("title").": ".$this->object->getTitle()."\n\r".
01492                         $this->lng->txt("gender").": ".$this->object->getGender()."\n\r".
01493                         $this->lng->txt("firstname").": ".$this->object->getFirstname()."\n\r".
01494                         $this->lng->txt("lastname").": ".$this->object->getLastname()."\n\r".
01495                         $this->lng->txt("institution").": ".$this->object->getInstitution()."\n\r".
01496                         $this->lng->txt("department").": ".$this->object->getDepartment()."\n\r".
01497                         $this->lng->txt("street").": ".$this->object->getStreet()."\n\r".
01498                         $this->lng->txt("city").": ".$this->object->getCity()."\n\r".
01499                         $this->lng->txt("zipcode").": ".$this->object->getZipcode()."\n\r".
01500                         $this->lng->txt("country").": ".$this->object->getCountry()."\n\r".
01501                         $this->lng->txt("phone_office").": ".$this->object->getPhoneOffice()."\n\r".
01502                         $this->lng->txt("phone_home").": ".$this->object->getPhoneHome()."\n\r".
01503                         $this->lng->txt("phone_mobile").": ".$this->object->getPhoneMobile()."\n\r".
01504                         $this->lng->txt("fax").": ".$this->object->getFax()."\n\r".
01505                         $this->lng->txt("email").": ".$this->object->getEmail()."\n\r".
01506                         $this->lng->txt("hobby").": ".$this->object->getHobby()."\n\r".
01507                         $this->lng->txt("matriculation").": ".$this->object->getMatriculation()."\n\r".
01508                         $this->lng->txt("client_ip").": ".$this->object->getClientIP()."\n\r".
01509                         $this->lng->txt("referral_comment").": ".$this->object->getComment()."\n\r".
01510                         $this->lng->txt("create_date").": ".$this->object->getCreateDate()."\n\r".
01511                         $this->lng->txt("default_role").": ".$_POST["Fobject"]["default_role"]."\n\r";
01512 
01513                         if($this->object->getTimeLimitUnlimited())
01514                         {
01515                                 $body .= $this->lng->txt('time_limit').": ".$this->lng->txt('crs_unlimited')."\n\r";
01516                         }
01517                         else
01518                         {
01519                                 $body .= $this->lng->txt('time_limit').": ".$this->lng->txt('crs_from')." ".
01520                                         strftime('%Y-%m-%d %R',$this->object->getTimeLimitFrom())." ".
01521                                         $this->lng->txt('crs_to')." ".
01522                                         strftime('%Y-%m-%d %R',$this->object->getTimeLimitUntil())."\n\r";
01523                         }
01524                         
01525                         $body .= $this->lng->txt('email_footer') . "\n\r";
01526 
01527                         if ($error_message = $umail->sendMail($this->object->getLogin(),"","",
01528                                 $this->lng->txt("profile_changed"),$body,array(),array("normal")))
01529                         {
01530                                 $msg = $this->lng->txt("saved_successfully")."<br/>".$error_message;
01531                         }
01532                         else
01533                         {
01534                                 $msg = $this->lng->txt("saved_successfully")."<br/>".$this->lng->txt("mail_sent");
01535                         }
01536                 }
01537                 else
01538                 {
01539                         $msg = $this->lng->txt("saved_successfully");
01540                 }
01541 
01542                 // feedback
01543                 sendInfo($msg,true);
01544 
01545                 if($this->ctrl->getTargetScript() == 'adm_object.php')
01546                 {
01547                         ilUtil::redirect("adm_object.php?ref_id=".$this->usrf_ref_id);
01548                 }
01549                 else
01550                 {
01551                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01552                 }
01553         }
01554 
01555 
01562         function activeRoleSaveObject()
01563         {
01564                 global $rbacreview;
01565 
01566                 $_POST["id"] = $_POST["id"] ? $_POST["id"] : array();
01567 
01568                 // at least one active global role must be assigned to user
01569                 $global_roles_all = $rbacreview->getGlobalRoles();
01570                 $assigned_global_roles = array_intersect($_POST["id"],$global_roles_all);
01571                 
01572                 if (!count($_POST["id"]) or count($assigned_global_roles) < 1)
01573                 {
01574                         $this->ilias->raiseError($this->lng->txt("msg_min_one_active_role"),$this->ilias->error_obj->MESSAGE);
01575                 }
01576 
01577                 if ($this->object->getId() == $_SESSION["AccountId"])
01578                 {
01579                         $_SESSION["RoleId"] = $_POST["id"];
01580                 }
01581                 else
01582                 {
01583                         if (count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
01584                         {
01585                                 //var_dump("<pre>",$user_online,$_POST["id"],"</pre>");exit;
01586 
01587                                 $roles = "RoleId|".serialize($_POST["id"]);
01588                                 $modified_data = preg_replace("/RoleId.*?;\}/",$roles,$user_online[$this->object->getId()]["data"]);
01589 
01590                                 $q = "UPDATE usr_session SET data='".$modified_data."' WHERE user_id = '".$this->object->getId()."'";
01591                                 $this->ilias->db->query($q);
01592                         }
01593                         else
01594                         {
01595                                 // user went offline - do nothing
01596                         }
01597                 }
01598 
01599                 sendInfo($this->lng->txt("msg_roleassignment_active_changed").".<br/>".$this->lng->txt("msg_roleassignment_active_changed_comment"),true);
01600                 ilUtil::redirect("adm_object.php?ref_id=".$this->usrf_ref_id."&obj_id=".$this->obj_id."&cmd=edit");
01601         }
01602 
01608         function assignSaveObject()
01609         {
01610                 global $rbacsystem, $rbacadmin, $rbacreview;
01611 
01612                 if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
01613                 {
01614                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
01615                 }
01616 
01617                 $selected_roles = $_POST["role_id"] ? $_POST["role_id"] : array();
01618                 $posted_roles = $_POST["role_id_ctrl"] ? $_POST["role_id_ctrl"] : array();
01619                 
01620                 // prevent unassignment of system role from system user
01621                 if ($this->object->getId() == SYSTEM_USER_ID and in_array(SYSTEM_ROLE_ID, $posted_roles))
01622                 {
01623                         array_push($selected_roles,SYSTEM_ROLE_ID);
01624                 }
01625 
01626                 $global_roles_all = $rbacreview->getGlobalRoles();
01627                 $assigned_roles_all = $rbacreview->assignedRoles($this->object->getId());
01628                 $assigned_roles = array_intersect($assigned_roles_all,$posted_roles);
01629                 $assigned_global_roles_all = array_intersect($assigned_roles_all,$global_roles_all);
01630                 $assigned_global_roles = array_intersect($assigned_global_roles_all,$posted_roles);
01631                 $posted_global_roles = array_intersect($selected_roles,$global_roles_all);
01632                 
01633                 if ((empty($selected_roles) and count($assigned_roles_all) == count($assigned_roles))
01634                          or (empty($posted_global_roles) and count($assigned_global_roles_all) == count($assigned_global_roles)))
01635                 {
01636             //$this->ilias->raiseError($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
01637             // workaround. sometimes jumps back to wrong page
01638             sendInfo($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),true);
01639             $this->ctrl->redirect($this,'roleassignment');
01640                 }
01641 
01642                 foreach (array_diff($assigned_roles,$selected_roles) as $role)
01643                 {
01644                         $rbacadmin->deassignUser($role,$this->object->getId());
01645                 }
01646 
01647                 foreach (array_diff($selected_roles,$assigned_roles) as $role)
01648                 {
01649                         $rbacadmin->assignUser($role,$this->object->getId(),false);
01650                 }
01651                 
01652         include_once "./classes/class.ilObjRole.php";
01653         ilObjRole::_updateSessionRoles(array($this->object->getId()));
01654 
01655                 // update object data entry (to update last modification date)
01656                 $this->object->update();
01657 
01658                 sendInfo($this->lng->txt("msg_roleassignment_changed"),true);
01659 
01660                 if($this->ctrl->getTargetScript() == 'adm_object.php')
01661                 {
01662             $this->ctrl->redirectByClass('ilobjusergui','roleassignment');
01663                 }
01664                 else
01665                 {
01666                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01667                 }
01668 
01669         }
01670         
01676         function roleassignmentObject ()
01677         {
01678                 global $rbacreview,$rbacsystem;
01679 
01680                 if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
01681                 {
01682                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
01683                 }
01684                 
01685                 $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
01686 
01687         if ($_SESSION['filtered_roles'] > 5)
01688         {
01689             $_SESSION['filtered_roles'] = 0;
01690         }
01691         
01692                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_role_assignment.html');
01693 
01694                 if(true)
01695                 {
01696                         $this->tpl->setCurrentBlock("filter");
01697                         $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
01698                         $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect());
01699                         $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
01700                         $this->tpl->setVariable("FILTER_NAME",'roleassignment');
01701                         $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
01702                         $this->tpl->parseCurrentBlock();
01703                 }
01704                 
01705                 // now get roles depending on filter settings
01706                 $role_list = $rbacreview->getRolesByFilter($_SESSION["filtered_roles"],$this->object->getId());
01707                 $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
01708 
01709         $counter = 0;
01710         
01711         include_once ('class.ilObjRole.php');
01712 
01713                 foreach ($role_list as $role)
01714                 {
01715                         // fetch context path of role
01716                         $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
01717 
01718                         // only list roles that are not set to status "deleted"
01719                         if ($rbacreview->isDeleted($rolf[0]))
01720                         {
01721                 continue;
01722             }
01723             
01724             // build context path
01725             $path = "";
01726 
01727                         if ($this->tree->isInTree($rolf[0]))
01728                         {
01729                 if ($rolf[0] == ROLE_FOLDER_ID)
01730                 {
01731                     $path = $this->lng->txt("global");
01732                 }
01733                 else
01734                 {
01735                                     $tmpPath = $this->tree->getPathFull($rolf[0]);
01736 
01737                                     // count -1, to exclude the role folder itself
01738                                     /*for ($i = 1; $i < (count($tmpPath)-1); $i++)
01739                                     {
01740                                             if ($path != "")
01741                                             {
01742                                                     $path .= " > ";
01743                                             }
01744 
01745                                             $path .= $tmpPath[$i]["title"];
01746                                     }*/
01747                                 
01748                                     $path = $tmpPath[count($tmpPath)-2]["title"];
01749                                 }
01750                         }
01751                         else
01752                         {
01753                                 $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role["obj_id"].")</b>";
01754                         }
01755                         
01756                         $disabled = false;
01757                         
01758                         // disable checkbox for system role for the system user
01759                         if (($this->object->getId() == SYSTEM_USER_ID and $role["obj_id"] == SYSTEM_ROLE_ID)
01760                                 or (!in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]) and $role["obj_id"] == SYSTEM_ROLE_ID))
01761                         {
01762                                 $disabled = true;
01763                         }
01764                         
01765             if (substr($role["title"],0,3) == "il_")
01766             {
01767                 if (!$assignable)
01768                 {
01769                         $rolf_arr = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
01770                         $rolf2 = $rolf_arr[0];
01771                 }
01772                 else
01773                 {
01774                         $rolf2 = $rolf;
01775                 }
01776                         
01777                                 $parent_node = $this->tree->getParentNodeData($rolf2);
01778                                 
01779                                 $role["description"] = $this->lng->txt("obj_".$parent_node["type"])."&nbsp;(#".$parent_node["obj_id"].")";
01780             }
01781                         
01782                         $role_ids[$counter] = $role["obj_id"];
01783                         
01784             $result_set[$counter][] = ilUtil::formCheckBox(in_array($role["obj_id"],$assigned_roles),"role_id[]",$role["obj_id"],$disabled)."<input type=\"hidden\" name=\"role_id_ctrl[]\" value=\"".$role["obj_id"]."\"/>";
01785             $result_set[$counter][] = "<a href=\"adm_object.php?ref_id=".$rolf[0]."&obj_id=".$role["obj_id"]."&cmd=perm\">".ilObjRole::_getTranslation($role["title"])."</a>";
01786             $result_set[$counter][] = $role["description"];
01787                     $result_set[$counter][] = $path;
01788 
01789                         ++$counter;
01790         }
01791 
01792                 return $this->__showRolesTable($result_set,$role_ids);
01793     }
01794                 
01803         function insertPublicProfile($a_template_var, $a_template_block_name, $a_additional = "")
01804         {
01805                 $this->tpl->addBlockFile($a_template_var, $a_template_block_name, "tpl.usr_public_profile.html");
01806                 $this->tpl->setCurrentBlock($a_template_block_name);
01807 
01808                 // Get name of picture of user
01809                 // TODO: the user is already the current user object !!
01810                 $userObj = new ilObjUser($_GET["user"]);
01811 
01812                 $this->tpl->setVariable("USR_PROFILE", $this->lng->txt("profile_of")." ".$this->object->getLogin());
01813 
01814                 $this->tpl->setVariable("ROWCOL1", "tblrow1");
01815                 $this->tpl->setVariable("ROWCOL2", "tblrow2");
01816 
01817                 require_once "./classes/class.ilvCard.php";
01818                 $vcard = new ilvCard();
01819 
01820                 //if (usr_id == $_GET["user"])
01821                 // Check from Database if value
01822                 // of public_profile = "y" show user infomation
01823                 if ($userObj->getPref("public_profile")=="y")
01824                 {
01825                         $this->tpl->setVariable("TXT_NAME",$this->lng->txt("name"));
01826                         $this->tpl->setVariable("FIRSTNAME",$userObj->getFirstName());
01827                         $this->tpl->setVariable("LASTNAME",$userObj->getLastName());
01828                         $vcard->setName($userObj->getLastName(), $userObj->getFirstName(), "", $userObj->getUTitle());
01829                         $vcard->setNickname($userObj->getLogin());
01830                 }
01831                 else
01832                 {
01833                         return;
01834                         $this->tpl->setVariable("TXT_NAME",$this->lng->txt("name"));
01835                         $this->tpl->setVariable("FIRSTNAME","N /");
01836                         $this->tpl->setVariable("LASTNAME","A");
01837                 }
01838                 $this->tpl->setCurrentBlock("vcard");
01839                 $this->tpl->setVariable("TXT_VCARD", $this->lng->txt("vcard"));
01840                 $this->tpl->setVariable("TXT_DOWNLOAD_VCARD", $this->lng->txt("vcard_download"));
01841                 $this->tpl->setVariable("HREF_VCARD", basename($_SERVER["PHP_SELF"]) ."?ref_id=".$_GET["ref_id"]. "&user=" . $_GET["user"] . "&vcard=1");
01842                 $this->tpl->setVariable("IMG_VCARD", ilUtil::getImagePath("vcard.png"));
01843                 $this->tpl->parseCurrentBlock();
01844                 $webspace_dir = ilUtil::getWebspaceDir("output");
01845                 $imagefile = $webspace_dir."/usr_images/".$userObj->getPref("profile_image");
01846                 if ($userObj->getPref("public_upload")=="y" && @is_file($imagefile))
01847                 {
01848                         //Getting the flexible path of image form ini file
01849                         //$webspace_dir = ilUtil::getWebspaceDir("output");
01850                         $this->tpl->setCurrentBlock("image");
01851                         $this->tpl->setVariable("TXT_IMAGE",$this->lng->txt("image"));
01852                         $this->tpl->setVariable("IMAGE_PATH", $webspace_dir."/usr_images/".$userObj->getPref("profile_image")."?dummy=".rand(1,999999));
01853                         $this->tpl->parseCurrentBlock();
01854                         $fh = fopen($imagefile, "r");
01855                         if ($fh)
01856                         {
01857                                 $image = fread($fh, filesize($imagefile));
01858                                 fclose($fh);
01859                                 require_once "./content/classes/Media/class.ilObjMediaObject.php";
01860                                 $mimetype = ilObjMediaObject::getMimeType($imagefile);
01861                                 if (preg_match("/^image/", $mimetype))
01862                                 {
01863                                         $type = $mimetype;
01864                                 }
01865                                 $vcard->setPhoto($image, $type);
01866                         }
01867                 }
01868 
01869                 $val_arr = array("getInstitution" => "institution", "getDepartment" => "department",
01870                         "getStreet" => "street",
01871                         "getZipcode" => "zip", "getCity" => "city", "getCountry" => "country",
01872                         "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
01873                         "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
01874                         "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
01875 
01876                 $org = array();
01877                 $adr = array();
01878                 foreach ($val_arr as $key => $value)
01879                 {
01880                         // if value "y" show information
01881                         if ($userObj->getPref("public_".$value) == "y")
01882                         {
01883                                 switch ($value)
01884                                 {
01885                                         case "institution":
01886                                                 $org[0] = $userObj->$key();
01887                                                 break;
01888                                         case "department":
01889                                                 $org[1] = $userObj->$key();
01890                                                 break;
01891                                         case "street":
01892                                                 $adr[2] = $userObj->$key();
01893                                                 break;
01894                                         case "zip":
01895                                                 $adr[5] = $userObj->$key();
01896                                                 break;
01897                                         case "city":
01898                                                 $adr[3] = $userObj->$key();
01899                                                 break;
01900                                         case "country":
01901                                                 $adr[6] = $userObj->$key();
01902                                                 break;
01903                                         case "phone_office":
01904                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_WORK);
01905                                                 break;
01906                                         case "phone_home":
01907                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_HOME);
01908                                                 break;
01909                                         case "phone_mobile":
01910                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_CELL);
01911                                                 break;
01912                                         case "fax":
01913                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_FAX);
01914                                                 break;
01915                                         case "email":
01916                                                 $vcard->setEmail($userObj->$key());
01917                                                 break;
01918                                         case "hobby":
01919                                                 $vcard->setNote($userObj->$key());
01920                                                 break;
01921                                 }
01922                                 $this->tpl->setCurrentBlock("profile_data");
01923                                 $this->tpl->setVariable("TXT_DATA", $this->lng->txt($value));
01924                                 $this->tpl->setVariable("DATA", $userObj->$key());
01925                                 $this->tpl->parseCurrentBlock();
01926                         }
01927                 }
01928 
01929                 if (count($org))
01930                 {
01931                         $vcard->setOrganization(join(";", $org));
01932                 }
01933                 if (count($adr))
01934                 {
01935                         $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
01936                 }
01937 
01938                 if (is_array($a_additional))
01939                 {
01940                         foreach($a_additional as $key => $val)
01941                         {
01942                                 $this->tpl->setCurrentBlock("profile_data");
01943                                 $this->tpl->setVariable("TXT_DATA", $key);
01944                                 $this->tpl->setVariable("DATA", $val);
01945                                 $this->tpl->parseCurrentBlock();
01946                         }
01947                 }
01948 
01949                 $this->tpl->setCurrentBlock($a_template_block_name);
01950                 $this->tpl->parseCurrentBlock();
01951 
01952                 if ($_GET["vcard"] == 1)
01953                 {
01954                         ilUtil::deliverData(utf8_decode($vcard->buildVCard()), $vcard->getFilename(), $vcard->getMimetype());
01955                         exit;
01956                 }
01957         }
01958 
01959 
01960         function __getDateSelect($a_type,$a_varname,$a_selected)
01961     {
01962         switch($a_type)
01963         {
01964             case "minute":
01965                 for($i=0;$i<=60;$i++)
01966                 {
01967                     $days[$i] = $i < 10 ? "0".$i : $i;
01968                 }
01969                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01970 
01971             case "hour":
01972                 for($i=0;$i<24;$i++)
01973                 {
01974                     $days[$i] = $i < 10 ? "0".$i : $i;
01975                 }
01976                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01977 
01978             case "day":
01979                 for($i=1;$i<32;$i++)
01980                 {
01981                     $days[$i] = $i < 10 ? "0".$i : $i;
01982                 }
01983                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01984 
01985             case "month":
01986                 for($i=1;$i<13;$i++)
01987                 {
01988                     $month[$i] = $i < 10 ? "0".$i : $i;
01989                 }
01990                 return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
01991 
01992             case "year":
01993                 for($i = date("Y",time());$i < date("Y",time()) + 11;++$i)
01994                 {
01995                     $year[$i] = $i;
01996                 }
01997                 return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
01998         }
01999     }
02000 
02001         function __toUnix($a_time_arr)
02002     {
02003         return mktime($a_time_arr["hour"],
02004                       $a_time_arr["minute"],
02005                       $a_time_arr["second"],
02006                       $a_time_arr["month"],
02007                       $a_time_arr["day"],
02008                       $a_time_arr["year"]);
02009     }
02010 
02011         function __showRolesTable($a_result_set,$a_role_ids = NULL)
02012         {
02013         global $rbacsystem;
02014 
02015                 $actions = array("assignSave"  => $this->lng->txt("change_assignment"));
02016 
02017         $tbl =& $this->__initTableGUI();
02018                 $tpl =& $tbl->getTemplateObject();
02019 
02020                 $tpl->setCurrentBlock("tbl_form_header");
02021                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02022                 $tpl->parseCurrentBlock();
02023 
02024                 $tpl->setCurrentBlock("tbl_action_row");
02025 
02026                         $tpl->setVariable("COLUMN_COUNTS",4);
02027                         $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02028 
02029             foreach ($actions as $name => $value)
02030                         {
02031                                 $tpl->setCurrentBlock("tbl_action_btn");
02032                                 $tpl->setVariable("BTN_NAME",$name);
02033                                 $tpl->setVariable("BTN_VALUE",$value);
02034                                 $tpl->parseCurrentBlock();
02035                         }
02036                         
02037                         if (!empty($a_role_ids))
02038                         {
02039                                 // set checkbox toggles
02040                                 $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
02041                                 $tpl->setVariable("JS_VARNAME","role_id");                      
02042                                 $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_role_ids));
02043                                 $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
02044                                 $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
02045                                 $tpl->parseCurrentBlock();
02046                         }
02047 
02048             $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
02049 
02050 
02051                 $this->ctrl->setParameter($this,"cmd","roleassignment");
02052 
02053                 // title & header columns
02054                 $tbl->setTitle($this->lng->txt("edit_roleassignment"),"icon_role_b.gif",$this->lng->txt("roles"));
02055 
02056                 //user must be administrator
02057                 $tbl->setHeaderNames(array("",$this->lng->txt("role"),$this->lng->txt("description"),$this->lng->txt("context")));
02058                 $tbl->setHeaderVars(array("","title","description","context"),$this->ctrl->getParameterArray($this,"",false));
02059                 $tbl->setColumnWidth(array("","30%","40%","30%"));
02060 
02061                 $this->__setTableGUIBasicData($tbl,$a_result_set,"roleassignment");
02062                 $tbl->render();
02063                 $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
02064 
02065                 return true;
02066         }
02067 
02068         function &__initTableGUI()
02069         {
02070                 include_once "class.ilTableGUI.php";
02071 
02072                 return new ilTableGUI(0,false);
02073         }
02074 
02075         function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
02076         {
02077         switch($from)
02078                 {
02079                         default:
02080                         $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
02081                                 break;
02082                 }
02083 
02084         //$tbl->enable("hits");
02085                 $tbl->setOrderColumn($order);
02086                 $tbl->setOrderDirection($_GET["sort_order"]);
02087                 $tbl->setOffset($_GET["offset"]);
02088                 $tbl->setLimit($_GET["limit"]);
02089                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02090                 $tbl->setData($result_set);
02091         }
02092 
02093         function __unsetSessionVariables()
02094         {
02095                 unset($_SESSION["filtered_roles"]);
02096         }
02097 
02098         function __buildFilterSelect()
02099         {
02100                 $action[0] = $this->lng->txt('assigned_roles');
02101                 $action[1] = $this->lng->txt('all_roles');
02102                 $action[2] = $this->lng->txt('all_global_roles');
02103                 $action[3] = $this->lng->txt('all_local_roles');
02104                 $action[4] = $this->lng->txt('internal_local_roles_only');
02105                 $action[5] = $this->lng->txt('non_internal_local_roles_only');
02106 
02107                 return ilUtil::formSelect($_SESSION['filtered_roles'],"filter",$action,false,true);
02108         }
02109 
02110         function hitsperpageObject()
02111         {
02112                 parent::hitsperpageObject();
02113                 $this->roleassignmentObject();
02114         }
02115         
02116 } // END class.ilObjUserGUI
02117 ?>

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