00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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;
00087 var $formaction;
00088 var $return_location;
00089 var $target_frame;
00090
00091 var $tab_target_script;
00092 var $actions;
00093 var $sub_objects;
00094
00102 function ilObjectGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
00103 {
00104 global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng;
00105
00106 if (!isset($ilErr))
00107 {
00108 $ilErr = new ilErrorHandling();
00109 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
00110 }
00111 else
00112 {
00113 $this->ilErr =& $ilErr;
00114 }
00115
00116 $this->ilias =& $ilias;
00117 $this->objDefinition =& $objDefinition;
00118 $this->tpl =& $tpl;
00119 $this->html = "";
00120 $this->ctrl =& $ilCtrl;
00121
00122 $params = array("ref_id");
00123
00124 if (!$a_call_by_reference)
00125 {
00126 $params = array("ref_id","obj_id");
00127 }
00128
00129 $this->ctrl->saveParameter($this, $params);
00130
00131 $this->lng =& $lng;
00132 $this->tree =& $tree;
00133 $this->formaction = array();
00134 $this->return_location = array();
00135 $this->target_frame = array();
00136 $this->tab_target_script = "adm_object.php";
00137 $this->actions = "";
00138 $this->sub_objects = "";
00139
00140 $this->data = $a_data;
00141 $this->id = $a_id;
00142 $this->call_by_reference = $a_call_by_reference;
00143 $this->prepare_output = $a_prepare_output;
00144
00145 $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
00146 $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
00147
00148 if ($this->id != 0)
00149 {
00150 $this->link_params = "ref_id=".$this->ref_id;
00151 }
00152
00153
00154 $this->assignObject();
00155
00156
00157
00158
00159
00160 if ($a_prepare_output)
00161 {
00162 $this->prepareOutput();
00163 }
00164
00165
00166 if (empty($_GET["sort_by"]) && is_object($this->object))
00167 {
00168
00169 if ($this->object->getType() == "usrf"
00170 or $this->object->getType() == "rolf")
00171 {
00172 $_GET["sort_by"] = "name";
00173 }
00174 elseif ($this->object->getType() == "typ")
00175 {
00176 $_GET["sort_by"] = "operation";
00177 }
00178 elseif ($this->object->getType() == "lngf")
00179 {
00180 $_GET["sort_by"] = "language";
00181 }
00182 else
00183 {
00184
00185 #$_GET["sort_by"] = "title";
00186 }
00187 }
00188 }
00189
00190
00194 function &executeCommand()
00195 {
00196 global $rbacsystem;
00197
00198 $next_class = $this->ctrl->getNextClass($this);
00199 $cmd = $this->ctrl->getCmd();
00200 switch($next_class)
00201 {
00202 default:
00203 if(!$cmd)
00204 {
00205 $cmd = "view";
00206 }
00207 $cmd .= "Object";
00208 $this->$cmd();
00209
00210 break;
00211 }
00212 return true;
00213 }
00214
00215
00219 function withReferences()
00220 {
00221 return $this->call_by_reference;
00222 }
00223
00224 function assignObject()
00225 {
00226
00227
00228 if ($this->id != 0)
00229 {
00230 if ($this->call_by_reference)
00231 {
00232 $this->object =& $this->ilias->obj_factory->getInstanceByRefId($this->id);
00233 }
00234 else
00235 {
00236 $this->object =& $this->ilias->obj_factory->getInstanceByObjId($this->id);
00237 }
00238 }
00239 }
00240
00241 function prepareOutput()
00242 {
00243 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00244 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00245 $title = $this->object->getTitle();
00246
00247
00248 sendInfo();
00249
00250 if (!empty($title))
00251 {
00252 $this->tpl->setVariable("HEADER", $title);
00253 }
00254
00255 $this->setAdminTabs($_POST["new_type"]);
00256 $this->setLocator();
00257
00258 }
00259
00264 function setAdminTabs($a_new_type = 0)
00265 {
00266
00267
00268 if (($this->object->getType() == "grp" or $this->object->getType() == "adm"
00269 or $this->object->getType() == "sty" or $this->object->getType() == "svy"
00270 or $this->object->getType() == "spl" or $this->object->getType() == "tst"
00271 or $this->object->getType() == "qpl" or $this->object->getType() == "exc") &&
00272 (
00273 $this->ctrl->getTargetScript() != 'adm_object.php' ||
00274 $this->object->getType() == "sty" ||
00275 $this->object->getType() == "adm"
00276 )
00277 )
00278 {
00279 include_once "./classes/class.ilTabsGUI.php";
00280 $tabs_gui =& new ilTabsGUI();
00281 $this->getTabs($tabs_gui);
00282
00283
00284 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00285 }
00286 else
00287 {
00288 global $rbacsystem;
00289
00290 $tabs = array();
00291 $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
00292
00293
00294 if ($a_new_type)
00295 {
00296 $d = $this->objDefinition->getProperties($this->object->getType());
00297 }
00298 else
00299 {
00300 $d = $this->objDefinition->getProperties($this->type);
00301 }
00302
00303 foreach ($d as $key => $row)
00304 {
00305 $tabs[] = array($row["lng"], $row["name"]);
00306 }
00307
00308
00309 if (isset($_GET["obj_id"]) and $this->call_by_reference === false)
00310 {
00311 $object_link = "&obj_id=".$_GET["obj_id"];
00312 }
00313
00314 foreach ($tabs as $row)
00315 {
00316 $i++;
00317
00318 if ($row[1] == $_GET["cmd"])
00319 {
00320 $tabtype = "tabactive";
00321 $tab = $tabtype;
00322 }
00323 else
00324 {
00325 $tabtype = "tabinactive";
00326 $tab = "tab";
00327 }
00328
00329 $show = true;
00330
00331
00332
00333 if (true)
00334
00335 {
00336
00337 switch ($row[1])
00338 {
00339 case 'view':
00340 if (!$rbacsystem->checkAccess('visible',$this->ref_id))
00341 {
00342 $show = false;
00343 }
00344 break;
00345
00346 case 'edit':
00347 if (!$rbacsystem->checkAccess('write',$this->ref_id))
00348 {
00349 $show = false;
00350 }
00351 break;
00352
00353 case 'perm':
00354 if (!$rbacsystem->checkAccess('edit_permission',$this->ref_id))
00355 {
00356 $show = false;
00357 }
00358 break;
00359
00360 case 'trash':
00361 if (!$this->tree->getSavedNodeData($this->ref_id))
00362 {
00363 $show = false;
00364 }
00365 break;
00366
00367
00368 case 'roleassignment':
00369 if (!$rbacsystem->checkAccess('edit_roleassignment',$this->ref_id))
00370 {
00371 $show = false;
00372 }
00373 break;
00374
00375
00376 case 'userassignment':
00377 if (!$rbacsystem->checkAccess('edit_userassignment',$this->ref_id))
00378 {
00379 $show = false;
00380 }
00381 break;
00382 }
00383 }
00384
00385 if (!$show)
00386 {
00387 continue;
00388 }
00389
00390 $this->tpl->setCurrentBlock("tab");
00391 $this->tpl->setVariable("TAB_TYPE", $tabtype);
00392 $this->tpl->setVariable("TAB_TYPE2", $tab);
00393 $this->tpl->setVariable("IMG_LEFT", ilUtil::getImagePath("eck_l.gif"));
00394 $this->tpl->setVariable("IMG_RIGHT", ilUtil::getImagePath("eck_r.gif"));
00395 $this->tpl->setVariable("TAB_LINK", $this->tab_target_script."?ref_id=".$_GET["ref_id"].$object_link."&cmd=".$row[1]);
00396 $this->tpl->setVariable("TAB_TEXT", $this->lng->txt($row[0]));
00397 $this->tpl->parseCurrentBlock();
00398 }
00399 }
00400 }
00401
00402 function getHTML()
00403 {
00404 return $this->html;
00405 }
00406
00407 function setTabTargetScript($a_script = "adm_object.php")
00408 {
00409 $this->tab_target_script = $a_script;
00410 }
00411
00412 function getTabTargetScript()
00413 {
00414 return $this->tab_target_script;
00415 }
00416
00423 function setActions($a_actions = "")
00424 {
00425 if (is_array($a_actions))
00426 {
00427 foreach ($a_actions as $name => $lng)
00428 {
00429 $this->actions[$name] = array("name" => $name, "lng" => $lng);
00430 }
00431 }
00432 else
00433 {
00434 $this->actions = "";
00435 }
00436 }
00437
00444 function setSubObjects($a_sub_objects = "")
00445 {
00446 if (is_array($a_sub_objects))
00447 {
00448 foreach ($a_sub_objects as $name => $options)
00449 {
00450 $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
00451 }
00452 }
00453 else
00454 {
00455 $this->sub_objects = "";
00456 }
00457 }
00458
00467 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php",
00468 $a_child_param = "ref_id", $a_output_obj = true, $a_root_title = "")
00469 {
00470 global $ilias_locator;
00471
00472 if (!is_object($a_tree))
00473 {
00474 $a_tree =& $this->tree;
00475 }
00476
00477 if (!($a_id))
00478 {
00479 $a_id = $_GET["ref_id"];
00480 }
00481
00482 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00483
00484 $path = $a_tree->getPathFull($a_id);
00485
00486
00487
00488 if ($a_parent_parent)
00489 {
00490
00491 $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
00492
00493 $path[] = array(
00494 "id" => $a_ref_id,
00495 "title" => $this->lng->txt($subObj->getTitle())
00496 );
00497 }
00498
00499
00500 $modifier = 1;
00501
00502 if (isset($_GET["obj_id"]) && $a_output_obj)
00503 {
00504 $modifier = 0;
00505 }
00506
00507
00508 $i = 1;
00509
00510 foreach ($path as $key => $row)
00511 {
00512 if ($key < count($path)-$modifier)
00513 {
00514 $this->tpl->touchBlock("locator_separator");
00515 }
00516
00517 $this->tpl->setCurrentBlock("locator_item");
00518
00519 if ($a_root_title != "" && ($row["child"] == $a_tree->getRootId()))
00520 {
00521 $title = $a_root_title;
00522 }
00523 else
00524 {
00525 $title = $row["title"];
00526 }
00527
00528 $this->tpl->setVariable("ITEM", $title);
00529
00530 $this->tpl->setVariable("LINK_ITEM",
00531 ilUtil::appendUrlParameterString($scriptname, $a_child_param."=".$row["child"]));
00532 $this->tpl->parseCurrentBlock();
00533
00534
00535
00536 $ilias_locator->navigate($i++,$title,
00537 ilUtil::appendUrlParameterString($scriptname, $a_child_param."=".$row["child"]),"bottom");
00538 }
00539
00540 if (($_GET["obj_id"] != "") && $a_output_obj)
00541 {
00542 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
00543
00544 $this->tpl->setCurrentBlock("locator_item");
00545 $this->tpl->setVariable("ITEM", $obj_data->getTitle());
00546
00547 $this->tpl->setVariable("LINK_ITEM",
00548 ilUtil::appendUrlParameterString($scriptname, "ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]));
00549 $this->tpl->parseCurrentBlock();
00550
00551
00552
00553 $ilias_locator->navigate($i++,$obj_data->getTitle(),
00554 ilUtil::appendUrlParameterString($scriptname, "ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]),"bottom");
00555 }
00556
00557 $this->tpl->setCurrentBlock("locator");
00558
00559 if (DEBUG)
00560 {
00561 $debug = "DEBUG: <font color=\"red\">".$this->type."::".$this->id."::".$_GET["cmd"]."</font><br/>";
00562 }
00563
00564 $prop_name = $this->objDefinition->getPropertyName($_GET["cmd"],$this->type);
00565
00566 if ($_GET["cmd"] == "confirmDeleteAdm")
00567 {
00568 $prop_name = "delete_object";
00569 }
00570
00571 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00572 $this->tpl->parseCurrentBlock();
00573
00574 }
00575
00581 function copyObject()
00582 {
00583 global $rbacsystem;
00584
00585 if (!isset($_POST["id"]))
00586 {
00587 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00588 }
00589
00590
00591 foreach ($_POST["id"] as $ref_id)
00592 {
00593
00594 $node_data = $this->tree->getNodeData($ref_id);
00595 $subtree_nodes = $this->tree->getSubTree($node_data);
00596
00597 $all_node_data[] = $node_data;
00598 $all_subtree_nodes[] = $subtree_nodes;
00599
00600
00601 foreach ($subtree_nodes as $node)
00602 {
00603 if (!$rbacsystem->checkAccess('read',$node["ref_id"]))
00604 {
00605 $no_copy[] = $node["ref_id"];
00606 }
00607 }
00608 }
00609
00610 if (count($no_copy))
00611 {
00612 $this->ilias->raiseError($this->lng->txt("msg_no_perm_copy")." ".implode(',',$this->getTitlesByRefId($no_copy)),
00613 $this->ilias->error_obj->MESSAGE);
00614 }
00615
00616 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
00617 $_SESSION["clipboard"]["cmd"] = key($_POST["cmd"]);
00618 $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
00619
00620 sendinfo($this->lng->txt("msg_copy_clipboard"),true);
00621
00622 ilUtil::redirect($this->getReturnLocation("copy","adm_object.php?ref_id=".$_GET["ref_id"]));
00623 }
00624
00630 function cloneObject($a_ref_ids)
00631 {
00632 global $rbacsystem;
00633
00634 if(!is_array($a_ref_ids))
00635 {
00636 $this->ilias->raiseError($this->lng->txt("msg_error_copy"),$this->ilias->error_obj->MESSAGE);
00637 }
00638
00639
00640
00641 foreach ($a_ref_ids as $id)
00642 {
00643 $this->cloneNodes($id,$this->ref_id,$mapping);
00644 }
00645
00646
00647
00648
00649 $this->clearObject();
00650
00651 sendinfo($this->lng->txt("msg_cloned"),true);
00652 ilUtil::redirect($this->getReturnLocation("paste","adm_object.php?ref_id=".$_GET["ref_id"]));
00653
00654 }
00655
00666 function cloneNodes($a_source_id,$a_dest_id,&$mapping)
00667 {
00668 if (!$mapping)
00669 {
00670 $mapping = array();
00671 }
00672
00673
00674 $source_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_source_id);
00675 $new_ref_id = $source_obj->ilClone($a_dest_id);
00676 unset($source_obj);
00677
00678 $mapping[$new_ref_id] = $a_source_id;
00679
00680
00681 foreach ($this->tree->getChilds($a_source_id) as $child)
00682 {
00683
00684 if ($child["type"] != 'rolf')
00685 {
00686 $this->cloneNodes($child["ref_id"],$new_ref_id,$mapping);
00687 }
00688 else
00689 {
00690 if (count($rolf = $this->tree->getChildsByType($new_ref_id,"rolf")))
00691 {
00692 $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
00693 }
00694 }
00695 }
00696
00697 return true;
00698 }
00699
00705 function undeleteObject()
00706 {
00707 global $rbacsystem, $log;
00708
00709
00710 if (!isset($_POST["trash_id"]))
00711 {
00712 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00713 }
00714
00715 foreach ($_POST["trash_id"] as $id)
00716 {
00717 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
00718
00719 if (!$rbacsystem->checkAccess('create',$_GET["ref_id"],$obj_data->getType()))
00720 {
00721 $no_create[] = $id;
00722 }
00723 }
00724
00725 if (count($no_create))
00726 {
00727 $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
00728 implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
00729 }
00730
00731 foreach ($_POST["trash_id"] as $id)
00732 {
00733
00734 $this->insertSavedNodes($id,$_GET["ref_id"],-(int) $id);
00735
00736 $saved_tree = new ilTree(-(int)$id);
00737 $saved_tree->deleteTree($saved_tree->getNodeData($id));
00738
00739 }
00740
00741
00742
00743 sendInfo($this->lng->txt("msg_undeleted"),true);
00744
00745 ilUtil::redirect($this->getReturnLocation("undelete","adm_object.php?ref_id=".$_GET["ref_id"]));
00746
00747 }
00748
00758 function insertSavedNodes($a_source_id,$a_dest_id,$a_tree_id)
00759 {
00760 global $rbacadmin, $rbacreview, $log;
00761
00762 $this->tree->insertNode($a_source_id,$a_dest_id);
00763
00764
00765 $log->write("ilObjectGUI::insertSavedNodes(), restored ref_id $a_source_id from trash");
00766
00767
00768 $parentRoles = $rbacreview->getParentRoleIds($a_dest_id);
00769 $obj =& $this->ilias->obj_factory->getInstanceByRefId($a_source_id);
00770
00771 foreach ($parentRoles as $parRol)
00772 {
00773 $ops = $rbacreview->getOperationsOfRole($parRol["obj_id"], $obj->getType(), $parRol["parent"]);
00774 $rbacadmin->grantPermission($parRol["obj_id"],$ops,$a_source_id);
00775 }
00776
00777 $saved_tree = new ilTree($a_tree_id);
00778 $childs = $saved_tree->getChilds($a_source_id);
00779
00780 foreach ($childs as $child)
00781 {
00782 $this->insertSavedNodes($child["child"],$a_source_id,$a_tree_id);
00783 }
00784 }
00785
00795 function confirmedDeleteObject()
00796 {
00797 include_once './payment/classes/class.ilPaymentObject.php';
00798
00799 global $rbacsystem, $rbacadmin, $log;
00800
00801
00802
00803
00804
00805
00806 if (!isset($_SESSION["saved_post"]))
00807 {
00808 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00809 }
00810
00811
00812 foreach ($_SESSION["saved_post"] as $id)
00813 {
00814
00815 $node_data = $this->tree->getNodeData($id);
00816 $subtree_nodes = $this->tree->getSubTree($node_data);
00817
00818 $all_node_data[] = $node_data;
00819 $all_subtree_nodes[] = $subtree_nodes;
00820
00821
00822 foreach ($subtree_nodes as $node)
00823 {
00824 if($node['type'] == 'rolf')
00825 {
00826 continue;
00827 }
00828 if (!$rbacsystem->checkAccess('delete',$node["child"]))
00829 {
00830 $not_deletable[] = $node["child"];
00831 $perform_delete = false;
00832 }
00833 else if(ilPaymentObject::_isBuyable($node['child']))
00834 {
00835 $buyable[] = $node['child'];
00836 $perform_delete = false;
00837 }
00838 }
00839 }
00840
00841
00842 if (count($not_deletable))
00843 {
00844 $not_deletable = implode(',',$not_deletable);
00845 session_unregister("saved_post");
00846 sendInfo($this->lng->txt("msg_no_perm_delete")." ".$not_deletable."<br/>".$this->lng->txt("msg_cancel"),true);
00847 ilUtil::redirect($this->getReturnLocation("confirmedDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
00848
00849
00850
00851 }
00852 if(count($buyable))
00853 {
00854 foreach($buyable as $id)
00855 {
00856 $tmp_object =& ilObjectFactory::getInstanceByRefId($id);
00857
00858 $titles[] = $tmp_object->getTitle();
00859 }
00860 $title_str = implode(',',$titles);
00861
00862 sendInfo($this->lng->txt('msg_obj_not_deletable_sold').' '.$title_str,true);
00863
00864 $_POST['id'] = $_SESSION['saved_post'];
00865 $this->deleteObject(true);
00866
00867 return false;
00868 }
00869
00870
00871 if (!$all_node_data[0]["type"])
00872 {
00873
00874 if ($rbacsystem->checkAccess('delete',$_GET["ref_id"]))
00875 {
00876 foreach($_SESSION["saved_post"] as $id)
00877 {
00878 $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
00879 $obj->delete();
00880
00881
00882 $log->write("ilObjectGUI::confirmedDeleteObject(), deleted obj_id ".$obj->getId().
00883 ", type: ".$obj->getType().", title: ".$obj->getTitle());
00884 }
00885 }
00886 else
00887 {
00888 unset($_SESSION["saved_post"]);
00889 sendInfo($this->lng->txt("no_perm_delete")."<br/>".$this->lng->txt("msg_cancel"),true);
00890 ilUtil::redirect($this->getReturnLocation("confirmedDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
00891 }
00892 }
00893 else
00894 {
00895
00896 foreach ($_SESSION["saved_post"] as $id)
00897 {
00898
00899 $subnodes = $this->tree->getSubtree($this->tree->getNodeData($id));
00900
00901 foreach ($subnodes as $subnode)
00902 {
00903 $rbacadmin->revokePermission($subnode["child"]);
00904
00905 $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
00906
00907
00908
00909 }
00910
00911 $this->tree->saveSubTree($id);
00912 $this->tree->deleteTree($this->tree->getNodeData($id));
00913
00914
00915 $log->write("ilObjectGUI::confirmedDeleteObject(), moved ref_id ".$id.
00916 " to trash");
00917
00918
00919 $affected_users = ilUtil::removeItemFromDesktops($id);
00920
00921
00922
00923 }
00924
00925
00926 }
00927
00928
00929 sendInfo($this->lng->txt("info_deleted"),true);
00930
00931 ilUtil::redirect($this->getReturnLocation("confirmedDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
00932
00933 }
00934
00940 function cancelDeleteObject()
00941 {
00942 session_unregister("saved_post");
00943
00944 sendInfo($this->lng->txt("msg_cancel"),true);
00945
00946 ilUtil::redirect($this->getReturnLocation("cancelDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
00947
00948 }
00949
00955 function removeFromSystemObject()
00956 {
00957 global $rbacsystem, $log;
00958
00959
00960 if (!isset($_POST["trash_id"]))
00961 {
00962 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00963 }
00964
00965
00966
00967
00968 foreach ($_POST["trash_id"] as $id)
00969 {
00970
00971 $saved_tree = new ilTree(-(int)$id);
00972 $node_data = $saved_tree->getNodeData($id);
00973 $subtree_nodes = $saved_tree->getSubTree($node_data);
00974
00975
00976
00977 $checked[] = -(int) $id;
00978
00979
00980 $this->removeDeletedNodes($id,$checked);
00981
00982 foreach ($subtree_nodes as $node)
00983 {
00984 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
00985
00986
00987 $log->write("ilObjectGUI::removeFromSystemObject(), delete obj_id: ".$node_obj->getId().
00988 ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
00989 "title: ".$node_obj->getTitle());
00990
00991 $node_obj->delete();
00992 }
00993
00994
00995 #$this->tree->deleteTree($node_data);
00996
00997 $saved_tree->deleteTree($node_data);
00998
00999
01000 $log->write("ilObjectGUI::removeFromSystemObject(), deleted tree, tree_id: ".$node_data["tree"].
01001 ", child: ".$node_data["child"]);
01002
01003 }
01004
01005 sendInfo($this->lng->txt("msg_removed"),true);
01006
01007 ilUtil::redirect($this->getReturnLocation("removeFromSystem","adm_object.php?ref_id=".$_GET["ref_id"]));
01008
01009 }
01010
01019 function removeDeletedNodes($a_node_id, $a_checked, $a_delete_objects = true)
01020 {
01021 global $log;
01022
01023 $q = "SELECT tree FROM tree WHERE parent='".$a_node_id."' AND tree < 0";
01024
01025 $r = $this->ilias->db->query($q);
01026
01027 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
01028 {
01029
01030 if (!in_array($row->tree,$a_checked))
01031 {
01032 $deleted_tree = new ilTree($row->tree);
01033 $a_checked[] = $row->tree;
01034
01035 $row->tree = $row->tree * (-1);
01036 $del_node_data = $deleted_tree->getNodeData($row->tree);
01037 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
01038
01039 $this->removeDeletedNodes($row->tree,$a_checked);
01040
01041 if ($a_delete_objects)
01042 {
01043 foreach ($del_subtree_nodes as $node)
01044 {
01045 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
01046
01047
01048 $log->write("ilObjectGUI::removeDeletedNodes(), delete obj_id: ".$node_obj->getId().
01049 ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
01050 "title: ".$node_obj->getTitle());
01051
01052 $node_obj->delete();
01053 }
01054 }
01055
01056 $this->tree->deleteTree($del_node_data);
01057
01058
01059 $log->write("ilObjectGUI::removeDeletedNodes(), deleted tree, tree_id: ".$del_node_data["tree"].
01060 ", child: ".$del_node_data["child"]);
01061 }
01062 }
01063
01064 return true;
01065 }
01066
01072 function createObject()
01073 {
01074 global $rbacsystem;
01075
01076 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01077
01078 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01079 {
01080 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01081 }
01082 else
01083 {
01084
01085 $data = array();
01086 $data["fields"] = array();
01087 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01088 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01089
01090 $this->getTemplateFile("edit",$new_type);
01091
01092 foreach ($data["fields"] as $key => $val)
01093 {
01094 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01095 $this->tpl->setVariable(strtoupper($key), $val);
01096
01097 if ($this->prepare_output)
01098 {
01099 $this->tpl->parseCurrentBlock();
01100 }
01101 }
01102
01103 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
01104 $_GET["ref_id"]."&new_type=".$new_type));
01105 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01106 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01107 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01108 $this->tpl->setVariable("CMD_SUBMIT", "save");
01109 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01110 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01111 }
01112 }
01113
01119 function cancelObject($in_rep = false)
01120 {
01121 session_unregister("saved_post");
01122
01123 sendInfo($this->lng->txt("msg_cancel"),true);
01124
01125
01126 $return_location = $_GET["cmd_return_location"];
01127
01128
01129 if ($in_rep)
01130 {
01131 $this->ctrl->returnToParent($this);
01132 }
01133 else
01134 {
01135 ilUtil::redirect($this->getReturnLocation("cancel",$this->ctrl->getTargetScript()."?".$this->link_params));
01136 }
01137 }
01138
01144 function saveObject()
01145 {
01146 global $rbacsystem, $objDefinition;
01147
01148 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01149
01150
01151 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01152 {
01153 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
01154 }
01155
01156 $module = $objDefinition->getModule($_GET["new_type"]);
01157 $module_dir = ($module == "")
01158 ? ""
01159 : $module."/";
01160
01161
01162 $class_name = "ilObj".$objDefinition->getClassName($_GET["new_type"]);
01163 include_once($module_dir."classes/class.".$class_name.".php");
01164 $newObj = new $class_name();
01165 $newObj->setType($_GET["new_type"]);
01166 $newObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01167 $newObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01168 $newObj->create();
01169 $newObj->createReference();
01170 $newObj->putInTree($_GET["ref_id"]);
01171 $newObj->setPermissions($_GET["ref_id"]);
01172
01173
01174 return $newObj;
01175 }
01176
01177
01183 function importObject()
01184 {
01185 global $rbacsystem;
01186
01187
01188 if (!$rbacsystem->checkAccess('write', $_GET["ref_id"], $_POST["new_type"]))
01189 {
01190 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->WARNING);
01191 }
01192
01193 $imp_obj =$this->objDefinition->getImportObjects($this->object->getType());
01194
01195 if (!in_array($_POST["new_type"], $imp_obj))
01196 {
01197 $this->ilias->raiseError($this->lng->txt("no_import_available").
01198 " ".$this->lng->txt("obj_".$_POST["new_type"]),
01199 $this->ilias->error_obj->MESSAGE);
01200 }
01201
01202
01203 }
01204
01205
01211 function editObject()
01212 {
01213 global $rbacsystem;
01214
01215 if (!$rbacsystem->checkAccess("write", $this->ref_id))
01216 {
01217 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01218 }
01219
01220 $fields = array();
01221
01222 if ($_SESSION["error_post_vars"])
01223 {
01224
01225 $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01226 $fields["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01227 }
01228 else
01229 {
01230 $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
01231 $fields["desc"] = ilUtil::stripSlashes($this->object->getLongDescription());
01232 }
01233
01234 $this->displayEditForm($fields);
01235 }
01236
01243 function displayEditForm($fields)
01244 {
01245 $this->getTemplateFile("edit");
01246
01247 foreach ($fields as $key => $val)
01248 {
01249 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01250 $this->tpl->setVariable(strtoupper($key), $val);
01251 $this->tpl->parseCurrentBlock();
01252 }
01253
01254 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
01255
01256 $this->tpl->setVariable("FORMACTION", $this->getFormAction("update",$this->ctrl->getFormAction($this).$obj_str));
01257
01258 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
01259 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
01260 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01261 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01262 $this->tpl->setVariable("CMD_SUBMIT", "update");
01263 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01264
01265 }
01266
01267
01273 function updateObject()
01274 {
01275 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01276 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01277 $this->update = $this->object->update();
01278
01279 sendInfo($this->lng->txt("msg_obj_modified"),true);
01280
01281 ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getLinkTarget($this)));
01282
01283 }
01284
01290 function permObject()
01291 {
01292 global $rbacsystem, $rbacreview;
01293
01294 if (!$rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
01295 {
01296 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
01297 }
01298
01299
01300 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01301
01302
01303 $this->tpl->setCurrentBlock("btn_cell");
01304 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this, "perm"));
01305 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("permission_settings"));
01306 $this->tpl->parseCurrentBlock();
01307
01308 $this->tpl->setCurrentBlock("btn_cell");
01309 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this, "info"));
01310 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("info_status_info"));
01311 $this->tpl->parseCurrentBlock();
01312
01313 static $num = 0;
01314
01315
01316 $parentRoles = $rbacreview->getParentRoleIds($this->object->getRefId());
01317
01318 $data = array();
01319
01320
01321 $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
01322
01323 $global_roles = $rbacreview->getGlobalRoles();
01324
01325 $local_roles = array();
01326
01327 if ($role_folder)
01328 {
01329 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);
01330 }
01331 foreach ($parentRoles as $key => $r)
01332 {
01333
01334 if ($r["obj_id"] == SYSTEM_ROLE_ID)
01335 {
01336 unset($parentRoles[$key]);
01337 continue;
01338 }
01339
01340 $r["global"] = false;
01341
01342 if (in_array($r["obj_id"],$global_roles))
01343 {
01344 $r["global"] = true;
01345 }
01346
01347 if (!in_array($r["obj_id"],$local_roles))
01348 {
01349 $data["check_inherit"][] = ilUtil::formCheckBox(0,"stop_inherit[]",$r["obj_id"]);
01350 $r["link"] = false;
01351 }
01352 else
01353 {
01354 $r["link"] = true;
01355
01356
01357 if ($rbacreview->isAssignable($r["obj_id"],$role_folder["ref_id"]))
01358 {
01359 $data["check_inherit"][] = " ";
01360 }
01361 else
01362 {
01363
01364 $data["check_inherit"][] = ilUtil::formCheckBox(1,"stop_inherit[]",$r["obj_id"]);
01365 }
01366 }
01367
01368 $data["roles"][] = $r;
01369 }
01370
01371 $ope_list = getOperationList($this->object->getType());
01372
01373
01374 foreach ($ope_list as $key => $operation)
01375 {
01376 $opdata = array();
01377
01378 $opdata["name"] = $operation["operation"];
01379
01380 $colspan = count($parentRoles) + 1;
01381
01382 foreach ($parentRoles as $role)
01383 {
01384 $checked = $rbacsystem->checkPermission($this->object->getRefId(), $role["obj_id"],$operation["operation"],$_GET["parent"]);
01385 $disabled = false;
01386
01387
01388 $box = ilUtil::formCheckBox($checked,"perm[".$role["obj_id"]."][]",$operation["ops_id"],$disabled);
01389 $opdata["values"][] = $box;
01390 }
01391
01392 $data["permission"][] = $opdata;
01393 }
01394
01396
01398 $this->getTemplateFile("perm");
01399 $this->tpl->setCurrentBlock("tableheader");
01400 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("permission_settings"));
01401 $this->tpl->setVariable("COLSPAN", $colspan);
01402 $this->tpl->setVariable("TXT_OPERATION", $this->lng->txt("operation"));
01403 $this->tpl->setVariable("TXT_ROLES", $this->lng->txt("roles"));
01404 $this->tpl->parseCurrentBlock();
01405
01406 $num = 0;
01407
01408
01409 foreach ($data["roles"] as $role)
01410 {
01411 $tmp_role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
01412 $tmp_local_roles = array();
01413 if ($tmp_role_folder)
01414 {
01415 $tmp_local_roles = $rbacreview->getRolesOfRoleFolder($tmp_role_folder["ref_id"]);
01416 }
01417
01418 if(in_array($role['obj_id'],$tmp_local_roles))
01419 {
01420 $role_folder_data = $rbacreview->getRoleFolderOfObject($_GET['ref_id']);
01421 $role_folder_id = $role_folder_data['ref_id'];
01422
01423
01424 $this->tpl->setCurrentBlock("ROLELINK_OPEN");
01425
01426 if($this->ctrl->getTargetScript() != 'adm_object.php')
01427 {
01428 $up_path = defined('ILIAS_MODULE') ? "../" : "";
01429 $this->tpl->setVariable("LINK_ROLE_RULESET",$up_path.'role.php?cmd=perm&ref_id='.
01430 $role_folder_id.'&obj_id='.$role['obj_id']);
01431
01432 #$this->ctrl->setParameterByClass('ilobjrolegui','obj_id',$role['obj_id']);
01433 #$this->tpl->setVariable("LINK_ROLE_RULESET",
01434 # $this->ctrl->getLinkTargetByClass('ilobjrolegui','perm'));
01435 }
01436 else
01437 {
01438 $this->tpl->setVariable("LINK_ROLE_RULESET",'adm_object.php?cmd=perm&ref_id='.
01439 $role_folder_id.'&obj_id='.$role['obj_id']);
01440 }
01441 $this->tpl->setVariable("TXT_ROLE_RULESET",$this->lng->txt("edit_perm_ruleset"));
01442 $this->tpl->parseCurrentBlock();
01443
01444 $this->tpl->touchBlock("ROLELINK_CLOSE");
01445 }
01446
01447 $this->tpl->setCurrentBlock("ROLENAMES");
01448
01449
01450 include_once ('class.ilObjRole.php');
01451 $this->tpl->setVariable("ROLE_NAME",str_replace(" "," ",ilObjRole::_getTranslation($role["title"])));
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464 if ($role["global"])
01465 {
01466 $this->tpl->setVariable("ROLE_CONTEXT_TYPE","global");
01467 }
01468 else
01469 {
01470 $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
01471 $parent_node = $this->tree->getParentNodeData($rolf[0]);
01472 $this->tpl->setVariable("ROLE_CONTEXT_TYPE",$this->lng->txt("obj_".$parent_node["type"])." (#".$parent_node["obj_id"].")");
01473 $this->tpl->setVariable("ROLE_CONTEXT",$parent_node["title"]);
01474 }
01475
01476
01477 $this->tpl->parseCurrentBlock();
01478
01479
01480 if ($this->objDefinition->stopInheritance($this->type))
01481 {
01482 $this->tpl->setCurrentBLock("CHECK_INHERIT");
01483 $this->tpl->setVariable("CHECK_INHERITANCE",$data["check_inherit"][$num]);
01484 $this->tpl->parseCurrentBlock();
01485 }
01486
01487 $num++;
01488 }
01489
01490
01491 $colspan = $num + 1;
01492 $num = 0;
01493
01494
01495 if ($this->objDefinition->stopInheritance($this->type))
01496 {
01497 $this->tpl->setCurrentBLock("STOP_INHERIT");
01498 $this->tpl->setVariable("TXT_STOP_INHERITANCE", $this->lng->txt("stop_inheritance"));
01499 $this->tpl->parseCurrentBlock();
01500 }
01501
01502 foreach ($data["permission"] as $ar_perm)
01503 {
01504 foreach ($ar_perm["values"] as $box)
01505 {
01506
01507 $this->tpl->setCurrentBlock("CHECK_PERM");
01508 $this->tpl->setVariable("CHECK_PERMISSION",$box);
01509 $this->tpl->parseCurrentBlock();
01510
01511 }
01512
01513
01514 $this->tpl->setCurrentBlock("TABLE_DATA_OUTER");
01515 $css_row = ilUtil::switchColor($num++, "tblrow1", "tblrow2");
01516 $this->tpl->setVariable("CSS_ROW",$css_row);
01517 $this->tpl->setVariable("PERMISSION", $this->lng->txt($this->object->getType()."_".$ar_perm["name"]));
01518 if (substr($ar_perm["name"], 0, 7) == "create_")
01519 {
01520 if ($this->objDefinition->getDevMode(substr($ar_perm["name"], 7, strlen($ar_perm["name"]) -7)))
01521 {
01522 $this->tpl->setVariable("TXT_NOT_IMPL", "(".$this->lng->txt("not_implemented_yet").")");
01523 }
01524 }
01525 $this->tpl->parseCurrentBlock();
01526
01527 }
01528
01529
01530
01531
01532 $object_types_exclude = array("adm","root","mail","usrf","objf","lngf","trac","taxf","auth", "assf",'seas','extt');
01533
01534 if (!in_array($this->object->getType(),$object_types_exclude) and $this->object->getRefId() != ROLE_FOLDER_ID)
01535
01536 {
01537 $this->tpl->setCurrentBlock("LOCAL_ROLE");
01538
01539
01540 $data = array();
01541 $data["fields"] = array();
01542 $data["fields"]["title"] = $_SESSION["error_post_vars"]["Fobject"]["title"];
01543 $data["fields"]["desc"] = $_SESSION["error_post_vars"]["Fobject"]["desc"];
01544
01545 foreach ($data["fields"] as $key => $val)
01546 {
01547 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01548 $this->tpl->setVariable(strtoupper($key), $val);
01549 }
01550
01551 $this->tpl->setVariable("FORMACTION_LR",$this->getFormAction("addRole", $this->ctrl->getLinkTarget($this, "addRole")));
01552
01553 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("you_may_add_local_roles"));
01554 $this->tpl->setVariable("TXT_ADD_ROLE", $this->lng->txt("role_add_local"));
01555 $this->tpl->setVariable("TARGET", $this->getTargetFrame("addRole"));
01556 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01557 $this->tpl->parseCurrentBlock();
01558 }
01559
01560
01561
01562 $this->tpl->setCurrentBlock("adm_content");
01563 $this->tpl->setVariable("FORMACTION",
01564 $this->getFormAction("permSave",$this->ctrl->getLinkTarget($this,"permSave")));
01565
01566
01567 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01568 $this->tpl->setVariable("COL_ANZ",$colspan);
01569 $this->tpl->parseCurrentBlock();
01570 }
01571
01580 function getFormAction($a_cmd, $a_formaction ="")
01581 {
01582 if ($this->formaction[$a_cmd] != "")
01583 {
01584 return $this->formaction[$a_cmd];
01585 }
01586 else
01587 {
01588 return $a_formaction;
01589 }
01590 }
01591
01600 function setFormAction($a_cmd, $a_formaction)
01601 {
01602 $this->formaction[$a_cmd] = $a_formaction;
01603 }
01604
01612 function getReturnLocation($a_cmd, $a_location ="")
01613 {
01614 if ($this->return_location[$a_cmd] != "")
01615 {
01616 return $this->return_location[$a_cmd];
01617 }
01618 else
01619 {
01620 return $a_location;
01621 }
01622 }
01623
01631 function setReturnLocation($a_cmd, $a_location)
01632 {
01633 $this->return_location[$a_cmd] = $a_location;
01634 }
01635
01643 function getTargetFrame($a_cmd, $a_target_frame = "")
01644 {
01645 if ($this->target_frame[$a_cmd] != "")
01646 {
01647 return $this->target_frame[$a_cmd];
01648 }
01649 elseif (!empty($a_target_frame))
01650 {
01651 return "target=\"".$a_target_frame."\"";
01652 }
01653 else
01654 {
01655 return;
01656 }
01657 }
01658
01666 function setTargetFrame($a_cmd, $a_target_frame)
01667 {
01668 $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
01669 }
01670
01676 function permSaveObject()
01677 {
01678 global $rbacsystem, $rbacreview, $rbacadmin;
01679
01680 if (!$rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
01681 {
01682 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
01683 }
01684
01685
01686 $rbacadmin->revokePermission($this->ref_id);
01687
01688 if (is_array($_POST["perm"]))
01689 {
01690 foreach ($_POST["perm"] as $key => $new_role_perms)
01691 {
01692
01693 $rbacadmin->grantPermission($key,$new_role_perms,$this->ref_id);
01694 }
01695 }
01696
01697
01698 $this->object->update();
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708 $rolf_data = $rbacreview->getRoleFolderOfObject($this->ref_id);
01709 $rolf_id = $rolf_data["child"];
01710
01711 $stop_inherit_roles = $_POST["stop_inherit"] ? $_POST["stop_inherit"] : array();
01712
01713 if ($stop_inherit_roles)
01714 {
01715
01716 if (empty($rolf_id))
01717 {
01718
01719 $rfoldObj = $this->object->createRoleFolder();
01720
01721
01722 $rolf_id = $rfoldObj->getRefId();
01723 }
01724
01725 $roles_of_folder = $rbacreview->getRolesOfRoleFolder($rolf_id);
01726
01727 foreach ($stop_inherit_roles as $stop_inherit)
01728 {
01729
01730 if (!in_array($stop_inherit,$roles_of_folder))
01731 {
01732 $parentRoles = $rbacreview->getParentRoleIds($rolf_id);
01733 $rbacadmin->copyRolePermission($stop_inherit,$parentRoles[$stop_inherit]["parent"],
01734 $rolf_id,$stop_inherit);
01735 $rbacadmin->assignRoleToFolder($stop_inherit,$rolf_id,'n');
01736 }
01737 }
01738 }
01739
01740 if ($rolf_id and $rolf_id != ROLE_FOLDER_ID)
01741 {
01742
01743 $linked_roles = $rbacreview->getLinkedRolesOfRoleFolder($rolf_id);
01744 $linked_roles_to_remove = array_diff($linked_roles,$stop_inherit_roles);
01745
01746
01747 foreach ($linked_roles_to_remove as $role_id)
01748 {
01749 $role_obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
01750 $role_obj->setParent($rolf_id);
01751 $role_obj->delete();
01752 unset($role_obj);
01753 }
01754 }
01755
01756 sendinfo($this->lng->txt("saved_successfully"),true);
01757 ilUtil::redirect($this->getReturnLocation("permSave",$this->ctrl->getLinkTarget($this,"perm")));
01758 }
01759
01765 function displayList()
01766 {
01767 include_once "./classes/class.ilTableGUI.php";
01768
01769
01770 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01771
01772 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
01773
01774 $num = 0;
01775
01776 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
01777 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
01778
01779
01780 $tbl = new ilTableGUI();
01781
01782
01783 $tbl->setTitle($this->object->getTitle(),"icon_".$this->object->getType().".gif",
01784 $this->lng->txt("obj_".$this->object->getType()));
01785 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
01786
01787 foreach ($this->data["cols"] as $val)
01788 {
01789 $header_names[] = $this->lng->txt($val);
01790 }
01791
01792 $tbl->setHeaderNames($header_names);
01793
01794 $header_params = array("ref_id" => $this->ref_id);
01795 $tbl->setHeaderVars($this->data["cols"],$header_params);
01796 $tbl->setColumnWidth(array("15","15","75%","25%"));
01797
01798
01799 $tbl->setOrderColumn($_GET["sort_by"]);
01800 $tbl->setOrderDirection($_GET["sort_order"]);
01801 $tbl->setLimit($_GET["limit"]);
01802 $tbl->setOffset($_GET["offset"]);
01803 $tbl->setMaxCount($this->maxcount);
01804
01805 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
01806
01807
01808 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01809
01810 if (!empty($this->data["data"][0]))
01811 {
01812
01813 for ($i=0; $i < count($this->data["data"]); $i++)
01814 {
01815 $data = $this->data["data"][$i];
01816 $ctrl = $this->data["ctrl"][$i];
01817
01818
01819 $css_row = ilUtil::switchColor($i+1,"tblrow2","tblrow1");
01820
01821
01822 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)
01823 {
01824 $this->tpl->touchBlock("empty_cell");
01825 }
01826 else
01827 {
01828
01829 if ($ctrl["type"] == "usr" or $ctrl["type"] == "role" or $ctrl["type"] == "rolt")
01830 {
01831 $link_id = $ctrl["obj_id"];
01832 }
01833 else
01834 {
01835 $link_id = $ctrl["ref_id"];
01836 }
01837
01838
01839 $this->ids[] = $link_id;
01840
01841 $this->tpl->setCurrentBlock("checkbox");
01842 $this->tpl->setVariable("CHECKBOX_ID", $link_id);
01843 $this->tpl->setVariable("CSS_ROW", $css_row);
01844 $this->tpl->parseCurrentBlock();
01845 }
01846
01847 $this->tpl->setCurrentBlock("table_cell");
01848 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
01849 $this->tpl->parseCurrentBlock();
01850
01851 foreach ($data as $key => $val)
01852 {
01853
01854 $link = "adm_object.php?";
01855
01856 $n = 0;
01857
01858 foreach ($ctrl as $key2 => $val2)
01859 {
01860 $link .= $key2."=".$val2;
01861
01862 if ($n < count($ctrl)-1)
01863 {
01864 $link .= "&";
01865 $n++;
01866 }
01867 }
01868
01869 if ($key == "name" || $key == "title")
01870 {
01871 $name_field = explode("#separator#",$val);
01872 }
01873
01874 if ($key == "title" || $key == "name" || $key == "type")
01875 {
01876 $this->tpl->setCurrentBlock("begin_link");
01877 $this->tpl->setVariable("LINK_TARGET", $link);
01878
01879 $this->tpl->parseCurrentBlock();
01880 $this->tpl->touchBlock("end_link");
01881 }
01882
01883
01884 if (($key == "title" || $key == "name") and isset($_SESSION["clipboard"]))
01885 {
01886
01887 if (in_array($ctrl["ref_id"],$_SESSION["clipboard"]["ref_ids"]))
01888 {
01889 switch($_SESSION["clipboard"]["cmd"])
01890 {
01891 case "cut":
01892 $name_field[0] = "<del>".$name_field[0]."</del>";
01893 break;
01894
01895 case "copy":
01896 $name_field[0] = "<font color=\"green\">+</font> ".$name_field[0];
01897 break;
01898
01899 case "link":
01900 $name_field[0] = "<font color=\"black\"><</font> ".$name_field[0];
01901 break;
01902 }
01903 }
01904 }
01905
01906 $this->tpl->setCurrentBlock("text");
01907
01908 if ($key == "type")
01909 {
01910 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
01911 }
01912
01913 if ($key == "name" || $key == "title")
01914 {
01915 $this->tpl->setVariable("TEXT_CONTENT", $name_field[0]);
01916
01917 $this->tpl->setCurrentBlock("subtitle");
01918 $this->tpl->setVariable("DESC", ilUtil::shortenText($name_field[1],MAXLENGTH_OBJ_DESC,true));
01919 $this->tpl->parseCurrentBlock();
01920 }
01921 else
01922 {
01923 $this->tpl->setVariable("TEXT_CONTENT", $val);
01924 }
01925
01926 $this->tpl->parseCurrentBlock();
01927
01928 $this->tpl->setCurrentBlock("table_cell");
01929 $this->tpl->parseCurrentBlock();
01930
01931 }
01932
01933 $this->tpl->setCurrentBlock("tbl_content");
01934 $this->tpl->setVariable("CSS_ROW", $css_row);
01935 $this->tpl->parseCurrentBlock();
01936 }
01937 }
01938 else
01939 {
01940 $tbl->disable("header");
01941 $tbl->disable("footer");
01942
01943 $this->tpl->setCurrentBlock("text");
01944 $this->tpl->setVariable("TEXT_CONTENT", $this->lng->txt("obj_not_found"));
01945 $this->tpl->parseCurrentBlock();
01946 }
01947
01948 $this->showActions(true);
01949
01950
01951 $tbl->render();
01952 }
01953
01959 function viewObject()
01960 {
01961 global $rbacsystem;
01962
01963 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
01964 {
01965 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01966 }
01967
01968 $_GET["sort_by"] = $_GET['sort_by'] ? $_GET['sort_by'] : 'title';
01969
01970
01971
01972 $this->objectList = array();
01973 $this->data["data"] = array();
01974 $this->data["ctrl"] = array();
01975 $this->data["cols"] = array("", "type", "title", "last_change");
01976
01977 $childs = $this->tree->getChilds($_GET["ref_id"], $_GET["order"], $_GET["direction"]);
01978
01979 foreach ($childs as $key => $val)
01980 {
01981
01982 if (!$rbacsystem->checkAccess("visible",$val["ref_id"]))
01983 {
01984 continue;
01985 }
01986
01987
01988 if ($this->objDefinition->getDevMode($val["type"]))
01989 {
01990 continue;
01991 }
01992
01993
01994 $this->data["data"][] = array(
01995 "type" => $val["type"],
01996 "title" => $val["title"]."#separator#".$val["desc"],
01997
01998 "last_change" => $val["last_update"],
01999 "ref_id" => $val["ref_id"]
02000 );
02001
02002
02003
02004 }
02005
02006 $this->maxcount = count($this->data["data"]);
02007
02008 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
02009 $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
02010
02011
02012 foreach ($this->data["data"] as $key => $val)
02013 {
02014 $this->data["ctrl"][$key] = array(
02015 "type" => $val["type"],
02016 "ref_id" => $val["ref_id"]
02017 );
02018
02019 unset($this->data["data"][$key]["ref_id"]);
02020 $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
02021 }
02022
02023 $this->displayList();
02024 }
02025
02033 function deleteObject($a_error = false)
02034 {
02035 if (!isset($_POST["id"]))
02036 {
02037 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
02038 }
02039
02040
02041 $_SESSION["saved_post"] = $_POST["id"];
02042
02043 unset($this->data);
02044 $this->data["cols"] = array("type", "title", "last_change");
02045
02046 foreach ($_POST["id"] as $id)
02047 {
02048
02049
02050
02051
02052 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
02053
02054
02055
02056
02057
02058
02059 $this->data["data"]["$id"] = array(
02060 "type" => $obj_data->getType(),
02061 "title" => $obj_data->getTitle()."#separator#".$obj_data->getDescription()." ",
02062 "last_update" => $obj_data->getLastUpdateDate()
02063 );
02064 }
02065
02066 $this->data["buttons"] = array( "confirmedDelete" => $this->lng->txt("confirm"),
02067 "cancelDelete" => $this->lng->txt("cancel"));
02068
02069 $this->getTemplateFile("confirm");
02070
02071 if(!$a_error)
02072 {
02073 sendInfo($this->lng->txt("info_delete_sure"));
02074 }
02075
02076 $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",
02077 "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway"));
02078
02079
02080 foreach ($this->data["cols"] as $key)
02081 {
02082 $this->tpl->setCurrentBlock("table_header");
02083 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
02084 $this->tpl->parseCurrentBlock();
02085 }
02086
02087
02088
02089 $counter = 0;
02090
02091 foreach ($this->data["data"] as $key => $value)
02092 {
02093
02094 foreach ($value as $key => $cell_data)
02095 {
02096 $this->tpl->setCurrentBlock("table_cell");
02097
02098
02099 if ($key == "type")
02100 {
02101 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
02102 }
02103 elseif ($key == "title")
02104 {
02105 $name_field = explode("#separator#",$cell_data);
02106
02107 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
02108
02109 $this->tpl->setCurrentBlock("subtitle");
02110 $this->tpl->setVariable("DESC", $name_field[1]);
02111 $this->tpl->parseCurrentBlock();
02112 $this->tpl->setCurrentBlock("table_cell");
02113 }
02114 else
02115 {
02116 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
02117 }
02118
02119 $this->tpl->parseCurrentBlock();
02120 }
02121
02122 $this->tpl->setCurrentBlock("table_row");
02123 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
02124 $this->tpl->parseCurrentBlock();
02125
02126 }
02127
02128
02129
02130 foreach ($this->data["buttons"] as $name => $value)
02131 {
02132 $this->tpl->setCurrentBlock("operation_btn");
02133 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
02134 $this->tpl->setVariable("BTN_NAME",$name);
02135 $this->tpl->setVariable("BTN_VALUE",$value);
02136 $this->tpl->parseCurrentBlock();
02137 }
02138 }
02139
02145 function trashObject()
02146 {
02147 $objects = $this->tree->getSavedNodeData($_GET["ref_id"]);
02148
02149 if (count($objects) == 0)
02150 {
02151 sendInfo($this->lng->txt("msg_trash_empty"));
02152 $this->data["empty"] = true;
02153 }
02154 else
02155 {
02156 $this->data["empty"] = false;
02157 $this->data["cols"] = array("","type", "title", "last_change");
02158
02159 foreach ($objects as $obj_data)
02160 {
02161 $this->data["data"]["$obj_data[child]"] = array(
02162 "checkbox" => "",
02163 "type" => $obj_data["type"],
02164 "title" => $obj_data["title"]."#separator#".$obj_data["desc"],
02165 "last_update" => $obj_data["last_update"]
02166 );
02167 }
02168
02169 $this->data["buttons"] = array( "undelete" => $this->lng->txt("btn_undelete"),
02170 "removeFromSystem" => $this->lng->txt("btn_remove_system"));
02171 }
02172
02173 $this->getTemplateFile("confirm");
02174
02175 if ($this->data["empty"] == true)
02176 {
02177 return;
02178 }
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway");
02189 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath);
02190
02191
02192 foreach ($this->data["cols"] as $key)
02193 {
02194 $this->tpl->setCurrentBlock("table_header");
02195 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
02196 $this->tpl->parseCurrentBlock();
02197 }
02198
02199
02200
02201 $counter = 0;
02202
02203 foreach ($this->data["data"] as $key1 => $value)
02204 {
02205
02206 foreach ($value as $key2 => $cell_data)
02207 {
02208 $this->tpl->setCurrentBlock("table_cell");
02209
02210 if ($key2 == "checkbox")
02211 {
02212 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::formCheckBox(0,"trash_id[]",$key1));
02213 }
02214
02215 elseif ($key2 == "type")
02216 {
02217 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
02218 }
02219 elseif ($key2 == "title")
02220 {
02221 $name_field = explode("#separator#",$cell_data);
02222
02223 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
02224
02225 $this->tpl->setCurrentBlock("subtitle");
02226 $this->tpl->setVariable("DESC", $name_field[1]);
02227 $this->tpl->parseCurrentBlock();
02228 $this->tpl->setCurrentBlock("table_cell");
02229 }
02230 else
02231 {
02232 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
02233 }
02234
02235 $this->tpl->parseCurrentBlock();
02236 }
02237
02238 $this->tpl->setCurrentBlock("table_row");
02239 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
02240 $this->tpl->parseCurrentBlock();
02241
02242 }
02243
02244
02245
02246 foreach ($this->data["buttons"] as $name => $value)
02247 {
02248 $this->tpl->setCurrentBlock("operation_btn");
02249 $this->tpl->setVariable("BTN_NAME",$name);
02250 $this->tpl->setVariable("BTN_VALUE",$value);
02251 $this->tpl->parseCurrentBlock();
02252 }
02253 }
02254
02262 function addRoleObject()
02263 {
02264 global $rbacadmin, $rbacreview, $rbacsystem;
02265
02266
02267 if ($rbacreview->roleExists($_POST["Fobject"]["title"]))
02268 {
02269 $this->ilias->raiseError($this->lng->txt("msg_role_exists1")." '".ilUtil::stripSlashes($_POST["Fobject"]["title"])."' ".
02270 $this->lng->txt("msg_role_exists2"),$this->ilias->error_obj->MESSAGE);
02271 }
02272
02273
02274 if (substr($_POST["Fobject"]["title"],0,3) == "il_")
02275 {
02276 $this->ilias->raiseError($this->lng->txt("msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
02277 }
02278
02279
02280 if ($this->object->getType() != "rolf")
02281 {
02282 $rolf_data = $rbacreview->getRoleFolderOfObject($this->ref_id);
02283
02284
02285 if (!($rolf_id = $rolf_data["child"]))
02286 {
02287
02288 $subobjects = $this->objDefinition->getSubObjects($this->object->getType());
02289
02290 if (!isset($subobjects["rolf"]))
02291 {
02292 $this->ilias->raiseError($this->lng->txt("msg_no_rolf_allowed1")." '".$this->object->getTitle()."' ".
02293 $this->lng->txt("msg_no_rolf_allowed2"),$this->ilias->error_obj->WARNING);
02294 }
02295
02296
02297 if (!$rbacsystem->checkAccess('create',$this->ref_id,'rolf'))
02298 {
02299 $this->ilias->raiseError($this->lng->txt("msg_no_perm_create_rolf"),$this->ilias->error_obj->WARNING);
02300 }
02301
02302
02303 $rolfObj = $this->object->createRoleFolder();
02304 $rolf_id = $rolfObj->getRefId();
02305 }
02306 }
02307 else
02308 {
02309
02310 $rolf_id = $this->object->getRefId();
02311 }
02312
02313 if ($this->object->getType() == "rolf")
02314 {
02315 $roleObj = $this->object->createRole($_POST["Fobject"]["title"],$_POST["Fobject"]["desc"]);
02316 }
02317 else
02318 {
02319 $rfoldObj = $this->ilias->obj_factory->getInstanceByRefId($rolf_id);
02320 $roleObj = $rfoldObj->createRole($_POST["Fobject"]["title"],$_POST["Fobject"]["desc"]);
02321 }
02322
02323 sendInfo($this->lng->txt("role_added"),true);
02324
02325 if ($this->ctrl->getTargetScript() != "repository.php")
02326 {
02327 $this->ctrl->setParameter($this,"obj_id",$roleObj->getId());
02328 $this->ctrl->setParameter($this,"ref_id",$rolf_id);
02329 ilUtil::redirect($this->getReturnLocation("addRole",$this->ctrl->getLinkTarget($this,"perm")));
02330 }
02331
02332 ilUtil::redirect($this->getReturnLocation("addRole",$this->ctrl->getLinkTarget($this,"perm")));
02333 }
02334
02341 function showActions($with_subobjects = false)
02342 {
02343 $notoperations = array();
02344
02345 if (empty($_SESSION["clipboard"]))
02346 {
02347 $notoperations[] = "copy";
02348 $notoperations[] = "paste";
02349 $notoperations[] = "clear";
02350 }
02351
02352 if ($_SESSION["clipboard"])
02353 {
02354 $notoperations[] = "cut";
02355 $notoperations[] = "copy";
02356 $notoperations[] = "link";
02357 }
02358
02359 $operations = array();
02360
02361 if ($this->actions == "")
02362 {
02363 $d = $this->objDefinition->getActions($_GET["type"]);
02364 }
02365 else
02366 {
02367 $d = $this->actions;
02368 }
02369
02370 foreach ($d as $row)
02371 {
02372 if (!in_array($row["name"], $notoperations))
02373 {
02374 $operations[] = $row;
02375 }
02376 }
02377
02378 if (count($operations) > 0)
02379 {
02380 foreach ($operations as $val)
02381 {
02382 $this->tpl->setCurrentBlock("tbl_action_btn");
02383 $this->tpl->setVariable("BTN_NAME", $val["name"]);
02384 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
02385 $this->tpl->parseCurrentBlock();
02386 }
02387 }
02388
02389 if ($with_subobjects === true)
02390 {
02391 $this->showPossibleSubObjects();
02392 }
02393
02394 if (!empty($this->ids))
02395 {
02396
02397 $this->tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
02398 $this->tpl->setVariable("JS_VARNAME","id");
02399 $this->tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($this->ids));
02400 $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
02401 $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
02402 $this->tpl->parseCurrentBlock();
02403 }
02404
02405 $this->tpl->setCurrentBlock("tbl_action_row");
02406 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02407 $this->tpl->parseCurrentBlock();
02408 }
02409
02415 function showPossibleSubObjects()
02416 {
02417 if ($this->sub_objects == "")
02418 {
02419 $d = $this->objDefinition->getCreatableSubObjects($_GET["type"]);
02420 }
02421 else
02422 {
02423 $d = $this->sub_objects;
02424 }
02425
02426 $import = false;
02427
02428 if (count($d) > 0)
02429 {
02430 foreach ($d as $row)
02431 {
02432 $count = 0;
02433
02434 if ($row["max"] > 0)
02435 {
02436
02437 for ($i=0; $i<count($this->data["ctrl"]); $i++)
02438 {
02439 if ($this->data["ctrl"][$i]["type"] == $row["name"])
02440 {
02441 $count++;
02442 }
02443 }
02444 }
02445
02446 if ($row["max"] == "" || $count < $row["max"])
02447 {
02448 $subobj[] = $row["name"];
02449
02450 if ($row["import"] == "1")
02451 {
02452 $import = true;
02453 }
02454 }
02455 }
02456 }
02457
02458 if (is_array($subobj))
02459 {
02460
02461
02462 if ($import)
02463 {
02464 $this->tpl->setCurrentBlock("import_object");
02465 $this->tpl->setVariable("BTN_IMP", "import");
02466 $this->tpl->setVariable("TXT_IMP", $this->lng->txt("import"));
02467 $this->tpl->parseCurrentBlock();
02468 }
02469
02470
02471 $opts = ilUtil::formSelect(12,"new_type",$subobj);
02472 $this->tpl->setCurrentBlock("add_object");
02473 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
02474 $this->tpl->setVariable("BTN_NAME", "create");
02475 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
02476 $this->tpl->parseCurrentBlock();
02477 }
02478 }
02479
02488 function getTemplateFile($a_cmd,$a_type = "")
02489 {
02490 if (!$a_type)
02491 {
02492 $a_type = $this->type;
02493 }
02494
02495 $template = "tpl.".$a_type."_".$a_cmd.".html";
02496
02497 if (!$this->tpl->fileExists($template))
02498 {
02499 $template = "tpl.obj_".$a_cmd.".html";
02500 }
02501 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", $template,$a_in_module);
02502
02503 }
02504
02513 function getTitlesByRefId($a_ref_ids)
02514 {
02515 foreach ($a_ref_ids as $id)
02516 {
02517
02518 $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($id);
02519 $title[] = $tmp_obj->getTitle();
02520 unset($tmp_obj);
02521 }
02522
02523 return $title ? $title : array();
02524 }
02525
02533 function getTabs(&$tabs_gui)
02534 {
02535
02536
02537 }
02538
02539
02540 function __showButton($a_cmd,$a_text,$a_target = '')
02541 {
02542 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02543
02544
02545 $this->tpl->setCurrentBlock("btn_cell");
02546 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
02547 $this->tpl->setVariable("BTN_TXT",$a_text);
02548 if($a_target)
02549 {
02550 $this->tpl->setVariable("BTN_TARGET",$a_target);
02551 }
02552
02553 $this->tpl->parseCurrentBlock();
02554 }
02555
02556 function hitsperpageObject()
02557 {
02558 $_SESSION["tbl_limit"] = $_POST["hitsperpage"];
02559 $_GET["limit"] = $_POST["hitsperpage"];
02560 }
02561
02562
02563 function &__initTableGUI()
02564 {
02565 include_once "./classes/class.ilTableGUI.php";
02566
02567 return new ilTableGUI(0,false);
02568 }
02569
02575 function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
02576 {
02577 switch ($a_from)
02578 {
02579 case "clipboardObject":
02580 $offset = $_GET["offset"];
02581 $order = $_GET["sort_by"];
02582 $direction = $_GET["sort_order"];
02583 $tbl->disable("footer");
02584 break;
02585
02586 default:
02587 $offset = $_GET["offset"];
02588 $order = $_GET["sort_by"];
02589 $direction = $_GET["sort_order"];
02590 break;
02591 }
02592
02593 $tbl->setOrderColumn($order);
02594 $tbl->setOrderDirection($direction);
02595 $tbl->setOffset($offset);
02596 $tbl->setLimit($_GET["limit"]);
02597 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02598 $tbl->setData($result_set);
02599 }
02600
02601 function __showClipboardTable($a_result_set,$a_from = "")
02602 {
02603 $tbl =& $this->__initTableGUI();
02604 $tpl =& $tbl->getTemplateObject();
02605
02606 $tpl->setCurrentBlock("tbl_form_header");
02607 $tpl->setVariable("FORMACTION",$this->ctrl->getTargetScript()."?".$this->link_params."&cmd=post");
02608 $tpl->parseCurrentBlock();
02609
02610 $tpl->setCurrentBlock("tbl_action_btn");
02611 $tpl->setVariable("BTN_NAME","paste");
02612 $tpl->setVariable("BTN_VALUE",$this->lng->txt("insert_object_here"));
02613 $tpl->parseCurrentBlock();
02614
02615 $tpl->setCurrentBlock("tbl_action_btn");
02616 $tpl->setVariable("BTN_NAME","clear");
02617 $tpl->setVariable("BTN_VALUE",$this->lng->txt("clear_clipboard"));
02618 $tpl->parseCurrentBlock();
02619
02620 $tpl->setCurrentBlock("tbl_action_row");
02621 $tpl->setVariable("COLUMN_COUNTS",3);
02622 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("spacer.gif"));
02623 $tpl->parseCurrentBlock();
02624
02625 $tbl->setTitle($this->lng->txt("clipboard"),"icon_typ_b.gif",$this->lng->txt("clipboard"));
02626 $tbl->setHeaderNames(array($this->lng->txt('obj_type'),
02627 $this->lng->txt('title'),
02628 $this->lng->txt('action')));
02629 $tbl->setHeaderVars(array('type',
02630 'title',
02631 'act'),
02632 array('ref_id' => $this->object->getRefId(),
02633 'cmd' => 'clipboard',
02634 'cmdClass' => $_GET['cmdClass'],
02635 'cmdNode' => $_GET['cmdNode']));
02636
02637 $tbl->setColumnWidth(array("","80%","19%"));
02638
02639
02640 $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from);
02641 $tbl->render();
02642
02643 $this->tpl->setVariable("RESULT_TABLE",$tbl->tpl->get());
02644
02645 return true;
02646 }
02647
02648 function infoObject()
02649 {
02650
02651
02652 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02653
02654
02655 $this->tpl->setCurrentBlock("btn_cell");
02656 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this, "perm"));
02657 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("permission_settings"));
02658 $this->tpl->parseCurrentBlock();
02659
02660 $this->tpl->setCurrentBlock("btn_cell");
02661 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this, "info"));
02662 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("info_status_info"));
02663 $this->tpl->parseCurrentBlock();
02664
02665 include_once('classes/class.ilObjectStatusGUI.php');
02666
02667 $ilInfo = new ilObjectStatusGUI($this->object);
02668
02669 $this->tpl->setVariable("ADM_CONTENT",$ilInfo->getHTML());
02670 }
02671 }
02672 ?>