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