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

classes/class.ilObjUserGUI.php

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

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