• 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-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00037 require_once "class.ilObjectGUI.php";
00038 
00039 class ilObjUserGUI extends ilObjectGUI
00040 {
00041         var $ilCtrl;
00042 
00048         var $gender;
00049 
00055         var $type;
00056 
00062         var $user_ref_id;
00063 
00068         function ilObjUserGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
00069         {
00070                 global $ilCtrl;
00071 
00072                 define('USER_FOLDER_ID',7);
00073 
00074                 $this->type = "usr";
00075                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output);
00076                 $this->usrf_ref_id =& $this->ref_id;
00077 
00078                 $this->ctrl =& $ilCtrl;
00079                 $this->ctrl->saveParameter($this,'obj_id');
00080 
00081                 // for gender selection. don't change this
00082                 // maybe deprecated
00083                 $this->gender = array(
00084                                                           'm'    => "salutation_m",
00085                                                           'f'    => "salutation_f"
00086                                                           );
00087         }
00088 
00089         function &executeCommand()
00090         {
00091                 global $rbacsystem;
00092 
00093                 $next_class = $this->ctrl->getNextClass($this);
00094                 $cmd = $this->ctrl->getCmd();
00095                 switch($next_class)
00096                 {
00097                         default:
00098                                 if(!$cmd)
00099                                 {
00100                                         $cmd = "view";
00101                                 }
00102                                 $cmd .= "Object";
00103                                 $this->$cmd();
00104                                         
00105                                 break;
00106                 }
00107                 return true;
00108         }
00109 
00110 
00111         function cancelObject()
00112         {
00113                 session_unregister("saved_post");
00114 
00115                 sendInfo($this->lng->txt("msg_cancel"),true);
00116 
00117                 if($this->ctrl->getTargetScript() == 'adm_object.php')
00118                 {
00119                         $return_location = $_GET["cmd_return_location"];
00120                         ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
00121                 }
00122                 else
00123                 {
00124                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
00125                 }
00126         }
00127 
00131         function createObject()
00132         {
00133                 global $ilias, $rbacsystem, $rbacreview, $styleDefinition;
00134                 //load ILIAS settings
00135                 $settings = $ilias->getAllSettings();
00136                 
00137                 if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
00138                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
00139                 {
00140                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00141                 }
00142                 
00143                 // role selection
00144                 $obj_list = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
00145                 $rol = array();
00146                 foreach ($obj_list as $obj_data)
00147                 {
00148                         // allow only 'assign_users' marked roles if called from category
00149                         if($this->object->getRefId() != USER_FOLDER_ID and !in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00150                         {
00151                                 include_once './classes/class.ilObjRole.php';
00152                 
00153                                 if(!ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
00154                                 {
00155                                         continue;
00156                                 }
00157                         }
00158                         // exclude anonymous role from list
00159                         if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
00160                         {
00161                                 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
00162                                 if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00163                                 {
00164                                         $rol[$obj_data["obj_id"]] = $obj_data["title"];
00165                                 }
00166                         }
00167                 }
00168                 
00169                 // raise error if there is no global role user can be assigned to
00170                 if(!count($rol))
00171                 {
00172                         $this->ilias->raiseError($this->lng->txt("msg_no_roles_users_can_be_assigned_to"),$this->ilias->error_obj->MESSAGE);
00173                 }
00174                 
00175                 $keys = array_keys($rol);
00176                 
00177                 // set pre defined user role to default
00178                 if (in_array(4,$keys))
00179                 {
00180                         $default_role = 4;
00181                 }
00182                 else
00183                 {
00184                         if (count($keys) > 1 and in_array(2,$keys))
00185                         {
00186                                 $key = key($keys[2]);
00187                                 unset($keys[$key]);
00188                         }
00189                 
00190                         $default_role = array_shift($keys);
00191                 }
00192                 
00193                 $pre_selected_role = (isset($_SESSION["error_post_vars"]["Fobject"]["default_role"])) ? $_SESSION["error_post_vars"]["Fobject"]["default_role"] : $default_role;
00194                 
00195                 $roles = ilUtil::formSelect($pre_selected_role,"Fobject[default_role]",$rol,false,true);
00196                 $data = array();
00197                 $data["fields"] = array();
00198                 $data["fields"]["login"] = "";
00199                 $data["fields"]["passwd"] = "";
00200                 $data["fields"]["passwd2"] = "";
00201                 $data["fields"]["title"] = "";
00202                 $data["fields"]["gender"] = "";
00203                 $data["fields"]["firstname"] = "";
00204                 $data["fields"]["lastname"] = "";
00205                 $data["fields"]["institution"] = "";
00206                 $data["fields"]["department"] = "";
00207                 $data["fields"]["street"] = "";
00208                 $data["fields"]["city"] = "";
00209                 $data["fields"]["zipcode"] = "";
00210                 $data["fields"]["country"] = "";
00211                 $data["fields"]["phone_office"] = "";
00212                 $data["fields"]["phone_home"] = "";
00213                 $data["fields"]["phone_mobile"] = "";
00214                 $data["fields"]["fax"] = "";
00215                 $data["fields"]["email"] = "";
00216                 $data["fields"]["hobby"] = "";
00217                 $data["fields"]["matriculation"] = "";
00218                 $data["fields"]["referral_comment"] = "";
00219                 $data["fields"]["create_date"] = "";
00220                 $data["fields"]["approve_date"] = "";
00221                 $data["fields"]["active"] = " checked=\"checked\"";
00222                 $data["fields"]["default_role"] = $roles;
00223                 
00224                 $this->getTemplateFile("edit","usr");
00225                 
00226                 // fill presets
00227                 foreach ($data["fields"] as $key => $val)
00228                 {
00229                         $str = $this->lng->txt($key);
00230                         if ($key == "title")
00231                         {
00232                                 $str = $this->lng->txt("person_title");
00233                         }
00234                 
00235                         // check to see if dynamically required
00236                         if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00237                         {
00238                                 $str = $str . '<span class="asterisk">*</span>';
00239                         }
00240                 
00241                         $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00242                 
00243                         if ($key == "default_role")
00244                         {
00245                                 $this->tpl->setVariable(strtoupper($key), $val);
00246                         }
00247                         else
00248                         {
00249                                 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00250                         }
00251                 
00252                         if ($this->prepare_output)
00253                         {
00254                                 $this->tpl->parseCurrentBlock();
00255                         }
00256                 }
00257                 
00258                 $this->ctrl->setParameter($this,'new_type',$this->type);
00259                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));                
00260                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->type."_new"));
00261                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00262                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($this->type."_add"));
00263                 $this->tpl->setVariable("CMD_SUBMIT", "save");
00264                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00265                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00266                 
00267                 $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
00268                 $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
00269                 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
00270                 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
00271                 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
00272                 $this->tpl->setVariable("TXT_PASSWD2", $this->lng->txt("retype_password"));
00273                 $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
00274                 $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
00275                 $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
00276                 $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
00277                 $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
00278 
00279                 // FILL SAVED VALUES IN CASE OF ERROR
00280                 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00281                 {
00282                         if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
00283                         {
00284                                 $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
00285                         }
00286                 
00287                         foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
00288                         {
00289                                 if ($key != "default_role" and $key != "language" and $key != "skin_style")
00290                                 {
00291                                         $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00292                                 }
00293                         }
00294                 
00295                         // gender selection
00296                         $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00297                 
00298                         if (!empty($gender))
00299                         {
00300                                 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00301                         }
00302 
00303                         $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
00304                         if ($active)
00305                         {
00306                                 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00307                         }
00308                 }
00309                 
00310                 // language selection
00311                 $languages = $this->lng->getInstalledLanguages();
00312                 
00313                 // preselect previous chosen language otherwise default language
00314                 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->ilias->getSetting("language");
00315                 
00316                 foreach ($languages as $lang_key)
00317                 {
00318                         $this->tpl->setCurrentBlock("language_selection");
00319                         $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
00320                         $this->tpl->setVariable("LANGSHORT", $lang_key);
00321                 
00322                         if ($selected_lang == $lang_key)
00323                         {
00324                                 $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00325                         }
00326                 
00327                         $this->tpl->parseCurrentBlock();
00328                 } // END language selection
00329                 
00330                 // skin & style selection
00331                 $templates = $styleDefinition->getAllTemplates();
00332                 //$this->ilias->getSkins();
00333                 
00334                 // preselect previous chosen skin/style otherwise default skin/style
00335                 if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
00336                 {
00337                         $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
00338                 
00339                         $selected_style = $sknst[1];
00340                         $selected_skin = $sknst[0];
00341                 }
00342                 else
00343                 {
00344                         $selected_style = $this->object->prefs["style"];
00345                         $selected_skin = $this->object->skin;
00346                 }
00347                 
00348                 foreach ($templates as $template)
00349                 {
00350                         // get styles for skin
00351                         //$this->ilias->getStyles($template["id"]);
00352                         $styleDef =& new ilStyleDefinition($template["id"]);
00353                         $styleDef->startParsing();
00354                         $styles = $styleDef->getStyles();
00355                 
00356                         foreach($styles as $style)
00357                         {
00358                                 $this->tpl->setCurrentBlock("selectskin");
00359                 
00360                                 if ($selected_skin == $template["id"] &&
00361                                         $selected_style == $style["id"])
00362                                 {
00363                                         $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00364                                 }
00365                 
00366                                 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00367                                 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00368                                 $this->tpl->parseCurrentBlock();
00369                         }
00370                 } // END skin & style selection
00371                 
00372                 
00373                 // time limit
00374                 if (is_array($_SESSION["error_post_vars"]))
00375                 {
00376                         $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"];
00377                 }
00378                 else
00379                 {
00380                         $time_limit_unlimited = 1;
00381                 }
00382                 
00383                 $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
00384                         $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
00385                         time();
00386                 
00387                 $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
00388                         $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
00389                         time();
00390                 
00391                 $this->lng->loadLanguageModule('crs');
00392                 
00393                 $this->tpl->setCurrentBlock("time_limit");
00394                 $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
00395                 $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
00396                 $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
00397                 $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
00398                 $this->tpl->setVariable("TXT_TIME_LIMIT_CLOCK", $this->lng->txt("clock"));
00399                 $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
00400                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
00401                         date("i",$time_limit_from)));
00402                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
00403                                                                                                                                                                          date("G",$time_limit_from)));
00404                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
00405                                                                                                                                                                         date("d",$time_limit_from)));
00406                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
00407                                                                                                                                                                           date("m",$time_limit_from)));
00408                 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
00409                                                                                                                                                                          date("Y",$time_limit_from)));
00410                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
00411                                                                                                                                                                                 date("i",$time_limit_until)));
00412                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
00413                                                                                                                                                                           date("G",$time_limit_until)));
00414                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
00415                                                                                                                                                                          date("d",$time_limit_until)));
00416                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
00417                                                                                                                                                                            date("m",$time_limit_until)));
00418                 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
00419                                                                                                                                                                           date("Y",$time_limit_until)));
00420                 $this->tpl->parseCurrentBlock();
00421 
00422 
00423         }
00424         
00549     function editObject()
00550     {
00551         global $ilias, $rbacsystem, $rbacreview, $rbacadmin, $styleDefinition;
00552 
00553         //load ILIAS settings
00554         $settings = $ilias->getAllSettings();
00555 
00556                 // deactivated:
00557                 // or ($this->id != $_SESSION["AccountId"])
00558                 if (!$rbacsystem->checkAccess('visible,read', $this->usrf_ref_id) and
00559                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
00560                 {
00561                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
00562                 }
00563 
00564                 $data = array();
00565                 $data["fields"] = array();
00566                 $data["fields"]["login"] = $this->object->getLogin();
00567                 $data["fields"]["passwd"] = "********"; // will not be saved
00568                 $data["fields"]["passwd2"] = "********";        // will not be saved
00569                 $data["fields"]["title"] = $this->object->getUTitle();
00570                 $data["fields"]["gender"] = $this->object->getGender();
00571                 $data["fields"]["firstname"] = $this->object->getFirstname();
00572                 $data["fields"]["lastname"] = $this->object->getLastname();
00573                 $data["fields"]["institution"] = $this->object->getInstitution();
00574                 $data["fields"]["department"] = $this->object->getDepartment();
00575                 $data["fields"]["street"] = $this->object->getStreet();
00576                 $data["fields"]["city"] = $this->object->getCity();
00577                 $data["fields"]["zipcode"] = $this->object->getZipcode();
00578                 $data["fields"]["country"] = $this->object->getCountry();
00579                 $data["fields"]["phone_office"] = $this->object->getPhoneOffice();
00580                 $data["fields"]["phone_home"] = $this->object->getPhoneHome();
00581                 $data["fields"]["phone_mobile"] = $this->object->getPhoneMobile();
00582                 $data["fields"]["fax"] = $this->object->getFax();
00583                 $data["fields"]["email"] = $this->object->getEmail();
00584                 $data["fields"]["hobby"] = $this->object->getHobby();
00585                 $data["fields"]["matriculation"] = $this->object->getMatriculation();
00586                 $data["fields"]["referral_comment"] = $this->object->getComment();
00587                 $data["fields"]["create_date"] = $this->object->getCreateDate();
00588                 $data["fields"]["approve_date"] = $this->object->getApproveDate();
00589                 $data["fields"]["active"] = $this->object->getActive();
00590 
00591                 if (!count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
00592                 {
00593                         $user_is_online = false;
00594                 }
00595                 else
00596                 {
00597                         $user_is_online = true;
00598 
00599                         // extract serialized role Ids from session data
00600                         preg_match("/RoleId.*?;\}/",$user_online[$this->object->getId()]["data"],$matches);
00601 
00602                         $active_roles = unserialize(substr($matches[0],7));
00603 
00604                         // gather data for active roles
00605                         $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
00606 
00607                         foreach ($assigned_roles as $key => $role)
00608                         {
00609                                 $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role);
00610 
00611                                 // fetch context path of role
00612                                 $rolf = $rbacreview->getFoldersAssignedToRole($role,true);
00613 
00614                                 // only list roles that are not set to status "deleted"
00615                                 if (count($rolf) > 0)
00616                                 {
00617                                         if (!$rbacreview->isDeleted($rolf[0]))
00618                                         {
00619                                                 $path = "";
00620 
00621                                                 if ($this->tree->isInTree($rolf[0]))
00622                                                 {
00623                                                         $tmpPath = $this->tree->getPathFull($rolf[0]);
00624 
00625                                                         // count -1, to exclude the role folder itself
00626                                                         for ($i = 0; $i < (count($tmpPath)-1); $i++)
00627                                                         {
00628                                                                 if ($path != "")
00629                                                                 {
00630                                                                         $path .= " > ";
00631                                                                 }
00632 
00633                                                                 $path .= $tmpPath[$i]["title"];
00634                                                         }
00635                                                 }
00636                                                 else
00637                                                 {
00638                                                         $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role.")</b>";
00639                                                 }
00640 
00641                                                 if (in_array($role,$active_roles))
00642                                                 {
00643                                                         $data["active_role"][$role]["active"] = true;
00644                                                 }
00645 
00646                                                 $data["active_role"][$role]["title"] = $roleObj->getTitle();
00647                                                 $data["active_role"][$role]["context"] = $path;
00648 
00649                                                 unset($roleObj);
00650                                         }
00651                                 }
00652                                 else
00653                                 {
00654                                         $path = "<b>No role folder found for role ".$role."!</b>";
00655                                 }
00656                         }
00657                 }
00658 
00659                 $this->getTemplateFile("edit","usr");
00660 
00661                 // FILL SAVED VALUES IN CASE OF ERROR
00662                 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00663                 {
00664             if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
00665             {
00666                 $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
00667             }
00668 
00669                         foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
00670                         {
00671                                 $str = $this->lng->txt($key);
00672                                 if ($key == "title")
00673                                 {
00674                                         $str = $this->lng->txt("person_title");
00675                                 }
00676 
00677                 // check to see if dynamically required
00678                 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00679                 {
00680                     $str = $str . '<span class="asterisk">*</span>';
00681                 }
00682 
00683                                 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00684 
00685                                 if ($key != "default_role" and $key != "language" and $key != "skin_style")
00686                                 {
00687                                         $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
00688                                 }
00689                         }
00690 
00691                         // gender selection
00692                         $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00693 
00694                         if (!empty($gender))
00695                         {
00696                                 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00697                         }
00698 
00699             $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
00700             if ($active)
00701             {
00702                 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00703             }
00704                 }
00705                 else
00706                 {
00707             if (!isset($data["fields"]["active"]))
00708             {
00709                 $data["fields"]["active"] = 0;
00710             }
00711 
00712                         foreach ($data["fields"] as $key => $val)
00713                         {
00714                                 $str = $this->lng->txt($key);
00715                                 if ($key == "title")
00716                                 {
00717                                         $str = $this->lng->txt("person_title");
00718                                 }
00719 
00720                 // check to see if dynamically required
00721                 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00722                 {
00723                     $str = $str . '<span class="asterisk">*</span>';
00724                 }
00725 
00726                                 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00727 
00728                                 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00729                                 $this->tpl->parseCurrentBlock();
00730                         }
00731                         
00732                         // gender selection
00733                         $gender = strtoupper($data["fields"]["gender"]);
00734                 
00735                         if (!empty($gender))
00736                         {
00737                                 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00738                         }
00739 
00740                         $active = $data["fields"]["active"];
00741                         if ($active)
00742                         {
00743                                 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00744                         }
00745                 }
00746                 
00747                 if (AUTH_CURRENT != AUTH_LOCAL)
00748                 {
00749                         $this->tpl->setVariable("OPTION_DISABLED", "\"disabled=disabled\"");
00750                 }
00751 
00752                 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00753                 
00754                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00755                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
00756                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00757                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00758                 $this->tpl->setVariable("CMD_SUBMIT", "update");
00759                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00760                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00761 
00762                 $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
00763         $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
00764                 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
00765                 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
00766                 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
00767                 $this->tpl->setVariable("TXT_PASSWD2", $this->lng->txt("retype_password"));
00768                 $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
00769                 $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
00770                 $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
00771                 $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
00772                 $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
00773 
00774                 // language selection
00775                 $languages = $this->lng->getInstalledLanguages();
00776 
00777                 // preselect previous chosen language otherwise default language
00778                 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->object->getLanguage();
00779 
00780                 foreach ($languages as $lang_key)
00781                 {
00782                         $this->tpl->setCurrentBlock("language_selection");
00783                         $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
00784                         $this->tpl->setVariable("LANGSHORT", $lang_key);
00785 
00786                         if ($selected_lang == $lang_key)
00787                         {
00788                                 $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00789                         }
00790 
00791                         $this->tpl->parseCurrentBlock();
00792                 } // END language selection
00793                 
00794                 // skin & style selection
00795                 //$this->ilias->getSkins();
00796                 $templates = $styleDefinition->getAllTemplates();
00797                 
00798                 // preselect previous chosen skin/style otherwise default skin/style
00799                 if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
00800                 {
00801                         $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
00802                         
00803                         $selected_style = $sknst[1];
00804                         $selected_skin = $sknst[0];     
00805                 }
00806                 else
00807                 {
00808                         $selected_style = $this->object->prefs["style"];
00809                         $selected_skin = $this->object->skin;   
00810                 }
00811                 foreach ($templates as $template)
00812                 {
00813                         // get styles for skin
00814                         //$this->ilias->getStyles($skin["name"]);
00815                         $styleDef =& new ilStyleDefinition($template["id"]);
00816                         $styleDef->startParsing();
00817                         $styles = $styleDef->getStyles();
00818                         foreach ($styles as $style)
00819                         {
00820                                 $this->tpl->setCurrentBlock("selectskin");
00821 
00822                                 if ($selected_skin == $template["id"] &&
00823                                         $selected_style == $style["id"])
00824                                 {
00825                                         $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00826                                 }
00827 
00828                                 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00829                                 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00830                                 $this->tpl->parseCurrentBlock();
00831                         }
00832                 } // END skin & style selection
00833 
00834                 // inform user about changes option
00835                 $this->tpl->setCurrentBlock("inform_user");
00836 
00837 
00838                 if (true)
00839                 {
00840                         $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
00841                 }
00842 
00843                 $this->tpl->setVariable("TXT_INFORM_USER_MAIL", $this->lng->txt("inform_user_mail"));
00844                 $this->tpl->parseCurrentBlock();
00845 
00846                 $this->lng->loadLanguageModule('crs');
00847 
00848                 $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"] ?
00849             $_SESSION["error_post_vars"]["time_limit"]["unlimited"] :
00850             $this->object->getTimeLimitUnlimited();
00851         $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
00852             $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
00853             $this->object->getTimeLimitFrom();
00854 
00855         $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
00856             $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
00857             $this->object->getTimeLimitUntil();
00858 
00859                 $this->tpl->setCurrentBlock("time_limit");
00860         $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
00861         $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
00862         $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
00863         $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
00864 
00865         $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
00866         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
00867                                                                                      date("i",$time_limit_from)));
00868         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
00869                                                                                      date("G",$time_limit_from)));
00870         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
00871                                                                                      date("d",$time_limit_from)));
00872         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
00873                                                                                        date("m",$time_limit_from)));
00874         $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
00875                                                                                       date("Y",$time_limit_from)));
00876         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
00877                                                                                      date("i",$time_limit_until)));
00878         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
00879                                                                                      date("G",$time_limit_until)));
00880         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
00881                                                                                    date("d",$time_limit_until)));
00882         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
00883                                                                                      date("m",$time_limit_until)));
00884         $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
00885                                                                                     date("Y",$time_limit_until)));
00886                 $this->tpl->parseCurrentBlock();
00887 
00888 
00889                 if ($user_is_online)
00890                 {
00891                         // BEGIN TABLE ROLES
00892                         $this->tpl->setCurrentBlock("TABLE_ROLES");
00893 
00894                         $counter = 0;
00895 
00896                         foreach ($data["active_role"] as $role_id => $role)
00897                         {
00898                                 ++$counter;
00899                                 $css_row = ilUtil::switchColor($counter,"tblrow2","tblrow1");
00900                                 ($role["active"]) ? $checked = "checked=\"checked\"" : $checked = "";
00901 
00902                                 $this->tpl->setVariable("ACTIVE_ROLE_CSS_ROW",$css_row);
00903                                 $this->tpl->setVariable("ROLECONTEXT",$role["context"]);
00904                                 $this->tpl->setVariable("ROLENAME",$role["title"]);
00905                                 $this->tpl->setVariable("CHECKBOX_ID", $role_id);
00906                                 $this->tpl->setVariable("CHECKED", $checked);
00907                                 $this->tpl->parseCurrentBlock();
00908                         }
00909                         // END TABLE ROLES
00910 
00911                         // BEGIN ACTIVE ROLES
00912                         $this->tpl->setCurrentBlock("ACTIVE_ROLE");
00913                         $this->tpl->setVariable("ACTIVE_ROLE_FORMACTION","adm_object.php?cmd=activeRoleSave&ref_id=".
00914                                                                         $this->usrf_ref_id."&obj_id=".$this->obj_id);
00915                         $this->tpl->setVariable("TXT_ACTIVE_ROLES",$this->lng->txt("active_roles"));
00916                         $this->tpl->setVariable("TXT_ASSIGN",$this->lng->txt("change_active_assignment"));
00917                         $this->tpl->parseCurrentBlock();
00918                         // END ACTIVE ROLES
00919                 }
00920         }
00921 
00926         function saveObject()
00927         {
00928         global $ilias, $rbacsystem, $rbacadmin;
00929 
00930         //load ILIAS settings
00931         $settings = $ilias->getAllSettings();
00932 
00933                 if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
00934                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
00935                 {
00936                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
00937                 }
00938 
00939         // check dynamically required fields
00940         foreach ($settings as $key => $val)
00941         {
00942             if (substr($key,0,8) == "require_")
00943             {
00944                 $require_keys[] = substr($key,8);
00945             }
00946         }
00947 
00948         foreach ($require_keys as $key => $val)
00949         {
00950             if (isset($settings["require_" . $val]) && $settings["require_" . $val])
00951             {
00952                 if (empty($_POST["Fobject"][$val]))
00953                 {
00954                     $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " . 
00955                                                                                          $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
00956                 }
00957             }
00958         }
00959 
00960                 // validate login
00961                 if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
00962                 {
00963                         $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
00964                 }
00965 
00966                 // check loginname
00967                 if (loginExists($_POST["Fobject"]["login"]))
00968                 {
00969                         $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
00970                 }
00971 
00972                 // check passwords
00973                 if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
00974                 {
00975                         $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
00976                 }
00977 
00978                 // validate password
00979                 if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
00980                 {
00981                         $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
00982                 }
00983 
00984                 // validate email
00985                 if (!ilUtil::is_email($_POST["Fobject"]["email"]))
00986                 {
00987                         $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
00988                 }
00989 
00990                 // validate time limit
00991         if ($_POST["time_limit"]["unlimited"] != 1 and
00992             ($this->__toUnix($_POST["time_limit"]["until"]) < $this->__toUnix($_POST["time_limit"]["from"])))
00993         {
00994             $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
00995         }
00996                 if(!$this->ilias->account->getTimeLimitUnlimited())
00997                 {
00998                         if($this->__toUnix($_POST["time_limit"]["from"]) < $this->ilias->account->getTimeLimitFrom() or
00999                            $this->__toUnix($_POST["time_limit"]["until"])> $this->ilias->account->getTimeLimitUntil() or
01000                            $_POST['time_limit']['unlimited'])
01001                         {
01002                                 $this->ilias->raiseError($this->lng->txt("time_limit_not_within_owners"),$this->ilias->error_obj->MESSAGE);
01003                         }
01004                 }
01005 
01006 
01007 
01008                 // TODO: check if login or passwd already exists
01009                 // TODO: check length of login and passwd
01010 
01011                 // checks passed. save user
01012                 $userObj = new ilObjUser();
01013                 $userObj->assignData($_POST["Fobject"]);
01014                 $userObj->setTitle($userObj->getFullname());
01015                 $userObj->setDescription($userObj->getEmail());
01016 
01017                 $userObj->setTimeLimitOwner($this->object->getRefId());
01018         $userObj->setTimeLimitUnlimited($_POST["time_limit"]["unlimited"]);
01019         $userObj->setTimeLimitFrom($this->__toUnix($_POST["time_limit"]["from"]));
01020         $userObj->setTimeLimitUntil($this->__toUnix($_POST["time_limit"]["until"]));
01021                 
01022                 $userObj->create();
01023 
01024                 //$user->setId($userObj->getId());
01025 
01026                 //insert user data in table user_data
01027                 $userObj->saveAsNew();
01028 
01029                 // setup user preferences
01030                 $userObj->setLanguage($_POST["Fobject"]["language"]);
01031 
01032                 //set user skin and style
01033                 $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
01034 
01035                 if ($userObj->getPref("style") != $sknst[1] ||
01036                         $userObj->getPref("skin") != $sknst[0])
01037                 {
01038                         $userObj->setPref("skin", $sknst[0]);
01039                         $userObj->setPref("style", $sknst[1]);
01040                 }
01041 
01042                 $userObj->writePrefs();
01043 
01044                 //set role entries
01045                 $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
01046 
01047                 /* moved the following to ObjUser->saveasNew
01048                 // CREATE ENTRIES FOR MAIL BOX
01049                 include_once ("classes/class.ilMailbox.php");
01050                 $mbox = new ilMailbox($userObj->getId());
01051                 $mbox->createDefaultFolder();
01052 
01053                 include_once "classes/class.ilMailOptions.php";
01054                 $mail_options = new ilMailOptions($userObj->getId());
01055                 $mail_options->createMailOptionsEntry();
01056 
01057                 // create personal bookmark folder tree
01058                 include_once "classes/class.ilBookmarkFolder.php";
01059                 $bmf = new ilBookmarkFolder(0, $userObj->getId());
01060                 $bmf->createNewBookmarkTree();*/
01061 
01062                 sendInfo($this->lng->txt("user_added"),true);
01063 
01064                 
01065                 if($this->ctrl->getTargetScript() == 'adm_object.php')
01066                 {
01067                         ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$this->usrf_ref_id));
01068                 }
01069                 else
01070                 {
01071                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01072                 }
01073         }
01074 
01079         function updateObject()
01080         {
01081         global $ilias, $rbacsystem, $rbacadmin;
01082 
01083         //load ILIAS settings
01084         $settings = $ilias->getAllSettings();
01085 
01086                 // check write access
01087                 if (!$rbacsystem->checkAccess('write', $this->usrf_ref_id) and
01088                         !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
01089                 {
01090                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
01091                 }
01092 
01093                 foreach ($_POST["Fobject"] as $key => $val)
01094                 {
01095                         $_POST["Fobject"][$key] = ilUtil::stripSlashes($val);
01096                 }
01097 
01098         // XXX not sure what the purpose of this conditional is
01099         // XXX for now, both conditions have the same effect
01100                 if (AUTH_CURRENT == AUTH_LOCAL)
01101                 {
01102             // check dynamically required fields
01103             foreach ($settings as $key => $val)
01104             {
01105                 if (substr($key,0,8) == "require_")
01106                 {
01107                     $require_keys[] = substr($key,8);
01108                 }
01109             }
01110 
01111             foreach ($require_keys as $key => $val)
01112             {
01113                 // exclude required system and registration-only fields
01114                 $system_fields = array("default_role");
01115                 if (!in_array($val, $system_fields))
01116                 {
01117                     if (isset($settings["require_" . $val]) && $settings["require_" . $val])
01118                     {
01119                         if (empty($_POST["Fobject"][$val]))
01120                         {
01121                             $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
01122                         }
01123                     }
01124                 }
01125             }
01126                 }
01127                 else
01128                 {
01129             // check dynamically required fields
01130             foreach ($settings as $key => $val)
01131             {
01132                 if (substr($key,0,8) == "require_")
01133                 {
01134                     $require_keys[] = substr($key,8);
01135                 }
01136             }
01137 
01138             foreach ($require_keys as $key => $val)
01139             {
01140                 // exclude required system and registration-only fields
01141                 $system_fields = array("default_role");
01142                 if (!in_array($val, $system_fields))
01143                 {
01144                     if (isset($settings["require_" . $val]) && $settings["require_" . $val])
01145                     {
01146                         if (empty($_POST["Fobject"][$val]))
01147                         {
01148                             $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
01149                         }
01150                     }
01151                 }
01152             }
01153                 }
01154 
01155                 if (AUTH_CURRENT == AUTH_LOCAL)
01156                 {
01157                         // validate login
01158                         if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
01159                         {
01160                                 $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
01161                         }
01162 
01163                         // check loginname
01164                         if (loginExists($_POST["Fobject"]["login"],$this->id))
01165                         {
01166                                 $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
01167                         }
01168 
01169                         // check passwords
01170                         if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
01171                         {
01172                                 $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
01173                         }
01174 
01175                         // validate password
01176                         if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
01177                         {
01178                                 $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
01179                         }
01180 
01181                         if ($_POST["Fobject"]["passwd"] != "********")
01182                         {
01183                                 $this->object->resetPassword($_POST["Fobject"]["passwd"],$_POST["Fobject"]["passwd2"]);
01184                         }
01185                 }
01186 
01187                 // validate email
01188                 if (!ilUtil::is_email($_POST["Fobject"]["email"]))
01189                 {
01190                         $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
01191                 }
01192                 
01193                 $start = $this->__toUnix($_POST["time_limit"]["from"]);
01194                 $end = $this->__toUnix($_POST["time_limit"]["until"]);
01195                 
01196                 // validate time limit
01197         if (!$_POST["time_limit"]["unlimited"]  and 
01198                         ( $start > $end))
01199         {
01200             $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
01201         }
01202 
01203                 if(!$this->ilias->account->getTimeLimitUnlimited())
01204                 {
01205                         if($start < $this->ilias->account->getTimeLimitFrom() or
01206                            $end > $this->ilias->account->getTimeLimitUntil() or
01207                            $_POST['time_limit']['unlimited'])
01208                         {
01209                                 $_SESSION['error_post_vars'] = $_POST;
01210 
01211                                 sendInfo($this->lng->txt('time_limit_not_within_owners'));
01212                                 $this->editObject();
01213 
01214                                 return false;
01215                         }
01216                 }
01217 
01218                 // TODO: check length of login and passwd
01219 
01220                 // checks passed. save user
01221                 $_POST['Fobject']['time_limit_owner'] = $this->object->getTimeLimitOwner();
01222 
01223                 $_POST['Fobject']['time_limit_unlimited'] = (int) $_POST['time_limit']['unlimited'];
01224                 $_POST['Fobject']['time_limit_from'] = $this->__toUnix($_POST['time_limit']['from']);
01225                 $_POST['Fobject']['time_limit_until'] = $this->__toUnix($_POST['time_limit']['until']);
01226 
01227                 if($_POST['Fobject']['time_limit_unlimited'] != $this->object->getTimeLimitUnlimited() or
01228                    $_POST['Fobject']['time_limit_from'] != $this->object->getTimeLimitFrom() or
01229                    $_POST['Fobject']['time_limit_until'] != $this->object->getTimeLimitUntil())
01230                 {
01231                         $_POST['Fobject']['time_limit_message'] = 0;
01232                 }
01233                 else
01234                 {
01235                         $_POST['Fobject']['time_limit_message'] = $this->object->getTimeLimitMessage();
01236                 }
01237                 $this->object->assignData($_POST["Fobject"]);
01238 
01239                 if (AUTH_CURRENT == AUTH_LOCAL)
01240                 {
01241                         $this->object->updateLogin($_POST["Fobject"]["login"]);
01242                 }
01243                 
01244                 $this->object->setTitle($this->object->getFullname());
01245                 $this->object->setDescription($this->object->getEmail());
01246                 $this->object->setLanguage($_POST["Fobject"]["language"]);
01247                 
01248                 //set user skin and style
01249                 $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
01250                         
01251                 if ($this->object->getPref("style") != $sknst[1] ||
01252                         $this->object->getPref("skin") != $sknst[0])
01253                 {
01254                         $this->object->setPref("skin", $sknst[0]);
01255                         $this->object->setPref("style", $sknst[1]);
01256                 }
01257 
01258                 $this->update = $this->object->update();
01259                 //$rbacadmin->updateDefaultRole($_POST["Fobject"]["default_role"], $this->object->getId());
01260 
01261                 // send email
01262                 if ($_POST["send_mail"] == "y")
01263                 {
01264                         $this->lng->loadLanguageModule('crs');
01265 
01266                         include_once "classes/class.ilFormatMail.php";
01267 
01268                         $umail = new ilFormatMail($_SESSION["AccountId"]);
01269 
01270                         // mail body
01271                         $body = $this->lng->txt("login").": ".$this->object->getLogin()."\n\r".
01272                     $this->lng->txt("passwd").": ".$_POST["Fobject"]["passwd"]."\n\r".
01273                     $this->lng->txt("title").": ".$this->object->getTitle()."\n\r".
01274                     $this->lng->txt("gender").": ".$this->object->getGender()."\n\r".
01275                     $this->lng->txt("firstname").": ".$this->object->getFirstname()."\n\r".
01276                     $this->lng->txt("lastname").": ".$this->object->getLastname()."\n\r".
01277                     $this->lng->txt("institution").": ".$this->object->getInstitution()."\n\r".
01278                     $this->lng->txt("department").": ".$this->object->getDepartment()."\n\r".
01279                     $this->lng->txt("street").": ".$this->object->getStreet()."\n\r".
01280                     $this->lng->txt("city").": ".$this->object->getCity()."\n\r".
01281                     $this->lng->txt("zipcode").": ".$this->object->getZipcode()."\n\r".
01282                     $this->lng->txt("country").": ".$this->object->getCountry()."\n\r".
01283                     $this->lng->txt("phone_office").": ".$this->object->getPhoneOffice()."\n\r".
01284                     $this->lng->txt("phone_home").": ".$this->object->getPhoneHome()."\n\r".
01285                     $this->lng->txt("phone_mobile").": ".$this->object->getPhoneMobile()."\n\r".
01286                     $this->lng->txt("fax").": ".$this->object->getFax()."\n\r".
01287                     $this->lng->txt("email").": ".$this->object->getEmail()."\n\r".
01288                     $this->lng->txt("hobby").": ".$this->object->getHobby()."\n\r".
01289                                                                                 $this->lng->txt("matriculation").": ".$this->object->getMatriculation()."\n\r".
01290                     $this->lng->txt("referral_comment").": ".$this->object->getComment()."\n\r".
01291                     $this->lng->txt("create_date").": ".$this->object->getCreateDate()."\n\r".
01292                     $this->lng->txt("default_role").": ".$_POST["Fobject"]["default_role"]."\n\r";
01293 
01294             if($this->object->getTimeLimitUnlimited())
01295             {
01296                 $body .= $this->lng->txt('time_limit').": ".$this->lng->txt('crs_unlimited')."\n\r";
01297             }
01298             else
01299             {
01300                 $body .= $this->lng->txt('time_limit').": ".$this->lng->txt('crs_from')." ".
01301                     strftime('%Y-%m-%d %R',$this->object->getTimeLimitFrom())." ".
01302                     $this->lng->txt('crs_to')." ".
01303                     strftime('%Y-%m-%d %R',$this->object->getTimeLimitUntil())."\n\r";
01304             }
01305 
01306             $body .= $this->lng->txt('email_footer') . "\n\r";
01307 
01308                         if ($error_message = $umail->sendMail($this->object->getLogin(),"","",
01309                                                                                                   $this->lng->txt("profile_changed"),$body,array(),array("normal")))
01310                         {
01311                                 $msg = $this->lng->txt("saved_successfully")."<br/>".$error_message;
01312                         }
01313                         else
01314                         {
01315                                 $msg = $this->lng->txt("saved_successfully")."<br/>".$this->lng->txt("mail_sent");
01316                         }
01317                 }
01318                 else
01319                 {
01320                         $msg = $this->lng->txt("saved_successfully");
01321                 }
01322 
01323                 // feedback
01324                 sendInfo($msg,true);
01325 
01326                 if($this->ctrl->getTargetScript() == 'adm_object.php')
01327                 {
01328                         ilUtil::redirect("adm_object.php?ref_id=".$this->usrf_ref_id);
01329                 }
01330                 else
01331                 {
01332                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01333                 }
01334         }
01335 
01336 
01343         function activeRoleSaveObject()
01344         {
01345                 global $rbacreview;
01346 
01347                 $_POST["id"] = $_POST["id"] ? $_POST["id"] : array();
01348 
01349                 // at least one active global role must be assigned to user
01350                 $global_roles_all = $rbacreview->getGlobalRoles();
01351                 $assigned_global_roles = array_intersect($_POST["id"],$global_roles_all);
01352                 
01353                 if (!count($_POST["id"]) or count($assigned_global_roles) < 1)
01354                 {
01355                         $this->ilias->raiseError($this->lng->txt("msg_min_one_active_role"),$this->ilias->error_obj->MESSAGE);
01356                 }
01357 
01358                 if ($this->object->getId() == $_SESSION["AccountId"])
01359                 {
01360                         $_SESSION["RoleId"] = $_POST["id"];
01361                 }
01362                 else
01363                 {
01364                         if (count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
01365                         {
01366                                 //var_dump("<pre>",$user_online,$_POST["id"],"</pre>");exit;
01367 
01368                                 $roles = "RoleId|".serialize($_POST["id"]);
01369                                 $modified_data = preg_replace("/RoleId.*?;\}/",$roles,$user_online[$this->object->getId()]["data"]);
01370 
01371                                 $q = "UPDATE usr_session SET data='".$modified_data."' WHERE user_id = '".$this->object->getId()."'";
01372                                 $this->ilias->db->query($q);
01373                         }
01374                         else
01375                         {
01376                                 // user went offline - do nothing
01377                         }
01378                 }
01379 
01380                 sendInfo($this->lng->txt("msg_roleassignment_active_changed").".<br/>".$this->lng->txt("msg_roleassignment_active_changed_comment"),true);
01381                 ilUtil::redirect("adm_object.php?ref_id=".$this->usrf_ref_id."&obj_id=".$this->obj_id."&cmd=edit");
01382         }
01383 
01389         function assignSaveObject()
01390         {
01391                 global $rbacsystem, $rbacadmin, $rbacreview;
01392 
01393                 if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
01394                 {
01395                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
01396                 }
01397 
01398                 $selected_roles = $_POST["role_id"] ? $_POST["role_id"] : array();
01399                 $posted_roles = $_POST["role_id_ctrl"] ? $_POST["role_id_ctrl"] : array();
01400                 
01401                 // prevent unassignment of system role from system user
01402                 if ($this->object->getId() == SYSTEM_USER_ID and in_array(SYSTEM_ROLE_ID, $posted_roles))
01403                 {
01404                         array_push($selected_roles,SYSTEM_ROLE_ID);
01405                 }
01406 
01407                 $global_roles_all = $rbacreview->getGlobalRoles();
01408                 $assigned_roles_all = $rbacreview->assignedRoles($this->object->getId());
01409                 $assigned_roles = array_intersect($assigned_roles_all,$posted_roles);
01410                 $assigned_global_roles_all = array_intersect($assigned_roles_all,$global_roles_all);
01411                 $assigned_global_roles = array_intersect($assigned_global_roles_all,$posted_roles);
01412                 $posted_global_roles = array_intersect($selected_roles,$global_roles_all);
01413                 
01414                 if ((empty($selected_roles) and count($assigned_roles_all) == count($assigned_roles))
01415                          or (empty($posted_global_roles) and count($assigned_global_roles_all) == count($assigned_global_roles)))
01416                 {
01417             //$this->ilias->raiseError($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
01418             // workaround. sometimes jumps back to wrong page
01419             sendInfo($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),true);
01420             $this->ctrl->redirect($this,'roleassignment');
01421                 }
01422 
01423                 foreach (array_diff($assigned_roles,$selected_roles) as $role)
01424                 {
01425                         $rbacadmin->deassignUser($role,$this->object->getId());
01426                 }
01427 
01428                 foreach (array_diff($selected_roles,$assigned_roles) as $role)
01429                 {
01430                         $rbacadmin->assignUser($role,$this->object->getId(),false);
01431                 }
01432                 
01433         include_once "./classes/class.ilObjRole.php";
01434         ilObjRole::_updateSessionRoles(array($this->object->getId()));
01435 
01436                 // update object data entry (to update last modification date)
01437                 $this->object->update();
01438 
01439                 sendInfo($this->lng->txt("msg_roleassignment_changed"),true);
01440 
01441                 if($this->ctrl->getTargetScript() == 'adm_object.php')
01442                 {
01443             $this->ctrl->redirectByClass('ilobjusergui','roleassignment');
01444                 }
01445                 else
01446                 {
01447                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01448                 }
01449 
01450         }
01451         
01457         function roleassignmentObject ()
01458         {
01459                 global $rbacreview,$rbacsystem;
01460 
01461                 if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
01462                 {
01463                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
01464                 }
01465                 
01466                 $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
01467 
01468         if ($_SESSION['filtered_roles'] > 5)
01469         {
01470             $_SESSION['filtered_roles'] = 0;
01471         }
01472         
01473                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_role_assignment.html');
01474 
01475                 if(true)
01476                 {
01477                         $this->tpl->setCurrentBlock("filter");
01478                         $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
01479                         $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect());
01480                         $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
01481                         $this->tpl->setVariable("FILTER_NAME",'roleassignment');
01482                         $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
01483                         $this->tpl->parseCurrentBlock();
01484                 }
01485                 
01486                 // now get roles depending on filter settings
01487                 $role_list = $rbacreview->getRolesByFilter($_SESSION["filtered_roles"],$this->object->getId());
01488                 $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
01489 
01490         $counter = 0;
01491 
01492                 foreach ($role_list as $role)
01493                 {
01494                         // fetch context path of role
01495                         $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
01496 
01497                         // only list roles that are not set to status "deleted"
01498                         if ($rbacreview->isDeleted($rolf[0]))
01499                         {
01500                 continue;
01501             }
01502             
01503             // build context path
01504             $path = "";
01505 
01506                         if ($this->tree->isInTree($rolf[0]))
01507                         {
01508                 if ($rolf[0] == ROLE_FOLDER_ID)
01509                 {
01510                     $path = $this->lng->txt("global");
01511                 }
01512                 else
01513                 {
01514                                     $tmpPath = $this->tree->getPathFull($rolf[0]);
01515 
01516                                     // count -1, to exclude the role folder itself
01517                                     /*for ($i = 1; $i < (count($tmpPath)-1); $i++)
01518                                     {
01519                                             if ($path != "")
01520                                             {
01521                                                     $path .= " > ";
01522                                             }
01523 
01524                                             $path .= $tmpPath[$i]["title"];
01525                                     }*/
01526                                 
01527                                     $path = $tmpPath[count($tmpPath)-2]["title"];
01528                                 }
01529                         }
01530                         else
01531                         {
01532                                 $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role["obj_id"].")</b>";
01533                         }
01534                         
01535                         $disabled = false;
01536                         
01537                         // disable checkbox for system role for the system user
01538                         if (($this->object->getId() == SYSTEM_USER_ID and $role["obj_id"] == SYSTEM_ROLE_ID)
01539                                 or (!in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]) and $role["obj_id"] == SYSTEM_ROLE_ID))
01540                         {
01541                                 $disabled = true;
01542                         }
01543                         
01544             $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"]."\"/>";
01545             $result_set[$counter][] = "<a href=\"adm_object.php?ref_id=".$rolf[0]."&obj_id=".$role["obj_id"]."&cmd=perm\">".$role["title"]."</a>";
01546             $result_set[$counter][] = $role["description"];
01547                     $result_set[$counter][] = $path;
01548 
01549                         ++$counter;
01550         }
01551 
01552                 return $this->__showRolesTable($result_set);
01553     }
01554                 
01563         function insertPublicProfile($a_template_var, $a_template_block_name, $a_additional = "")
01564         {
01565                 $this->tpl->addBlockFile($a_template_var, $a_template_block_name, "tpl.usr_public_profile.html");
01566                 $this->tpl->setCurrentBlock($a_template_block_name);
01567 
01568                 // Get name of picture of user
01569                 // TODO: the user is already the current user object !!
01570                 $userObj = new ilObjUser($_GET["user"]);
01571 
01572                 $this->tpl->setVariable("USR_PROFILE", $this->lng->txt("profile_of")." ".$this->object->getLogin());
01573 
01574                 $this->tpl->setVariable("ROWCOL1", "tblrow1");
01575                 $this->tpl->setVariable("ROWCOL2", "tblrow2");
01576 
01577                 require_once "./classes/class.ilvCard.php";
01578                 $vcard = new ilvCard();
01579 
01580                 //if (usr_id == $_GET["user"])
01581                 // Check from Database if value
01582                 // of public_profile = "y" show user infomation
01583                 if ($userObj->getPref("public_profile")=="y")
01584                 {
01585                         $this->tpl->setVariable("TXT_NAME",$this->lng->txt("name"));
01586                         $this->tpl->setVariable("FIRSTNAME",$userObj->getFirstName());
01587                         $this->tpl->setVariable("LASTNAME",$userObj->getLastName());
01588                         $vcard->setName($userObj->getLastName(), $userObj->getFirstName(), "", $userObj->getUTitle());
01589                         $vcard->setNickname($userObj->getLogin());
01590                 }
01591                 else
01592                 {
01593                         return;
01594                         $this->tpl->setVariable("TXT_NAME",$this->lng->txt("name"));
01595                         $this->tpl->setVariable("FIRSTNAME","N /");
01596                         $this->tpl->setVariable("LASTNAME","A");
01597                 }
01598                 $this->tpl->setCurrentBlock("vcard");
01599                 $this->tpl->setVariable("TXT_VCARD", $this->lng->txt("vcard"));
01600                 $this->tpl->setVariable("TXT_DOWNLOAD_VCARD", $this->lng->txt("vcard_download"));
01601                 $this->tpl->setVariable("HREF_VCARD", "profile.php?user=" . $_GET["user"] . "&vcard=1");
01602                 $this->tpl->setVariable("IMG_VCARD", ilUtil::getImagePath("vcard.png"));
01603                 $this->tpl->parseCurrentBlock();
01604                 $webspace_dir = ilUtil::getWebspaceDir("output");
01605                 $imagefile = $webspace_dir."/usr_images/".$userObj->getPref("profile_image");
01606                 if ($userObj->getPref("public_upload")=="y" && @is_file($imagefile))
01607                 {
01608                         //Getting the flexible path of image form ini file
01609                         //$webspace_dir = ilUtil::getWebspaceDir("output");
01610                         $this->tpl->setCurrentBlock("image");
01611                         $this->tpl->setVariable("TXT_IMAGE",$this->lng->txt("image"));
01612                         $this->tpl->setVariable("IMAGE_PATH", $webspace_dir."/usr_images/".$userObj->getPref("profile_image")."?dummy=".rand(1,999999));
01613                         $this->tpl->parseCurrentBlock();
01614                         $fh = fopen($imagefile, "r");
01615                         if ($fh)
01616                         {
01617                                 $image = fread($fh, filesize($imagefile));
01618                                 fclose($fh);
01619                                 require_once "./content/classes/Media/class.ilObjMediaObject.php";
01620                                 $mimetype = ilObjMediaObject::getMimeType($imagefile);
01621                                 if (preg_match("/^image/", $mimetype))
01622                                 {
01623                                         $type = $mimetype;
01624                                 }
01625                                 $vcard->setPhoto($image, $type);
01626                         }
01627                 }
01628 
01629                 $val_arr = array("getInstitution" => "institution", "getDepartment" => "department",
01630                         "getStreet" => "street",
01631                         "getZipcode" => "zip", "getCity" => "city", "getCountry" => "country",
01632                         "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
01633                         "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
01634                         "getHobby" => "hobby", "getMatriculation" => "matriculation");
01635 
01636                 $org = array();
01637                 $adr = array();
01638                 foreach ($val_arr as $key => $value)
01639                 {
01640                         // if value "y" show information
01641                         if ($userObj->getPref("public_".$value) == "y")
01642                         {
01643                                 switch ($value)
01644                                 {
01645                                         case "institution":
01646                                                 $org[0] = $userObj->$key();
01647                                                 break;
01648                                         case "department":
01649                                                 $org[1] = $userObj->$key();
01650                                                 break;
01651                                         case "street":
01652                                                 $adr[2] = $userObj->$key();
01653                                                 break;
01654                                         case "zip":
01655                                                 $adr[5] = $userObj->$key();
01656                                                 break;
01657                                         case "city":
01658                                                 $adr[3] = $userObj->$key();
01659                                                 break;
01660                                         case "country":
01661                                                 $adr[6] = $userObj->$key();
01662                                                 break;
01663                                         case "phone_office":
01664                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_WORK);
01665                                                 break;
01666                                         case "phone_home":
01667                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_HOME);
01668                                                 break;
01669                                         case "phone_mobile":
01670                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_CELL);
01671                                                 break;
01672                                         case "fax":
01673                                                 $vcard->setPhone($userObj->$key(), TEL_TYPE_FAX);
01674                                                 break;
01675                                         case "email":
01676                                                 $vcard->setEmail($userObj->$key());
01677                                                 break;
01678                                         case "hobby":
01679                                                 $vcard->setNote($userObj->$key());
01680                                                 break;
01681                                 }
01682                                 $this->tpl->setCurrentBlock("profile_data");
01683                                 $this->tpl->setVariable("TXT_DATA", $this->lng->txt($value));
01684                                 $this->tpl->setVariable("DATA", $userObj->$key());
01685                                 $this->tpl->parseCurrentBlock();
01686                         }
01687                 }
01688 
01689                 if (count($org))
01690                 {
01691                         $vcard->setOrganization(join(";", $org));
01692                 }
01693                 if (count($adr))
01694                 {
01695                         $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
01696                 }
01697 
01698                 if (is_array($a_additional))
01699                 {
01700                         foreach($a_additional as $key => $val)
01701                         {
01702                                 $this->tpl->setCurrentBlock("profile_data");
01703                                 $this->tpl->setVariable("TXT_DATA", $key);
01704                                 $this->tpl->setVariable("DATA", $val);
01705                                 $this->tpl->parseCurrentBlock();
01706                         }
01707                 }
01708 
01709                 $this->tpl->setCurrentBlock($a_template_block_name);
01710                 $this->tpl->parseCurrentBlock();
01711 
01712                 if ($_GET["vcard"] == 1)
01713                 {
01714                         ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
01715                         exit;
01716                 }
01717         }
01718 
01719 
01720         function __getDateSelect($a_type,$a_varname,$a_selected)
01721     {
01722         switch($a_type)
01723         {
01724             case "minute":
01725                 for($i=0;$i<=60;$i++)
01726                 {
01727                     $days[$i] = $i < 10 ? "0".$i : $i;
01728                 }
01729                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01730 
01731             case "hour":
01732                 for($i=0;$i<24;$i++)
01733                 {
01734                     $days[$i] = $i < 10 ? "0".$i : $i;
01735                 }
01736                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01737 
01738             case "day":
01739                 for($i=1;$i<32;$i++)
01740                 {
01741                     $days[$i] = $i < 10 ? "0".$i : $i;
01742                 }
01743                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01744 
01745             case "month":
01746                 for($i=1;$i<13;$i++)
01747                 {
01748                     $month[$i] = $i < 10 ? "0".$i : $i;
01749                 }
01750                 return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
01751 
01752             case "year":
01753                 for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
01754                 {
01755                     $year[$i] = $i;
01756                 }
01757                 return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
01758         }
01759     }
01760 
01761         function __toUnix($a_time_arr)
01762     {
01763         return mktime($a_time_arr["hour"],
01764                       $a_time_arr["minute"],
01765                       $a_time_arr["second"],
01766                       $a_time_arr["month"],
01767                       $a_time_arr["day"],
01768                       $a_time_arr["year"]);
01769     }
01770 
01771         function __showRolesTable($a_result_set)
01772         {
01773         global $rbacsystem;
01774 
01775                 $actions = array("assignSave"  => $this->lng->txt("change_assignment"));
01776 
01777         $tbl =& $this->__initTableGUI();
01778                 $tpl =& $tbl->getTemplateObject();
01779 
01780                 $tpl->setCurrentBlock("tbl_form_header");
01781                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01782                 $tpl->parseCurrentBlock();
01783 
01784                 $tpl->setCurrentBlock("tbl_action_row");
01785 
01786                         $tpl->setVariable("COLUMN_COUNTS",4);
01787                         $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01788 
01789             foreach ($actions as $name => $value)
01790                         {
01791                                 $tpl->setCurrentBlock("tbl_action_btn");
01792                                 $tpl->setVariable("BTN_NAME",$name);
01793                                 $tpl->setVariable("BTN_VALUE",$value);
01794                                 $tpl->parseCurrentBlock();
01795                         }
01796 
01797             $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01798 
01799 
01800                 $this->ctrl->setParameter($this,"cmd","roleassignment");
01801 
01802                 // title & header columns
01803                 $tbl->setTitle($this->lng->txt("edit_roleassignment"),"icon_role_b.gif",$this->lng->txt("roles"));
01804 
01805                 //user must be administrator
01806                 $tbl->setHeaderNames(array("",$this->lng->txt("role"),$this->lng->txt("description"),$this->lng->txt("context")));
01807                 $tbl->setHeaderVars(array("","title","description","context"),$this->ctrl->getParameterArray($this,"",false));
01808                 $tbl->setColumnWidth(array("","30%","40%","30%"));
01809 
01810                 $this->__setTableGUIBasicData($tbl,$a_result_set,"roleassignment");
01811                 $tbl->render();
01812                 $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
01813 
01814                 return true;
01815         }
01816 
01817         function &__initTableGUI()
01818         {
01819                 include_once "class.ilTableGUI.php";
01820 
01821                 return new ilTableGUI(0,false);
01822         }
01823 
01824         function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
01825         {
01826         switch($from)
01827                 {
01828                         default:
01829                         $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
01830                                 break;
01831                 }
01832 
01833         //$tbl->enable("hits");
01834                 $tbl->setOrderColumn($order);
01835                 $tbl->setOrderDirection($_GET["sort_order"]);
01836                 $tbl->setOffset($_GET["offset"]);
01837                 $tbl->setLimit($_GET["limit"]);
01838                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01839                 $tbl->setData($result_set);
01840         }
01841 
01842         function __unsetSessionVariables()
01843         {
01844         unset($_SESSION["filtered_roles"]);
01845         }
01846 
01847         function __buildFilterSelect()
01848         {
01849                 $action[0] = $this->lng->txt('assigned_roles');
01850                 $action[1] = $this->lng->txt('all_roles');
01851                 $action[2] = $this->lng->txt('all_global_roles');
01852                 $action[3] = $this->lng->txt('all_local_roles');
01853                 $action[4] = $this->lng->txt('internal_local_roles_only');
01854                 $action[5] = $this->lng->txt('non_internal_local_roles_only');
01855 
01856                 return ilUtil::formSelect($_SESSION['filtered_roles'],"filter",$action,false,true);
01857         }
01858 
01859         function hitsperpageObject()
01860         {
01861         parent::hitsperpageObject();
01862         $this->roleassignmentObject();
01863         }
01864         
01865 } // END class.ilObjUserGUI
01866 ?>

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