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

classes/class.ilObjectGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00034 class ilObjectGUI
00035 {
00041         var $ilias;
00042 
00048         var $objDefinition;
00049 
00055         var $tpl;
00056 
00062         var $tree;
00063 
00069         var $lng;
00070 
00076         var $data;
00077 
00083         var $object;
00084         var $ref_id;
00085         var $obj_id;
00086         var $maxcount;                  // contains number of child objects
00087         var $formaction;                // special formation (array "cmd" => "formaction")
00088         var $return_location;   // special return location (array "cmd" => "location")
00089         var $target_frame;      // special target frame (array "cmd" => "location")
00090 
00091         var $tab_target_script;
00092         var $actions;
00093         var $sub_objects;
00094         var $omit_locator = false;
00095 
00103         function ilObjectGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
00104         {
00105                 global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng, $ilTabs;
00106 
00107                 $this->tabs_gui =& $ilTabs;
00108 
00109                 if (!isset($ilErr))
00110                 {
00111                         $ilErr = new ilErrorHandling();
00112                         $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
00113                 }
00114                 else
00115                 {
00116                         $this->ilErr =& $ilErr;
00117                 }
00118 
00119                 $this->ilias =& $ilias;
00120                 $this->objDefinition =& $objDefinition;
00121                 $this->tpl =& $tpl;
00122                 $this->html = "";
00123                 $this->ctrl =& $ilCtrl;
00124 
00125                 $params = array("ref_id");
00126 
00127                 if (!$a_call_by_reference)
00128                 {
00129                         $params = array("ref_id","obj_id");
00130                 }
00131 
00132                 $this->ctrl->saveParameter($this, $params);
00133 
00134                 $this->lng =& $lng;
00135                 $this->tree =& $tree;
00136                 $this->formaction = array();
00137                 $this->return_location = array();
00138                 $this->target_frame = array();
00139                 $this->actions = "";
00140                 $this->sub_objects = "";
00141 
00142                 $this->data = $a_data;
00143                 $this->id = $a_id;
00144                 $this->call_by_reference = $a_call_by_reference;
00145                 $this->prepare_output = $a_prepare_output;
00146                 $this->creation_mode = false;
00147 
00148                 $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
00149                 $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
00150 
00151                 if ($this->id != 0)
00152                 {
00153                         $this->link_params = "ref_id=".$this->ref_id;
00154                 }
00155 
00156                 // get the object
00157                 $this->assignObject();
00158 
00159                 // use global $lng instead, when creating new objects object is not available
00160                 //$this->lng =& $this->object->lng;
00161 
00162                 //prepare output
00163                 if ($a_prepare_output)
00164                 {
00165                         $this->prepareOutput();
00166                 }
00167         }
00168         
00169         
00173         function &executeCommand()
00174         {
00175                 global $rbacsystem;
00176 
00177                 $next_class = $this->ctrl->getNextClass($this);
00178                 $cmd = $this->ctrl->getCmd();
00179 
00180                 switch($next_class)
00181                 {
00182                         default:
00183                                 $this->prepareOutput();
00184                                 if(!$cmd)
00185                                 {
00186                                         $cmd = "view";
00187                                 }
00188                                 $cmd .= "Object";
00189                                 $this->$cmd();
00190                                         
00191                                 break;
00192                 }
00193 
00194                 return true;
00195         }
00196 
00197 
00201         function withReferences()
00202         {
00203                 return $this->call_by_reference;
00204         }
00205         
00212         function setCreationMode($a_mode = true)
00213         {
00214                 $this->creation_mode = $a_mode;
00215         }
00216         
00220         function getCreationMode()
00221         {
00222                 return $this->creation_mode;
00223         }
00224 
00225         function assignObject()
00226         {
00227                 // TODO: it seems that we always have to pass only the ref_id
00228 //echo "<br>ilObjectGUIassign:".get_class($this).":".$this->id.":<br>";
00229                 if ($this->id != 0)
00230                 {
00231                         if ($this->call_by_reference)
00232                         {
00233                                 $this->object =& $this->ilias->obj_factory->getInstanceByRefId($this->id);
00234                         }
00235                         else
00236                         {
00237                                 $this->object =& $this->ilias->obj_factory->getInstanceByObjId($this->id);
00238                         }
00239                 }
00240         }
00241 
00245         function prepareOutput()
00246         {
00247                 global $ilLocator, $tpl;
00248 
00249                 $this->tpl->getStandardTemplate();
00250                 // administration prepare output
00251                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00252                 {
00253                         $this->addAdminLocatorItems();
00254                         $tpl->setLocator();
00255 
00256                         sendInfo();
00257                         infoPanel();
00258 
00259                         $this->setTitleAndDescription();
00260 
00261                         if ($this->getCreationMode() != true)
00262                         {
00263                                 $this->setAdminTabs();
00264                                 $this->showUpperIcon();
00265                         }
00266                         
00267                         return false;
00268                 }
00269 
00270                 // set locator
00271                 $this->setLocator();
00272 
00273                 // catch feedback message
00274                 sendInfo();
00275                 infoPanel();
00276 
00277                 // in creation mode (parent) object and gui object
00278                 // do not fit
00279                 if ($this->getCreationMode() == true)
00280                 {
00281                         // get gui class of parent and call their title and description method
00282                         $obj_type = ilObject::_lookupType($_GET["ref_id"],true);
00283                         $class_name = $this->objDefinition->getClassName($obj_type);
00284                         $class = strtolower("ilObj".$class_name."GUI");
00285                         $class_path = $this->ctrl->lookupClassPath($class);
00286                         include_once($class_path);
00287                         $class_name = $this->ctrl->getClassForClasspath($class_path);
00288 //echo "<br>instantiating parent for title and description";
00289                         $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
00290                         $this->parent_gui_obj->setTitleAndDescription();
00291                 }
00292                 else
00293                 {
00294                         // set title and description and title icon
00295                         $this->setTitleAndDescription();
00296         
00297                         // set tabs
00298                         $this->setTabs();
00299                         $this->showUpperIcon();
00300                 }
00301                 
00302                 return true;
00303         }
00304         
00305 
00309         function setTitleAndDescription()
00310         {
00311                 $this->tpl->setTitle($this->object->getTitle());
00312                 $this->tpl->setDescription($this->object->getLongDescription());
00313                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_" . $this->object->getType()));
00314         }
00315         
00316         function showUpperIcon()
00317         {
00318                 global $tree, $tpl, $objDefinition;
00319 
00320                 if ($this->object->getRefId() == "")
00321                 {
00322                         return;
00323                 }
00324 
00325                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00326                 {               
00327                         if ($this->object->getRefId() != ROOT_FOLDER_ID &&
00328                                 $this->object->getRefId() != SYSTEM_FOLDER_ID)
00329                         {
00330                                 $par_id = $tree->getParentId($this->object->getRefId());
00331                                 $obj_type = ilObject::_lookupType($par_id,true);
00332                                 $class_name = $objDefinition->getClassName($obj_type);
00333                                 $class = strtolower("ilObj".$class_name."GUI");
00334                                 $this->ctrl->setParameterByClass($class, "ref_id", $par_id);
00335                                 $tpl->setUpperIcon($this->ctrl->getLinkTargetByClass($class, "view"));
00336                                 $this->ctrl->clearParametersByClass($class);
00337                         }
00338                         // link repository admin to admin settings
00339                         else if ($this->object->getRefId() == ROOT_FOLDER_ID)
00340                         {
00341                                 $this->ctrl->setParameterByClass("iladministrationgui", "ref_id", "");
00342                                 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
00343                                 $tpl->setUpperIcon($this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00344                                         ilFrameTargetInfo::_getFrame("MainContent"));
00345                                 $this->ctrl->clearParametersByClass("iladministrationgui");
00346                         }
00347                 }
00348                 else
00349                 {
00350                         if ($this->object->getRefId() != ROOT_FOLDER_ID &&
00351                                 $this->object->getRefId() != SYSTEM_FOLDER_ID &&
00352                                 $_GET["obj_id"] == "")
00353                         {
00354                                 if (defined("ILIAS_MODULE"))
00355                                 {
00356                                         $prefix = "../";
00357                                 }
00358                                 $par_id = $tree->getParentId($this->object->getRefId());
00359                                 $tpl->setUpperIcon($prefix."repository.php?cmd=frameset&ref_id=".$par_id,
00360                                         ilFrameTargetInfo::_getFrame("MainContent"));
00361                         }
00362                 }
00363         }
00364 
00365 
00370         function setTabs()
00371         {
00372                 #include_once "./classes/class.ilTabsGUI.php";
00373                 #$tabs_gui =& new ilTabsGUI();
00374                 $this->getTabs($this->tabs_gui);
00375                 
00376                 //var_dump(get_class($this));
00377 
00378                 // output tabs
00379                 #$this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00380                         
00381                 /*
00382                 }
00383                 else
00384                 {
00385                         global $rbacsystem;
00386         
00387                         $tabs = array();
00388                         $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
00389         
00390                         // for new objects display properties of parent object
00391                         if ($a_new_type)
00392                         {
00393                                 $d = $this->objDefinition->getProperties($this->object->getType());
00394                         }
00395                         else
00396                         {
00397                                 $d = $this->objDefinition->getProperties($this->type);
00398                         }
00399         
00400                         foreach ($d as $key => $row)
00401                         {
00402                                 $tabs[] = array($row["lng"], $row["name"]);
00403                         }
00404         
00405                         // check for call_by_reference too to avoid hacking
00406                         if (isset($_GET["obj_id"]) and $this->call_by_reference === false)
00407                         {
00408                                 $object_link = "&obj_id=".$_GET["obj_id"];
00409                         }
00410         
00411                         foreach ($tabs as $row)
00412                         {
00413                                 $i++;
00414         
00415                                 if ($row[1] == $_GET["cmd"])
00416                                 {
00417                                         $tabtype = "tabactive";
00418                                         $tab = $tabtype;
00419                                 }
00420                                 else
00421                                 {
00422                                         $tabtype = "tabinactive";
00423                                         $tab = "tab";
00424                                 }
00425         
00426                                 $show = true;
00427         
00428                                 // only check permissions for tabs if object is a permission object
00429                                 // TODO: automize checks by using objects.xml definitions!!
00430                                 if (true)
00431                                 //if ($this->call_by_reference)
00432                                 {
00433                                         // only show tab when the corresponding permission is granted
00434                                         switch ($row[1])
00435                                         {
00436                                                 case 'view':
00437                                                         if (!$rbacsystem->checkAccess('visible',$this->ref_id))
00438                                                         {
00439                                                                 $show = false;
00440                                                         }
00441                                                         break;
00442         
00443                                                 case 'edit':
00444                                                         if (!$rbacsystem->checkAccess('write',$this->ref_id))
00445                                                         {
00446                                                                 $show = false;
00447                                                         }
00448                                                         break;
00449         
00450                                                 case 'perm':
00451                                                         if (!$rbacsystem->checkAccess('edit_permission',$this->ref_id))
00452                                                         {
00453                                                                 $show = false;
00454                                                         }
00455                                                         break;
00456         
00457                                                 case 'trash':
00458                                                         if (!$this->tree->getSavedNodeData($this->ref_id))
00459                                                         {
00460                                                                 $show = false;
00461                                                         }
00462                                                         break;
00463         
00464                                                 // user object only
00465                                                 case 'roleassignment':
00466                                                         if (!$rbacsystem->checkAccess('edit_roleassignment',$this->ref_id))
00467                                                         {
00468                                                                 $show = false;
00469                                                         }
00470                                                         break;
00471 
00472                                                 // role object only
00473                                                 case 'userassignment':
00474                                                         if (!$rbacsystem->checkAccess('edit_userassignment',$this->ref_id))
00475                                                         {
00476                                                                 $show = false;
00477                                                         }
00478                                                         break;
00479                                         } //switch
00480                                 }
00481         
00482                                 if (!$show)
00483                                 {
00484                                         continue;
00485                                 }
00486         
00487                                 $this->tpl->setCurrentBlock("tab");
00488                                 $this->tpl->setVariable("TAB_TYPE", $tabtype);
00489                                 $this->tpl->setVariable("TAB_TYPE2", $tab);
00490                                 $this->tpl->setVariable("IMG_LEFT", ilUtil::getImagePath("eck_l.gif"));
00491                                 $this->tpl->setVariable("IMG_RIGHT", ilUtil::getImagePath("eck_r.gif"));
00492                                 $this->tpl->setVariable("TAB_LINK", $this->tab_target_script."?ref_id=".$_GET["ref_id"].$object_link."&cmd=".$row[1]);
00493                                 $this->tpl->setVariable("TAB_TEXT", $this->lng->txt($row[0]));
00494                                 $this->tpl->parseCurrentBlock();
00495                         }
00496                 }*/
00497         }
00498 
00503         function setAdminTabs()
00504         {
00505                 #include_once "./classes/class.ilTabsGUI.php";
00506                 #$tabs_gui =& new ilTabsGUI();
00507                 $this->getAdminTabs($this->tabs_gui);
00508 
00509                 // output tabs
00510                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00511                 //$this->tpl->setTabs($tabs_gui->getHTML());
00512         }
00513 
00517         function getAdminTabs(&$tabs_gui)
00518         {
00519                 global $rbacsystem;
00520 
00521                 if ($_GET["admin_mode"] == "repository")
00522                 {
00523                         $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
00524                         $tabs_gui->setBackTarget($this->lng->txt("administration"),
00525                                 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00526                                 ilFrameTargetInfo::_getFrame("MainContent"));
00527                         $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
00528                 }
00529                 
00530                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00531                 {
00532                         $tabs_gui->addTarget("view",
00533                                 $this->ctrl->getLinkTarget($this, "view"), array("", "view"), get_class($this));
00534                 }
00535                 
00536                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00537                 {
00538                         $tabs_gui->addTarget("perm_settings",
00539                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), "", "ilpermissiongui");
00540                 }
00541                         
00542                 if ($this->tree->getSavedNodeData($this->object->getRefId()))
00543                 {
00544                         $tabs_gui->addTarget("trash",
00545                                 $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
00546                 }
00547         }
00548 
00549 
00550         function getHTML()
00551         {
00552                 return $this->html;
00553         }
00554 
00555 
00562         function setActions($a_actions = "")
00563         {
00564                 if (is_array($a_actions))
00565                 {
00566                         foreach ($a_actions as $name => $lng)
00567                         {
00568                                 $this->actions[$name] = array("name" => $name, "lng" => $lng);
00569                         }
00570                 }
00571                 else
00572                 {
00573                         $this->actions = "";
00574                 }
00575         }
00576 
00583         function setSubObjects($a_sub_objects = "")
00584         {
00585                 if (is_array($a_sub_objects))
00586                 {
00587                         foreach ($a_sub_objects as $name => $options)
00588                         {
00589                                 $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
00590                         }
00591                 }
00592                 else
00593                 {
00594                         $this->sub_objects = "";
00595                 }
00596         }
00597 
00606         function setLocator()
00607         {
00608                 global $ilLocator, $tpl;
00609 
00610                 if ($this->omit_locator)
00611                 {
00612                         return;
00613                 }
00614                 
00615                 // todo: admin workaround
00616                 // in the future, objectgui classes should not be called in
00617                 // admin section anymore (rbac/trash handling in own classes)
00618                 $ref_id = ($_GET["ref_id"] != "")
00619                         ? $_GET["ref_id"]
00620                         : $this->object->getRefId();
00621                 $ilLocator->addRepositoryItems($ref_id);
00622                 $this->addLocatorItems();
00623                 
00624                 // not so nice workaround: todo: handle $ilLocator as tabs in ilTemplate
00625                 if ($_GET["admin_mode"] == "" &&
00626                         strtolower($this->ctrl->getCmdClass()) == "ilobjrolegui")
00627                 {
00628                         $this->ctrl->setParameterByClass("ilobjrolegui",
00629                                 "rolf_ref_id", $_GET["rolf_ref_id"]);
00630                         $this->ctrl->setParameterByClass("ilobjrolegui",
00631                                 "obj_id", $_GET["obj_id"]);
00632                         $ilLocator->addItem($this->lng->txt("role"),
00633                                 $this->ctrl->getLinkTargetByClass(array("ilpermissiongui",
00634                                         "ilobjrolegui"), "perm"));
00635                 }
00636 
00637                 $tpl->setLocator();
00638                 
00639                 return;
00640 
00641 /*
00642                 if (!is_object($a_tree))
00643                 {
00644                         $a_tree =& $this->tree;
00645                 }
00646 
00647                 if (!($a_id))
00648                 {
00649                         $a_id = $_GET["ref_id"];
00650                 }
00651 
00652                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00653 
00654                 $path = $a_tree->getPathFull($a_id);
00655 
00656         //check if object isn't in tree, this is the case if parent_parent is set
00657                 // TODO: parent_parent no longer exist. need another marker
00658                 if ($a_parent_parent)
00659                 {
00660                         //$subObj = getObject($a_ref_id);
00661                         $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
00662 
00663                         $path[] = array(
00664                                 "id"     => $a_ref_id,
00665                                 "title"  => $this->lng->txt($subObj->getTitle())
00666                                 );
00667                 }
00668 */
00669 
00670 /*
00671                 // this is a stupid workaround for a bug in PEAR:IT
00672                 $modifier = 1;
00673 
00674                 if (isset($_GET["obj_id"]) && $a_output_obj)
00675                 {
00676                         $modifier = 0;
00677                 }
00678 
00679                 // ### AA 03.11.10 added new locator GUI class ###
00680                 $i = 1;
00681 
00682                 foreach ($path as $key => $row)
00683                 {
00684                         if ($key < count($path)-$modifier)
00685                         {
00686                                 $this->tpl->touchBlock("locator_separator");
00687                         }
00688 
00689                         $this->tpl->setCurrentBlock("locator_item");
00690 
00691                         if ($a_root_title != "" && ($row["child"] == $a_tree->getRootId()))
00692                         {
00693                                 $title = $a_root_title;
00694                         }
00695                         else
00696                         {
00697                                 $title = $row["title"];
00698                         }
00699 
00700                         $this->tpl->setVariable("ITEM", $title);
00701 
00702                         $this->tpl->setVariable("LINK_ITEM",
00703                                 ilUtil::appendUrlParameterString($scriptname, $a_child_param."=".$row["child"]));
00704                         $this->tpl->parseCurrentBlock();
00705 
00706                         // ### AA 03.11.10 added new locator GUI class ###
00707                         // navigate locator
00708                         $ilias_locator->navigate($i++,$title,
00709                                 ilUtil::appendUrlParameterString($scriptname, $a_child_param."=".$row["child"]),"bottom");
00710                 }
00711 
00712                 if (($_GET["obj_id"] != "") && $a_output_obj)
00713                 {
00714                         $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
00715 
00716                         $this->tpl->setCurrentBlock("locator_item");
00717                         $this->tpl->setVariable("ITEM", $obj_data->getTitle());
00718 
00719                         $this->tpl->setVariable("LINK_ITEM",
00720                                 ilUtil::appendUrlParameterString($scriptname, "ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]));
00721                         $this->tpl->parseCurrentBlock();
00722 
00723                         // ### AA 03.11.10 added new locator GUI class ###
00724                         // navigate locator
00725                         $ilias_locator->navigate($i++,$obj_data->getTitle(),
00726                                 ilUtil::appendUrlParameterString($scriptname, "ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]),"bottom");
00727                 }
00728 
00729                 $this->tpl->setCurrentBlock("locator");
00730 
00731                 if (DEBUG)
00732                 {
00733                         $debug = "DEBUG: <font color=\"red\">".$this->type."::".$this->id."::".$_GET["cmd"]."</font><br/>";
00734                 }
00735 
00736                 $prop_name = $this->objDefinition->getPropertyName($_GET["cmd"],$this->type);
00737 
00738                 if ($_GET["cmd"] == "confirmDeleteAdm")
00739                 {
00740                         $prop_name = "delete_object";
00741                 }
00742 
00743                 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00744                 $this->tpl->parseCurrentBlock();
00745 */
00746         }
00747         
00752         function addLocatorItems()
00753         {
00754         }
00755         
00756         function omitLocator($a_omit = true)
00757         {
00758                 $this->omit_locator = $a_omit;
00759         }
00760 
00765         function addAdminLocatorItems()
00766         {
00767                 global $ilLocator;
00768 
00769                 if ($_GET["admin_mode"] == "settings")  // system settings
00770                 {               
00771                         $ilLocator->addItem($this->lng->txt("administration"),
00772                                 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00773                                 ilFrameTargetInfo::_getFrame("MainContent"));
00774                         if ($this->object->getRefId() != SYSTEM_FOLDER_ID)
00775                         {
00776                                 $ilLocator->addItem($this->object->getTitle(),
00777                                         $this->ctrl->getLinkTarget($this, "view"));
00778                         }
00779                 }
00780                 else                                                    // repository administration
00781                 {
00782                         $this->ctrl->setParameterByClass("iladministrationgui",
00783                                 "ref_id", "");
00784                         $this->ctrl->setParameterByClass("iladministrationgui",
00785                                 "admin_mode", "settings");
00786                         $ilLocator->addItem($this->lng->txt("administration"),
00787                                 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00788                                 ilFrameTargetInfo::_getFrame("MainContent"));
00789                         $this->ctrl->clearParametersByClass("iladministrationgui");
00790                         $ilLocator->addAdministrationItems();
00791                 }
00792 
00793         }
00794 
00800         function undeleteObject()
00801         {
00802                 global $rbacsystem, $log;
00803 
00804                 // AT LEAST ONE OBJECT HAS TO BE CHOSEN.
00805                 if (!isset($_POST["trash_id"]))
00806                 {
00807                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00808                 }
00809 
00810                 foreach ($_POST["trash_id"] as $id)
00811                 {
00812                         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
00813 
00814                         if (!$rbacsystem->checkAccess('create',$_GET["ref_id"],$obj_data->getType()))
00815                         {
00816                                 $no_create[] = $id;
00817                         }
00818                 }
00819 
00820                 if (count($no_create))
00821                 {
00822                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
00823                                                                          implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
00824                 }
00825                 foreach ($_POST["trash_id"] as $id)
00826                 {
00827                         // INSERT AND SET PERMISSIONS
00828                         $this->insertSavedNodes($id,$_GET["ref_id"],-(int) $id);
00829                         // DELETE SAVED TREE
00830                         $saved_tree = new ilTree(-(int)$id);
00831                         $saved_tree->deleteTree($saved_tree->getNodeData($id));
00832                         
00833                 }
00834 
00835                 //$this->object->notify("undelete", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$_POST["trash_id"]);
00836                 
00837                 sendInfo($this->lng->txt("msg_undeleted"),true);
00838                 
00839                 $this->ctrl->redirect($this, "view");
00840         }
00841 
00851         function insertSavedNodes($a_source_id,$a_dest_id,$a_tree_id)
00852         {
00853                 global $rbacadmin, $rbacreview, $log;
00854 
00855                 $this->tree->insertNode($a_source_id,$a_dest_id, IL_LAST_NODE, true);
00856                 
00857                 // write log entry
00858                 $log->write("ilObjectGUI::insertSavedNodes(), restored ref_id $a_source_id from trash");
00859 
00860                 // SET PERMISSIONS
00861                 $parentRoles = $rbacreview->getParentRoleIds($a_dest_id);
00862                 $obj =& $this->ilias->obj_factory->getInstanceByRefId($a_source_id);
00863 
00864                 foreach ($parentRoles as $parRol)
00865                 {
00866                         $ops = $rbacreview->getOperationsOfRole($parRol["obj_id"], $obj->getType(), $parRol["parent"]);
00867                         $rbacadmin->grantPermission($parRol["obj_id"],$ops,$a_source_id);
00868                 }
00869 
00870                 $saved_tree = new ilTree($a_tree_id);
00871                 $childs = $saved_tree->getChilds($a_source_id);
00872 
00873                 foreach ($childs as $child)
00874                 {
00875                         $this->insertSavedNodes($child["child"],$a_source_id,$a_tree_id);
00876                 }
00877         }
00878 
00888         function confirmedDeleteObject()
00889         {
00890                 include_once './payment/classes/class.ilPaymentObject.php';
00891 
00892                 global $rbacsystem, $rbacadmin, $log;
00893         
00894                 // TODO: move checkings to deleteObject
00895                 // TODO: cannot distinguish between obj_id from ref_id with the posted IDs.
00896                 // change the form field and use instead of 'id' 'ref_id' and 'obj_id'. Then switch with varname
00897                 
00898                 // AT LEAST ONE OBJECT HAS TO BE CHOSEN.
00899                 if (!isset($_SESSION["saved_post"]))
00900                 {
00901                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00902                 }
00903 
00904                 // FOR ALL SELECTED OBJECTS
00905                 foreach ($_SESSION["saved_post"] as $id)
00906                 {
00907                         // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
00908                         $node_data = $this->tree->getNodeData($id);
00909                         $subtree_nodes = $this->tree->getSubTree($node_data);
00910 
00911                         $all_node_data[] = $node_data;
00912                         $all_subtree_nodes[] = $subtree_nodes;
00913 
00914                         // CHECK DELETE PERMISSION OF ALL OBJECTS
00915                         foreach ($subtree_nodes as $node)
00916                         {
00917                                 if($node['type'] == 'rolf')
00918                                 {
00919                                         continue;
00920                                 }
00921                                 if (!$rbacsystem->checkAccess('delete',$node["child"]))
00922                                 {
00923                                         $not_deletable[] = $node["child"];
00924                                         $perform_delete = false;
00925                                 }
00926                                 else if(ilPaymentObject::_isBuyable($node['child']))
00927                                 {
00928                                         $buyable[] = $node['child'];
00929                                         $perform_delete = false;
00930                                 }
00931                         }
00932                 }
00933 
00934                 // IF THERE IS ANY OBJECT WITH NO PERMISSION TO DELETE
00935                 if (count($not_deletable))
00936                 {
00937                         $not_deletable = implode(',',$not_deletable);
00938                         session_unregister("saved_post");
00939                         sendInfo($this->lng->txt("msg_no_perm_delete")." ".$not_deletable."<br/>".$this->lng->txt("msg_cancel"),true);
00940 
00941                         $this->ctrl->returnToParent($this);
00942                 }
00943 
00944                 if(count($buyable))
00945                 {
00946                         foreach($buyable as $id)
00947                         {
00948                                 $tmp_object =& ilObjectFactory::getInstanceByRefId($id);
00949 
00950                                 $titles[] = $tmp_object->getTitle();
00951                         }
00952                         $title_str = implode(',',$titles);
00953 
00954                         sendInfo($this->lng->txt('msg_obj_not_deletable_sold').' '.$title_str,true);
00955 
00956                         $_POST['id'] = $_SESSION['saved_post'];
00957                         $this->deleteObject(true);
00958 
00959                         return false;
00960                 }
00961 
00962                 // DELETE THEM
00963                 if (!$all_node_data[0]["type"])
00964                 {
00965                         // OBJECTS ARE NO 'TREE OBJECTS'
00966                         if ($rbacsystem->checkAccess('delete',$_GET["ref_id"]))
00967                         {
00968                                 foreach($_SESSION["saved_post"] as $id)
00969                                 {
00970                                         $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
00971                                         $obj->delete();
00972                                         
00973                                         // write log entry
00974                                         $log->write("ilObjectGUI::confirmedDeleteObject(), deleted obj_id ".$obj->getId().
00975                                                 ", type: ".$obj->getType().", title: ".$obj->getTitle());
00976                                 }
00977                         }
00978                         else
00979                         {
00980                                 unset($_SESSION["saved_post"]);
00981                                 sendInfo($this->lng->txt("no_perm_delete")."<br/>".$this->lng->txt("msg_cancel"),true);
00982                                 $this->ctrl->returnToParent($this);
00983                         }
00984                 }
00985                 else
00986                 {
00987                         // SAVE SUBTREE AND DELETE SUBTREE FROM TREE
00988                         foreach ($_SESSION["saved_post"] as $id)
00989                         {
00990                                 // DELETE OLD PERMISSION ENTRIES
00991                                 $subnodes = $this->tree->getSubtree($this->tree->getNodeData($id));
00992 
00993                                 foreach ($subnodes as $subnode)
00994                                 {
00995                                         $rbacadmin->revokePermission($subnode["child"]);
00996                                         // remove item from all user desktops
00997                                         $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
00998                                 
00999                                         // TODO: inform users by mail that object $id was deleted
01000                                         //$mail->sendMail($id,$msg,$affected_users);
01001                                 }
01002 
01003                                 $this->tree->saveSubTree($id, true);
01004                                 $this->tree->deleteTree($this->tree->getNodeData($id));
01005 
01006                                 // write log entry
01007                                 $log->write("ilObjectGUI::confirmedDeleteObject(), moved ref_id ".$id.
01008                                         " to trash");
01009                                 
01010                                 // remove item from all user desktops
01011                                 $affected_users = ilUtil::removeItemFromDesktops($id);
01012 
01013                                 // TODO: inform users by mail that object $id was deleted
01014                                 //$mail->sendMail($id,$msg,$affected_users);
01015                         }
01016                         // inform other objects in hierarchy about paste operation
01017                         //$this->object->notify("confirmedDelete", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$_SESSION["saved_post"]);
01018                 }
01019                 
01020                 // Feedback
01021                 sendInfo($this->lng->txt("info_deleted"),true);
01022                 
01023                 $this->ctrl->returnToParent($this);
01024 
01025         }
01026 
01032         function cancelDeleteObject()
01033         {
01034                 session_unregister("saved_post");
01035 
01036                 sendInfo($this->lng->txt("msg_cancel"),true);
01037 
01038                 $this->ctrl->returnToParent($this);
01039 
01040         }
01041 
01047         function removeFromSystemObject()
01048         {
01049                 global $rbacsystem, $log;
01050                 
01051                 // AT LEAST ONE OBJECT HAS TO BE CHOSEN.
01052                 if (!isset($_POST["trash_id"]))
01053                 {
01054                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01055                 }
01056 
01057                 //$this->object->notify("removeFromSystem", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$_POST["trash_id"]);
01058 
01059                 // DELETE THEM
01060                 foreach ($_POST["trash_id"] as $id)
01061                 {
01062                         // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
01063                         $saved_tree = new ilTree(-(int)$id);
01064                         $node_data = $saved_tree->getNodeData($id);
01065                         $subtree_nodes = $saved_tree->getSubTree($node_data);
01066 
01067                         // remember already checked deleted node_ids
01068                         $checked[] = -(int) $id;
01069 
01070                         // dive in recursive manner in each already deleted subtrees and remove these objects too
01071                         $this->removeDeletedNodes($id,$checked);
01072 
01073                         foreach ($subtree_nodes as $node)
01074                         {
01075                                 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
01076 
01077                                 // write log entry
01078                                 $log->write("ilObjectGUI::removeFromSystemObject(), delete obj_id: ".$node_obj->getId().
01079                                         ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
01080                                         "title: ".$node_obj->getTitle());
01081                                         
01082                                 $node_obj->delete();
01083                         }
01084 
01085                         // FIRST DELETE ALL ENTRIES IN RBAC TREE
01086                         #$this->tree->deleteTree($node_data);
01087                         // Use the saved tree object here (negative tree_id)
01088                         $saved_tree->deleteTree($node_data);
01089 
01090                         // write log entry
01091                         $log->write("ilObjectGUI::removeFromSystemObject(), deleted tree, tree_id: ".$node_data["tree"].
01092                                 ", child: ".$node_data["child"]);
01093 
01094                 }
01095                 
01096                 sendInfo($this->lng->txt("msg_removed"),true);
01097 
01098                 $this->ctrl->returnToParent($this);
01099 
01100         }
01101 
01110         function removeDeletedNodes($a_node_id, $a_checked, $a_delete_objects = true)
01111         {
01112                 global $log;
01113                 
01114                 $q = "SELECT tree FROM tree WHERE parent='".$a_node_id."' AND tree < 0";
01115                 
01116                 $r = $this->ilias->db->query($q);
01117 
01118                 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
01119                 {
01120                         // only continue recursion if fetched node wasn't touched already!
01121                         if (!in_array($row->tree,$a_checked))
01122                         {
01123                                 $deleted_tree = new ilTree($row->tree);
01124                                 $a_checked[] = $row->tree;
01125 
01126                                 $row->tree = $row->tree * (-1);
01127                                 $del_node_data = $deleted_tree->getNodeData($row->tree);
01128                                 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
01129 
01130                                 $this->removeDeletedNodes($row->tree,$a_checked);
01131                         
01132                                 if ($a_delete_objects)
01133                                 {
01134                                         foreach ($del_subtree_nodes as $node)
01135                                         {
01136                                                 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
01137                                                 
01138                                                 // write log entry
01139                                                 $log->write("ilObjectGUI::removeDeletedNodes(), delete obj_id: ".$node_obj->getId().
01140                                                         ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
01141                                                         "title: ".$node_obj->getTitle());
01142                                                         
01143                                                 $node_obj->delete();
01144                                         }
01145                                 }
01146                         
01147                                 $this->tree->deleteTree($del_node_data);
01148                                 
01149                                 // write log entry
01150                                 $log->write("ilObjectGUI::removeDeletedNodes(), deleted tree, tree_id: ".$del_node_data["tree"].
01151                                         ", child: ".$del_node_data["child"]);
01152                         }
01153                 }
01154                 
01155                 return true;
01156         }
01157 
01163         function createObject()
01164         {
01165                 global $rbacsystem;
01166 
01167                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01168 
01169                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01170                 {
01171                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01172                 }
01173                 else
01174                 {
01175                         // fill in saved values in case of error
01176                         $data = array();
01177                         $data["fields"] = array();
01178                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01179                         $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01180 
01181                         $this->getTemplateFile("edit",$new_type);
01182 
01183                         foreach ($data["fields"] as $key => $val)
01184                         {
01185                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01186                                 $this->tpl->setVariable(strtoupper($key), $val);
01187 
01188                                 if ($this->prepare_output)
01189                                 {
01190                                         $this->tpl->parseCurrentBlock();
01191                                 }
01192                         }
01193                         $this->ctrl->setParameter($this, "new_type", $new_type);
01194                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01195                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01196                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01197                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01198                         $this->tpl->setVariable("CMD_SUBMIT", "save");
01199                         $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01200                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01201                 }
01202         }
01203 
01209         function cancelObject($in_rep = false)
01210         {
01211                 session_unregister("saved_post");
01212 
01213                 sendInfo($this->lng->txt("msg_cancel"),true);
01214 
01215                 //sendInfo($this->lng->txt("action_aborted"),true);
01216                 $return_location = $_GET["cmd_return_location"];
01217 //echo "-".$_GET["cmd_return_location"]."-".$this->ctrl->getLinkTarget($this,$return_location);
01218                 //ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
01219 //echo "1";
01220                 //if ($in_rep)
01221                 //{
01222                         $this->ctrl->returnToParent($this);
01223                 //}
01224                 //else
01225                 //{
01226 //echo "3";
01227                 //      ilUtil::redirect($this->getReturnLocation("cancel",$this->ctrl->getTargetScript()."?".$this->link_params));
01228                 //}
01229         }
01230 
01236         function saveObject()
01237         {
01238                 global $rbacsystem, $objDefinition;
01239 
01240                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01241 
01242                 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
01243                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01244                 {
01245                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
01246                 }
01247 //echo ":".$_GET["new_type"].":".$_POST["new_type"].":";
01248                 $module = $objDefinition->getModule($_GET["new_type"]);
01249                 $module_dir = ($module == "")
01250                         ? ""
01251                         : $module."/";
01252 
01253                         // create and insert object in objecttree
01254                 $class_name = "ilObj".$objDefinition->getClassName($_GET["new_type"]);
01255                 include_once($module_dir."classes/class.".$class_name.".php");
01256                 $newObj = new $class_name();
01257                 $newObj->setType($_GET["new_type"]);
01258                 $newObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01259                 $newObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01260                 $newObj->create();
01261                 $newObj->createReference();
01262                 $newObj->putInTree($_GET["ref_id"]);
01263                 $newObj->setPermissions($_GET["ref_id"]);
01264                 //$newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
01265 
01266                 return $newObj;
01267         }
01268 
01269 
01275         function importObject()
01276         {
01277                 global $rbacsystem;
01278                 // CHECK ACCESS 'write' of role folder
01279                 // TODO: new_type will never be checked, if queried operation is not 'create'
01280                 if (!$rbacsystem->checkAccess('write', $_GET["ref_id"], $_POST["new_type"]))
01281                 {
01282                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->WARNING);
01283                 }
01284 
01285                 $imp_obj =$this->objDefinition->getImportObjects($this->object->getType());
01286 
01287                 if (!in_array($_POST["new_type"], $imp_obj))
01288                 {
01289                         $this->ilias->raiseError($this->lng->txt("no_import_available").
01290                                 " ".$this->lng->txt("obj_".$_POST["new_type"]),
01291                                 $this->ilias->error_obj->MESSAGE);
01292                 }
01293                 // no general implementation of this feature, the specialized classes
01294                 // must provide further processing
01295         }
01296 
01297 
01303         function editObject()
01304         {
01305                 global $rbacsystem;
01306 
01307                 if (!$rbacsystem->checkAccess("write", $this->ref_id))
01308                 {
01309                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01310                 }
01311 
01312                 $fields = array();
01313 
01314                 if ($_SESSION["error_post_vars"])
01315                 {
01316                         // fill in saved values in case of error
01317                         $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01318                         $fields["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01319                 }
01320                 else
01321                 {
01322                         $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
01323                         $fields["desc"] = ilUtil::stripSlashes($this->object->getLongDescription());
01324                 }
01325 
01326                 $this->displayEditForm($fields);
01327         }
01328 
01335         function displayEditForm($fields)
01336         {
01337                 $this->getTemplateFile("edit");
01338 
01339                 foreach ($fields as $key => $val)
01340                 {
01341                         $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01342                         $this->tpl->setVariable(strtoupper($key), $val);
01343                         $this->tpl->parseCurrentBlock();
01344                 }
01345 
01346                 //$obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
01347                 if (!$this->call_by_reference)
01348                 {
01349                         $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
01350                 }
01351 
01352                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01353                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
01354                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
01355                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01356                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01357                 $this->tpl->setVariable("CMD_SUBMIT", "update");
01358                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01359 
01360         }
01361 
01362 
01368         function updateObject()
01369         {
01370                 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01371                 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01372                 $this->update = $this->object->update();
01373 
01374                 sendInfo($this->lng->txt("msg_obj_modified"),true);
01375 
01376                 $this->ctrl->redirect($this);
01377         }
01378 
01384         function permObject()
01385         {
01386                 include_once './classes/class.ilPermissionGUI.php';
01387                 $perm_gui =& new ilPermissionGUI($this);
01388                 
01389                 // dirty work around to forward command in admin panel
01390                 $this->ctrl->current_node = 1;
01391                 $this->ctrl->setCmd('perm');
01392                 $ret =& $this->ctrl->forwardCommand($perm_gui);
01393                 
01394                 return true;
01395         }
01396 
01405         function getFormAction($a_cmd, $a_formaction ="")
01406         {
01407                 if ($this->formaction[$a_cmd] != "")
01408                 {
01409                         return $this->formaction[$a_cmd];
01410                 }
01411                 else
01412                 {
01413                         return $a_formaction;
01414                 }
01415         }
01416 
01425         function setFormAction($a_cmd, $a_formaction)
01426         {
01427                 $this->formaction[$a_cmd] = $a_formaction;
01428         }
01429 
01437         function getReturnLocation($a_cmd, $a_location ="")
01438         {
01439                 if ($this->return_location[$a_cmd] != "")
01440                 {
01441                         return $this->return_location[$a_cmd];
01442                 }
01443                 else
01444                 {
01445                         return $a_location;
01446                 }
01447         }
01448 
01456         function setReturnLocation($a_cmd, $a_location)
01457         {
01458 //echo "-".$a_cmd."-".$a_location."-";
01459                 $this->return_location[$a_cmd] = $a_location;
01460         }
01461 
01469         function getTargetFrame($a_cmd, $a_target_frame = "")
01470         {
01471                 if ($this->target_frame[$a_cmd] != "")
01472                 {
01473                         return $this->target_frame[$a_cmd];
01474                 }
01475                 elseif (!empty($a_target_frame))
01476                 {
01477                         return "target=\"".$a_target_frame."\"";
01478                 }
01479                 else
01480                 {
01481                         return;
01482                 }
01483         }
01484 
01492         function setTargetFrame($a_cmd, $a_target_frame)
01493         {
01494                 $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
01495         }
01496 
01502         function permSaveObject()
01503         {
01504                 include_once './classes/class.ilPermissionGUI.php';
01505                 $perm_gui =& new ilPermissionGUI($this);
01506                 
01507                 // dirty work around to forward command in admin panel
01508                 $this->ctrl->current_node = 1;
01509                 $this->ctrl->setCmd('permSave');
01510                 $ret =& $this->ctrl->forwardCommand($perm_gui);
01511                 
01512                 return true;
01513         }
01514 
01520         function displayList()
01521         {
01522                 include_once "./classes/class.ilTableGUI.php";
01523 
01524                 // load template for table
01525                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01526                 // load template for table content data
01527                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
01528 
01529                 $num = 0;
01530 
01531                 if (!$this->call_by_reference)
01532                 {
01533                         $this->ctrl->setParameter($this, "obj_id", $this->obj_id); 
01534                 }
01535                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01536 
01537                 // create table
01538                 $tbl = new ilTableGUI();
01539 
01540                 // title & header columns
01541                 $tbl->setTitle($this->object->getTitle(),"icon_".$this->object->getType().".gif",
01542                                            $this->lng->txt("obj_".$this->object->getType()));
01543                 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
01544 
01545                 foreach ($this->data["cols"] as $val)
01546                 {
01547                         $header_names[] = $this->lng->txt($val);
01548                 }
01549 
01550                 $tbl->setHeaderNames($header_names);
01551 
01552                 //$header_params = array("ref_id" => $this->ref_id);
01553                 //$header_params = array("ref_id" => $this->ref_id);
01554                 $header_params = $this->ctrl->getParameterArray($this, "view");
01555                 $tbl->setHeaderVars($this->data["cols"],$header_params);
01556                 $tbl->setColumnWidth(array("15","15","75%","25%"));
01557 
01558                 // control
01559                 $tbl->setOrderColumn($_GET["sort_by"]);
01560                 $tbl->setOrderDirection($_GET["sort_order"]);
01561                 $tbl->setLimit($_GET["limit"]);
01562                 $tbl->setOffset($_GET["offset"]);
01563                 $tbl->setMaxCount($this->maxcount);
01564 
01565                 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
01566 
01567                 // footer
01568                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01569 
01570                 if (!empty($this->data["data"][0]))
01571                 {
01572                         //table cell
01573                         for ($i=0; $i < count($this->data["data"]); $i++)
01574                         {
01575                                 $data = $this->data["data"][$i];
01576                                 $ctrl = $this->data["ctrl"][$i];
01577 
01578                                 // color changing
01579                                 $css_row = ilUtil::switchColor($i+1,"tblrow2","tblrow1");
01580 
01581                                 // surpress checkbox for particular object types AND the system role
01582                                 if (!$this->objDefinition->hasCheckbox($ctrl["type"]) or $ctrl["obj_id"] == SYSTEM_ROLE_ID or $ctrl["obj_id"] == SYSTEM_USER_ID or $ctrl["obj_id"] == ANONYMOUS_ROLE_ID)
01583                                 {
01584                                         $this->tpl->touchBlock("empty_cell");
01585                                 }
01586                                 else
01587                                 {
01588                                         // TODO: this object type depending 'if' could become really a problem!!
01589                                         if ($ctrl["type"] == "usr" or $ctrl["type"] == "role" or $ctrl["type"] == "rolt")
01590                                         {
01591                                                 $link_id = $ctrl["obj_id"];
01592                                         }
01593                                         else
01594                                         {
01595                                                 $link_id = $ctrl["ref_id"];
01596                                         }
01597                                         
01598                                         // dirty workaround to have ids for function showActions (checkbox toggle option)
01599                                         $this->ids[] = $link_id;
01600                                         
01601                                         $this->tpl->setCurrentBlock("checkbox");
01602                                         $this->tpl->setVariable("CHECKBOX_ID", $link_id);
01603                                         $this->tpl->setVariable("CSS_ROW", $css_row);
01604                                         $this->tpl->parseCurrentBlock();
01605                                 }
01606 
01607                                 $this->tpl->setCurrentBlock("table_cell");
01608                                 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
01609                                 $this->tpl->parseCurrentBlock();
01610 
01611                                 foreach ($data as $key => $val)
01612                                 {
01613                                         //build link
01614                                         $obj_type = ilObject::_lookupType($ctrl["ref_id"],true);
01615                                         $class_name = $this->objDefinition->getClassName($obj_type);
01616                                         $class = strtolower("ilObj".$class_name."GUI");
01617                                         $this->ctrl->setParameterByClass($class, "ref_id", $ctrl["ref_id"]);
01618                                         $this->ctrl->setParameterByClass($class, "obj_id", $ctrl["obj_id"]);
01619                                         $link = $this->ctrl->getLinkTargetByClass($class, "view");
01620 
01621                                         /*
01622                                         $n = 0;
01623 
01624                                         foreach ($ctrl as $key2 => $val2)
01625                                         {
01626                                                 $link .= $key2."=".$val2;
01627 
01628                                                 if ($n < count($ctrl)-1)
01629                                                 {
01630                                                 $link .= "&";
01631                                                         $n++;
01632                                                 }
01633                                         }*/
01634 
01635                                         if ($key == "name" || $key == "title")
01636                                         {
01637                                                 $name_field = explode("#separator#",$val);
01638                                         }
01639 
01640                                         if ($key == "title" || $key == "name" || $key == "type")
01641                                         {
01642                                                 $this->tpl->setCurrentBlock("begin_link");
01643                                                 $this->tpl->setVariable("LINK_TARGET", $link);
01644 
01645                                                 $this->tpl->parseCurrentBlock();
01646                                                 $this->tpl->touchBlock("end_link");
01647                                         }
01648 
01649                                         // process clipboard information
01650                                         if (($key == "title" || $key == "name") and is_array(($_SESSION["clipboard"])))
01651                                         {
01652                                                 // TODO: broken! fix me
01653                                                 if (in_array($ctrl["ref_id"],$_SESSION["clipboard"]["ref_ids"]))
01654                                                 {
01655                             switch($_SESSION["clipboard"]["cmd"])
01656                                                         {
01657                                 case "cut":
01658                                     $name_field[0] = "<del>".$name_field[0]."</del>";
01659                                     break;
01660 
01661                                 case "copy":
01662                                     $name_field[0] = "<font color=\"green\">+</font>  ".$name_field[0];
01663                                     break;
01664                                         
01665                                 case "link":
01666                                     $name_field[0] = "<font color=\"black\"><</font> ".$name_field[0];
01667                                     break;
01668                             }
01669                                         }
01670                                 }
01671 
01672                                         $this->tpl->setCurrentBlock("text");
01673 
01674                                         if ($key == "type")
01675                                         {
01676                                                 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
01677                                         }
01678 
01679                                         if ($key == "name" || $key == "title")
01680                                         {
01681                                                 $this->tpl->setVariable("TEXT_CONTENT", $name_field[0]);
01682                                                 
01683                                                 $this->tpl->setCurrentBlock("subtitle");
01684                                                 $this->tpl->setVariable("DESC", ilUtil::shortenText($name_field[1],MAXLENGTH_OBJ_DESC,true));
01685                                                 $this->tpl->parseCurrentBlock();
01686                                         }
01687                                         else
01688                                         {
01689                                                 $this->tpl->setVariable("TEXT_CONTENT", $val);
01690                                         }
01691                                         
01692                                         $this->tpl->parseCurrentBlock();
01693 
01694                                         $this->tpl->setCurrentBlock("table_cell");
01695                                         $this->tpl->parseCurrentBlock();
01696 
01697                                 } //foreach
01698 
01699                                 $this->tpl->setCurrentBlock("tbl_content");
01700                                 $this->tpl->setVariable("CSS_ROW", $css_row);
01701                                 $this->tpl->parseCurrentBlock();
01702                         } //for
01703                 } //if is_array
01704                 else
01705                 {
01706             $tbl->disable("header");
01707                         $tbl->disable("footer");
01708                         
01709                         $this->tpl->setCurrentBlock("text");
01710                         
01711                         // do not display an "error message" here
01712                         // this confuses people in administratino
01713                         //$this->tpl->setVariable("TEXT_CONTENT",
01714                         //      $this->lng->txt("obj_not_found"));
01715                         $this->tpl->setVariable("CSS_ROW", "tblrow1");
01716                         $this->tpl->setVariable("TEXT_CONTENT",
01717                                 "&nbsp;");
01718                         $this->tpl->parseCurrentBlock();
01719                 }
01720                 
01721                 $this->showActions(true);
01722                 
01723                 // render table
01724                 $tbl->render();
01725         }
01726 
01732         function viewObject()
01733         {
01734                 global $rbacsystem;
01735 
01736                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
01737                 {
01738                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01739                 }
01740 
01741                 //prepare objectlist
01742                 $this->objectList = array();
01743                 $this->data["data"] = array();
01744                 $this->data["ctrl"] = array();
01745                 $this->data["cols"] = array("", "type", "title", "last_change");
01746 
01747                 $childs = $this->tree->getChilds($_GET["ref_id"], $_GET["order"], $_GET["direction"]);
01748 
01749                 foreach ($childs as $key => $val)
01750             {
01751                         // visible
01752                         if (!$rbacsystem->checkAccess("visible",$val["ref_id"]))
01753                         {
01754                                 continue;
01755                         }
01756                         
01757                         // hide object types in devmode
01758                         if ($this->objDefinition->getDevMode($val["type"]))
01759                         {
01760                                 continue;
01761                         }
01762                         
01763                         // don't show administration in root node list
01764                         if ($val["type"] == "adm")
01765                         {
01766                                 continue;
01767                         }
01768 
01769                         //visible data part
01770                         $this->data["data"][] = array(
01771                                                                                 "type" => $val["type"],
01772                                                                                 "title" => $val["title"]."#separator#".$val["desc"],
01773                                                                                 //"description" => $val["desc"],
01774                                                                                 "last_change" => $val["last_update"],
01775                                                                                 "ref_id" => $val["ref_id"]
01776                                                                                 );
01777 
01778                         //control information is set below
01779 
01780             } //foreach
01781 
01782                 $this->maxcount = count($this->data["data"]);
01783                 // sorting array
01784                 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
01785                 $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
01786 
01787                 // now compute control information
01788                 foreach ($this->data["data"] as $key => $val)
01789                 {
01790                         $this->data["ctrl"][$key] = array(
01791                                                                                         "type" => $val["type"],
01792                                                                                         "ref_id" => $val["ref_id"]
01793                                                                                         );
01794 
01795                         unset($this->data["data"][$key]["ref_id"]);
01796                                                 $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
01797                 }
01798 
01799                 $this->displayList();
01800         }
01801 
01809         function deleteObject($a_error = false)
01810         {
01811                 if ($_GET["item_ref_id"] != "")
01812                 {
01813                         $_POST["id"] = array($_GET["item_ref_id"]);
01814                 }
01815 
01816                 if (!isset($_POST["id"]))
01817                 {
01818                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01819                 }
01820 
01821                 // SAVE POST VALUES
01822                 $_SESSION["saved_post"] = $_POST["id"];
01823 
01824                 unset($this->data);
01825                 $this->data["cols"] = array("type", "title", "last_change");
01826 
01827                 foreach ($_POST["id"] as $id)
01828                 {
01829                         // TODO: cannot distinguish between obj_id from ref_id with the posted IDs.
01830                         // change the form field and use instead of 'id' 'ref_id' and 'obj_id'. Then switch with varname
01831                         //if ($this->call_by_reference)
01832                         //{
01833                                 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
01834                         //}
01835                         //else
01836                         //{
01837                         //      $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($id);
01838                         //}
01839 
01840                         $this->data["data"]["$id"] = array(
01841                                                                                                 "type"        => $obj_data->getType(),
01842                                                                                                 "title"       => $obj_data->getTitle()."#separator#".$obj_data->getDescription()." ",   // workaround for empty desc
01843                                                                                                 "last_update" => $obj_data->getLastUpdateDate()
01844                                                                                         );
01845                 }
01846 
01847                 $this->data["buttons"] = array( "confirmedDelete"  => $this->lng->txt("confirm"),
01848                                                                   "cancelDelete"  => $this->lng->txt("cancel"));
01849 
01850                 $this->getTemplateFile("confirm");
01851 
01852                 if(!$a_error)
01853                 {
01854                         sendInfo($this->lng->txt("info_delete_sure"));
01855                 }
01856 
01857                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01858         
01859                 // BEGIN TABLE HEADER
01860                 foreach ($this->data["cols"] as $key)
01861                 {
01862                         $this->tpl->setCurrentBlock("table_header");
01863                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
01864                         $this->tpl->parseCurrentBlock();
01865                 }
01866                 // END TABLE HEADER
01867 
01868                 // BEGIN TABLE DATA
01869                 $counter = 0;
01870 
01871                 foreach ($this->data["data"] as $key => $value)
01872                 {
01873                         // BEGIN TABLE CELL
01874                         foreach ($value as $key => $cell_data)
01875                         {
01876                                 $this->tpl->setCurrentBlock("table_cell");
01877 
01878                                 // CREATE TEXT STRING
01879                                 if ($key == "type")
01880                                 {
01881                                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
01882                                 }
01883                                 elseif ($key == "title")
01884                                 {
01885                                         $name_field = explode("#separator#",$cell_data);
01886 
01887                                         $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
01888                                                 
01889                                         $this->tpl->setCurrentBlock("subtitle");
01890                                         $this->tpl->setVariable("DESC", $name_field[1]);
01891                                         $this->tpl->parseCurrentBlock();
01892                                         $this->tpl->setCurrentBlock("table_cell");
01893                                 }
01894                                 else
01895                                 {
01896                                         $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
01897                                 }
01898 
01899                                 $this->tpl->parseCurrentBlock();
01900                         }
01901 
01902                         $this->tpl->setCurrentBlock("table_row");
01903                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01904                         $this->tpl->parseCurrentBlock();
01905                         // END TABLE CELL
01906                 }
01907                 // END TABLE DATA
01908 
01909                 // BEGIN OPERATION_BTN
01910                 foreach ($this->data["buttons"] as $name => $value)
01911                 {
01912                         $this->tpl->setCurrentBlock("operation_btn");
01913                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01914                         $this->tpl->setVariable("BTN_NAME",$name);
01915                         $this->tpl->setVariable("BTN_VALUE",$value);
01916                         $this->tpl->parseCurrentBlock();
01917                 }
01918         }
01919 
01925         function trashObject()
01926         {
01927                 $objects = $this->tree->getSavedNodeData($_GET["ref_id"]);
01928 
01929                 if (count($objects) == 0)
01930                 {
01931                         sendInfo($this->lng->txt("msg_trash_empty"));
01932                         $this->data["empty"] = true;
01933                 }
01934                 else
01935                 {
01936                         $this->data["empty"] = false;
01937                         $this->data["cols"] = array("","type", "title", "last_change");
01938 
01939                         foreach ($objects as $obj_data)
01940                         {
01941                                 $this->data["data"]["$obj_data[child]"] = array(
01942                                                                                                                         "checkbox"              => "",
01943                                                                                                                         "type"                  => $obj_data["type"],
01944                                                                                                                         "title"                 => $obj_data["title"]."#separator#".$obj_data["desc"],
01945                                                                                                                         "last_update"   => $obj_data["last_update"]
01946                                                                         );
01947                         }
01948 
01949                         $this->data["buttons"] = array( "undelete"  => $this->lng->txt("btn_undelete"),
01950                                                                           "removeFromSystem"  => $this->lng->txt("btn_remove_system"));
01951                 }
01952 
01953                 $this->getTemplateFile("confirm");
01954 
01955                 if ($this->data["empty"] == true)
01956                 {
01957                         return;
01958                 }
01959                 
01960                 /* TODO: fix message display in conjunction with sendInfo & raiseError functionality
01961                 $this->tpl->addBlockfile("MESSAGE", "adm_trash", "tpl.message.html");
01962                 $this->tpl->setCurrentBlock("adm_trash");
01963                 $this->tpl->setVariable("MSG",$this->lng->txt("info_trash"));
01964                 $this->tpl->parseCurrentBlock();
01965                 */
01966                 //sendInfo($this->lng->txt("info_trash"));
01967 
01968                 $this->tpl->setVariable("FORMACTION",
01969                         $this->ctrl->getFormAction($this));
01970                 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01971 
01972                 // BEGIN TABLE HEADER
01973                 foreach ($this->data["cols"] as $key)
01974                 {
01975                         $this->tpl->setCurrentBlock("table_header");
01976                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
01977                         $this->tpl->parseCurrentBlock();
01978                 }
01979                 // END TABLE HEADER
01980 
01981                 // BEGIN TABLE DATA
01982                 $counter = 0;
01983 
01984                 foreach ($this->data["data"] as $key1 => $value)
01985                 {
01986                         // BEGIN TABLE CELL
01987                         foreach ($value as $key2 => $cell_data)
01988                         {
01989                                 $this->tpl->setCurrentBlock("table_cell");
01990                                 // CREATE CHECKBOX
01991                                 if ($key2 == "checkbox")
01992                                 {
01993                                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::formCheckBox(0,"trash_id[]",$key1));
01994                                 }
01995                                 // CREATE TEXT STRING
01996                                 elseif ($key2 == "type")
01997                                 {
01998                                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
01999                                 }
02000                                 elseif ($key2 == "title")
02001                                 {
02002                                         $name_field = explode("#separator#",$cell_data);
02003 
02004                                         $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
02005                                                 
02006                                         $this->tpl->setCurrentBlock("subtitle");
02007                                         $this->tpl->setVariable("DESC", $name_field[1]);
02008                                         $this->tpl->parseCurrentBlock();
02009                                         $this->tpl->setCurrentBlock("table_cell");
02010                                 }
02011                                 else
02012                                 {
02013                                         $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
02014                                 }
02015 
02016                                 $this->tpl->parseCurrentBlock();
02017                         }
02018 
02019                         $this->tpl->setCurrentBlock("table_row");
02020                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
02021                         $this->tpl->parseCurrentBlock();
02022                         // END TABLE CELL
02023                 }
02024                 // END TABLE DATA
02025 
02026                 // BEGIN OPERATION_BTN
02027                 foreach ($this->data["buttons"] as $name => $value)
02028                 {
02029                         $this->tpl->setCurrentBlock("operation_btn");
02030                         $this->tpl->setVariable("BTN_NAME",$name);
02031                         $this->tpl->setVariable("BTN_VALUE",$value);
02032                         $this->tpl->parseCurrentBlock();
02033                 }
02034         }
02035 
02043         function addRoleObject()
02044         {
02045                 include_once './classes/class.ilPermissionGUI.php';
02046                 $perm_gui =& new ilPermissionGUI($this);
02047                 
02048                 // dirty work around to forward command in admin panel
02049                 $this->ctrl->current_node = 1;
02050                 $this->ctrl->setCmd('addRole');
02051                 $ret =& $this->ctrl->forwardCommand($perm_gui);
02052                 
02053                 return true;
02054         }
02055 
02062         function showActions($with_subobjects = false)
02063         {
02064                 $notoperations = array();
02065                 // NO PASTE AND CLEAR IF CLIPBOARD IS EMPTY
02066                 if (empty($_SESSION["clipboard"]))
02067                 {
02068                         $notoperations[] = "copy";                      // disable copy operation!
02069                         $notoperations[] = "paste";
02070                         $notoperations[] = "clear";
02071                 }
02072                 // CUT COPY PASTE LINK DELETE IS NOT POSSIBLE IF CLIPBOARD IS FILLED
02073                 if ($_SESSION["clipboard"])
02074                 {
02075                         $notoperations[] = "cut";
02076                         $notoperations[] = "copy";
02077                         $notoperations[] = "link";
02078                 }
02079 
02080                 $operations = array();
02081 
02082                 if ($this->actions == "")
02083                 {
02084                         $d = $this->objDefinition->getActions($this->object->getType());
02085                         //$d = $this->objDefinition->getActions($_GET["type"]);
02086                 }
02087                 else
02088                 {
02089                         $d = $this->actions;
02090                 }
02091 
02092                 foreach ($d as $row)
02093                 {
02094                         if (!in_array($row["name"], $notoperations))
02095                         {
02096                                 $operations[] = $row;
02097                         }
02098                 }
02099 
02100                 if (count($operations) > 0)
02101                 {
02102                         foreach ($operations as $val)
02103                         {
02104                                 $this->tpl->setCurrentBlock("tbl_action_btn");
02105                                 $this->tpl->setVariable("BTN_NAME", $val["name"]);
02106                                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
02107                                 $this->tpl->parseCurrentBlock();
02108                         }
02109                 }
02110 
02111                 if ($with_subobjects === true)
02112                 {
02113                         //$this->showPossibleSubObjects();
02114                 }
02115                 
02116                 if (!empty($this->ids) && count($operations) > 0)
02117                 {
02118                         // set checkbox toggles
02119                         $this->tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
02120                         $this->tpl->setVariable("JS_VARNAME","id");                     
02121                         $this->tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($this->ids));
02122                         $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
02123                         $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
02124                         $this->tpl->parseCurrentBlock();
02125                 }
02126                 
02127                 if (count($operations) > 0)
02128                 {
02129                         $this->tpl->setCurrentBlock("tbl_action_row");
02130                         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02131                         $this->tpl->parseCurrentBlock();
02132                 }
02133         }
02134 
02140         function showPossibleSubObjects()
02141         {
02142                 if ($this->sub_objects == "")
02143                 {
02144                         $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
02145                 }
02146                 else
02147                 {
02148                         $d = $this->sub_objects;
02149                 }
02150 
02151                 $import = false;
02152 
02153                 if (count($d) > 0)
02154                 {
02155                         foreach ($d as $row)
02156                         {
02157                             $count = 0;
02158 
02159                                 if ($row["max"] > 0)
02160                                 {
02161                                         //how many elements are present?
02162                                         for ($i=0; $i<count($this->data["ctrl"]); $i++)
02163                                         {
02164                                                 if ($this->data["ctrl"][$i]["type"] == $row["name"])
02165                                                 {
02166                                                     $count++;
02167                                                 }
02168                                         }
02169                                 }
02170 
02171                                 if ($row["max"] == "" || $count < $row["max"])
02172                                 {
02173                                         $subobj[] = $row["name"];
02174 
02175                                         if ($row["import"] == "1")      // import allowed?
02176                                         {
02177                                                 $import = true;
02178                                         }
02179                                 }
02180                         }
02181                 }
02182 
02183                 if (is_array($subobj))
02184                 {
02185                         // show import button if at least one
02186                         // object type can be imported
02187                         if ($import)
02188                         {
02189                                 $this->tpl->setCurrentBlock("import_object");
02190                                 $this->tpl->setVariable("BTN_IMP", "import");
02191                                 $this->tpl->setVariable("TXT_IMP", $this->lng->txt("import"));
02192                                 $this->tpl->parseCurrentBlock();
02193                         }
02194 
02195                         //build form
02196                         $opts = ilUtil::formSelect(12,"new_type",$subobj);
02197                         $this->tpl->setCurrentBlock("add_object");
02198                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
02199                         $this->tpl->setVariable("BTN_NAME", "create");
02200                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
02201                         $this->tpl->parseCurrentBlock();
02202                 }
02203         }
02204 
02213         function getTemplateFile($a_cmd,$a_type = "")
02214         {
02215                 if (!$a_type)
02216                 {
02217                         $a_type = $this->type;
02218                 }
02219 
02220                 $template = "tpl.".$a_type."_".$a_cmd.".html";
02221 
02222                 if (!$this->tpl->fileExists($template))
02223                 {
02224                         $template = "tpl.obj_".$a_cmd.".html";
02225                 }
02226 
02227                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", $template,$a_in_module);
02228 
02229         }
02230 
02239         function getTitlesByRefId($a_ref_ids)
02240         {
02241                 foreach ($a_ref_ids as $id)
02242                 {
02243                         // GET OBJECT TITLE
02244                         $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($id);
02245                         $title[] = $tmp_obj->getTitle();
02246                         unset($tmp_obj);
02247                 }
02248 
02249                 return $title ? $title : array();
02250         }
02251 
02259         function getTabs(&$tabs_gui)
02260         {
02261                 // please define your tabs here
02262 
02263         }
02264 
02265         // PROTECTED
02266         function __showButton($a_cmd,$a_text,$a_target = '')
02267         {
02268                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02269 
02270                 // display button
02271                 $this->tpl->setCurrentBlock("btn_cell");
02272                 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
02273                 $this->tpl->setVariable("BTN_TXT",$a_text);
02274                 if($a_target)
02275                 {
02276                         $this->tpl->setVariable("BTN_TARGET",$a_target);
02277                 }
02278 
02279                 $this->tpl->parseCurrentBlock();
02280         }
02281 
02282         function hitsperpageObject()
02283         {
02284         $_SESSION["tbl_limit"] = $_POST["hitsperpage"];
02285         $_GET["limit"] = $_POST["hitsperpage"];
02286         }
02287         
02288 
02289         function &__initTableGUI()
02290         {
02291                 include_once "./classes/class.ilTableGUI.php";
02292 
02293                 return new ilTableGUI(0,false);
02294         }
02295         
02301         function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
02302         {
02303                 switch ($a_from)
02304                 {
02305                         case "clipboardObject":
02306                                 $offset = $_GET["offset"];
02307                                 $order = $_GET["sort_by"];
02308                                 $direction = $_GET["sort_order"];
02309                                 $tbl->disable("footer");
02310                                 break;
02311 
02312                         default:
02313                                 $offset = $_GET["offset"];
02314                                 $order = $_GET["sort_by"];
02315                                 $direction = $_GET["sort_order"];
02316                                 break;
02317                 }
02318 
02319                 $tbl->setOrderColumn($order);
02320                 $tbl->setOrderDirection($direction);
02321                 $tbl->setOffset($offset);
02322                 $tbl->setLimit($_GET["limit"]);
02323                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02324                 $tbl->setData($result_set);
02325         }
02326         
02327         function __showClipboardTable($a_result_set,$a_from = "")
02328         {
02329         $tbl =& $this->__initTableGUI();
02330                 $tpl =& $tbl->getTemplateObject();
02331 
02332                 $tpl->setCurrentBlock("tbl_form_header");
02333                 $tpl->setVariable("FORMACTION",$this->ctrl->getTargetScript()."?".$this->link_params."&cmd=post");
02334                 $tpl->parseCurrentBlock();
02335 
02336                 $tpl->setCurrentBlock("tbl_action_btn");
02337                 $tpl->setVariable("BTN_NAME","paste");
02338                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("insert_object_here"));
02339                 $tpl->parseCurrentBlock();
02340                 
02341                 $tpl->setCurrentBlock("tbl_action_btn");
02342                 $tpl->setVariable("BTN_NAME","clear");
02343                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("clear_clipboard"));
02344                 $tpl->parseCurrentBlock();
02345 
02346                 $tpl->setCurrentBlock("tbl_action_row");
02347                 $tpl->setVariable("COLUMN_COUNTS",3);
02348                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("spacer.gif"));
02349                 $tpl->parseCurrentBlock();
02350                 
02351                 $tbl->setTitle($this->lng->txt("clipboard"),"icon_typ_b.gif",$this->lng->txt("clipboard"));
02352                 $tbl->setHeaderNames(array($this->lng->txt('obj_type'),
02353                                                                    $this->lng->txt('title'),
02354                                                                    $this->lng->txt('action')));
02355                 $tbl->setHeaderVars(array('type',
02356                                   'title',
02357                                                                   'act'),
02358                                                         array('ref_id' => $this->object->getRefId(),
02359                                                                   'cmd' => 'clipboard',
02360                                                                   'cmdClass' => $_GET['cmdClass'],
02361                                                                   'cmdNode' => $_GET['cmdNode']));
02362 
02363                 $tbl->setColumnWidth(array("","80%","19%"));
02364 
02365 
02366                 $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from);
02367                 $tbl->render();
02368                 
02369                 $this->tpl->setVariable("RESULT_TABLE",$tbl->tpl->get());
02370 
02371                 return true;
02372         }
02373         
02374         function infoObject()
02375         {
02376                 include_once './classes/class.ilPermissionGUI.php';
02377                 $perm_gui =& new ilPermissionGUI($this);
02378                 
02379                 // dirty work around to forward command in admin panel
02380                 $this->ctrl->current_node = 1;
02381                 $this->ctrl->setCmd('info');
02382                 $ret =& $this->ctrl->forwardCommand($perm_gui);
02383                 
02384                 return true;
02385         }
02386         
02387         function __buildRoleFilterSelect()
02388         {
02389                 $action[1] = $this->lng->txt('all_roles');
02390                 $action[2] = $this->lng->txt('all_global_roles');
02391                 $action[3] = $this->lng->txt('all_local_roles');
02392                 $action[4] = $this->lng->txt('linked_local_roles');
02393                 $action[5] = $this->lng->txt('local_roles_this_object_only');
02394                 
02395                 return ilUtil::formSelect($_SESSION['perm_filtered_roles'],"filter",$action,false,true);
02396         }
02397         
02398         function __filterRoles($a_roles,$a_filter)
02399         {
02400                 global $rbacreview;
02401 
02402                 switch ($a_filter)
02403                 {
02404                         case 1: // all roles
02405                                 return $a_roles;
02406                                 break;
02407                         
02408                         case 2: // all global roles
02409                                 $arr_global_roles = $rbacreview->getGlobalRoles();
02410                                 $arr_remove_roles = array_diff(array_keys($a_roles),$arr_global_roles);
02411 
02412                                 foreach ($arr_remove_roles as $role_id)
02413                                 {
02414                                         unset($a_roles[$role_id]);
02415                                 }
02416                                 
02417                                 return $a_roles;
02418                                 break;                  
02419 
02420                         case 3: // all local roles
02421                                 $arr_global_roles = $rbacreview->getGlobalRoles();
02422 
02423                                 foreach ($arr_global_roles as $role_id)
02424                                 {
02425                                         unset($a_roles[$role_id]);
02426                                 }
02427                                 
02428                                 return $a_roles;
02429                                 break;
02430                                 
02431                         case 4: // all roles
02432                                 return $a_roles;
02433                                 break;
02434                                 
02435                         case 5: // local role only at this position
02436                                 
02437                                 $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
02438                 
02439                                 if (!$role_folder)
02440                                 {
02441                                         return array();
02442                                 }
02443                                 
02444                                 $arr_local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);
02445                                 $arr_remove_roles = array_diff(array_keys($a_roles),$arr_local_roles);
02446 
02447                                 foreach ($arr_remove_roles as $role_id)
02448                                 {
02449                                         unset($a_roles[$role_id]);
02450                                 }
02451 
02452                                 return $a_roles;
02453                                 break;
02454                 }
02455 
02456                 return $a_roles;
02457         }
02458 
02459         function ownerObject()
02460         {
02461                 include_once './classes/class.ilPermissionGUI.php';
02462                 $perm_gui =& new ilPermissionGUI($this);
02463                 
02464                 // dirty work around to forward command in admin panel
02465                 $this->ctrl->current_node = 1;
02466                 $this->ctrl->setCmd('owner');
02467                 $ret =& $this->ctrl->forwardCommand($perm_gui);
02468                 
02469                 return true;
02470         }
02471 
02472         function changeOwnerObject()
02473         {
02474                 include_once './classes/class.ilPermissionGUI.php';
02475                 $perm_gui =& new ilPermissionGUI($this);
02476                 
02477                 // dirty work around to forward command in admin panel
02478                 $this->ctrl->current_node = 1;
02479                 $this->ctrl->setCmd('changeOwner');
02480                 $ret =& $this->ctrl->forwardCommand($perm_gui);
02481                 
02482                 return true;
02483         }
02484         
02494         function redirectToRefId($a_ref_id, $a_cmd = "")
02495         {
02496                 $obj_type = ilObject::_lookupType($a_ref_id,true);
02497                 $class_name = $this->objDefinition->getClassName($obj_type);
02498                 $class = strtolower("ilObj".$class_name."GUI");
02499                 $this->ctrl->redirectByClass($class, $a_cmd);
02500         }
02501         
02502 } // END class.ilObjectGUI
02503 ?>

Generated on Fri Dec 13 2013 11:57:54 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1