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
00038 require_once "class.ilObjectGUI.php";
00039
00040 class ilContainerGUI extends ilObjectGUI
00041 {
00046 function ilContainerGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00047 {
00048 global $rbacsystem;
00049
00050 $this->rbacsystem =& $rbacsystem;
00051
00052
00053
00054
00055
00056 $this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
00057 }
00058
00063 function &executeCommand()
00064 {
00065 $next_class = $this->ctrl->getNextClass();
00066 $cmd = $this->ctrl->getCmd("render");
00067
00068 switch($next_class)
00069 {
00070 default:
00071 $this->prepareOutput();
00072 $cmd .= "Object";
00073 $this->$cmd();
00074
00075 break;
00076 }
00077 return true;
00078 }
00079
00083 function prepareOutput()
00084 {
00085 if (parent::prepareOutput())
00086 {
00087 if ($this->getCreationMode() != true)
00088 {
00089
00090 #$this->showPossibleSubObjects();
00091 $this->showTreeFlatIcon();
00092 }
00093 }
00094 }
00095
00096 function showTreeFlatIcon()
00097 {
00098 global $tpl;
00099
00100
00101 if ($_GET["obj_id"] != "")
00102 {
00103 return;
00104 }
00105
00106 $mode = ($_SESSION["il_rep_mode"] == "flat")
00107 ? "tree"
00108 : "flat";
00109 $link = "repository.php?cmd=frameset&set_mode=".$mode."&ref_id=".$this->object->getRefId();
00110 $tpl->setTreeFlatIcon($link, $mode);
00111 }
00112
00116 function setTitleAndDescription()
00117 {
00118 global $ilias;
00119
00120 $this->tpl->setTitle($this->object->getTitle());
00121 $this->tpl->setDescription($this->object->getLongDescription());
00122
00123
00124 $icon = ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif");
00125 if ($ilias->getSetting("custom_icons") &&
00126 in_array($this->object->getType(), array("cat","grp","crs")))
00127 {
00128 require_once("classes/class.ilContainer.php");
00129 if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
00130 {
00131 $icon = $path;
00132 }
00133 }
00134 $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
00135 }
00136
00137
00141 function showPossibleSubObjects()
00142 {
00143 $found = false;
00144 $cmd = ($this->cmd != "")
00145 ? $this->cmd
00146 : $this->ctrl->getCmd();
00147
00148 #if ($cmd != "" && $cmd != "showList" && $cmd != "render"
00149 # && $cmd != "view")
00150 #{
00151 # return;
00152 #}
00153
00154 $type = $this->object->getType();
00155
00156 $d = $this->objDefinition->getCreatableSubObjects($type);
00157
00158 if (count($d) > 0)
00159 {
00160 foreach ($d as $row)
00161 {
00162 $count = 0;
00163 if ($row["max"] > 0)
00164 {
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 }
00177
00178 if ($row["max"] == "" || $count < $row["max"])
00179 {
00180 if (in_array($row["name"], array("sahs", "alm", "hlm", "lm", "grp", "frm", "mep","crs",
00181 "cat", "glo", "dbk","exc", "qpl", "tst", "svy", "spl", "chat",
00182 "htlm","fold","linkr","file","icrs","icla","crsg",'webr')))
00183 {
00184 if ($this->rbacsystem->checkAccess("create", $this->object->getRefId(), $row["name"]))
00185 {
00186 $subobj[] = $row["name"];
00187 }
00188 }
00189 }
00190 }
00191 }
00192
00193 if (is_array($subobj))
00194 {
00195 $this->tpl->parseCurrentBlock("add_commands");
00196 $this->tpl->setVariable("H_FORMACTION", "repository.php?ref_id=".$this->object->getRefId().
00197 "&cmd=post");
00198
00199 $opts = ilUtil::formSelect("", "new_type", $subobj);
00200 $this->tpl->setVariable("SELECT_OBJTYPE_REPOS", $opts);
00201 $this->tpl->setVariable("BTN_NAME_REPOS", "create");
00202 $this->tpl->setVariable("TXT_ADD_REPOS", $this->lng->txt("add"));
00203 $this->tpl->parseCurrentBlock();
00204 }
00205 }
00206
00207
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00257 function renderObject()
00258 {
00259 global $ilBench, $tree;
00260
00261
00262 $this->showPossibleSubObjects();
00263
00264
00265
00266 if($this->type != 'icrs' and $tree->checkForParentType($this->ref_id,'crs'))
00267 {
00268 $this->initCourseContentInterface();
00269 $this->cci_obj->cci_setContainer($this);
00270 $this->cci_obj->cci_view();
00271
00272 return;
00273 }
00274
00275
00276 $ilBench->start("ilContainerGUI", "0000__renderObject");
00277
00278 $tpl = new ilTemplate ("tpl.container_page.html", true, true);
00279
00280
00281 $ilBench->start("ilContainerGUI", "0100_getSubItems");
00282 $this->getSubItems();
00283 $ilBench->stop("ilContainerGUI", "0100_getSubItems");
00284
00285 $ilBench->start("ilContainerGUI", "0200_renderItemList");
00286 $html = $this->renderItemList();
00287 $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
00288 $ilBench->stop("ilContainerGUI", "0200_renderItemList");
00289
00290 $this->showAdministrationPanel($tpl);
00291
00292 $this->html = $tpl->get();
00293
00294 $ilBench->stop("ilContainerGUI", "0000__renderObject");
00295 }
00296
00300 function showAdministrationPanel(&$tpl)
00301 {
00302 if ($this->isActiveAdministrationPanel())
00303 {
00304 $tpl->setCurrentBlock("admin_button_off");
00305 $tpl->setVariable("ADMIN_MODE_LINK",
00306 $this->ctrl->getLinkTarget($this, "disableAdministrationPanel"));
00307 $tpl->setVariable("TXT_ADMIN_MODE",
00308 $this->lng->txt("admin_panel_disable"));
00309 $tpl->parseCurrentBlock();
00310
00311
00312 $tpl->setCurrentBlock("admin_panel_cmd");
00313 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("delete_selected_items"));
00314 $tpl->setVariable("PANEL_CMD", "delete");
00315 $tpl->parseCurrentBlock();
00316 if (!$_SESSION["clipboard"])
00317 {
00318 $tpl->setCurrentBlock("admin_panel_cmd");
00319 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("move_selected_items"));
00320 $tpl->setVariable("PANEL_CMD", "cut");
00321 $tpl->parseCurrentBlock();
00322 $tpl->setCurrentBlock("admin_panel_cmd");
00323 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("link_selected_items"));
00324 $tpl->setVariable("PANEL_CMD", "link");
00325 $tpl->parseCurrentBlock();
00326 }
00327 else
00328 {
00329 $tpl->setCurrentBlock("admin_panel_cmd");
00330 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("paste_clipboard_items"));
00331 $tpl->setVariable("PANEL_CMD", "paste");
00332 $tpl->parseCurrentBlock();
00333 $tpl->setCurrentBlock("admin_panel_cmd");
00334 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("clear_clipboard"));
00335 $tpl->setVariable("PANEL_CMD", "clear");
00336 $tpl->parseCurrentBlock();
00337 }
00338 $tpl->setCurrentBlock("admin_panel");
00339 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00340 $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
00341 $tpl->setVariable("TXT_ADMIN_PANEL", $this->lng->txt("admin_panel"));
00342 $tpl->parseCurrentBlock();
00343 $this->ctrl->setParameter($this, "type", "");
00344 $this->ctrl->setParameter($this, "item_ref_id", "");
00345 $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00346 }
00347 else if ($this->adminCommands)
00348 {
00349 $tpl->setCurrentBlock("admin_button");
00350 $tpl->setVariable("ADMIN_MODE_LINK",
00351 $this->ctrl->getLinkTarget($this, "enableAdministrationPanel"));
00352 $tpl->setVariable("TXT_ADMIN_MODE",
00353 $this->lng->txt("admin_panel_enable"));
00354 $tpl->parseCurrentBlock();
00355 }
00356 }
00357
00361 function getSubItems()
00362 {
00363 global $objDefinition, $ilBench;
00364
00365 $objects = $this->tree->getChilds($this->object->getRefId(), "title");
00366
00367 $found = false;
00368
00369 foreach ($objects as $key => $object)
00370 {
00371
00372
00373 if ($objDefinition->getDevMode($object["type"]))
00374 {
00375 continue;
00376 }
00377
00378
00379
00380 switch ($object["type"])
00381 {
00382
00383 case "sahs":
00384 case "lm":
00385 case "dbk":
00386 case "htlm":
00387 $type = "lres";
00388 break;
00389
00390 default:
00391 $type = $object["type"];
00392 break;
00393 }
00394
00395 $this->items[$type][$key] = $object;
00396 }
00397 }
00398
00399 function renderItemList($a_type = "all")
00400 {
00401 global $objDefinition, $ilBench;
00402
00403 include_once("classes/class.ilObjectListGUIFactory.php");
00404
00405 $html = "";
00406 $this->clearAdminCommandsDetermination();
00407
00408 switch ($a_type)
00409 {
00410
00411 case "all":
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 $type_ordering = array(
00427 "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
00428 "glo", "webr", "file", "exc",
00429 "tst", "svy", "mep", "qpl", "spl");
00430
00431 $cur_obj_type = "";
00432 $tpl =& $this->newBlockTemplate();
00433 $first = true;
00434 foreach ($type_ordering as $type)
00435 {
00436 $item_html = array();
00437
00438 if (is_array($this->items[$type]))
00439 {
00440 foreach($this->items[$type] as $key => $item)
00441 {
00442
00443 if ($cur_obj_type != $item["type"])
00444 {
00445
00446
00447
00448
00449
00450
00451 $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
00452 $item_list_gui->setContainerObject($this);
00453 }
00454
00455 $ilBench->start("ilContainerGUI", "0210_getListHTML");
00456
00457
00458 if (!$this->isActiveAdministrationPanel())
00459 {
00460 $item_list_gui->enableDelete(false);
00461 $item_list_gui->enableLink(false);
00462 $item_list_gui->enableCut(false);
00463 }
00464
00465 $html = $item_list_gui->getListItemHTML($item["ref_id"],
00466 $item["obj_id"], $item["title"], $item["description"]);
00467
00468
00469
00470 $this->determineAdminCommands($item["ref_id"],
00471 $item_list_gui->adminCommandsIncluded());
00472 $ilBench->stop("ilContainerGUI", "0210_getListHTML");
00473 if ($html != "")
00474 {
00475 $item_html[] = array("html" => $html, "item_ref_id" => $item["ref_id"]
00476 , "item_obj_id" => $item["obj_id"]);
00477 }
00478 }
00479
00480
00481 if (count($item_html) > 0)
00482 {
00483
00484 if (!$first)
00485 {
00486 $this->addSeparatorRow($tpl);
00487 }
00488 $first = false;
00489
00490
00491 if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
00492 {
00493 $this->addHeaderRow($tpl, $type, false);
00494 }
00495 else
00496 {
00497 $this->addHeaderRow($tpl, $type);
00498 }
00499 $this->resetRowType();
00500
00501
00502 foreach($item_html as $item)
00503 {
00504 if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
00505 {
00506 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $type);
00507 }
00508 else
00509 {
00510 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"]);
00511 }
00512 }
00513 }
00514 }
00515 }
00516 $html = $tpl->get();
00517
00518 break;
00519
00520 default:
00521
00522 break;
00523 }
00524
00525 return $html;
00526 }
00527
00531 function clearAdminCommandsDetermination()
00532 {
00533 $this->adminCommands = false;
00534 }
00535
00539 function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
00540 {
00541 if (!$this->adminCommands)
00542 {
00543 if (!$this->isActiveAdministrationPanel())
00544 {
00545 if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
00546 {
00547 $this->adminCommands = true;
00548 }
00549 }
00550 else
00551 {
00552 $this->adminCommands = $a_admin_com_included_in_list;
00553 }
00554 }
00555 }
00556
00563 function &newBlockTemplate()
00564 {
00565 $tpl = new ilTemplate ("tpl.container_list_block.html", true, true);
00566 $this->cur_row_type = "row_type_1";
00567 return $tpl;
00568 }
00569
00577 function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
00578 {
00579 if ($a_type != "lres")
00580 {
00581 $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
00582 $title = $this->lng->txt("objs_".$a_type);
00583 }
00584 else
00585 {
00586 $icon = ilUtil::getImagePath("icon_lm.gif");
00587 $title = $this->lng->txt("learning_resources");
00588 }
00589
00590 if ($a_show_image)
00591 {
00592 $a_tpl->setCurrentBlock("container_header_row_image");
00593 $a_tpl->setVariable("HEADER_IMG", $icon);
00594 $a_tpl->setVariable("HEADER_ALT", $title);
00595 }
00596 else
00597 {
00598 $a_tpl->setCurrentBlock("container_header_row");
00599 }
00600
00601 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00602 $a_tpl->parseCurrentBlock();
00603 $a_tpl->touchBlock("container_row");
00604 }
00605
00613 function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
00614 $a_image_type = "")
00615 {
00616 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00617 ? "row_type_2"
00618 : "row_type_1";
00619
00620 $a_tpl->touchBlock($this->cur_row_type);
00621
00622 $nbsp = true;
00623 if ($a_image_type != "")
00624 {
00625 if ($a_image_type != "lres")
00626 {
00627 $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
00628 $alt = $this->lng->txt("obj_".$a_image_type);
00629 }
00630 else
00631 {
00632 $icon = ilUtil::getImagePath("icon_lm.gif");
00633 $alt = $this->lng->txt("learning_resource");
00634 }
00635
00636
00637 if ($this->ilias->getSetting("custom_icons") &&
00638 in_array($a_image_type, array("cat","grp","crs")))
00639 {
00640 require_once("classes/class.ilContainer.php");
00641 if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
00642 {
00643 $icon = $path;
00644 }
00645 }
00646
00647 $a_tpl->setCurrentBlock("block_row_image");
00648 $a_tpl->setVariable("ROW_IMG", $icon);
00649 $a_tpl->setVariable("ROW_ALT", $alt);
00650 $a_tpl->parseCurrentBlock();
00651 $nbsp = false;
00652 }
00653
00654 if ($this->isActiveAdministrationPanel())
00655 {
00656 $a_tpl->setCurrentBlock("block_row_check");
00657 $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
00658 $a_tpl->parseCurrentBlock();
00659 $nbsp = false;
00660 }
00661 if ($nbsp)
00662 {
00663 $a_tpl->setVariable("ROW_NBSP", " ");
00664 }
00665 $a_tpl->setCurrentBlock("container_standard_row");
00666 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
00667 $a_tpl->parseCurrentBlock();
00668 $a_tpl->touchBlock("container_row");
00669 }
00670
00671 function resetRowType()
00672 {
00673 $this->cur_row_type = "";
00674 }
00675
00676 function addSeparatorRow(&$a_tpl)
00677 {
00678 $a_tpl->touchBlock("separator_row");
00679 $a_tpl->touchBlock("container_row");
00680 }
00681
00686 function getTabs(&$tabs_gui)
00687 {
00688 global $rbacsystem;
00689
00690
00691 if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
00692 {
00693 $tabs_gui->addTarget("perm_settings",
00694 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00695 }
00696
00697
00698 if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION["clipboard"]))
00699 {
00700 $tabs_gui->addTarget("clipboard",
00701 $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
00702 }
00703
00704 }
00705
00706
00707
00708
00709
00710
00714 function enableAdministrationPanelObject()
00715 {
00716 $_SESSION["il_cont_admin_panel"] = true;
00717 $this->ctrl->redirect($this, "render");
00718 }
00719
00723 function disableAdministrationPanelObject()
00724 {
00725 $_SESSION["il_cont_admin_panel"] = false;
00726 $this->ctrl->redirect($this, "render");
00727 }
00728
00732 function addToDeskObject()
00733 {
00734 if ($_GET["item_ref_id"] and $_GET["type"])
00735 {
00736 $this->ilias->account->addDesktopItem($_GET["item_ref_id"], $_GET["type"]);
00737 }
00738 else
00739 {
00740 if ($_POST["items"])
00741 {
00742 foreach ($_POST["items"] as $item)
00743 {
00744 $type = ilObject::_lookupType($item, true);
00745 $this->ilias->account->addDesktopItem($item, $type);
00746 unset($tmp_obj);
00747 }
00748 }
00749 }
00750 $this->renderObject();
00751 }
00752
00756 function removeFromDeskObject()
00757 {
00758 if ($_GET["item_ref_id"] and $_GET["type"])
00759 {
00760 $this->ilias->account->dropDesktopItem($_GET["item_ref_id"], $_GET["type"]);
00761 }
00762 else
00763 {
00764 if ($_POST["items"])
00765 {
00766 foreach ($_POST["items"] as $item)
00767 {
00768 $type = ilObject::_lookupType($item, true);
00769 $this->ilias->account->dropDesktopItem($item, $type);
00770 unset($tmp_obj);
00771 }
00772 }
00773 }
00774 $this->renderObject();
00775 }
00776
00777
00784 function cutObject()
00785 {
00786 global $rbacsystem;
00787
00788 if ($_GET["item_ref_id"] != "")
00789 {
00790 $_POST["id"] = array($_GET["item_ref_id"]);
00791 }
00792
00793
00794
00795
00796
00797 if (!isset($_POST["id"]))
00798 {
00799 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00800 }
00801
00802
00803 foreach ($_POST["id"] as $ref_id)
00804 {
00805
00806 $node_data = $this->tree->getNodeData($ref_id);
00807 $subtree_nodes = $this->tree->getSubTree($node_data);
00808
00809 $all_node_data[] = $node_data;
00810 $all_subtree_nodes[] = $subtree_nodes;
00811
00812
00813 foreach ($subtree_nodes as $node)
00814 {
00815 if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
00816 {
00817 $no_cut[] = $node["ref_id"];
00818 }
00819 }
00820 }
00821
00822 if (count($no_cut))
00823 {
00824 $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
00825 $this->ilias->error_obj->MESSAGE);
00826 }
00827
00828 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
00829 $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
00830 ? $_GET["cmd"]
00831 : key($_POST["cmd"]);
00832
00833 $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
00834
00835
00836 sendinfo($this->lng->txt("msg_cut_clipboard"),true);
00837
00838 $this->ctrl->returnToParent($this);
00839
00840 }
00841
00842
00849 function linkObject()
00850 {
00851 global $clipboard, $rbacsystem, $rbacadmin;
00852
00853 if ($_GET["item_ref_id"] != "")
00854 {
00855 $_POST["id"] = array($_GET["item_ref_id"]);
00856 }
00857
00858 if (!isset($_POST["id"]))
00859 {
00860 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00861 }
00862
00863
00864 foreach ($_POST["id"] as $ref_id)
00865 {
00866 if (!$rbacsystem->checkAccess('delete',$ref_id))
00867 {
00868 $no_cut[] = $ref_id;
00869 }
00870
00871 $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
00872
00873 if (!$this->objDefinition->allowLink($object->getType()))
00874 {
00875 $no_link[] = $object->getType();
00876 }
00877 }
00878
00879
00880 if (count($no_cut))
00881 {
00882 $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
00883 implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
00884 }
00885
00886 if (count($no_link))
00887 {
00888 $no_link = array_unique($no_link);
00889
00890 foreach ($no_link as $type)
00891 {
00892 $txt_objs[] = $this->lng->txt("objs_".$type);
00893 }
00894
00895 $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
00896
00897
00898
00899 }
00900
00901
00902 $clipboard["parent"] = $_GET["ref_id"];
00903 $clipboard["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
00904 ? $_GET["cmd"]
00905 : key($_POST["cmd"]);
00906
00907 foreach ($_POST["id"] as $ref_id)
00908 {
00909 $clipboard["ref_ids"][] = $ref_id;
00910 }
00911
00912 $_SESSION["clipboard"] = $clipboard;
00913
00914 sendinfo($this->lng->txt("msg_link_clipboard"),true);
00915
00916 $this->ctrl->returnToParent($this);
00917
00918 }
00919
00920
00926 function clearObject()
00927 {
00928 unset($_SESSION["clipboard"]);
00929 unset($_SESSION["il_rep_clipboard"]);
00930
00931
00932
00933 if (isset($_POST["cmd"]["clear"]))
00934 {
00935 sendinfo($this->lng->txt("msg_clear_clipboard"),true);
00936
00937 $this->ctrl->returnToParent($this);
00938
00939 }
00940 }
00941
00948 function pasteObject()
00949 {
00950 global $rbacsystem, $rbacadmin, $rbacreview, $log;
00951
00952
00953 if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
00954 {
00955 $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
00956 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00957 }
00958
00959
00960 foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
00961 {
00962 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
00963
00964
00965 if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
00966 {
00967 $no_paste[] = $ref_id;
00968 }
00969
00970
00971 if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
00972 {
00973 $exists[] = $ref_id;
00974 break;
00975 }
00976
00977
00978 if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
00979 {
00980 $is_child[] = $ref_id;
00981 }
00982
00983
00984 $obj_type = $obj_data->getType();
00985
00986 if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
00987 {
00988 $not_allowed_subobject[] = $obj_data->getType();
00989 }
00990 }
00991
00993
00994 if (count($exists))
00995 {
00996 $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
00997 }
00998
00999 if (count($is_child))
01000 {
01001 $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
01002 $this->ilias->error_obj->MESSAGE);
01003 }
01004
01005 if (count($not_allowed_subobject))
01006 {
01007 $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
01008 $this->ilias->error_obj->MESSAGE);
01009 }
01010
01011 if (count($no_paste))
01012 {
01013 $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
01014 implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
01015 }
01016
01017
01018 $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
01019
01021
01022
01023
01024 $ref_ids = $_SESSION["clipboard"]["ref_ids"];
01025 unset($_SESSION["clipboard"]["ref_ids"]);
01026
01027
01028 if ($_SESSION["clipboard"]["cmd"] == "copy")
01029 {
01030
01031 $this->cloneObject($ref_ids);
01032 }
01033
01034
01035 if ($_SESSION["clipboard"]["cmd"] == "cut")
01036 {
01037
01038 foreach($ref_ids as $ref_id)
01039 {
01040
01041 $top_node = $this->tree->getNodeData($ref_id);
01042
01043
01044 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
01045 }
01046
01047
01048 $log->write("ilObjectGUI::pasteObject(), (1/3) move subtrees to trash");
01049
01050 foreach($ref_ids as $ref_id)
01051 {
01052 $tnodes = $this->tree->getSubtree($this->tree->getNodeData($ref_id));
01053
01054 foreach ($tnodes as $tnode)
01055 {
01056 $rbacadmin->revokePermission($tnode["child"],0,false);
01057
01058
01059
01060
01061 }
01062
01063 $this->tree->saveSubTree($ref_id);
01064 $this->tree->deleteTree($this->tree->getNodeData($ref_id));
01065 }
01066
01067
01068 $log->write("ilObjectGUI::pasteObject(), (2/3) move subtrees to new location");
01069
01070
01071 foreach ($subnodes as $key => $subnode)
01072 {
01073 $log->write("ilObjectGUI::pasteObject(), 0");
01074
01075 $rbacadmin->revokePermission($key,0,false);
01076 $log->write("ilObjectGUI::pasteObject(), 1");
01077 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
01078 $log->write("ilObjectGUI::pasteObject(), 2");
01079 $obj_data->putInTree($this->object->getRefId());
01080 $log->write("ilObjectGUI::pasteObject(), 3");
01081 $obj_data->setPermissions($key);
01082 $log->write("ilObjectGUI::pasteObject(), 4");
01083
01084 $log->write("ilObjectGUI::pasteObject(), inserted top node. ref_id: $key,".
01085 " rgt: ".$subnode[0]["rgt"].", lft: ".$subnode[0]["lft"].", parent: ".$subnode[0]["parent"].",".
01086 " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
01087 ", title: ".$obj_data->getTitle());
01088
01089
01090 array_shift($subnode);
01091
01092
01093 if (count($subnode) > 0)
01094 {
01095 foreach ($subnode as $node)
01096 {
01097 $rbacadmin->revokePermission($node["child"],0,false);
01098 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
01099 $obj_data->putInTree($node["parent"]);
01100 $obj_data->setPermissions($node["parent"]);
01101
01102
01103 $log->write("ilObjectGUI::pasteObject(), inserted subnode. ref_id: ".$node["child"].",".
01104 " rgt: ".$node["rgt"].", lft: ".$node["lft"].", parent: ".$node["parent"].",".
01105 " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
01106 ", title: ".$obj_data->getTitle());
01107 }
01108 }
01109 }
01110
01111
01112 $log->write("ilObjectGUI::pasteObject(), (3/3) remove trashed subtrees from system");
01113
01114 foreach ($ref_ids as $ref_id)
01115 {
01116
01117 $saved_tree = new ilTree(-(int)$ref_id);
01118 $node_data = $saved_tree->getNodeData($ref_id);
01119 $subtree_nodes = $saved_tree->getSubTree($node_data);
01120
01121
01122 $checked[] = -(int) $ref_id;
01123
01124
01125 $this->removeDeletedNodes($ref_id, $checked, false);
01126
01127
01128 $this->tree->deleteTree($node_data);
01129
01130
01131 $log->write("ilObjectGUI::pasteObject(), deleted tree, tree_id: ".$node_data["tree"].
01132 ", child: ".$node_data["child"]);
01133 }
01134
01135
01136 $log->write("ilObjectGUI::pasteObject(), cut finished");
01137
01138
01139
01140
01141
01142
01143 $tmp_object = $this->ilias->obj_factory->getInstanceByRefId($_SESSION["clipboard"]["parent"]);
01144
01145 unset($tmp_object);
01146 }
01147
01148
01149 if ($_SESSION["clipboard"]["cmd"] == "link")
01150 {
01151 foreach ($ref_ids as $ref_id)
01152 {
01153
01154 $top_node = $this->tree->getNodeData($ref_id);
01155
01156
01157 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
01158 }
01159
01160
01161 foreach ($subnodes as $key => $subnode)
01162 {
01163
01164 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
01165 $new_ref_id = $obj_data->createReference();
01166 $obj_data->putInTree($_GET["ref_id"]);
01167 $obj_data->setPermissions($_GET["ref_id"]);
01168
01169
01170 array_shift($subnode);
01171
01172
01173 $mapping[$new_ref_id] = $key;
01174
01175
01176 $old_ref_id = $obj_data->getRefId();
01177 $obj_data->setRefId($new_ref_id);
01178 $obj_data->initDefaultRoles();
01179 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
01180
01181 if (isset($rolf_data["child"]))
01182 {
01183
01184 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
01185
01186
01187
01188
01189 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
01190
01191
01192 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
01193 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
01194 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
01195
01196 }
01197
01198
01199 if (count($subnode) > 0)
01200 {
01201 foreach ($subnode as $node)
01202 {
01203 if ($node["type"] != 'rolf')
01204 {
01205 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
01206 $new_ref_id = $obj_data->createReference();
01207
01208
01209 $new_parent = array_search($node["parent"],$mapping);
01210
01211 $mapping[$new_ref_id] = (int) $node["child"];
01212
01213 $obj_data->putInTree($new_parent);
01214 $obj_data->setPermissions($new_parent);
01215
01216
01217 $old_ref_id = $obj_data->getRefId();
01218 $obj_data->setRefId($new_ref_id);
01219 $obj_data->initDefaultRoles();
01220 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
01221
01222 if (isset($rolf_data["child"]))
01223 {
01224
01225 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
01226
01227
01228
01229
01230 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
01231
01232
01233 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
01234 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
01235 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
01236
01237 }
01238 }
01239
01240
01241 foreach ($subnodes as $old_ref => $subnode)
01242 {
01243 $new_ref = array_search($old_ref,$mapping);
01244
01245 foreach ($subnode as $node)
01246 {
01247 $node["child"] = array_search($node["child"],$mapping);
01248 $node["parent"] = array_search($node["parent"],$mapping);
01249 $new_subnodes[$ref_id][] = $node;
01250 }
01251 }
01252
01253 }
01254 }
01255 }
01256
01257 $log->write("ilObjectGUI::pasteObject(), link finished");
01258
01259
01260
01261 }
01262
01263
01264 $last_cmd = $_SESSION["clipboard"]["cmd"];
01265
01266
01267
01268 $this->clearObject();
01269
01270 if ($last_cmd == "cut")
01271 {
01272 sendInfo($this->lng->txt("msg_cut_copied"),true);
01273 }
01274 else
01275 {
01276 sendInfo($this->lng->txt("msg_linked"),true);
01277 }
01278
01279 $this->ctrl->returnToParent($this);
01280
01281 }
01282
01283
01284
01288 function clipboardObject()
01289 {
01290 global $ilErr,$ilLog;
01291
01292
01293 if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
01294 {
01295 $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
01296 $ilLog->write($message,$ilLog->FATAL);
01297 $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
01298 }
01299
01300 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html");
01301
01302
01303 $counter = 0;
01304 $f_result = array();
01305
01306 foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
01307 {
01308 if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
01309 {
01310 continue;
01311 }
01312
01313
01314 $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
01315 $f_result[$counter][] = $tmp_obj->getTitle();
01316
01317 $f_result[$counter][] = ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]);
01318
01319 unset($tmp_obj);
01320 ++$counter;
01321 }
01322
01323 $this->__showClipboardTable($f_result, "clipboardObject");
01324
01325 return true;
01326 }
01327
01328
01333 function showCustomIconsEditing($a_input_colspan = 1)
01334 {
01335 if ($this->ilias->getSetting("custom_icons"))
01336 {
01337 $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
01338 "tpl.container_icon_settings.html");
01339
01340 if (($big_icon = $this->object->getBigIconPath()) != "")
01341 {
01342 $this->tpl->setCurrentBlock("big_icon");
01343 $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
01344 $this->tpl->parseCurrentBlock();
01345 }
01346 if (($small_icon = $this->object->getSmallIconPath()) != "")
01347 {
01348 $this->tpl->setCurrentBlock("small_icon");
01349 $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
01350 $this->tpl->parseCurrentBlock();
01351 }
01352 $this->tpl->setCurrentBlock("container_icon_settings");
01353 $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
01354 $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
01355 $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
01356 $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
01357 $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("small_icon"));
01358 $this->tpl->setVariable("BIG_SIZE", "(".
01359 $this->ilias->getSetting("custom_icon_big_width")."x".
01360 $this->ilias->getSetting("custom_icon_big_height").")");
01361 $this->tpl->setVariable("SMALL_SIZE", "(".
01362 $this->ilias->getSetting("custom_icon_small_width")."x".
01363 $this->ilias->getSetting("custom_icon_small_height").")");
01364 $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
01365 $this->tpl->parseCurrentBlock();
01366 }
01367 }
01368
01369 function isActiveAdministrationPanel()
01370 {
01371 return $_SESSION["il_cont_admin_panel"];
01372 }
01373
01374 }
01375 ?>