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

classes/class.ilObjCategoryGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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.ilContainerGUI.php";
00039 
00040 class ilObjCategoryGUI extends ilContainerGUI
00041 {
00042         var $ctrl;
00043 
00048         function ilObjCategoryGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00049         {
00050                 //global $ilCtrl;
00051 
00052                 // CONTROL OPTIONS
00053                 //$this->ctrl =& $ilCtrl;
00054                 //$this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
00055 
00056                 $this->type = "cat";
00057                 $this->ilContainerGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00058         }
00059 
00060         function &executeCommand()
00061         {
00062                 global $rbacsystem;
00063 
00064                 $next_class = $this->ctrl->getNextClass($this);
00065                 $cmd = $this->ctrl->getCmd();
00066                 
00067                 switch($next_class)
00068                 {
00069                         case "ilobjusergui":
00070                                 include_once("./classes/class.ilObjUserGUI.php");
00071                                 
00072                                 $this->tabs_gui->setTabActive('administrate_users');
00073                                 if(!$_GET['obj_id'])
00074                                 {
00075                                         $this->gui_obj = new ilObjUserGUI("",$_GET['ref_id'],true, false);
00076                                         $this->gui_obj->setCreationMode($this->creation_mode);
00077                                         $ret =& $this->ctrl->forwardCommand($this->gui_obj);
00078                                 }
00079                                 else
00080                                 {
00081                                         $this->gui_obj = new ilObjUserGUI("", $_GET['obj_id'],false, false);
00082                                         $this->gui_obj->setCreationMode($this->creation_mode);
00083                                         $ret =& $this->ctrl->forwardCommand($this->gui_obj);
00084                                 }
00085                                 break;
00086 
00087                         case "ilobjuserfoldergui":
00088                                 include_once("./classes/class.ilObjUserFolderGUI.php");
00089 
00090                                 $this->tabs_gui->setTabActive('administrate_users');
00091                                 $this->gui_obj = new ilObjUserFolderGUI("",(int) $_GET['ref_id'],true, false);
00092                                 $this->gui_obj->setUserOwnerId((int) $_GET['ref_id']);
00093                                 $this->gui_obj->setCreationMode($this->creation_mode);
00094                                 $ret =& $this->ctrl->forwardCommand($this->gui_obj);
00095                                 break;
00096 
00097 
00098                         case 'ilpermissiongui':
00099                                 $this->prepareOutput();
00100                                 include_once("./classes/class.ilPermissionGUI.php");
00101                                 $perm_gui =& new ilPermissionGUI($this);
00102                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00103                                 break;
00104                                 
00105                         case 'ilcontainerlinklistgui':
00106                                 include_once("./classes/class.ilContainerLinkListGUI.php");
00107                                 $link_list_gui =& new ilContainerLinkListGUI();
00108                                 $ret =& $this->ctrl->forwardCommand($link_list_gui);
00109                                 break;
00110 
00111                                 // container page editing
00112                         case "ilpageobjectgui":
00113                                 $this->tpl->getStandardTemplate();
00114                                 $this->setLocator();
00115                                 sendInfo();
00116                                 infoPanel();
00117                                 //$this->prepareOutput(false);
00118                                 $ret = $this->forwardToPageObject();
00119                                 $this->setTitleAndDescription();
00120                                 $this->setPageEditorTabs();
00121                                 return $ret;
00122                                 break;
00123 
00124                         default:
00125                                 $this->prepareOutput();
00126                                 include_once("classes/class.ilObjStyleSheet.php");
00127                                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00128                                         ilObjStyleSheet::getContentStylePath(0));
00129 
00130                                 if(!$cmd)
00131                                 {
00132                                         $cmd = "render";
00133                                 }
00134 
00135                                 $cmd .= "Object";
00136                                 $this->$cmd();
00137 
00138                                 break;
00139                 }
00140                 return true;
00141         }
00142 
00143         function getTabs(&$tabs_gui)
00144         {
00145                 global $rbacsystem;
00146 
00147                 if ($this->ctrl->getCmd() == "editPageContent")
00148                 {
00149                         return;
00150                 }
00151                 #$this->ctrl->setParameter($this,"ref_id",$this->ref_id);
00152 
00153                 if ($rbacsystem->checkAccess('read',$this->ref_id))
00154                 {
00155                         $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "render")
00156                                 ? true
00157                                 : false;
00158                         $tabs_gui->addTarget("view_content",
00159                                 $this->ctrl->getLinkTarget($this, ""),
00160                                 array("view", ""), "", "", $force_active);
00161                 }
00162                 
00163                 if ($rbacsystem->checkAccess('write',$this->ref_id))
00164                 {
00165                         $force_active = ($_GET["cmd"] == "edit")
00166                                 ? true
00167                                 : false;
00168                         $tabs_gui->addTarget("edit_properties",
00169                                 $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this)
00170                                 , "", $force_active);
00171                 }
00172 
00173                 if($rbacsystem->checkAccess('cat_administrate_users',$this->ref_id))
00174                 {
00175                         $tabs_gui->addTarget("administrate_users",
00176                                 $this->ctrl->getLinkTarget($this, "listUsers"), "listUsers", get_class($this));
00177                 }
00178                 
00179                 // parent tabs (all container: edit_permission, clipboard, trash
00180                 parent::getTabs($tabs_gui);
00181 
00182         }
00183 
00189         function createObject()
00190         {
00191                 global $rbacsystem;
00192 
00193                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00194 
00195                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00196                 {
00197                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00198                 }
00199                 else
00200                 {
00201                         // for lang selection include metadata class
00202                         include_once "./classes/class.ilMetaData.php";
00203 
00204                         //add template for buttons
00205                         $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00206 
00207                         // only in administration
00208                         // to do: make this in repository work
00209                         if (false)
00210                         {
00211                                 $this->tpl->setCurrentBlock("btn_cell");
00212                                 $this->tpl->setVariable("BTN_LINK",
00213                                 $this->ctrl->getLinkTarget($this, "importCategoriesForm"));
00214                                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("import_categories"));
00215                                 $this->tpl->parseCurrentBlock();
00216                         }
00217 
00218                         $this->getTemplateFile("edit",$new_type);
00219 
00220                         $array_push = true;
00221 
00222                         if ($_SESSION["error_post_vars"])
00223                         {
00224                                 $_SESSION["translation_post"] = $_SESSION["error_post_vars"];
00225                                 $array_push = false;
00226                         }
00227 
00228                         // clear session data if a fresh category should be created
00229                         if (($_GET["mode"] != "session"))
00230                         {
00231                                 unset($_SESSION["translation_post"]);
00232                         }       // remove a translation from session
00233                         elseif ($_GET["entry"] != 0)
00234                         {
00235                                 array_splice($_SESSION["translation_post"]["Fobject"],$_GET["entry"],1,array());
00236 
00237                                 if ($_GET["entry"] == $_SESSION["translation_post"]["default_language"])
00238                                 {
00239                                         $_SESSION["translation_post"]["default_language"] = "";
00240                                 }
00241                         }
00242 
00243                         // stripslashes in form output?
00244                         $strip = isset($_SESSION["translation_post"]) ? true : false;
00245 
00246                         $data = $_SESSION["translation_post"];
00247 
00248                         if (!is_array($data["Fobject"]))
00249                         {
00250                                 $data["Fobject"] = array();
00251                         }
00252 
00253                         // add additional translation form
00254                         if (!$_GET["entry"] and $array_push)
00255                         {
00256                                 $count = array_push($data["Fobject"],array("title" => "","desc" => ""));
00257                         }
00258                         else
00259                         {
00260                                 $count = count($data["Fobject"]);
00261                         }
00262 
00263                         foreach ($data["Fobject"] as $key => $val)
00264                         {
00265                                 // add translation button
00266                                 if ($key == $count -1)
00267                                 {
00268                                         $this->tpl->setCurrentBlock("addTranslation");
00269                                         $this->tpl->setVariable("TXT_ADD_TRANSLATION",$this->lng->txt("add_translation")." >>");
00270                                         $this->tpl->parseCurrentBlock();
00271                                 }
00272 
00273                                 // remove translation button
00274                                 if ($key != 0)
00275                                 {
00276                                         $this->tpl->setCurrentBlock("removeTranslation");
00277                                         $this->tpl->setVariable("TXT_REMOVE_TRANSLATION",$this->lng->txt("remove_translation"));
00278                                         $this->ctrl->setParameter($this, "entry", $key);
00279                                         $this->ctrl->setParameter($this, "new_type", $new_type);
00280                                         $this->ctrl->setParameter($this, "mode", "create");
00281                                         $this->tpl->setVariable("LINK_REMOVE_TRANSLATION", $this->ctrl->getLinkTarget($this, "removeTranslation"));
00282 
00283                                         $this->tpl->parseCurrentBlock();
00284                                 }
00285 
00286                                 // lang selection
00287                                 $this->tpl->addBlockFile("SEL_LANGUAGE", "sel_language", "tpl.lang_selection.html", false);
00288                                 $this->tpl->setVariable("SEL_NAME", "Fobject[".$key."][lang]");
00289 
00290                                 $languages = ilMetaData::getLanguages();
00291 
00292                                 foreach($languages as $code => $language)
00293                                 {
00294                                         $this->tpl->setCurrentBlock("lg_option");
00295                                         $this->tpl->setVariable("VAL_LG", $code);
00296                                         $this->tpl->setVariable("TXT_LG", $language);
00297 
00298                                         if ($count == 1 AND $code == $this->ilias->account->getPref("language") AND !isset($_SESSION["translation_post"]))
00299                                         {
00300                                                 $this->tpl->setVariable("SELECTED", "selected=\"selected\"");
00301                                         }
00302                                         elseif ($code == $val["lang"])
00303                                         {
00304                                                 $this->tpl->setVariable("SELECTED", "selected=\"selected\"");
00305                                         }
00306 
00307                                         $this->tpl->parseCurrentBlock();
00308                                 }
00309 
00310                                 if ($key == 0)
00311                                 {
00312                                         $this->tpl->setCurrentBlock("type_image");
00313                                         $this->tpl->setVariable("TYPE_IMG",
00314                                                 ilUtil::getImagePath("icon_cat.gif"));
00315                                         $this->tpl->parseCurrentBlock();
00316                                 }
00317                                 
00318                                 // object data
00319                                 $this->tpl->setCurrentBlock("obj_form");
00320 
00321                                 if ($key == 0)
00322                                 {
00323                                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00324                                 }
00325                                 else
00326                                 {
00327                                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("translation")." ".$key);
00328                                 }
00329 
00330                                 if ($key == $data["default_language"])
00331                                 {
00332                                         $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
00333                                 }
00334 
00335                                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00336                                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
00337                                 $this->tpl->setVariable("TXT_DEFAULT", $this->lng->txt("default"));
00338                                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00339                                 $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($val["title"],$strip));
00340                                 $this->tpl->setVariable("DESC", ilUtil::stripSlashes($val["desc"]));
00341                                 $this->tpl->setVariable("NUM", $key);
00342                                 $this->tpl->parseCurrentBlock();
00343                         }
00344 
00345                         // global
00346                         $this->ctrl->setParameter($this, "mode", "create");
00347                         $this->ctrl->setParameter($this, "new_type", $new_type);
00348                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00349                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00350                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00351                         $this->tpl->setVariable("CMD_SUBMIT", "save");
00352                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00353                 }
00354         }
00355 
00360         function saveObject()
00361         {
00362                 $data = $_POST;
00363 
00364                 // default language set?
00365                 if (!isset($data["default_language"]))
00366                 {
00367                         $this->ilias->raiseError($this->lng->txt("msg_no_default_language"),$this->ilias->error_obj->MESSAGE);
00368                 }
00369 
00370                 // prepare array fro further checks
00371                 foreach ($data["Fobject"] as $key => $val)
00372                 {
00373                         $langs[$key] = $val["lang"];
00374                 }
00375 
00376                 $langs = array_count_values($langs);
00377 
00378                 // all languages set?
00379                 if (array_key_exists("",$langs))
00380                 {
00381                         $this->ilias->raiseError($this->lng->txt("msg_no_language_selected"),$this->ilias->error_obj->MESSAGE);
00382                 }
00383 
00384                 // no single language is selected more than once?
00385                 if (array_sum($langs) > count($langs))
00386                 {
00387                         $this->ilias->raiseError($this->lng->txt("msg_multi_language_selected"),$this->ilias->error_obj->MESSAGE);
00388                 }
00389 
00390                 // copy default translation to variable for object data entry
00391                 $_POST["Fobject"]["title"] = $_POST["Fobject"][$_POST["default_language"]]["title"];
00392                 $_POST["Fobject"]["desc"] = $_POST["Fobject"][$_POST["default_language"]]["desc"];
00393 
00394                 // always call parent method first to create an object_data entry & a reference
00395                 $newObj = parent::saveObject();
00396 
00397                 // setup rolefolder & default local roles if needed (see ilObjForum & ilObjForumGUI for an example)
00398                 //$roles = $newObj->initDefaultRoles();
00399 
00400                 // write translations to object_translation
00401                 foreach ($data["Fobject"] as $key => $val)
00402                 {
00403                         if ($key == $data["default_language"])
00404                         {
00405                                 $default = 1;
00406                         }
00407                         else
00408                         {
00409                                 $default = 0;
00410                         }
00411 
00412                         $newObj->addTranslation(ilUtil::stripSlashes($val["title"]),ilUtil::stripSlashes($val["desc"]),$val["lang"],$default);
00413                 }
00414 
00415                 // always send a message
00416                 sendInfo($this->lng->txt("cat_added"),true);
00417                 //$this->ctrl->setParameter($this, "ref_id", $newObj->getRefId());
00418                 
00419                 $this->redirectToRefId($_GET["ref_id"]);
00420         }
00421 
00427         function editObject()
00428         {
00429                 global $rbacsystem;
00430 
00431                 if (!$rbacsystem->checkAccess("write", $this->ref_id))
00432                 {
00433                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00434                 }
00435                 
00436                 $this->ctrl->setParameter($this,"mode","edit");
00437 
00438                 // for lang selection include metadata class
00439                 include_once "./classes/class.ilMetaData.php";
00440 
00441                 $this->getTemplateFile("edit",$new_type);
00442                 $array_push = true;
00443 
00444                 if ($_SESSION["error_post_vars"])
00445                 {
00446                         $_SESSION["translation_post"] = $_SESSION["error_post_vars"];
00447                         $_GET["mode"] = "session";
00448                         $array_push = false;
00449                 }
00450 
00451                 // load from db if edit category is called the first time
00452                 if (($_GET["mode"] != "session"))
00453                 {
00454                         $data = $this->object->getTranslations();
00455                         $_SESSION["translation_post"] = $data;
00456                         $array_push = false;
00457                 }       // remove a translation from session
00458                 elseif ($_GET["entry"] != 0)
00459                 {
00460                         array_splice($_SESSION["translation_post"]["Fobject"],$_GET["entry"],1,array());
00461 
00462                         if ($_GET["entry"] == $_SESSION["translation_post"]["default_language"])
00463                         {
00464                                 $_SESSION["translation_post"]["default_language"] = "";
00465                         }
00466                 }
00467 
00468                 $data = $_SESSION["translation_post"];
00469 
00470                 // add additional translation form
00471                 if (!$_GET["entry"] and $array_push)
00472                 {
00473                         $count = array_push($data["Fobject"],array("title" => "","desc" => ""));
00474                 }
00475                 else
00476                 {
00477                         $count = count($data["Fobject"]);
00478                 }
00479 
00480                 // stripslashes in form?
00481                 $strip = isset($_SESSION["translation_post"]) ? true : false;
00482 
00483                 foreach ($data["Fobject"] as $key => $val)
00484                 {
00485                         // add translation button
00486                         if ($key == $count -1)
00487                         {
00488                                 $this->tpl->setCurrentBlock("addTranslation");
00489                                 $this->tpl->setVariable("TXT_ADD_TRANSLATION",$this->lng->txt("add_translation")." >>");
00490                                 $this->tpl->parseCurrentBlock();
00491                         }
00492 
00493                         // remove translation button
00494                         if ($key != 0)
00495                         {
00496                                 $this->tpl->setCurrentBlock("removeTranslation");
00497                                 $this->tpl->setVariable("TXT_REMOVE_TRANSLATION",$this->lng->txt("remove_translation"));
00498                                 $this->ctrl->setParameter($this, "entry", $key);
00499                                 $this->ctrl->setParameter($this, "mode", "edit");
00500                                 $this->tpl->setVariable("LINK_REMOVE_TRANSLATION", $this->ctrl->getLinkTarget($this, "removeTranslation"));
00501                                 $this->tpl->parseCurrentBlock();
00502                         }
00503 
00504                         // lang selection
00505                         $this->tpl->addBlockFile("SEL_LANGUAGE", "sel_language", "tpl.lang_selection.html", false);
00506                         $this->tpl->setVariable("SEL_NAME", "Fobject[".$key."][lang]");
00507 
00508                         $languages = ilMetaData::getLanguages();
00509 
00510                         foreach ($languages as $code => $language)
00511                         {
00512                                 $this->tpl->setCurrentBlock("lg_option");
00513                                 $this->tpl->setVariable("VAL_LG", $code);
00514                                 $this->tpl->setVariable("TXT_LG", $language);
00515 
00516                                 if ($code == $val["lang"])
00517                                 {
00518                                         $this->tpl->setVariable("SELECTED", "selected=\"selected\"");
00519                                 }
00520 
00521                                 $this->tpl->parseCurrentBlock();
00522                         }
00523 
00524                         // object data
00525                         $this->tpl->setCurrentBlock("obj_form");
00526 
00527                         if ($key == 0)
00528                         {
00529                                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
00530                         }
00531                         else
00532                         {
00533                                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("translation")." ".$key);
00534                         }
00535 
00536                         if ($key == $data["default_language"])
00537                         {
00538                                 $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
00539                         }
00540 
00541                         $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00542                         $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
00543                         $this->tpl->setVariable("TXT_DEFAULT", $this->lng->txt("default"));
00544                         $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00545                         $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($val["title"],$strip));
00546                         $this->tpl->setVariable("DESC", ilUtil::stripSlashes($val["desc"]));
00547                         $this->tpl->setVariable("NUM", $key);
00548                         $this->tpl->parseCurrentBlock();
00549                 }
00550                 
00551                 $this->showCustomIconsEditing();
00552 
00553                 // global
00554                 $this->tpl->setCurrentBlock("adm_content");
00555                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00556                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00557                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00558                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00559                 $this->tpl->setVariable("CMD_SUBMIT", "update");
00560                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00561         }
00562 
00568         function updateObject()
00569         {
00570                 global $rbacsystem;
00571                 if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00572                 {
00573                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00574                 }
00575                 else
00576                 {
00577                         $data = $_POST;
00578 
00579                         // default language set?
00580                         if (!isset($data["default_language"]))
00581                         {
00582                                 $this->ilias->raiseError($this->lng->txt("msg_no_default_language"),$this->ilias->error_obj->MESSAGE);
00583                         }
00584 
00585                         // prepare array fro further checks
00586                         foreach ($data["Fobject"] as $key => $val)
00587                         {
00588                                 $langs[$key] = $val["lang"];
00589                         }
00590 
00591                         $langs = array_count_values($langs);
00592 
00593                         // all languages set?
00594                         if (array_key_exists("",$langs))
00595                         {
00596                                 $this->ilias->raiseError($this->lng->txt("msg_no_language_selected"),$this->ilias->error_obj->MESSAGE);
00597                         }
00598 
00599                         // no single language is selected more than once?
00600                         if (array_sum($langs) > count($langs))
00601                         {
00602                                 $this->ilias->raiseError($this->lng->txt("msg_multi_language_selected"),$this->ilias->error_obj->MESSAGE);
00603                         }
00604 
00605                         // copy default translation to variable for object data entry
00606                         $_POST["Fobject"]["title"] = $_POST["Fobject"][$_POST["default_language"]]["title"];
00607                         $_POST["Fobject"]["desc"] = $_POST["Fobject"][$_POST["default_language"]]["desc"];
00608 
00609                         // first delete all translation entries...
00610                         $this->object->removeTranslations();
00611 
00612                         // ...and write new translations to object_translation
00613                         foreach ($data["Fobject"] as $key => $val)
00614                         {
00615                                 if ($key == $data["default_language"])
00616                                 {
00617                                         $default = 1;
00618                                 }
00619                                 else
00620                                 {
00621                                         $default = 0;
00622                                 }
00623 
00624                                 $this->object->addTranslation(ilUtil::stripSlashes($val["title"]),ilUtil::stripSlashes($val["desc"]),$val["lang"],$default);
00625                         }
00626 
00627                         // update object data entry with default translation
00628                         $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00629                         $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00630                         
00631                         //save custom icons
00632                         if ($this->ilias->getSetting("custom_icons"))
00633                         {
00634                                 $this->object->saveIcons($_FILES["cont_big_icon"],
00635                                         $_FILES["cont_small_icon"]);
00636                         }
00637                         
00638                         $this->update = $this->object->update();
00639                 }
00640 
00641                 sendInfo($this->lng->txt("msg_obj_modified"),true);
00642                 ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getTargetScript()."?".$this->link_params));
00643         }
00644 
00650         function addTranslationObject()
00651         {
00652                 if (!($_GET["mode"] != "create" or $_GET["mode"] != "edit"))
00653                 {
00654                         $message = get_class($this)."::addTranslationObject(): Missing or wrong parameter! mode: ".$_GET["mode"];
00655                         $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00656                 }
00657 
00658                 $_SESSION["translation_post"] = $_POST;
00659                 $this->ctrl->setParameter($this, "entry", 0);
00660                 $this->ctrl->setParameter($this, "mode", "session");
00661                 $this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
00662                 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00663         }
00664 
00670         function removeTranslationObject()
00671         {
00672                 if (!($_GET["mode"] != "create" or $_GET["mode"] != "edit"))
00673                 {
00674                         $message = get_class($this)."::removeTranslationObject(): Missing or wrong parameter! mode: ".$_GET["mode"];
00675                         $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00676                 }
00677 
00678                 $this->ctrl->setParameter($this, "entry", $_GET["entry"]);
00679                 $this->ctrl->setParameter($this, "mode", "session");
00680                 $this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
00681                 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00682 
00683         }
00684 
00690         function removeBigIconObject()
00691         {
00692 
00693                 $_SESSION["translation_post"] = $_POST;
00694                 $this->object->removeBigIcon();
00695                 //$this->ctrl->setParameter($this, "entry", 0);
00696                 //$this->ctrl->setParameter($this, "mode", "session");
00697                 //$this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
00698                 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00699         }
00700         
00706         function removeSmallIconObject()
00707         {
00708 
00709                 $_SESSION["translation_post"] = $_POST;
00710                 $this->object->removeSmallIcon();
00711                 //$this->ctrl->setParameter($this, "entry", 0);
00712                 //$this->ctrl->setParameter($this, "mode", "session");
00713                 //$this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
00714                 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00715         }
00716 
00720         function importCategoriesFormObject ()
00721         {
00722                 ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
00723         }
00724 
00728         function _importCategoriesForm ($a_ref_id, &$a_tpl)
00729         {
00730                 global $lng, $rbacreview;
00731 
00732                 $a_tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.cat_import_form.html");
00733 
00734                 $a_tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00735 
00736                 $a_tpl->setVariable("TXT_IMPORT_CATEGORIES", $lng->txt("import_categories"));
00737                 $a_tpl->setVariable("TXT_HIERARCHY_OPTION", $lng->txt("import_cat_localrol"));
00738                 $a_tpl->setVariable("TXT_IMPORT_FILE", $lng->txt("import_file"));
00739                 $a_tpl->setVariable("TXT_IMPORT_TABLE", $lng->txt("import_cat_table"));
00740 
00741                 $a_tpl->setVariable("BTN_IMPORT", $lng->txt("import"));
00742                 $a_tpl->setVariable("BTN_CANCEL", $lng->txt("cancel"));
00743 
00744                 // NEED TO FILL ADOPT_PERMISSIONS HTML FORM....
00745                 $parent_role_ids = $rbacreview->getParentRoleIds($a_ref_id,true);
00746                 
00747                 // sort output for correct color changing
00748                 ksort($parent_role_ids);
00749                 
00750                 foreach ($parent_role_ids as $key => $par)
00751                   {
00752                     if ($par["obj_id"] != SYSTEM_ROLE_ID)
00753                       {
00754                         $check = ilUtil::formCheckbox(0,"adopt[]",$par["obj_id"],1);
00755                         $output["adopt"][$key]["css_row_adopt"] = ilUtil::switchColor($key, "tblrow1", "tblrow2");
00756                         $output["adopt"][$key]["check_adopt"] = $check;
00757                         $output["adopt"][$key]["role_id"] = $par["obj_id"];
00758                         $output["adopt"][$key]["type"] = ($par["type"] == 'role' ? 'Role' : 'Template');
00759                         $output["adopt"][$key]["role_name"] = $par["title"];
00760                       }
00761                   }
00762                 
00763                 //var_dump($output);
00764 
00765                 // BEGIN ADOPT PERMISSIONS
00766                 foreach ($output["adopt"] as $key => $value)
00767                   {
00768                     $a_tpl->setCurrentBlock("ADOPT_PERM_ROW");
00769                     $a_tpl->setVariable("CSS_ROW_ADOPT",$value["css_row_adopt"]);
00770                     $a_tpl->setVariable("CHECK_ADOPT",$value["check_adopt"]);
00771                     $a_tpl->setVariable("LABEL_ID",$value["role_id"]);
00772                     $a_tpl->setVariable("TYPE",$value["type"]);
00773                     $a_tpl->setVariable("ROLE_NAME",$value["role_name"]);
00774                     $a_tpl->parseCurrentBlock();
00775                   }
00776         }
00777 
00778 
00784         function importCancelledObject()
00785         {
00786                 sendInfo($this->lng->txt("action_aborted"),true);
00787                 $this->ctrl->redirect($this);
00788         }
00789 
00793         function _getImportDir()
00794         {
00795                 return ilUtil::getDataDir()."/cat_import";
00796         }
00797 
00801         function importCategoriesObject()
00802         {
00803                 ilObjCategoryGUI::_importCategories($_GET["ref_id"]);
00804                 // call to importCategories with $withrol = 0
00805                 ilObjCategoryGUI::_importCategories($_GET["ref_id"], 0);
00806         }
00807         
00811         function importCategoriesWithRolObject()
00812         {
00813         
00814           //echo "entra aqui";
00815           // call to importCategories with $withrol = 1
00816           ilObjCategoryGUI::_importCategories($_GET["ref_id"], 1);
00817         }
00818 
00823         function _importCategories($a_ref_id, $withrol_tmp)     
00824         {
00825                 global $lng;
00826 
00827                 require_once("classes/class.ilCategoryImportParser.php");
00828 
00829                 $import_dir = ilObjCategoryGUI::_getImportDir();
00830 
00831                 // create user import directory if necessary
00832                 if (!@is_dir($import_dir))
00833                 {
00834                         ilUtil::createDirectory($import_dir);
00835                 }
00836 
00837                 // move uploaded file to user import directory
00838 
00839                 $file_name = $_FILES["importFile"]["name"];
00840 
00841                 // added to prevent empty file names
00842                 if (!strcmp($file_name,"")) {
00843                   sendInfo($lng->txt("no_import_file_found"), true);
00844                   $this->ctrl->redirect($this);
00845                 }
00846 
00847                 $parts = pathinfo($file_name);
00848                 $full_path = $import_dir."/".$file_name;
00849                 //move_uploaded_file($_FILES["importFile"]["tmp_name"], $full_path);
00850                 ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $file_name, $full_path);
00851 
00852                 // unzip file
00853                 ilUtil::unzip($full_path);
00854 
00855                 $subdir = basename($parts["basename"],".".$parts["extension"]);
00856                 $xml_file = $import_dir."/".$subdir."/".$subdir.".xml";
00857                 // CategoryImportParser
00858                 //var_dump($_POST);
00859                 $importParser = new ilCategoryImportParser($xml_file, $a_ref_id, $withrol_tmp);
00860                 $importParser->startParsing();
00861 
00862                 sendInfo($lng->txt("categories_imported"), true);
00863                 $this->ctrl->redirect($this);
00864         }
00865 
00866         function applyFilterObject()
00867         {
00868                 unset($_GET['offset']);
00869                 unset($_SESSION['lua_offset'][$this->object->getRefId()]);
00870                 $this->listUsersObject();
00871         }
00872 
00873         // METHODS for local user administration
00874         function listUsersObject($show_delete = false)
00875         {
00876                 global $ilUser;
00877 
00878                 include_once './classes/class.ilLocalUser.php';
00879                 include_once './classes/class.ilObjUserGUI.php';
00880 
00881                 global $rbacsystem,$rbacreview;
00882 
00883                 if(!$rbacsystem->checkAccess("cat_administrate_users",$this->object->getRefId()))
00884                 {
00885                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_admin_users"),$this->ilias->error_obj->MESSAGE);
00886                 }
00887                 $this->tabs_gui->setTabActive('administrate_users');
00888 
00889 
00890                 $_GET['sort_by'] = ($_SESSION['lua_sort_by'][$this->object->getRefId()] = 
00891                                                         ($_GET['sort_by'] ? $_GET['sort_by'] : $_SESSION['lua_sort_by'][$this->object->getRefId()]));
00892                 $_GET['sort_order'] = $_SESSION['lua_sort_order'][$this->object->getRefId()] = 
00893                         ($_GET['sort_order'] ? $_GET['sort_order'] : $_SESSION['lua_sort_order'][$this->object->getRefId()]);
00894                 $_GET['offset'] = $_SESSION['lua_offset'][$this->object->getRefId()] = 
00895                         (isset($_GET['offset']) ? $_GET['offset'] : $_SESSION['lua_offset'][$this->object->getRefId()]);
00896 
00897 
00898                 // default to local users view
00899                 if(!isset($_SESSION['filtered_users'][$this->object->getRefId()]))
00900                 {
00901                         $_SESSION['filtered_users'][$this->object->getRefId()] = $this->object->getRefId();
00902                 }
00903 
00904                 $_SESSION['delete_users'] = $show_delete ? $_SESSION['delete_users'] : array();
00905                 $_SESSION['filtered_users'][$this->object->getRefId()] = isset($_POST['filter']) ? 
00906                         $_POST['filter'] : 
00907                         $_SESSION['filtered_users'][$this->object->getRefId()];
00908 
00909                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.cat_admin_users.html');
00910                 $parent = ilLocalUser::_getFolderIds();
00911                 if(count($parent) > 1)
00912                 {
00913                         $this->tpl->setCurrentBlock("filter");
00914                         $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
00915                         $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect($parent));
00916                         $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
00917                         $this->tpl->setVariable("FILTER_NAME",'applyFilter');
00918                         $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
00919                         $this->tpl->parseCurrentBlock();
00920                 }
00921 
00922                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00923                 if(count($rbacreview->getGlobalAssignableRoles()) or in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00924                 {
00925                         // add user button
00926                         $this->tpl->setCurrentBlock("btn_cell");
00927                         $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilobjusergui','create'));
00928                         $this->tpl->setVariable("BTN_TXT",$this->lng->txt('add_user'));
00929                         $this->tpl->parseCurrentBlock();
00930 
00931                         // import user button
00932                         $this->tpl->setCurrentBlock("btn_cell");
00933                         $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilobjuserfoldergui','importUserForm'));
00934                         $this->tpl->setVariable("BTN_TXT",$this->lng->txt('import_users'));
00935                         $this->tpl->parseCurrentBlock();
00936                 }
00937                 else
00938                 {
00939                         sendInfo($this->lng->txt('no_roles_user_can_be_assigned_to'));
00940                 }
00941                 if(!count($users = ilLocalUser::_getAllUserIds($_SESSION['filtered_users'][$this->object->getRefId()])))
00942                 {
00943                         sendInfo($this->lng->txt('no_local_users'));
00944                 }
00945 
00946 
00947                 if($show_delete)
00948                 {
00949                         $this->tpl->setCurrentBlock("confirm_delete");
00950                         $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
00951                         $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00952                         $this->tpl->setVariable("CONFIRM_CMD",'performDeleteUsers');
00953                         $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('delete'));
00954                         $this->tpl->parseCurrentBlock();
00955                 }
00956                 
00957                 $counter = 0;
00958                 $editable = false;
00959 
00960                 // pre sort
00961                 $users = ilLocalUser::_getUserData($_SESSION['filtered_users'][$this->object->getRefId()]);
00962                 $this->all_users_count = count($users);
00963 
00964                 $users = ilUtil::sortArray($users,$_GET["sort_by"] ? $_GET['sort_by'] : 'login',$_GET["sort_order"]);
00965                 $users = array_slice($users,$_GET["offset"],$ilUser->getPref('hits_per_page'));
00966 
00967                 foreach($users as $user_data)
00968                 {
00969                         if($user_data['time_limit_owner'] == $this->object->getRefId())
00970                         {
00971                                 $editable = true;
00972                                 $f_result[$counter][]   = ilUtil::formCheckbox(in_array($user_data['usr_id'],$_SESSION['delete_users']) ? 1 : 0,
00973                                                                                                                            "user_ids[]",$user_data['usr_id']);
00974 
00975                                 $this->ctrl->setParameterByClass('ilobjusergui','obj_id',$user_data['usr_id']);
00976                                 $f_result[$counter][]   = '<a  href="'.$this->ctrl->getLinkTargetByClass('ilobjusergui','edit').'">'.
00977                                         $user_data['login'].'</a>';
00978                         }
00979                         else
00980                         {
00981                                 $f_result[$counter][]   = '&nbsp;';
00982                                 $f_result[$counter][]   = $user_data['login'];
00983                         }
00984 
00985                         $f_result[$counter][]   = $user_data['firstname'];
00986                         $f_result[$counter][]   = $user_data['lastname'];
00987 
00988                         
00989                         switch($usr_data['time_limit_owner'])
00990                         {
00991                                 case 7:
00992                                         $f_result[$counter][]   = $this->lng->txt('global');
00993                                         break;
00994 
00995                                 default:
00996                                         $f_result[$counter][] = ($title = ilObject::_lookupTitle(ilObject::_lookupObjId($user_data['time_limit_owner']))) ?
00997                                                 $title : '';
00998                         }
00999                         
01000                         // role assignment
01001                         $this->ctrl->setParameter($this,'obj_id',$user_data['usr_id']);
01002                         $f_result[$counter][]   = '<a class="il_ContainerItemCommand" href="'.$this->ctrl->getLinkTarget($this,'assignRoles').'">'.
01003                                 $this->lng->txt('edit').'</a>';
01004                         
01005                         unset($tmp_obj);
01006                         ++$counter;
01007                 }
01008                 $this->__showUsersTable($f_result,"listUsersObject",$editable);
01009                 
01010                 return true;
01011         }
01012 
01013         function performDeleteUsersObject()
01014         {
01015                 include_once './classes/class.ilLocalUser.php';
01016 
01017                 foreach($_SESSION['delete_users'] as $user_id)
01018                 {
01019                         if(!in_array($user_id,ilLocalUser::_getAllUserIds($this->object->getRefId())))
01020                         {
01021                                 die('user id not valid');
01022                         }
01023                         if(!$tmp_obj =& ilObjectFactory::getInstanceByObjId($user_id,false))
01024                         {
01025                                 continue;
01026                         }
01027                         $tmp_obj->delete();
01028                 }
01029                 sendInfo($this->lng->txt('deleted_users'));
01030                 $this->listUsersObject();
01031 
01032                 return true;
01033         }
01034                         
01035         function deleteUserObject()
01036         {
01037                 if(!count($_POST['user_ids']))
01038                 {
01039                         sendInfo($this->lng->txt('no_users_selected'));
01040                         $this->listUsersObject();
01041                         
01042                         return true;
01043                 }
01044                 $_SESSION['delete_users'] = $_POST['user_ids'];
01045 
01046                 sendInfo($this->lng->txt('sure_delete_selected_users'));
01047                 $this->listUsersObject(true);
01048                 return true;
01049         }
01050 
01051         function assignRolesObject()
01052         {
01053                 global $rbacreview;
01054 
01055                 include_once './classes/class.ilLocalUser.php';
01056 
01057                 if(!isset($_GET['obj_id']))
01058                 {
01059                         sendInfo('no_user_selected');
01060                         $this->listUsersObject();
01061 
01062                         return true;
01063                 }
01064 
01065                 $this->tabs_gui->setTabActive('administrate_users');
01066 
01067                 $roles = $this->__getAssignableRoles();
01068 
01069                 if(!count($roles))
01070                 {
01071                         #sendInfo($this->lng->txt('no_roles_user_can_be_assigned_to'));
01072                         #$this->listUsersObject();
01073 
01074                         #return true;
01075                 }
01076                 
01077                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.cat_role_assignment.html');
01078                 $this->__showButton('listUsers',$this->lng->txt('back'));
01079 
01080                 $ass_roles = $rbacreview->assignedRoles($_GET['obj_id']);
01081 
01082                 $counter = 0;
01083                 foreach($roles as $role)
01084                 {
01085                         $role_obj =& ilObjectFactory::getInstanceByObjId($role['obj_id']);
01086                         
01087                         $disabled = false;
01088                         $f_result[$counter][] = ilUtil::formCheckbox(in_array($role['obj_id'],$ass_roles) ? 1 : 0,
01089                                                                                                                  'role_ids[]',
01090                                                                                                                  $role['obj_id'],
01091                                                                                                                  $disabled);
01092                         $f_result[$counter][] = $role_obj->getTitle();
01093                         $f_result[$counter][] = $role_obj->getDescription();
01094                         $f_result[$counter][] = $role['role_type'] == 'local' ? 
01095                                 $this->lng->txt('local') :
01096                                 $this->lng->txt('global');
01097                         
01098                         unset($role_obj);
01099                         ++$counter;
01100                 }
01101                 $this->__showRolesTable($f_result,"assignRolesObject");
01102         }
01103 
01104         function assignSaveObject()
01105         {
01106                 global $rbacreview,$rbacadmin;
01107 
01108                 include_once './classes/class.ilLocalUser.php';
01109                 // check hack
01110                 if(!isset($_GET['obj_id']) or !in_array($_REQUEST['obj_id'],ilLocalUser::_getAllUserIds()))
01111                 {
01112                         sendInfo('no_user_selected');
01113                         $this->listUsersObject();
01114 
01115                         return true;
01116                 }
01117                 $roles = $this->__getAssignableRoles();
01118 
01119                 // check minimum one global role
01120                 if(!$this->__checkGlobalRoles($_POST['role_ids']))
01121                 {
01122                         sendInfo($this->lng->txt('no_global_role_left'));
01123                         $this->assignRolesObject();
01124 
01125                         return false;
01126                 }
01127                 
01128                 $new_role_ids = $_POST['role_ids'] ? $_POST['role_ids'] : array();
01129                 $assigned_roles = $rbacreview->assignedRoles((int) $_REQUEST['obj_id']);
01130                 foreach($roles as $role)
01131                 {
01132                         if(in_array($role['obj_id'],$new_role_ids) and !in_array($role['obj_id'],$assigned_roles))
01133                         {
01134                                 $rbacadmin->assignUser($role['obj_id'],(int) $_REQUEST['obj_id']);
01135                         }
01136                         if(in_array($role['obj_id'],$assigned_roles) and !in_array($role['obj_id'],$new_role_ids))
01137                         {
01138                                 $rbacadmin->deassignUser($role['obj_id'],(int) $_REQUEST['obj_id']);
01139                         }
01140                 }
01141                 sendInfo($this->lng->txt('role_assignment_updated'));
01142                 $this->assignRolesObject();
01143                 
01144                 return true;
01145         }
01146 
01147         // PRIVATE
01148         function __getAssignableRoles()
01149         {
01150                 global $rbacreview;
01151 
01152                 // check local user
01153                 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
01154                 // Admin => all roles
01155                 if(in_array(SYSTEM_ROLE_ID,$_SESSION['RoleId']))
01156                 {
01157                         $global_roles = $rbacreview->getGlobalRolesArray();
01158                 }
01159                 elseif($tmp_obj->getTimeLimitOwner() == $this->object->getRefId())
01160                 {
01161                         $global_roles = $rbacreview->getGlobalAssignableRoles();
01162                 }                       
01163                 else
01164                 {
01165                         $global_roles = array();
01166                 }
01167                 return $roles = array_merge($global_roles,
01168                                                                         $rbacreview->getAssignableChildRoles($this->object->getRefId()));
01169         }
01170 
01171         function __checkGlobalRoles($new_assigned)
01172         {
01173                 global $rbacreview;
01174 
01175                 // return true if it's not a local user
01176                 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
01177                 if($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
01178                    !in_array(SYSTEM_ROLE_ID,$_SESSION['RoleId']))
01179                 {
01180                         return true;
01181                 }
01182 
01183                 // new assignment by form
01184                 $new_assigned = $new_assigned ? $new_assigned : array();
01185                 $assigned = $rbacreview->assignedRoles((int) $_GET['obj_id']);
01186 
01187                 // all assignable globals
01188                 if(!in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
01189                 {
01190                         $ga = $rbacreview->getGlobalAssignableRoles();
01191                 }
01192                 else
01193                 {
01194                         $ga = $rbacreview->getGlobalRolesArray();
01195                 }
01196                 $global_assignable = array();
01197                 foreach($ga as $role)
01198                 {
01199                         $global_assignable[] = $role['obj_id'];
01200                 }
01201 
01202                 $new_visible_assigned_roles = array_intersect($new_assigned,$global_assignable);
01203                 $all_assigned_roles = array_intersect($assigned,$rbacreview->getGlobalRoles());
01204                 $main_assigned_roles = array_diff($all_assigned_roles,$global_assignable);
01205 
01206                 if(!count($new_visible_assigned_roles) and !count($main_assigned_roles))
01207                 {
01208                         return false;
01209                 }
01210                 return true;
01211         }
01212 
01213 
01214         function __showRolesTable($a_result_set,$a_from = "")
01215         {
01216                 $tbl =& $this->__initTableGUI();
01217                 $tpl =& $tbl->getTemplateObject();
01218 
01219                 // SET FORMAACTION
01220                 $tpl->setCurrentBlock("tbl_form_header");
01221 
01222                 $this->ctrl->setParameter($this,'obj_id',$_GET['obj_id']);
01223                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01224                 $tpl->parseCurrentBlock();
01225 
01226                 // SET FOOTER BUTTONS
01227                 $tpl->setVariable("COLUMN_COUNTS",4);
01228                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01229                 
01230                 $tpl->setCurrentBlock("tbl_action_button");
01231                 $tpl->setVariable("BTN_NAME","assignSave");
01232                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("change_assignment"));
01233                 $tpl->parseCurrentBlock();
01234                 
01235                 $tpl->setCurrentBlock("tbl_action_row");
01236                 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01237                 $tpl->parseCurrentBlock();
01238 
01239                 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_GET['obj_id']);
01240                 $title = $this->lng->txt('role_assignment').' ('.$tmp_obj->getFullname().')';
01241 
01242                 $tbl->setTitle($title,"icon_role.gif",$this->lng->txt("role_assignment"));
01243                 $tbl->setHeaderNames(array('',
01244                                                                    $this->lng->txt("title"),
01245                                                                    $this->lng->txt('description'),
01246                                                                    $this->lng->txt("type")));
01247                 $tbl->setHeaderVars(array("",
01248                                                                   "title",
01249                                                                   "description",
01250                                                                   "type"),
01251                                                         array("ref_id" => $this->object->getRefId(),
01252                                                                   "cmd" => "assignRoles",
01253                                                                   "obj_id" => $_GET['obj_id'],
01254                                                                   "cmdClass" => "ilobjcategorygui",
01255                                                                   "cmdNode" => $_GET["cmdNode"]));
01256                 $tbl->setColumnWidth(array("4%","35%","45%","16%"));
01257 
01258                 $this->set_unlimited = true;
01259                 $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from,true);
01260                 $tbl->render();
01261 
01262                 $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
01263 
01264                 return true;
01265         }               
01266 
01267         function __showUsersTable($a_result_set,$a_from = "",$a_footer = true)
01268         {
01269                 $tbl =& $this->__initTableGUI();
01270                 $tpl =& $tbl->getTemplateObject();
01271 
01272                 // SET FORMAACTION
01273                 $tpl->setCurrentBlock("tbl_form_header");
01274 
01275                 $this->ctrl->setParameter($this,'sort_by',$_GET['sort_by']);
01276                 $this->ctrl->setParameter($this,'sort_order',$_GET['sort_order']);
01277                 $this->ctrl->setParameter($this,'offset',$_GET['offset']);
01278                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01279                 $tpl->parseCurrentBlock();
01280 
01281 
01282                 if($a_footer)
01283                 {
01284                         // SET FOOTER BUTTONS
01285                         $tpl->setVariable("COLUMN_COUNTS",6);
01286                         $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01287 
01288                         $tpl->setCurrentBlock("tbl_action_button");
01289                         $tpl->setVariable("BTN_NAME","deleteUser");
01290                         $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
01291                         $tpl->parseCurrentBlock();
01292                         
01293                         $tpl->setCurrentBlock("tbl_action_row");
01294                         $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01295                         $tpl->parseCurrentBlock();
01296                 }
01297 
01298                 $tbl->setTitle($this->lng->txt("users"),"icon_usr_b.gif",$this->lng->txt("users"));
01299                 $tbl->setHeaderNames(array('',
01300                                                                    $this->lng->txt("username"),
01301                                                                    $this->lng->txt("firstname"),
01302                                                                    $this->lng->txt("lastname"),
01303                                                                    $this->lng->txt('context'),
01304                                                                    $this->lng->txt('role_assignment')));
01305                 $tbl->setHeaderVars(array("",
01306                                                                   "login",
01307                                                                   "firstname",
01308                                                                   "lastname",
01309                                                                   "context",
01310                                                                   "role_assignment"),
01311                                                         array("ref_id" => $this->object->getRefId(),
01312                                                                   "cmd" => "listUsers",
01313                                                                   "cmdClass" => "ilobjcategorygui",
01314                                                                   "cmdNode" => $_GET["cmdNode"]));
01315                 $tbl->setColumnWidth(array("4%","20%","20%","20%","20%","20%"));
01316 
01317                 $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from,true);
01318                 $tbl->render();
01319 
01320                 $this->tpl->setVariable("USERS_TABLE",$tbl->tpl->get());
01321 
01322                 return true;
01323         }               
01324 
01325         function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "",$a_footer = true)
01326         {
01327                 global $ilUser;
01328 
01329                 switch ($a_from)
01330                 {
01331                         case "listUsersObject":
01332                                 $tbl->setOrderColumn($_GET["sort_by"]);
01333                                 $tbl->setOrderDirection($_GET["sort_order"]);
01334                                 $tbl->setOffset($_GET["offset"]);
01335                                 $tbl->setMaxCount($this->all_users_count);
01336                                 $tbl->setLimit($ilUser->getPref('hits_per_page'));
01337                                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01338                                 $tbl->setData($result_set);
01339                                 $tbl->disable('auto_sort');
01340 
01341                                 return true;
01342 
01343 
01344                         case "assignRolesObject":
01345                                 $offset = $_GET["offset"];
01346                                 // init sort_by (unfortunatly sort_by is preset with 'title'
01347                                 if ($_GET["sort_by"] == "title" or empty($_GET["sort_by"]))
01348                                 {
01349                                         $_GET["sort_by"] = "login";
01350                                 }
01351                                 $order = $_GET["sort_by"];
01352                                 $direction = $_GET["sort_order"];
01353                                 break;
01354                         
01355                         case "clipboardObject":
01356                                 $offset = $_GET["offset"];
01357                                 $order = $_GET["sort_by"];
01358                                 $direction = $_GET["sort_order"];
01359                                 $tbl->disable("footer");
01360                                 break;
01361                                 
01362                         default:
01363                                 $offset = $_GET["offset"];
01364                                 $order = $_GET["sort_by"];
01365                                 $direction = $_GET["sort_order"];
01366                                 break;
01367                 }
01368 
01369                 $tbl->setOrderColumn($order);
01370                 $tbl->setOrderDirection($direction);
01371                 $tbl->setOffset($offset);
01372                 if($this->set_unlimited)
01373                 {
01374                         $tbl->setLimit($_GET["limit"]*100);
01375                 }
01376                 else
01377                 {
01378                         $tbl->setLimit($_GET['limit']);
01379                 }
01380                 $tbl->setMaxCount(count($result_set));
01381 
01382                 if($a_footer)
01383                 {
01384                         $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01385                 }
01386                 else
01387                 {
01388                         $tbl->disable('footer');
01389                 }
01390                 $tbl->setData($result_set);
01391         }
01392 
01393         function &__initTableGUI()
01394         {
01395                 include_once "./classes/class.ilTableGUI.php";
01396 
01397                 return new ilTableGUI(0,false);
01398         }
01399 
01400         function __buildFilterSelect($a_parent_ids)
01401         {
01402                 $action[0] = $this->lng->txt('all_users');
01403                 $action[$this->object->getRefId()] = $this->lng->txt('users').
01404                         ' ('.ilObject::_lookupTitle(ilObject::_lookupObjId($this->object->getRefId())).')';
01405 
01406                 foreach($a_parent_ids as $parent)
01407                 {
01408                         if($parent == $this->object->getRefId())
01409                         {
01410                                 continue;
01411                         }
01412                         switch($parent)
01413                         {
01414                                 case ilLocalUser::_getUserFolderId():
01415                                         $action[ilLocalUser::_getUserFolderId()] = $this->lng->txt('global_user'); 
01416                                         
01417                                         break;
01418 
01419                                 default:
01420                                         $action[$parent] = $this->lng->txt('users').' ('.ilObject::_lookupTitle(ilObject::_lookupObjId($parent)).')';
01421 
01422                                         break;
01423                         }
01424                 }
01425                 return ilUtil::formSelect($_SESSION['filtered_users'][$this->object->getRefId()],"filter",$action,false,true);
01426         }
01427         
01428         function _goto($a_target)
01429         {
01430                 global $ilAccess, $ilErr, $lng;
01431 
01432                 if ($ilAccess->checkAccess("read", "", $a_target))
01433                 {
01434                         $_GET["cmd"] = "frameset";
01435                         $_GET["ref_id"] = $a_target;
01436                         include("repository.php");
01437                         exit;
01438                 }
01439                 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
01440                 {
01441                         $_GET["cmd"] = "frameset";
01442                         $_GET["target"] = "";
01443                         $_GET["ref_id"] = ROOT_FOLDER_ID;
01444                         sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
01445                                 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
01446                         include("repository.php");
01447                         exit;
01448                 }
01449 
01450                 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
01451 
01452         }
01453 
01454 
01455 } // END class.ilObjCategoryGUI
01456 ?>

Generated on Fri Dec 13 2013 13:52:07 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1