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

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