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

classes/class.ilObjUserFolderGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00038 require_once "class.ilObjectGUI.php";
00039 
00040 class ilObjUserFolderGUI extends ilObjectGUI
00041 {
00042         var $ctrl;
00043 
00048         function ilObjUserFolderGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
00049         {
00050                 global $ilCtrl;
00051 
00052                 define('USER_FOLDER_ID',7);
00053 
00054                 $this->ctrl =& $ilCtrl;
00055 
00056                 $this->type = "usrf";
00057 
00058                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00059         }
00060 
00061         function &executeCommand()
00062         {
00063                 global $rbacsystem;
00064 
00065                 $next_class = $this->ctrl->getNextClass($this);
00066                 $cmd = $this->ctrl->getCmd();
00067                 switch($next_class)
00068                 {
00069                         default:
00070                                 if(!$cmd)
00071                                 {
00072                                         $cmd = "view";
00073                                 }
00074                                 $cmd .= "Object";
00075                                 $this->$cmd();
00076                                         
00077                                 break;
00078                 }
00079                 return true;
00080         }
00081 
00087         function viewObject()
00088         {
00089                 global $rbacsystem;
00090 
00091                 $_SESSION["user_filter"] = (isset($_POST["user_filter"]))?$_POST["user_filter"]:"1";
00092                 
00093                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00094                 {
00095                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00096                 }
00097 
00098                 //prepare objectlist
00099                 $this->data = array();
00100                 $this->data["data"] = array();
00101                 $this->data["ctrl"] = array();
00102 
00103                 $this->data["cols"] = array("", "login", "firstname", "lastname", "email");
00104                 
00105                 $usr_data = ilObjUser::_getAllUserData(array("login","firstname","lastname","email"), $_SESSION["user_filter"]);
00106 
00107                 foreach ($usr_data as $val)
00108                 {
00109                         if ($val["usr_id"] == ANONYMOUS_USER_ID)
00110                         {
00111                 continue;
00112             }
00113 
00114                         //visible data part
00115                         $this->data["data"][] = array(
00116                                                         "login"                 => $val["login"],
00117                                                         "firstname"             => $val["firstname"],
00118                                                         "lastname"              => $val["lastname"],
00119                                                         "email"                 => $val["email"],
00120                                                         "obj_id"                => $val["usr_id"]
00121                                                 );
00122                 }
00123                 
00124                 $this->maxcount = count($this->data["data"]);
00125                 // TODO: correct this in objectGUI
00126                 if ($_GET["sort_by"] == "name")
00127                 {
00128                         $_GET["sort_by"] = "login";
00129                 }
00130                 
00131                 // sorting array
00132                 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00133                 $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
00134 
00135                 // now compute control information
00136                 foreach ($this->data["data"] as $key => $val)
00137                 {
00138                         $this->data["ctrl"][$key] = array(
00139                                                                                                 "ref_id"        => $this->id,
00140                                                                                                 "obj_id"        => $val["obj_id"]
00141                                                                                         );
00142                         $tmp[] = $val["obj_id"];
00143                         unset($this->data["data"][$key]["obj_id"]);
00144                 }
00145 
00146                 //add template for buttons
00147                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00148 
00149                 // display button
00150                 $this->tpl->setCurrentBlock("btn_cell");
00151                 $this->tpl->setVariable("BTN_LINK","adm_object.php?ref_id=".$this->ref_id.$obj_str."&cmd=searchUserForm");
00152                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("search_user"));
00153                 $this->tpl->parseCurrentBlock();
00154 
00155                 //if (AUTH_DEFAULT == AUTH_LOCAL)
00156                 //{
00157                         $this->tpl->setCurrentBlock("btn_cell");
00158                         $this->tpl->setVariable("BTN_LINK", "adm_object.php?ref_id=".$this->ref_id.$obj_str."&cmd=importUserForm");
00159                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("import_users"));
00160                         $this->tpl->parseCurrentBlock();
00161                 //}
00162 
00163                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_list.html");
00164                 
00165                 $this->tpl->setCurrentBlock("filter");
00166                 $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
00167                 $this->tpl->setVariable("SELECT_FILTER",$this->__buildUserFilterSelect());
00168                 $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
00169                 $this->tpl->setVariable("FILTER_NAME",'view');
00170                 $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
00171                 $this->tpl->parseCurrentBlock();
00172                 
00173                 /*$this->tpl->addBlockfile("FILTER", "filter", "tpl.usr_filter.html");
00174                 
00175                 $this->tpl->setVariable("FORM_ACTION", "adm_object.php?ref_id=".$this->ref_id.$obj_str."&cmd=importUserForm");
00176                 $this->tpl->setVariable("FILTER_SELECT", $this->__buildUserFilterSelect());
00177                 $this->tpl->setVariable("BTN_SET_TXT", $this->lng->txt("set"));*/
00178 
00179                 $this->displayList();
00180         } //function
00181 
00182 
00188         function displayList()
00189         {
00190                 include_once "./classes/class.ilTableGUI.php";
00191 
00192                 // load template for table
00193                 $this->tpl->addBlockfile("USR_TABLE", "user_table", "tpl.table.html");
00194                 // load template for table content data
00195                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00196 
00197                 $num = 0;
00198 
00199                 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00200                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
00201 
00202                 // create table
00203                 $tbl = new ilTableGUI();
00204 
00205                 // title & header columns
00206                 $tbl->setTitle($this->object->getTitle(),"icon_".$this->object->getType()."_b.gif",
00207                                            $this->lng->txt("obj_".$this->object->getType()));
00208                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00209 
00210                 foreach ($this->data["cols"] as $val)
00211                 {
00212                         $header_names[] = $this->lng->txt($val);
00213                 }
00214 
00215                 $tbl->setHeaderNames($header_names);
00216 
00217                 $header_params = array("ref_id" => $this->ref_id);
00218                 $tbl->setHeaderVars($this->data["cols"],$header_params);
00219                 $tbl->setColumnWidth(array("","25%","25$%","25%","25%"));
00220                 
00221 
00222                 // control
00223         //$tbl->enable("hits");
00224                 $tbl->setOrderColumn($_GET["sort_by"]);
00225                 $tbl->setOrderDirection($_GET["sort_order"]);
00226                 $tbl->setLimit($_GET["limit"]);
00227                 $tbl->setOffset($_GET["offset"]);
00228                 $tbl->setMaxCount($this->maxcount);
00229 
00230                 // footer
00231                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00232                 #$tbl->disable("footer");
00233 
00234                 // render table
00235                 $tbl->render();
00236                 
00237                 if (is_array($this->data["data"][0]))
00238                 {
00239                         //table cell
00240                         for ($i=0; $i < count($this->data["data"]); $i++)
00241                         {
00242                                 $data = $this->data["data"][$i];
00243                                 $ctrl = $this->data["ctrl"][$i];
00244 
00245                                 // color changing
00246                                 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00247 
00248                                 $this->tpl->setCurrentBlock("checkbox");
00249                                 $this->tpl->setVariable("CHECKBOX_ID", $ctrl["obj_id"]);
00250                                 //$this->tpl->setVariable("CHECKED", $checked);
00251                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00252                                 $this->tpl->parseCurrentBlock();
00253 
00254                                 $this->tpl->setCurrentBlock("table_cell");
00255                                 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00256                                 $this->tpl->parseCurrentBlock();
00257 
00258                                 foreach ($data as $key => $val)
00259                                 {
00260                                         //build link
00261                                         $link = "adm_object.php?ref_id=7&obj_id=".$ctrl["obj_id"];
00262                                         
00263                                         // dirty workaround to have ids for function showActions (checkbox toggle option)
00264                                         $this->ids[] = $ctrl["obj_id"];
00265 
00266                                         if ($key == "login")
00267                                         {
00268                                                 $this->tpl->setCurrentBlock("begin_link");
00269                                                 $this->tpl->setVariable("LINK_TARGET", $link);
00270                                                 $this->tpl->parseCurrentBlock();
00271                                                 $this->tpl->touchBlock("end_link");
00272                                         }
00273 
00274                                         $this->tpl->setCurrentBlock("text");
00275                                         $this->tpl->setVariable("TEXT_CONTENT", $val);
00276                                         $this->tpl->parseCurrentBlock();
00277                                         $this->tpl->setCurrentBlock("table_cell");
00278                                         $this->tpl->parseCurrentBlock();
00279                                 } //foreach
00280 
00281                                 $this->tpl->setCurrentBlock("tbl_content");
00282                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00283                                 $this->tpl->parseCurrentBlock();
00284                         } //for
00285                 }
00286                 
00287 /*              if (AUTH_DEFAULT != AUTH_LOCAL)
00288                 {
00289                         $this->showActions(false);
00290                 }
00291                 else*/
00292                 {
00293                         $this->showActions(true);
00294                 }
00295         }
00296         
00303         function showActions($with_subobjects = false)
00304         {
00305                 global $rbacsystem;
00306 
00307                 $operations = array();
00308 
00309                 if ($this->actions == "")
00310                 {
00311                         $d = $this->objDefinition->getActions($_GET["type"]);
00312                 }
00313                 else
00314                 {
00315                         $d = $this->actions;
00316                 }
00317 
00318                 foreach ($d as $row)
00319                 {
00320                         if ($rbacsystem->checkAccess($row["name"],$this->object->getRefId()))
00321                         {
00322                                 $operations[] = $row;
00323                         }
00324                 }
00325 
00326                 if (count($operations) > 0)
00327                 {
00328                         foreach ($operations as $val)
00329                         {
00330                                 $this->tpl->setCurrentBlock("tbl_action_btn");
00331                                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00332                                 $this->tpl->setVariable("BTN_NAME", $val["name"]);
00333                                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
00334                                 $this->tpl->parseCurrentBlock();
00335                         }
00336                 }
00337 
00338                 if ($with_subobjects === true)
00339                 {
00340                         $subobjs = $this->showPossibleSubObjects();
00341                 }
00342 
00343                 if ((count($operations) > 0) or $subobjs === true)
00344                 {
00345 
00346                         if (!empty($this->ids))
00347                         {
00348                                 // set checkbox toggles
00349                                 $this->tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
00350                                 $this->tpl->setVariable("JS_VARNAME","id");                     
00351                                 $this->tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($this->ids));
00352                                 $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
00353                                 $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
00354                                 $this->tpl->parseCurrentBlock();
00355                         }
00356                 
00357                         $this->tpl->setCurrentBlock("tbl_action_row");
00358                         $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
00359                         $this->tpl->parseCurrentBlock();
00360                 }
00361         }
00362 
00369         function showPossibleSubObjects()
00370         {
00371                 global $rbacsystem;
00372 
00373                 $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
00374                 
00375                 if (!$rbacsystem->checkAccess('create_user',$this->object->getRefId()))
00376                 {
00377                         unset($d["usr"]);                       
00378                 }
00379 
00380                 if (count($d) > 0)
00381                 {
00382                         foreach ($d as $row)
00383                         {
00384                             $count = 0;
00385                                 if ($row["max"] > 0)
00386                                 {
00387                                         //how many elements are present?
00388                                         for ($i=0; $i<count($this->data["ctrl"]); $i++)
00389                                         {
00390                                                 if ($this->data["ctrl"][$i]["type"] == $row["name"])
00391                                                 {
00392                                                     $count++;
00393                                                 }
00394                                         }
00395                                 }
00396                                 if ($row["max"] == "" || $count < $row["max"])
00397                                 {
00398                                         $subobj[] = $row["name"];
00399                                 }
00400                         }
00401                 }
00402 
00403                 if (is_array($subobj))
00404                 {
00405                         //build form
00406                         $opts = ilUtil::formSelect(12,"new_type",$subobj);
00407                         $this->tpl->setCurrentBlock("add_object");
00408                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
00409                         $this->tpl->setVariable("BTN_NAME", "create");
00410                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00411                         $this->tpl->parseCurrentBlock();
00412                         
00413                         return true;
00414                 }
00415 
00416                 return false;
00417         }
00418 
00424         function confirmedDeleteObject()
00425         {
00426                 global $rbacsystem;
00427 
00428                 // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
00429                 if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
00430                 {
00431                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete"),$this->ilias->error_obj->WARNING);
00432                 }
00433 
00434                 if (in_array($_SESSION["AccountId"],$_SESSION["saved_post"]))
00435                 {
00436                         $this->ilias->raiseError($this->lng->txt("msg_no_delete_yourself"),$this->ilias->error_obj->WARNING);
00437                 }
00438 
00439                 // FOR ALL SELECTED OBJECTS
00440                 foreach ($_SESSION["saved_post"] as $id)
00441                 {
00442                         // instatiate correct object class (usr)
00443                         $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
00444                         $obj->delete();
00445                 }
00446 
00447                 // Feedback
00448                 sendInfo($this->lng->txt("user_deleted"),true);
00449 
00450                 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]);
00451         }
00452 
00456         function deleteObject()
00457         {
00458                 if(!isset($_POST["id"]))
00459                 {
00460                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00461                 }
00462                 // SAVE POST VALUES
00463                 $_SESSION["saved_post"] = $_POST["id"];
00464 
00465                 unset($this->data);
00466                 $this->data["cols"] = array("type", "title", "description", "last_change");
00467 
00468                 foreach($_POST["id"] as $id)
00469                 {
00470                         $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($id);
00471 
00472                         $this->data["data"]["$id"] = array(
00473                                 "type"        => $obj_data->getType(),
00474                                 "title"       => $obj_data->getTitle(),
00475                                 "desc"        => $obj_data->getDescription(),
00476                                 "last_update" => $obj_data->getLastUpdateDate());
00477                 }
00478 
00479                 $this->data["buttons"] = array( "cancelDelete"  => $this->lng->txt("cancel"),
00480                                                                   "confirmedDelete"  => $this->lng->txt("confirm"));
00481 
00482                 $this->getTemplateFile("confirm");
00483 
00484                 sendInfo($this->lng->txt("info_delete_sure"));
00485 
00486                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway");
00487 
00488                 // BEGIN TABLE HEADER
00489                 foreach ($this->data["cols"] as $key)
00490                 {
00491                         $this->tpl->setCurrentBlock("table_header");
00492                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00493                         $this->tpl->parseCurrentBlock();
00494                 }
00495                 // END TABLE HEADER
00496 
00497                 // BEGIN TABLE DATA
00498                 $counter = 0;
00499 
00500                 foreach($this->data["data"] as $key => $value)
00501                 {
00502                         // BEGIN TABLE CELL
00503                         foreach($value as $key => $cell_data)
00504                         {
00505                                 $this->tpl->setCurrentBlock("table_cell");
00506 
00507                                 // CREATE TEXT STRING
00508                                 if($key == "type")
00509                                 {
00510                                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
00511                                 }
00512                                 else
00513                                 {
00514                                         $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
00515                                 }
00516                                 $this->tpl->parseCurrentBlock();
00517                         }
00518 
00519                         $this->tpl->setCurrentBlock("table_row");
00520                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00521                         $this->tpl->parseCurrentBlock();
00522                         // END TABLE CELL
00523                 }
00524                 // END TABLE DATA
00525 
00526                 // BEGIN OPERATION_BTN
00527                 foreach($this->data["buttons"] as $name => $value)
00528                 {
00529                         $this->tpl->setCurrentBlock("operation_btn");
00530                         $this->tpl->setVariable("BTN_NAME",$name);
00531                         $this->tpl->setVariable("BTN_VALUE",$value);
00532                         $this->tpl->parseCurrentBlock();
00533                 }
00534         }
00535         
00541         function searchUserFormObject ()
00542         {
00543                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_search_form.html");
00544 
00545                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."&cmd=gateway");
00546                 $this->tpl->setVariable("USERNAME_CHECKED", " checked=\"checked\"");
00547                 $this->tpl->setVariable("FIRSTNAME_CHECKED", " checked=\"checked\"");
00548                 $this->tpl->setVariable("LASTNAME_CHECKED", " checked=\"checked\"");
00549                 $this->tpl->setVariable("EMAIL_CHECKED", " checked=\"checked\"");
00550                 $this->tpl->setVariable("ACTIVE_CHECKED", " checked=\"checked\"");
00551                 $this->tpl->setVariable("INACTIVE_CHECKED", " checked=\"checked\"");
00552                 $this->tpl->setVariable("TXT_SEARCH_USER",$this->lng->txt("search_user"));
00553                 $this->tpl->setVariable("TXT_SEARCH_IN",$this->lng->txt("search_in"));
00554                 $this->tpl->setVariable("TXT_SEARCH_USERNAME",$this->lng->txt("username"));
00555                 $this->tpl->setVariable("TXT_SEARCH_FIRSTNAME",$this->lng->txt("firstname"));
00556                 $this->tpl->setVariable("TXT_SEARCH_LASTNAME",$this->lng->txt("lastname"));
00557                 $this->tpl->setVariable("TXT_SEARCH_EMAIL",$this->lng->txt("email"));
00558         $this->tpl->setVariable("TXT_SEARCH_ACTIVE",$this->lng->txt("search_active"));
00559         $this->tpl->setVariable("TXT_SEARCH_INACTIVE",$this->lng->txt("search_inactive"));
00560                 $this->tpl->setVariable("BUTTON_SEARCH",$this->lng->txt("search"));
00561                 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00562         $this->tpl->setVariable("TXT_SEARCH_NOTE",$this->lng->txt("search_note"));
00563         }
00564 
00565         function searchCancelledObject()
00566         {
00567                 sendInfo($this->lng->txt("action_aborted"),true);
00568 
00569                 header("Location: adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway");
00570                 exit();
00571         }
00572 
00573         function searchUserObject()
00574         {
00575                 global $rbacreview;
00576 
00577                 $obj_str = "&obj_id=".$this->obj_id;
00578 
00579                 $_POST["search_string"] = $_POST["search_string"] ? $_POST["search_string"] : urldecode($_GET["search_string"]);
00580         $_POST["search_fields"] = $_POST["search_fields"] ? $_POST["search_fields"] : explode(",",urldecode($_GET["search_fields"]));
00581 
00582         if (empty($_POST["search_string"]))
00583         {
00584             $_POST["search_string"] = "%";
00585         }
00586 
00587         if (empty($_POST["search_fields"]))
00588         {
00589             $_POST["search_fields"] = array();
00590         }
00591         
00592                 if (count($search_result = ilObjUser::searchUsers($_POST["search_string"])) == 0)
00593                 {
00594                         sendInfo($this->lng->txt("msg_no_search_result")." ".$this->lng->txt("with")." '".htmlspecialchars($_POST["search_string"])."'",true);
00595                         header("Location: adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=searchUserForm");
00596                         exit();         
00597                 }
00598                 //add template for buttons
00599                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00600                 
00601                 // display button
00602                 $this->tpl->setCurrentBlock("btn_cell");
00603                 $this->tpl->setVariable("BTN_LINK","adm_object.php?ref_id=".$this->ref_id."&cmd=searchUserForm");
00604                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("search_new"));
00605                 $this->tpl->parseCurrentBlock();
00606 
00607         $this->data["cols"] = array("", "login", "firstname", "lastname", "email", "active");
00608 
00609         if (in_array("active", $_POST["search_fields"]))
00610         {
00611             $searchActive = true;
00612         }
00613         if (in_array("inactive", $_POST["search_fields"]))
00614         {
00615             $searchInactive = true;
00616         }
00617 
00618                 foreach ($search_result as $key => $val)
00619                 {
00620             $val["active_text"] = $this->lng->txt("inactive");
00621             if ($val["active"])
00622             {
00623                 $val["active_text"] = $this->lng->txt("active");
00624             }
00625 
00626                                                 // check if the fields are set
00627                                                 $searchStringToLower = strtolower($_POST["search_string"]);
00628                                                 $displaySearchResult = false;
00629                                                 if (in_array("username", $_POST["search_fields"]))
00630                                                         if (strpos(strtolower($val["login"]), strtolower($_POST["search_string"])) !== false)
00631                                                                 $displaySearchResult = true;
00632                                                 if (in_array("firstname", $_POST["search_fields"]))
00633                                                         if (strpos(strtolower($val["firstname"]), strtolower($_POST["search_string"])) !== false)
00634                                                                 $displaySearchResult = true;
00635                                                 if (in_array("lastname", $_POST["search_fields"]))
00636                                                         if (strpos(strtolower($val["lastname"]), strtolower($_POST["search_string"])) !== false)
00637                                                                 $displaySearchResult = true;
00638                                                 if (in_array("email", $_POST["search_fields"]))
00639                                                         if (strpos(strtolower($val["email"]), strtolower($_POST["search_string"])) !== false)
00640                                                                 $displaySearchResult = true;
00641                                                 if (($val["active"] == 1) && ($searchActive == true) ||
00642                     ($val["active"] == 0) && ($searchInactive == true))
00643             {
00644                                                                 if ((strcmp($_POST["search_string"], "%") == 0) || $displaySearchResult)
00645                                                                 {
00646                                                                         //visible data part
00647                                                                         $this->data["data"][] = array(
00648                                                                                                         "login"         => $val["login"],
00649                                                                                                         "firstname"     => $val["firstname"],
00650                                                                                                         "lastname"      => $val["lastname"],
00651                                                                                                         "email"         => $val["email"],
00652                                                                                                         "active"        => $val["active_text"],
00653                                                                                                         "obj_id"        => $val["usr_id"]
00654                                                                                                         );
00655                                                                 }
00656             }
00657                 }
00658                 if (count($this->data["data"]) == 0)
00659                 {
00660                         sendInfo($this->lng->txt("msg_no_search_result")." ".$this->lng->txt("with")." '".htmlspecialchars($_POST["search_string"])."'",true);
00661 
00662                         header("Location: adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=searchUserForm");
00663                         exit();         
00664                 }
00665                 
00666                 $this->maxcount = count($this->data["data"]);
00667 
00668                 // TODO: correct this in objectGUI
00669                 if ($_GET["sort_by"] == "name")
00670                 {
00671                         $_GET["sort_by"] = "login";
00672                 }
00673 
00674                 // sorting array
00675                 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00676                 $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
00677 
00678                 // now compute control information
00679                 foreach ($this->data["data"] as $key => $val)
00680                 {
00681                         $this->data["ctrl"][$key] = array(
00682                                                                                                 "ref_id"        => $this->id,
00683                                                                                                 "obj_id"        => $val["obj_id"]
00684                                                                                         );
00685                         $tmp[] = $val["obj_id"];
00686                         unset($this->data["data"][$key]["obj_id"]);
00687                 }
00688 
00689                 // remember filtered users
00690                 $_SESSION["user_list"] = $tmp;          
00691         
00692                 // load template for table
00693                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00694                 // load template for table content data
00695                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00696 
00697                 $num = 0;
00698 
00699                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."&cmd=gateway&sort_by=name&sort_order=".$_GET["sort_order"]."&offset=".$_GET["offset"]);
00700 
00701                 // create table
00702                 include_once "./classes/class.ilTableGUI.php";
00703                 $tbl = new ilTableGUI();
00704 
00705                 // title & header columns
00706                 $tbl->setTitle($this->lng->txt("search_result"),"icon_".$this->object->getType()."_b.gif",$this->lng->txt("obj_".$this->object->getType()));
00707                 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00708                 
00709                 foreach ($this->data["cols"] as $val)
00710                 {
00711                         $header_names[] = $this->lng->txt($val);
00712                 }
00713                 
00714                 $tbl->setHeaderNames($header_names);
00715 
00716                 $header_params = array(
00717                                                         "ref_id"                => $this->ref_id,
00718                                                         "cmd"                   => "searchUser",
00719                                                         "search_string" => urlencode($_POST["search_string"]),
00720                                                         "search_fields" => urlencode(implode(",",$_POST["search_fields"]))
00721                                                         );
00722 
00723                 $tbl->setHeaderVars($this->data["cols"],$header_params);
00724                 $tbl->setColumnWidth(array("","25%","25$%","25%","25%"));
00725 
00726                 // control
00727         $tbl->enable("hits");
00728                 $tbl->setOrderColumn($_GET["sort_by"]);
00729                 $tbl->setOrderDirection($_GET["sort_order"]);
00730                 $tbl->setLimit($_GET["limit"]);
00731                 $tbl->setOffset($_GET["offset"]);
00732                 $tbl->setMaxCount($this->maxcount);
00733 
00734                 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));    
00735 
00736                 // footer
00737                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00738 
00739                 // render table
00740                 $tbl->render();
00741 
00742                 if (is_array($this->data["data"][0]))
00743                 {
00744                         //table cell
00745                         for ($i=0; $i < count($this->data["data"]); $i++)
00746                         {
00747                                 $data = $this->data["data"][$i];
00748                                 $ctrl = $this->data["ctrl"][$i];
00749 
00750                                 // dirty workaround to have ids for function showActions (checkbox toggle option)
00751                                 $this->ids[] = $ctrl["obj_id"];
00752                                         
00753                                 // color changing
00754                                 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00755 
00756                                 $this->tpl->setCurrentBlock("checkbox");
00757                                 $this->tpl->setVariable("CHECKBOX_ID", $ctrl["obj_id"]);
00758                                 //$this->tpl->setVariable("CHECKED", $checked);
00759                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00760                                 $this->tpl->parseCurrentBlock();
00761 
00762                                 $this->tpl->setCurrentBlock("table_cell");
00763                                 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00764                                 $this->tpl->parseCurrentBlock();
00765 
00766                                 foreach ($data as $key => $val)
00767                                 {
00768                                         //build link
00769                                         $link = "adm_object.php?ref_id=7&obj_id=".$ctrl["obj_id"];
00770 
00771                                         if ($key == "login")
00772                                         {
00773                                                 $this->tpl->setCurrentBlock("begin_link");
00774                                                 $this->tpl->setVariable("LINK_TARGET", $link);
00775                                                 $this->tpl->parseCurrentBlock();
00776                                                 $this->tpl->touchBlock("end_link");
00777                                         }
00778 
00779                                         $this->tpl->setCurrentBlock("text");
00780                                         $this->tpl->setVariable("TEXT_CONTENT", $val);
00781                                         $this->tpl->parseCurrentBlock();
00782                                         $this->tpl->setCurrentBlock("table_cell");
00783                                         $this->tpl->parseCurrentBlock();
00784                                 } //foreach
00785 
00786                                 $this->tpl->setCurrentBlock("tbl_content");
00787                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00788                                 $this->tpl->parseCurrentBlock();
00789                         } //for
00790                         
00791                         $this->showActions(true);
00792                 }
00793         }
00794 
00798         function importUserFormObject ()
00799         {
00800                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_form.html");
00801 
00802                 //$this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."&cmd=gateway");
00803                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
00804 
00805                 $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
00806                 $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
00807                 $this->tpl->setVariable("TXT_IMPORT_ROOT_USER", $this->lng->txt("import_root_user"));
00808 
00809                 $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("upload"));
00810                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00811         }
00812 
00813 
00819         function importCancelledObject()
00820         {
00821                 // purge user import directory
00822                 $import_dir = $this->getImportDir();
00823                 if (@is_dir($import_dir))
00824                 {
00825                         ilUtil::delDir($import_dir);
00826                 }
00827 
00828                 sendInfo($this->lng->txt("msg_cancel"),true);
00829 
00830                 if($this->ctrl->getTargetScript() == 'adm_object.php')
00831                 {
00832                         $return_location = $_GET["cmd_return_location"];
00833                         ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
00834                 }
00835                 else
00836                 {
00837                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
00838                 }
00839         }
00840 
00844         function getImportDir()
00845         {
00846                 // For each user session a different directory must be used to prevent
00847                 // that one user session overwrites the import data that another session
00848                 // is currently importing.
00849                 global $ilUser;
00850                 $importDir = ilUtil::getDataDir().'/user_import/usr_'.$ilUser->getId().'_'.session_id(); 
00851                 ilUtil::makeDirParents($importDir);
00852                 return $importDir;
00853         }
00854 
00858         function importUserRoleAssignmentObject ()
00859         {
00860                 include_once './classes/class.ilObjRole.php';
00861                 include_once './classes/class.ilUserImportParser.php';
00862                 
00863                 global $rbacreview, $rbacsystem, $tree, $lng;
00864                 
00865 
00866                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html");
00867 
00868                 $import_dir = $this->getImportDir();
00869 
00870                 // recreate user import directory
00871                 if (@is_dir($import_dir))
00872                 {
00873                         ilUtil::delDir($import_dir);
00874                 }
00875                 ilUtil::makeDir($import_dir);
00876 
00877                 // move uploaded file to user import directory
00878                 $file_name = $_FILES["importFile"]["name"];
00879                 $parts = pathinfo($file_name);
00880                 $full_path = $import_dir."/".$file_name;
00881 
00882                 // check if import file exists
00883                 if (!is_file($_FILES["importFile"]["tmp_name"]))
00884                 {
00885                         ilUtil::delDir($import_dir);
00886                         $this->ilias->raiseError($this->lng->txt("no_import_file_found")
00887                                 , $this->ilias->error_obj->MESSAGE);
00888                 }
00889                 ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"],
00890                         $_FILES["importFile"]["name"], $full_path);
00891 
00892                 // handle zip file              
00893                 if (strtolower($parts["extension"]) == "zip")
00894                 {
00895                         // unzip file
00896                         ilUtil::unzip($full_path);
00897 
00898                         $xml_file = null;
00899                         $file_list = ilUtil::getDir($import_dir);
00900                         foreach ($file_list as $a_file)
00901                         {
00902                                 if (substr($a_file['entry'],-4) == '.xml')
00903                                 {
00904                                         $xml_file = $import_dir."/".$a_file['entry'];
00905                                         break;
00906                                 }
00907                         }
00908                         if (is_null($xml_file))
00909                         {
00910                                 $subdir = basename($parts["basename"],".".$parts["extension"]);
00911                                 $xml_file = $import_dir."/".$subdir."/".$subdir.".xml";
00912                         }
00913                 }
00914                 // handle xml file
00915                 else
00916                 {
00917                         $xml_file = $full_path;
00918                 }
00919 
00920                 // check xml file               
00921                 if (!is_file($xml_file))
00922                 {
00923                         ilUtil::delDir($import_dir);
00924                         $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip")
00925                                 ." ".$subdir."/".$subdir.".xml", $this->ilias->error_obj->MESSAGE);
00926                 }
00927 
00928                 require_once("classes/class.ilUserImportParser.php");
00929 
00930                 // Verify the data
00931                 // ---------------
00932                 $importParser = new ilUserImportParser($xml_file, IL_VERIFY);
00933                 $importParser->startParsing();
00934                 switch ($importParser->getErrorLevel())
00935                 {
00936                         case IL_IMPORT_SUCCESS :
00937                                 break;
00938                         case IL_IMPORT_WARNING :
00939                                 $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
00940                                 break;
00941                         case IL_IMPORT_FAILURE :
00942                                 ilUtil::delDir($import_dir);
00943                                 $this->ilias->raiseError(
00944                                         $lng->txt("verification_failed").$importParser->getProtocolAsHTML($lng->txt("verification_failure_log")),
00945                                         $this->ilias->error_obj->MESSAGE
00946                                 );
00947                                 return;
00948                 }
00949 
00950                 // Create the role selection form
00951                 // ------------------------------
00952                 $this->tpl->setCurrentBlock("role_selection_form");
00953                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00954                 $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
00955                 $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
00956                 $this->tpl->setVariable("IMPORT_FILE", $file_name);
00957                 $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
00958                 $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
00959                 $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
00960                 $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
00961                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00962                 $this->tpl->setVariable("XML_FILE_NAME", $xml_file);
00963 
00964                 // Extract the roles
00965                 $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
00966                 $importParser->startParsing();
00967                 $roles = $importParser->getCollectedRoles();
00968 
00969                 // get global roles
00970                 $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
00971                 $gl_roles = array();
00972                 foreach ($all_gl_roles as $obj_data)
00973                 {
00974                         // check assignment permission if called from local admin
00975                         if($this->object->getRefId() != USER_FOLDER_ID)
00976                         {
00977                                 if(!ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
00978                                 {
00979                                         continue;
00980                                 }
00981                         }
00982                         // exclude anonymous role from list
00983                         if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
00984                         {
00985                                 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
00986                                 if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00987                                 {
00988                                         $gl_roles[$obj_data["obj_id"]] = $obj_data["title"];
00989                                 }
00990                         }
00991                 }
00992 
00993                 // global roles
00994                 $got_globals = false;
00995                 foreach($roles as $role_id => $role)
00996                 {
00997                         if ($role["type"] == "Global")
00998                         {
00999                                 if (! $got_globals)
01000                                 {
01001                                         $got_globals = true;
01002 
01003                                         $this->tpl->setCurrentBlock("global_role_section");
01004                                         $this->tpl->setVariable("TXT_GLOBAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_global"));
01005                                         $this->tpl->setVariable("TXT_GLOBAL_ROLES", $this->lng->txt("assign_global_role"));
01006                                 }
01007 
01008                                 // pre selection for role
01009                                 $pre_select = array_search($role[name], $gl_roles);
01010                                 if (! $pre_select)
01011                                 {
01012                                         switch($role["name"])
01013                                         {
01014                                                 case "Administrator":   // ILIAS 2/3 Administrator
01015                                                         $pre_select = array_search("Administrator", $gl_roles);
01016                                                         break;
01017 
01018                                                 case "Autor":                   // ILIAS 2 Author
01019                                                         $pre_select = array_search("User", $gl_roles);
01020                                                         break;
01021 
01022                                                 case "Lerner":                  // ILIAS 2 Learner
01023                                                         $pre_select = array_search("User", $gl_roles);
01024                                                         break;
01025 
01026                                                 case "Gast":                    // ILIAS 2 Guest
01027                                                         $pre_select = array_search("Guest", $gl_roles);
01028                                                         break;
01029 
01030                                                 default:
01031                                                         $pre_select = array_search("User", $gl_roles);
01032                                                         break;
01033                                         }
01034                                 }
01035                                 $this->tpl->setCurrentBlock("global_role");
01036                                 $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $gl_roles, false, true);
01037                                 $this->tpl->setVariable("TXT_IMPORT_GLOBAL_ROLE", $role["name"]." [".$role_id."]");
01038                                 $this->tpl->setVariable("SELECT_GLOBAL_ROLE", $role_select);
01039                                 $this->tpl->parseCurrentBlock();
01040                         }
01041                 }
01042 
01043                 // Check if local roles need to be assigned
01044                 $got_locals = false;
01045                 foreach($roles as $role_id => $role)
01046                 {
01047                         if ($role["type"] == "Local")
01048                         {
01049                                 $got_locals = true;
01050                                 break;
01051                         }
01052                 }
01053 
01054                 if ($got_locals) 
01055                 {
01056                         $this->tpl->setCurrentBlock("local_role_section");
01057                         $this->tpl->setVariable("TXT_LOCAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_local"));
01058                         $this->tpl->setVariable("TXT_LOCAL_ROLES", $this->lng->txt("assign_local_role"));
01059 
01060 
01061                         // get local roles
01062                         $loc_roles = $rbacreview->getAssignableRoles();
01063                         $l_roles = array();
01064                         $l_roles_searcharray = array(); 
01065                         foreach ($loc_roles as $key => $loc_role)
01066                         {
01067                                 // fetch context path of role
01068                                 $rolf = $rbacreview->getFoldersAssignedToRole($loc_role["obj_id"],true);
01069 
01070                                 // only process role folders that are not set to status "deleted" 
01071                                 // and for which the user has write permissions.
01072                                 // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
01073                                 // (The ROLE_FOLDER_ID folder contains the global roles).
01074                                 if (!$rbacreview->isDeleted($rolf[0])
01075                                 && $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0]))
01076                                 && $rolf[0] != ROLE_FOLDER_ID
01077                                 )
01078                                 {
01079                                         // A local role is only displayed, if it is contained in the subtree of 
01080                                         // the localy administrated category. If the import function has been 
01081                                         // invoked from the user folder object, we show all local roles, because
01082                                         // the user folder object is considered the parent of all local roles.
01083                                         // Thus, if we start from the user folder object, we initialize the
01084                                         // isInSubtree variable with true. In all other cases it is initialized 
01085                                         // with false, and only set to true if we find the object id of the
01086                                         // locally administrated category in the tree path to the local role.
01087                                         $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID;
01088                                         
01089                                         $path = "";
01090                                         if ($this->tree->isInTree($rolf[0]))
01091                                         {
01092                                                 // Create path. Paths which have more than 4 segments
01093                                                 // are truncated in the middle.
01094                                                 $tmpPath = $this->tree->getPathFull($rolf[0]);
01095                                                 for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++)
01096                                                 {
01097                                                         if ($i > 1)
01098                                                         {
01099                                                                 $path = $path.' > ';
01100                                                         }
01101                                                         if ($i < 3 || $i > $n - 3)
01102                                                         {
01103                                                                 $path = $path.$tmpPath[$i]['title'];
01104                                                         } 
01105                                                         else if ($i == 3 || $i == $n - 3)
01106                                                         {
01107                                                                 $path = $path.'...';
01108                                                         }
01109                                                         
01110                                                         $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId();
01111                                                 }
01112                                         }
01113                                         else
01114                                         {
01115                                                 $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$loc_role["obj_id"].")</b>";
01116                                         }
01117 
01118                                         if ($loc_role["role_type"] != "Global" && $isInSubtree)
01119                                         {
01120                                                 $l_roles[$loc_role['obj_id']] = $loc_role["title"]." ($path)";
01121                                                 $l_roles_searcharray[$loc_role['obj_id']] = $loc_role["title"];
01122                                         }
01123                                 }
01124                         } //foreach role
01125 
01126                         $l_roles[""] = ""; 
01127                         natsort($l_roles);
01128                         $l_roles[""] = $this->lng->txt("usrimport_ignore_role"); 
01129 
01130                         foreach($roles as $role_id => $role)
01131                         {
01132                                 if ($role["type"] == "Local")
01133                                 {
01134                                         $this->tpl->setCurrentBlock("local_role");
01135                                         $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]." [".$role_id."]");
01136                                         $pre_select = array_search($role_id, $l_roles_searcharray);
01137                                         if (!($pre_select !== false)) 
01138                                         {
01139                                                 $pre_select = array_search($role['name'], $l_roles_searcharray);
01140                                         }
01141                                         $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $l_roles, false, true);
01142                                         $this->tpl->setVariable("SELECT_LOCAL_ROLE", $role_select);
01143                                         $this->tpl->parseCurrentBlock();
01144                                 }
01145                         }
01146                 }
01147                 // 
01148  
01149                 $this->tpl->setVariable("TXT_CONFLICT_HANDLING", $lng->txt("conflict_handling"));
01150                 $handlers = array(
01151                         IL_IGNORE_ON_CONFLICT => "ignore_on_conflict",
01152                         IL_UPDATE_ON_CONFLICT => "update_on_conflict"
01153                 );
01154                 $this->tpl->setVariable("TXT_CONFLICT_HANDLING_INFO", str_replace('\n','<br>',$this->lng->txt("usrimport_conflict_handling_info")));
01155                 $this->tpl->setVariable("TXT_CONFLICT_CHOICE", $lng->txt("conflict_handling"));
01156                 $this->tpl->setVariable("SELECT_CONFLICT", ilUtil::formSelect(IL_IGNORE_ON_CONFLICT, "conflict_handling_choice", $handlers, false, false));
01157         }
01158 
01162         function importUsersObject()
01163         {
01164                 include_once './classes/class.ilObjRole.php';
01165                 include_once './classes/class.ilUserImportParser.php';
01166 
01167                 global $rbacreview, $rbacsystem, $tree, $lng;
01168 
01169                 switch ($_POST["conflict_handling_choice"])
01170                 {
01171                         case "update_on_conflict" :
01172                                 $rule = IL_UPDATE_ON_CONFLICT;
01173                                 break;
01174                         case "ignore_on_conflict" :
01175                         default :
01176                                 $rule = IL_IGNORE_ON_CONFLICT;
01177                                 break;
01178                 }
01179                 $importParser = new ilUserImportParser($_POST["xml_file"],  IL_USER_IMPORT, $rule);
01180                 $importParser->setFolderId($this->object->getRefId());
01181                 $import_dir = $this->getImportDir();
01182 
01183                 // Catch hack attempts
01184                 // We check here again, if the role folders are in the tree, and if the
01185                 // user has permission on the roles.
01186                 if ($_POST["role_assign"])
01187                 {
01188                         $global_roles = $rbacreview->getGlobalRoles();
01189                         foreach ($_POST["role_assign"] as $role_id)
01190                         {
01191                                 if ($role_id != "") 
01192                                 {
01193                                         if (in_array($role_id, $global_roles))
01194                                         {
01195                                                 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"])
01196                                                 || ($this->object->getRefId() != USER_FOLDER_ID 
01197                                                         && ! ilObjRole::_getAssignUsersStatus($role_id))
01198                                                 )
01199                                                 {
01200                                                         ilUtil::delDir($import_dir);
01201                                                         $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), 
01202                                                                 $this->ilias->error_obj->MESSAGE);
01203                                                 }
01204                                         }
01205                                         else
01206                                         {
01207                                                 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,true);
01208                                                 if ($rbacreview->isDeleted($rolf[0])
01209                                                         || ! $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0])))
01210                                                 {
01211                                                         ilUtil::delDir($import_dir);
01212                                                         $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), 
01213                                                                 $this->ilias->error_obj->MESSAGE);
01214                                                         return;
01215                                                 }
01216                                         }
01217                                 }
01218                         }
01219                 }
01220 
01221                 $importParser->setRoleAssignment($_POST["role_assign"]);
01222                 $importParser->startParsing();
01223 
01224                 // purge user import directory
01225                 ilUtil::delDir($import_dir);
01226 
01227                 switch ($importParser->getErrorLevel())
01228                 {
01229                         case IL_IMPORT_SUCCESS :
01230                                 sendInfo($this->lng->txt("user_imported"), true);
01231                                 break;
01232                         case IL_IMPORT_WARNING :
01233                                 sendInfo($this->lng->txt("user_imported_with_warnings").$importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true);
01234                                 break;
01235                         case IL_IMPORT_FAILURE :
01236                                 $this->ilias->raiseError(
01237                                         $this->lng->txt("user_import_failed")
01238                                         .$importParser->getProtocolAsHTML($lng->txt("import_failure_log")),
01239                                         $this->ilias->error_obj->MESSAGE
01240                                 );
01241                                 break;
01242                 }
01243 
01244                 if($this->ctrl->getTargetScript() == 'adm_object.php')
01245                 {
01246                         ilUtil::redirect($this->ctrl->getLinkTarget($this));
01247                 }
01248                 else
01249                 {
01250                         $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01251                 }
01252         }
01253 
01254 
01255         function appliedUsersObject()
01256         {
01257                 global $rbacsystem,$ilias;
01258 
01259                 unset($_SESSION['applied_users']);
01260 
01261                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
01262                 {
01263                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01264                 }
01265                 
01266                 if(!count($app_users =& $ilias->account->getAppliedUsers()))
01267                 {
01268                         sendInfo($this->lng->txt('no_users_applied'));
01269 
01270                         return false;
01271                 }
01272 
01273                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_applied_users.html");
01274                 $this->lng->loadLanguageModule('crs');
01275                 
01276                 $counter = 0;
01277                 foreach($app_users as $usr_id)
01278                 {
01279                         $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
01280 
01281                         $f_result[$counter][]   = ilUtil::formCheckbox(0,"users[]",$usr_id);
01282                         $f_result[$counter][]   = $tmp_user->getLogin();
01283                         $f_result[$counter][]   = $tmp_user->getFirstname();
01284                         $f_result[$counter][]   = $tmp_user->getLastname();
01285                         
01286                         if($tmp_user->getTimeLimitUnlimited())
01287                         {
01288                                 $f_result[$counter][]   = "<b>".$this->lng->txt('crs_unlimited')."</b>";
01289                         }
01290                         else
01291                         {
01292                                 $limit = "<b>".$this->lng->txt('crs_from').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitFrom()).'<br />';
01293                                 $limit .= "<b>".$this->lng->txt('crs_to').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitUntil());
01294 
01295                                 $f_result[$counter][]   = $limit;
01296                         }
01297                         ++$counter;
01298                 }
01299 
01300                 $this->__showAppliedUsersTable($f_result);
01301 
01302                 return true;
01303         }
01304 
01305         function editAppliedUsersObject()
01306         {
01307                 global $rbacsystem;
01308 
01309                 if(!$rbacsystem->checkAccess("write", $this->ref_id))
01310                 {
01311                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01312                 }
01313 
01314                 $this->lng->loadLanguageModule('crs');
01315 
01316                 $_POST['users'] = $_SESSION['applied_users'] = ($_SESSION['applied_users'] ? $_SESSION['applied_users'] : $_POST['users']);
01317 
01318                 if(!isset($_SESSION['error_post_vars']))
01319                 {
01320                         sendInfo($this->lng->txt('time_limit_add_time_limit_for_selected'));
01321                 }
01322 
01323                 if(!count($_POST["users"]))
01324                 {
01325                         sendInfo($this->lng->txt("time_limit_no_users_selected"));
01326                         $this->appliedUsersObject();
01327 
01328                         return false;
01329                 }
01330                 
01331                 $counter = 0;
01332                 foreach($_POST['users'] as $usr_id)
01333                 {
01334                         if($counter)
01335                         {
01336                                 $title .= ', ';
01337                         }
01338                         $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
01339                         $title .= $tmp_user->getLogin();
01340                         ++$counter;
01341                 }
01342                 if(strlen($title) > 79)
01343                 {
01344                         $title = substr($title,0,80);
01345                         $title .= '...';
01346                 }
01347 
01348 
01349                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_edit_applied_users.html");
01350                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01351 
01352                 // LOAD SAVED DATA IN CASE OF ERROR
01353                 $time_limit_unlimited = $_SESSION["error_post_vars"]["au"]["time_limit_unlimited"] ? 
01354                         1 : 0;
01355 
01356                 $time_limit_start = $_SESSION["error_post_vars"]["au"]["time_limit_start"] ? 
01357                         $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_start"]) :
01358                         time();
01359                 $time_limit_end = $_SESSION["error_post_vars"]["au"]["time_limit_end"] ? 
01360                         $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_end"]) :
01361                         time();
01362 
01363                 
01364                 // SET TEXT VARIABLES
01365                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_usr"));
01366                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_usr_b.gif"));
01367                 $this->tpl->setVariable("TITLE",$title);
01368                 $this->tpl->setVariable("TXT_TIME_LIMIT",$this->lng->txt("time_limit"));
01369                 $this->tpl->setVariable("TXT_TIME_LIMIT_START",$this->lng->txt("crs_start"));
01370                 $this->tpl->setVariable("TXT_TIME_LIMIT_END",$this->lng->txt("crs_end"));
01371                 $this->tpl->setVariable("CMD_SUBMIT","updateAppliedUsers");
01372                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
01373                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("submit"));
01374                 
01375 
01376 
01377                 $this->tpl->setVariable("SELECT_TIME_LIMIT_START_DAY",$this->__getDateSelect("day","au[time_limit_start][day]",
01378                                                                                                                                                                          date("d",$time_limit_start)));
01379                 $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MONTH",$this->__getDateSelect("month","au[time_limit_start][month]",
01380                                                                                                                                                                            date("m",$time_limit_start)));
01381                 $this->tpl->setVariable("SELECT_TIME_LIMIT_START_YEAR",$this->__getDateSelect("year","au[time_limit_start][year]",
01382                                                                                                                                                                           date("Y",$time_limit_start)));
01383                 $this->tpl->setVariable("SELECT_TIME_LIMIT_START_HOUR",$this->__getDateSelect("hour","au[time_limit_start][hour]",
01384                                                                                                                                                                           date("G",$time_limit_start)));
01385                 $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MINUTE",$this->__getDateSelect("minute","au[time_limit_start][minute]",
01386                                                                                                                                                                           date("i",$time_limit_start)));
01387                 $this->tpl->setVariable("SELECT_TIME_LIMIT_END_DAY",$this->__getDateSelect("day","au[time_limit_end][day]",
01388                                                                                                                                                                    date("d",$time_limit_end)));
01389                 $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MONTH",$this->__getDateSelect("month","au[time_limit_end][month]",
01390                                                                                                                                                                          date("m",$time_limit_end)));
01391                 $this->tpl->setVariable("SELECT_TIME_LIMIT_END_YEAR",$this->__getDateSelect("year","au[time_limit_end][year]",
01392                                                                                                                                                                         date("Y",$time_limit_end)));
01393                 $this->tpl->setVariable("SELECT_TIME_LIMIT_END_HOUR",$this->__getDateSelect("hour","au[time_limit_end][hour]",
01394                                                                                                                                                                           date("G",$time_limit_end)));
01395                 $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MINUTE",$this->__getDateSelect("minute","au[time_limit_end][minute]",
01396                                                                                                                                                                           date("i",$time_limit_end)));
01397                 if($this->ilias->account->getTimeLimitUnlimited())
01398                 {
01399                         $this->tpl->setVariable("ROWSPAN",3);
01400                         $this->tpl->setCurrentBlock("unlimited");
01401                         $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED",$this->lng->txt("crs_unlimited"));
01402                         $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"au[time_limit_unlimited]",1));
01403                         $this->tpl->parseCurrentBlock();
01404                 }
01405                 else
01406                 {
01407                         $this->tpl->setVariable("ROWSPAN",2);
01408                 }
01409         }
01410 
01411         function updateAppliedUsersObject()
01412         {
01413                 global $rbacsystem;
01414 
01415                 if(!$rbacsystem->checkAccess("write", $this->ref_id))
01416                 {
01417                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01418                 }
01419 
01420                 $start  = $this->__toUnix($_POST['au']['time_limit_start']);
01421                 $end    = $this->__toUnix($_POST['au']['time_limit_end']);
01422 
01423                 if(!$_POST['au']['time_limit_unlimited'])
01424                 {
01425                         if($start > $end)
01426                         {
01427                                 $_SESSION['error_post_vars'] = $_POST;
01428                                 sendInfo($this->lng->txt('time_limit_not_valid'));
01429                                 $this->editAppliedUsersObject();
01430 
01431                                 return false;
01432                         }
01433                 }
01434                 #if(!$this->ilias->account->getTimeLimitUnlimited())
01435                 #{
01436                 #       if($start < $this->ilias->account->getTimeLimitFrom() or
01437                 #          $end > $this->ilias->account->getTimeLimitUntil())
01438                 #       {
01439                 #               $_SESSION['error_post_vars'] = $_POST;
01440                 #               sendInfo($this->lng->txt('time_limit_not_within_owners'));
01441                 #               $this->editAppliedUsersObject();
01442 
01443                 #               return false;
01444                 #       }
01445                 #}
01446 
01447                 foreach($_SESSION['applied_users'] as $usr_id)
01448                 {
01449                         $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
01450 
01451                         $tmp_user->setTimeLimitUnlimited((int) $_POST['au']['time_limit_unlimited']);
01452                         $tmp_user->setTimeLimitFrom($start);
01453                         $tmp_user->setTimeLimitUntil($end);
01454                         $tmp_user->setTimeLimitMessage(0);
01455                         $tmp_user->update();
01456 
01457                         unset($tmp_user);
01458                 }
01459 
01460                 unset($_SESSION['applied_users']);
01461                 sendInfo($this->lng->txt('time_limit_users_updated'));
01462                 $this->appliedUsersObject();
01463                 
01464                 return true;
01465         }
01466 
01467         function __showAppliedUsersTable($a_result_set)
01468         {
01469                 $tbl =& $this->__initTableGUI();
01470                 $tpl =& $tbl->getTemplateObject();
01471 
01472                 // SET FORMAACTION
01473                 $tpl->setCurrentBlock("tbl_form_header");
01474 
01475                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01476                 $tpl->parseCurrentBlock();
01477 
01478                 $tpl->setCurrentBlock("tbl_action_btn");
01479                 $tpl->setVariable("BTN_NAME",'editAppliedUsers');
01480                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('edit'));
01481                 $tpl->parseCurrentBlock();
01482 
01483                 $tpl->setCurrentBlock("tbl_action_row");
01484                 $tpl->setVariable("COLUMN_COUNTS",5);
01485                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01486                 $tpl->parseCurrentBlock();
01487 
01488 
01489 
01490                 $tbl->setTitle($this->lng->txt("time_limit_applied_users"),"icon_usr_b.gif",$this->lng->txt("users"));
01491                 $tbl->setHeaderNames(array('',
01492                                                                    $this->lng->txt("login"),
01493                                                                    $this->lng->txt("firstname"),
01494                                                                    $this->lng->txt("lastname"),
01495                                                                    $this->lng->txt("time_limits")));
01496                 $tbl->setHeaderVars(array("",
01497                                                                   "login",
01498                                                                   "firstname",
01499                                                                   "lastname",
01500                                                                   "time_limit"),
01501                                                         array("ref_id" => $this->object->getRefId(),
01502                                                                   "cmd" => "appliedUsers"));
01503                 $tbl->setColumnWidth(array("3%","19%","19%","19%","40%"));
01504 
01505 
01506                 $this->__setTableGUIBasicData($tbl,$a_result_set);
01507                 $tbl->render();
01508 
01509                 $this->tpl->setVariable("APPLIED_USERS",$tbl->tpl->get());
01510 
01511                 return true;
01512         }
01513 
01514         function &__initTableGUI()
01515         {
01516                 include_once "./classes/class.ilTableGUI.php";
01517 
01518                 return new ilTableGUI(0,false);
01519         }
01520 
01521         function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
01522         {
01523                 $offset = $_GET["offset"];
01524                 $order = $_GET["sort_by"];
01525                 $direction = $_GET["sort_order"];
01526 
01527         //$tbl->enable("hits");
01528                 $tbl->setOrderColumn($order);
01529                 $tbl->setOrderDirection($direction);
01530                 $tbl->setOffset($offset);
01531                 $tbl->setLimit($_GET["limit"]);
01532                 $tbl->setMaxCount(count($result_set));
01533                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01534                 $tbl->setData($result_set);
01535         }
01536 
01537         function __getDateSelect($a_type,$a_varname,$a_selected)
01538     {
01539         switch($a_type)
01540         {
01541             case "minute":
01542                 for($i=0;$i<=60;$i++)
01543                 {
01544                     $days[$i] = $i < 10 ? "0".$i : $i;
01545                 }
01546                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01547 
01548             case "hour":
01549                 for($i=0;$i<24;$i++)
01550                 {
01551                     $days[$i] = $i < 10 ? "0".$i : $i;
01552                 }
01553                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01554 
01555             case "day":
01556                 for($i=1;$i<32;$i++)
01557                 {
01558                     $days[$i] = $i < 10 ? "0".$i : $i;
01559                 }
01560                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01561 
01562             case "month":
01563                 for($i=1;$i<13;$i++)
01564                 {
01565                     $month[$i] = $i < 10 ? "0".$i : $i;
01566                 }
01567                 return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
01568 
01569             case "year":
01570                 for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
01571                 {
01572                     $year[$i] = $i;
01573                 }
01574                 return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
01575         }
01576     }
01577         function __toUnix($a_time_arr)
01578     {
01579         return mktime($a_time_arr["hour"],
01580                       $a_time_arr["minute"],
01581                       $a_time_arr["second"],
01582                       $a_time_arr["month"],
01583                       $a_time_arr["day"],
01584                       $a_time_arr["year"]);
01585     }
01586 
01587         function hitsperpageObject()
01588         {
01589         parent::hitsperpageObject();
01590         $this->viewObject();
01591         }
01592 
01603         function settingsObject()
01604         {
01605                 global $ilias;
01606                 
01607                 $this->getTemplateFile("settings","usr");
01608 
01609                 $profile_fields =& $this->object->getProfileFields();
01610                 // For the following fields, the required state can not be changed.
01611                 // key = field, value = 1 (field is required), 0 (field is not required)
01612                 $fixed_required_fields = array(
01613                         "gender" => 1,
01614                         "firstname" => 1,
01615                         "lastname" => 1,
01616                         "upload" => 0,
01617                         "email" => 1,
01618                         "password" => 0,
01619                         "language" => 0,
01620                         "skin_style" => 0,
01621                         "hits_per_page" => 0,
01622                         "show_users_online" => 0
01623                 );
01624                 $no_export_fields = array(
01625                         "skin_style",
01626                         "hits_per_page",
01627                         "show_users_online"
01628                 );
01629                 foreach ($profile_fields as $field)
01630                 {
01631                         $this->tpl->setCurrentBlock("profile_settings");
01632                         $this->tpl->setVariable("TXT_PROFILE_DATA", $this->lng->txt($field));
01633                         $this->tpl->setVariable("PROFILE_OPTION_ENABLED", "enabled_" . $field);
01634                         $this->tpl->setVariable("PROFILE_OPTION_VISIBLE", "visible_" . $field);
01635                         $this->tpl->setVariable("PROFILE_OPTION_REQUIRED", "required_" . $field);
01636 
01637                         // BEGIN Enable field in Personal Profile
01638                         if ($ilias->getSetting("usr_settings_disable_".$field) != "1")
01639                         {
01640                                 $this->tpl->setVariable("CHECKED_ENABLED", " checked=\"checked\"");
01641                         }
01642                         // END Enable field in Personal Profile
01643                         // BEGIN Show field in Personal Profile
01644                         if ($ilias->getSetting("usr_settings_hide_".$field) != "1")
01645                         {
01646                                 $this->tpl->setVariable("CHECKED_VISIBLE", " checked=\"checked\"");
01647                         }
01648                         // END Show field in Personal Profile
01649                         if (!in_array($field, $no_export_fields))
01650                         {
01651                                 $this->tpl->setVariable("PROFILE_OPTION_EXPORT", "export_" . $field);
01652                                 // BEGIN Export field of Personal Profile
01653                                 if ($ilias->getSetting("usr_settings_export_".$field) == "1")
01654                                 {
01655                                         $this->tpl->setVariable("CHECKED_EXPORT", " checked=\"checked\"");
01656                                 }
01657                                 // END Export field of Personal Profile
01658                         }
01659                         // BEGIN Require field in Personal Profile
01660                         $is_fixed = array_key_exists($field, $fixed_required_fields);
01661                         if ($is_fixed && $fixed_required_fields[$field] || ! $is_fixed && $ilias->getSetting("require_".$field) == "1")
01662                         {
01663                                 $this->tpl->setVariable("CHECKED_REQUIRED", " checked=\"checked\"");
01664                         }
01665                         if ($is_fixed)
01666                         {
01667                                 $this->tpl->setVariable("DISABLE_REQUIRED", " disabled=\"disabled\"");
01668                         }
01669                         // END Require field in Personal Profile
01670 
01671                         // BEGIN Default value for hits per pages field in Personal Profile
01672                         if ($field == "hits_per_page")
01673                         {
01674                                 $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
01675                                 $options = array(2,10,15,20,30,40,50,100,9999);
01676                                 $selected_option = $ilias->getSetting("hits_per_page");
01677                                 if ($selected_option == null) $selected_option = 10;
01678                                 $this->tpl->setCurrentBlock("default_value_option");
01679                                 foreach ($options as $option)
01680                                 {
01681                                         if ($option == $selected_option)
01682                                         {
01683                                                 $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
01684                                         }
01685 
01686                                         $this->tpl->setVariable("OPTION_VALUE", $option);
01687                                         $this->tpl->setVariable("OPTION_TEXT", ($option == 9999) ? $this->lng->txt("no_limit") : $option);
01688                                         $this->tpl->parseCurrentBlock();
01689                                 }
01690                                 $this->tpl->setCurrentBlock("profile_settings");
01691                         }
01692                         // END Default value for language field in Personal Profile
01693 
01694                         // BEGIN Show Users Online
01695                         else if ($field == "show_users_online")
01696                         {
01697                                 $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
01698                                 $options = array('y','associated','n');
01699                                 $selected_option = $ilias->getSetting("show_users_online");
01700                                 if ($selected_option == null) $selected_option = 10;
01701                                 $this->tpl->setCurrentBlock("default_value_option");
01702                                 foreach ($options as $option)
01703                                 {
01704                                         if ($option == $selected_option)
01705                                         {
01706                                                 $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
01707                                         }
01708 
01709                                         $this->tpl->setVariable("OPTION_VALUE", $option);
01710                                         $this->tpl->setVariable("OPTION_TEXT", $this->lng->txt("users_online_show_".$option));
01711                                         $this->tpl->parseCurrentBlock();
01712                                 }
01713                                 $this->tpl->setCurrentBlock("profile_settings");
01714                         }
01715                         // END Show Users Online
01716 
01717                         $this->tpl->parseCurrentBlock();
01718                 }
01719                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway");
01720                 $this->tpl->setVariable("TXT_HEADER_PROFILE", $this->lng->txt("usr_settings_header_profile"));
01721                 $this->tpl->setVariable("TXT_EXPLANATION_PROFILE", $this->lng->txt("usr_settings_explanation_profile"));
01722                 $this->tpl->setVariable("HEADER_PROFILE_DATA", $this->lng->txt("usr_settings_header_profile_profile"));
01723                 $this->tpl->setVariable("HEADER_ENABLED", $this->lng->txt("changeable"));
01724                 $this->tpl->setVariable("HEADER_VISIBLE", $this->lng->txt("visible"));
01725                 $this->tpl->setVariable("HEADER_REQUIRED", $this->lng->txt("required_field"));
01726                 $this->tpl->setVariable("HEADER_EXPORT", $this->lng->txt("export"));
01727                 $this->tpl->setVariable("HEADER_DEFAULT_VALUE", $this->lng->txt("default_value"));
01728                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01729         }
01730         
01731         function saveGlobalUserSettingsObject()
01732         {
01733                 global $ilias;
01734                 
01735                 $profile_fields =& $this->object->getProfileFields();
01736                 // For the following fields, the required state can not be changed
01737                 $fixed_required_fields = array(
01738                         "gender" => 1,
01739                         "firstname" => 1,
01740                         "lastname" => 1,
01741                         "upload" => 0,
01742                         "email" => 1,
01743                         "password" => 0,
01744                         "language" => 0,
01745                         "skin_style" => 0,
01746                         "hits_per_page" => 0,
01747                         "show_users_online" => 0
01748                 );
01749 
01750                 foreach ($profile_fields as $field)
01751                 {
01752                         if (! $_POST["chb"]["visible_".$field])
01753                         {
01754                                 $ilias->setSetting("usr_settings_hide_".$field, "1");
01755                         }
01756                         else
01757                         {
01758                                 $ilias->deleteSetting("usr_settings_hide_".$field);
01759                         }
01760 
01761                         if (! $_POST["chb"]["enabled_" . $field])
01762                         {
01763                                 $ilias->setSetting("usr_settings_disable_".$field, "1");
01764                         }
01765                         else
01766                         {
01767                                 $ilias->deleteSetting("usr_settings_disable_".$field);
01768                         }
01769 
01770                         if ($_POST["chb"]["export_" . $field])
01771                         {
01772                                 $ilias->setSetting("usr_settings_export_".$field, "1");
01773                         }
01774                         else
01775                         {
01776                                 $ilias->deleteSetting("usr_settings_export_".$field);
01777                         }
01778 
01779                         $is_fixed = array_key_exists($field, $fixed_required_fields);
01780                         if ($is_fixed && $fixed_required_fields[$field] || ! $is_fixed && $_POST["chb"]["required_".$field])
01781                         {
01782                                 $ilias->setSetting("require_".$field, "1");
01783                         }
01784                         else
01785                         {
01786                                 $ilias->deleteSetting("require_" . $field);
01787                         }
01788                 }
01789 
01790                 if ($_POST["select"]["default_hits_per_page"])
01791                 {       
01792                         $ilias->setSetting("hits_per_page",$_POST["select"]["default_hits_per_page"]);
01793                 }
01794 
01795                 if ($_POST["select"]["default_show_users_online"])
01796                 {
01797                         $ilias->setSetting("show_users_online",$_POST["select"]["default_show_users_online"]);
01798                 }
01799 
01800                 sendInfo($this->lng->txt("usr_settings_saved"));
01801                 $this->settingsObject();
01802         }
01803         
01804         
01808         function __buildUserFilterSelect()
01809         {
01810                 $action[-1] = $this->lng->txt('all_users');
01811                 $action[1] = $this->lng->txt('usr_active_only');
01812                 $action[0] = $this->lng->txt('usr_inactive_only');
01813 
01814                 return  ilUtil::formSelect($_SESSION['user_filter'],"user_filter",$action,false,true);
01815         }
01816 
01823         function downloadExportFileObject()
01824         {
01825                 if(!isset($_POST["file"]))
01826                 {
01827                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01828                 }
01829 
01830                 if (count($_POST["file"]) > 1)
01831                 {
01832                         $this->ilias->raiseError($this->lng->txt("select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01833                 }
01834 
01835 
01836                 $export_dir = $this->object->getExportDirectory();
01837                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01838                         $_POST["file"][0]);
01839         }
01840         
01844         function confirmDeleteExportFileObject()
01845         {
01846                 if(!isset($_POST["file"]))
01847                 {
01848                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01849                 }
01850 
01851                 // SAVE POST VALUES
01852                 $_SESSION["ilExportFiles"] = $_POST["file"];
01853 
01854                 $this->getTemplateFile("confirm_delete_export","usr");          
01855 
01856                 sendInfo($this->lng->txt("info_delete_sure"));
01857 
01858                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01859 
01860                 // BEGIN TABLE HEADER
01861                 $this->tpl->setCurrentBlock("table_header");
01862                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01863                 $this->tpl->parseCurrentBlock();
01864 
01865                 // BEGIN TABLE DATA
01866                 $counter = 0;
01867                 foreach($_POST["file"] as $file)
01868                 {
01869                                 $this->tpl->setCurrentBlock("table_row");
01870                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01871                                 $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_usrf.gif"));
01872                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01873                                 $this->tpl->parseCurrentBlock();
01874                 }
01875 
01876                 // cancel/confirm button
01877                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01878                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
01879                         "deleteExportFile"  => $this->lng->txt("confirm"));
01880                 foreach ($buttons as $name => $value)
01881                 {
01882                         $this->tpl->setCurrentBlock("operation_btn");
01883                         $this->tpl->setVariable("BTN_NAME",$name);
01884                         $this->tpl->setVariable("BTN_VALUE",$value);
01885                         $this->tpl->parseCurrentBlock();
01886                 }
01887         }
01888 
01889 
01893         function cancelDeleteExportFileObject()
01894         {
01895                 session_unregister("ilExportFiles");
01896                 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "export"));
01897         }
01898 
01899 
01903         function deleteExportFileObject()
01904         {
01905                 $export_dir = $this->object->getExportDirectory();
01906                 foreach($_SESSION["ilExportFiles"] as $file)
01907                 {
01908                         $exp_file = $export_dir."/".$file;
01909                         if (@is_file($exp_file))
01910                         {
01911                                 unlink($exp_file);
01912                         }
01913                 }
01914                 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "export"));
01915         }
01916 
01927         function exportObject()
01928         {
01929                 global $ilias;
01930                 
01931                 if ($_POST["cmd"]["export"])
01932                 {
01933                         $this->object->buildExportFile($_POST["export_type"]);
01934                         ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "export"));
01935                         exit;
01936                 }
01937                 
01938                 $this->getTemplateFile("export","usr");
01939                 
01940                 $export_types = array(
01941                         "userfolder_export_excel_x86",
01942                         "userfolder_export_excel_ppc",
01943                         "userfolder_export_csv",
01944                         "userfolder_export_xml"
01945                 );
01946 
01947                 // create table
01948                 include_once("./classes/class.ilTableGUI.php");
01949                 $tbl = new ilTableGUI();
01950 
01951                 // load files templates
01952                 $this->tpl->addBlockfile("EXPORT_FILES", "export_files", "tpl.table.html");
01953 
01954                 // load template for table content data
01955                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.usr_export_file_row.html");
01956 
01957                 $num = 0;
01958 
01959                 $tbl->setTitle($this->lng->txt("userfolder_export_files"));
01960 
01961                 $tbl->setHeaderNames(array("<input type=\"checkbox\" name=\"chb_check_all\" value=\"1\" onclick=\"setCheckboxes('ObjectItems', 'file', document.ObjectItems.chb_check_all.checked);\" />", $this->lng->txt("userfolder_export_file"),
01962                         $this->lng->txt("userfolder_export_file_size"), $this->lng->txt("date") ));
01963 
01964                 $tbl->enabled["sort"] = false;
01965                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01966 
01967                 // control
01968                 $tbl->setOrderColumn($_GET["sort_by"]);
01969                 $tbl->setOrderDirection($_GET["sort_order"]);
01970                 $tbl->setLimit($_GET["limit"]);
01971                 $tbl->setOffset($_GET["offset"]);
01972                 $tbl->setMaxCount($this->maxcount);             // ???
01973 
01974 
01975                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
01976 
01977                 // delete button
01978                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01979                 $this->tpl->setCurrentBlock("tbl_action_btn");
01980                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01981                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01982                 $this->tpl->parseCurrentBlock();
01983 
01984                 $this->tpl->setCurrentBlock("tbl_action_btn");
01985                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01986                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01987                 $this->tpl->parseCurrentBlock();
01988 
01989                 // footer
01990                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01991                 //$tbl->disable("footer");
01992 
01993                 $export_files = $this->object->getExportFiles();
01994 
01995                 $tbl->setMaxCount(count($export_files));
01996                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01997 
01998                 $tbl->render();
01999 
02000                 if(count($export_files) > 0)
02001                 {
02002                         $i=0;
02003                         foreach($export_files as $exp_file)
02004                         {
02005                                 $this->tpl->setCurrentBlock("tbl_content");
02006                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file["filename"]);
02007 
02008                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
02009                                 $this->tpl->setVariable("CSS_ROW", $css_row);
02010 
02011                                 $this->tpl->setVariable("TXT_SIZE", $exp_file["filesize"]);
02012                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["filename"]);
02013 
02014                                 $file_arr = explode("__", $exp_file["filename"]);
02015                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
02016 
02017                                 $this->tpl->parseCurrentBlock();
02018                         }
02019                 } //if is_array
02020                 else
02021                 {
02022                         $this->tpl->setCurrentBlock("notfound");
02023                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
02024                         $this->tpl->setVariable("NUM_COLS", 3);
02025                         $this->tpl->parseCurrentBlock();
02026                 }
02027 
02028                 $this->tpl->parseCurrentBlock();
02029                 
02030                 
02031                 foreach ($export_types as $export_type)
02032                 {               
02033                         $this->tpl->setCurrentBlock("option");
02034                         $this->tpl->setVariable("OPTION_VALUE", $export_type);
02035                         $this->tpl->setVariable("OPTION_TEXT", $this->lng->txt($export_type));
02036                         $this->tpl->parseCurrentBlock();
02037                 }
02038                 
02039                 $this->tpl->setVariable("EXPORT_BUTTON", $this->lng->txt("create_export_file"));
02040                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02041         }
02042 
02043 } // END class.ilObjUserFolderGUI
02044 ?>

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