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 $this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00053 }
00054
00058 function &executeCommand()
00059 {
00060 $next_class = $this->ctrl->getNextClass();
00061 $cmd = $this->ctrl->getCmd("render");
00062
00063 switch($next_class)
00064 {
00065 default:
00066 $cmd .= "Object";
00067 $this->$cmd();
00068
00069 break;
00070 }
00071 return true;
00072 }
00073
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00123 function renderObject()
00124 {
00125 global $ilBench, $tree;
00126
00127
00128
00129
00130 if($this->type != 'icrs' and $tree->checkForParentType($this->ref_id,'crs'))
00131 {
00132 $this->initCourseContentInterface();
00133 $this->cci_obj->cci_setContainer($this);
00134 $this->cci_obj->cci_view();
00135
00136 return;
00137 }
00138
00139
00140 $ilBench->start("ilContainerGUI", "0000__renderObject");
00141
00142 $tpl = new ilTemplate ("tpl.container_page.html", true, true);
00143
00144
00145 $ilBench->start("ilContainerGUI", "0100_getSubItems");
00146 $this->getSubItems();
00147 $ilBench->stop("ilContainerGUI", "0100_getSubItems");
00148
00149 $ilBench->start("ilContainerGUI", "0200_renderItemList");
00150 $html = $this->renderItemList();
00151 $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
00152 $ilBench->stop("ilContainerGUI", "0200_renderItemList");
00153
00154
00155
00156 if ($this->isActiveAdministrationPanel())
00157 {
00158 $tpl->setCurrentBlock("admin_button_off");
00159 $tpl->setVariable("ADMIN_MODE_LINK",
00160 $this->ctrl->getLinkTarget($this, "disableAdministrationPanel"));
00161 $tpl->setVariable("TXT_ADMIN_MODE",
00162 $this->lng->txt("admin_panel_disable"));
00163 $tpl->parseCurrentBlock();
00164
00165
00166 $tpl->setCurrentBlock("admin_panel_cmd");
00167 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("delete_selected_items"));
00168 $tpl->setVariable("PANEL_CMD", "delete");
00169 $tpl->parseCurrentBlock();
00170 if (!$_SESSION["clipboard"])
00171 {
00172 $tpl->setCurrentBlock("admin_panel_cmd");
00173 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("move_selected_items"));
00174 $tpl->setVariable("PANEL_CMD", "cut");
00175 $tpl->parseCurrentBlock();
00176 $tpl->setCurrentBlock("admin_panel_cmd");
00177 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("link_selected_items"));
00178 $tpl->setVariable("PANEL_CMD", "link");
00179 $tpl->parseCurrentBlock();
00180 }
00181 else
00182 {
00183 $tpl->setCurrentBlock("admin_panel_cmd");
00184 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("paste_clipboard_items"));
00185 $tpl->setVariable("PANEL_CMD", "paste");
00186 $tpl->parseCurrentBlock();
00187 $tpl->setCurrentBlock("admin_panel_cmd");
00188 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("clear_clipboard"));
00189 $tpl->setVariable("PANEL_CMD", "clear");
00190 $tpl->parseCurrentBlock();
00191 }
00192 $tpl->setCurrentBlock("admin_panel");
00193 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00194 $tpl->setVariable("TXT_ADMIN_PANEL", $this->lng->txt("admin_panel"));
00195 $tpl->parseCurrentBlock();
00196 $this->ctrl->setParameter($this, "type", "");
00197 $this->ctrl->setParameter($this, "item_ref_id", "");
00198 $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00199 }
00200 else if ($this->adminCommands)
00201 {
00202 $tpl->setCurrentBlock("admin_button");
00203 $tpl->setVariable("ADMIN_MODE_LINK",
00204 $this->ctrl->getLinkTarget($this, "enableAdministrationPanel"));
00205 $tpl->setVariable("TXT_ADMIN_MODE",
00206 $this->lng->txt("admin_panel_enable"));
00207 $tpl->parseCurrentBlock();
00208 }
00209
00210 $this->html = $tpl->get();
00211
00212 $ilBench->stop("ilContainerGUI", "0000__renderObject");
00213 }
00214
00218 function getSubItems()
00219 {
00220 global $objDefinition, $ilBench;
00221
00222 $objects = $this->tree->getChilds($this->object->getRefId(), "title");
00223
00224 $found = false;
00225
00226 foreach ($objects as $key => $object)
00227 {
00228
00229
00230 if ($objDefinition->getDevMode($object["type"]))
00231 {
00232 continue;
00233 }
00234
00235
00236
00237 switch ($object["type"])
00238 {
00239
00240 case "sahs":
00241 case "lm":
00242 case "dbk":
00243 case "htlm":
00244 $type = "lres";
00245 break;
00246
00247 default:
00248 $type = $object["type"];
00249 break;
00250 }
00251
00252 $this->items[$type][$key] = $object;
00253 }
00254 }
00255
00256 function renderItemList($a_type = "all")
00257 {
00258 global $objDefinition, $ilBench;
00259
00260 include_once("classes/class.ilObjectListGUIFactory.php");
00261
00262 $html = "";
00263 $this->adminCommands = false;
00264
00265 switch ($a_type)
00266 {
00267
00268 case "all":
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 $type_ordering = array(
00284 "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
00285 "glo", "webr", "file", "exc",
00286 "tst", "svy", "mep", "qpl", "spl");
00287
00288 $cur_obj_type = "";
00289 $tpl =& $this->newBlockTemplate();
00290 $first = true;
00291 foreach ($type_ordering as $type)
00292 {
00293 $item_html = array();
00294
00295 if (is_array($this->items[$type]))
00296 {
00297 foreach($this->items[$type] as $key => $item)
00298 {
00299
00300 if ($cur_obj_type != $item["type"])
00301 {
00302
00303
00304
00305
00306
00307
00308 $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
00309 $item_list_gui->setContainerObject($this);
00310 }
00311
00312 $ilBench->start("ilContainerGUI", "0210_getListHTML");
00313 if (!$this->isActiveAdministrationPanel())
00314 {
00315 $item_list_gui->enableDelete(false);
00316 $item_list_gui->enableLink(false);
00317 $item_list_gui->enableCut(false);
00318 }
00319
00320 $html = $item_list_gui->getListItemHTML($item["ref_id"],
00321 $item["obj_id"], $item["title"], $item["description"]);
00322
00323
00324
00325 if (!$this->adminCommands)
00326 {
00327 if (!$this->isActiveAdministrationPanel())
00328 {
00329 if ($this->rbacsystem->checkAccess("delete", $item["ref_id"]))
00330 {
00331 $this->adminCommands = true;
00332 }
00333 }
00334 else
00335 {
00336 $this->adminCommands = $item_list_gui->adminCommandsIncluded();
00337 }
00338 }
00339 $ilBench->stop("ilContainerGUI", "0210_getListHTML");
00340 if ($html != "")
00341 {
00342 $item_html[] = array("html" => $html, "item_id" => $item["ref_id"]);
00343 }
00344 }
00345
00346
00347 if (count($item_html) > 0)
00348 {
00349
00350 if (!$first)
00351 {
00352 $this->addSeparatorRow($tpl);
00353 }
00354 $first = false;
00355
00356
00357 $this->addHeaderRow($tpl, $type);
00358 $this->resetRowType();
00359
00360
00361 foreach($item_html as $item)
00362 {
00363 $this->addStandardRow($tpl, $item["html"], $item["item_id"]);
00364 }
00365 }
00366 }
00367 }
00368 $html = $tpl->get();
00369
00370 break;
00371
00372 default:
00373
00374 break;
00375 }
00376
00377 return $html;
00378 }
00379
00386 function &newBlockTemplate()
00387 {
00388 $tpl = new ilTemplate ("tpl.container_list_block.html", true, true);
00389 $this->cur_row_type = "row_type_1";
00390 return $tpl;
00391 }
00392
00400 function addHeaderRow(&$a_tpl, $a_type)
00401 {
00402 if ($a_type != "lres")
00403 {
00404 $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
00405 $title = $this->lng->txt("objs_".$a_type);
00406 }
00407 else
00408 {
00409 $icon = ilUtil::getImagePath("icon_lm.gif");
00410 $title = $this->lng->txt("learning_resources");
00411 }
00412 $a_tpl->setCurrentBlock("container_header_row");
00413 $a_tpl->setVariable("HEADER_IMG", $icon);
00414 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00415 $a_tpl->parseCurrentBlock();
00416 $a_tpl->touchBlock("container_row");
00417 }
00418
00426 function addStandardRow(&$a_tpl, $a_html, $a_item_id = "")
00427 {
00428 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00429 ? "row_type_2"
00430 : "row_type_1";
00431
00432 $a_tpl->touchBlock($this->cur_row_type);
00433
00434 if ($this->isActiveAdministrationPanel())
00435 {
00436 $a_tpl->setCurrentBlock("block_row_check");
00437 $a_tpl->setVariable("ITEM_ID", $a_item_id);
00438 $a_tpl->parseCurrentBlock();
00439 }
00440 else
00441 {
00442 $a_tpl->setVariable("ROW_NBSP", " ");
00443 }
00444 $a_tpl->setCurrentBlock("container_standard_row");
00445 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
00446 $a_tpl->parseCurrentBlock();
00447 $a_tpl->touchBlock("container_row");
00448 }
00449
00450 function resetRowType()
00451 {
00452 $this->cur_row_type = "";
00453 }
00454
00455 function addSeparatorRow(&$a_tpl)
00456 {
00457 $a_tpl->touchBlock("separator_row");
00458 $a_tpl->touchBlock("container_row");
00459 }
00460
00465 function getTabs(&$tabs_gui)
00466 {
00467 global $rbacsystem;
00468
00469
00470 if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
00471 {
00472 $tabs_gui->addTarget("perm_settings",
00473 $this->ctrl->getLinkTarget($this, "perm"), "perm", get_class($this));
00474 }
00475
00476
00477 if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION["clipboard"]))
00478 {
00479 $tabs_gui->addTarget("clipboard",
00480 $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
00481 }
00482
00483 if ($this->ctrl->getTargetScript() == "adm_object.php")
00484 {
00485 if ($this->tree->getSavedNodeData($this->ref_id))
00486 {
00487 $tabs_gui->addTarget("trash",
00488 $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
00489 }
00490 }
00491 }
00492
00493
00494
00495
00496
00497
00501 function enableAdministrationPanelObject()
00502 {
00503 $_SESSION["il_cont_admin_panel"] = true;
00504 $this->ctrl->redirect($this, "render");
00505 }
00506
00510 function disableAdministrationPanelObject()
00511 {
00512 $_SESSION["il_cont_admin_panel"] = false;
00513 $this->ctrl->redirect($this, "render");
00514 }
00515
00519 function addToDeskObject()
00520 {
00521 if ($_GET["item_ref_id"] and $_GET["type"])
00522 {
00523 $this->ilias->account->addDesktopItem($_GET["item_ref_id"], $_GET["type"]);
00524 }
00525 else
00526 {
00527 if ($_POST["items"])
00528 {
00529 foreach ($_POST["items"] as $item)
00530 {
00531 $type = ilObject::_lookupType($item, true);
00532 $this->ilias->account->addDesktopItem($item, $type);
00533 unset($tmp_obj);
00534 }
00535 }
00536 }
00537 $this->renderObject();
00538 }
00539
00543 function removeFromDeskObject()
00544 {
00545 if ($_GET["item_ref_id"] and $_GET["type"])
00546 {
00547 $this->ilias->account->dropDesktopItem($_GET["item_ref_id"], $_GET["type"]);
00548 }
00549 else
00550 {
00551 if ($_POST["items"])
00552 {
00553 foreach ($_POST["items"] as $item)
00554 {
00555 $type = ilObject::_lookupType($item, true);
00556 $this->ilias->account->dropDesktopItem($item, $type);
00557 unset($tmp_obj);
00558 }
00559 }
00560 }
00561 $this->renderObject();
00562 }
00563
00564
00571 function cutObject()
00572 {
00573 global $rbacsystem;
00574
00575
00576 if (!isset($_POST["id"]))
00577 {
00578 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00579 }
00580
00581
00582 foreach ($_POST["id"] as $ref_id)
00583 {
00584
00585 $node_data = $this->tree->getNodeData($ref_id);
00586 $subtree_nodes = $this->tree->getSubTree($node_data);
00587
00588 $all_node_data[] = $node_data;
00589 $all_subtree_nodes[] = $subtree_nodes;
00590
00591
00592 foreach ($subtree_nodes as $node)
00593 {
00594 if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
00595 {
00596 $no_cut[] = $node["ref_id"];
00597 }
00598 }
00599 }
00600
00601 if (count($no_cut))
00602 {
00603 $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
00604 $this->ilias->error_obj->MESSAGE);
00605 }
00606
00607 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
00608 $_SESSION["clipboard"]["cmd"] = key($_POST["cmd"]);
00609 $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
00610
00611
00612 sendinfo($this->lng->txt("msg_cut_clipboard"),true);
00613
00614 ilUtil::redirect($this->getReturnLocation("cut","adm_object.php?ref_id=".$_GET["ref_id"]));
00615
00616 }
00617
00618
00625 function linkObject()
00626 {
00627 global $clipboard, $rbacsystem, $rbacadmin;
00628
00629 if (!isset($_POST["id"]))
00630 {
00631 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00632 }
00633
00634
00635 foreach ($_POST["id"] as $ref_id)
00636 {
00637 if (!$rbacsystem->checkAccess('delete',$ref_id))
00638 {
00639 $no_cut[] = $ref_id;
00640 }
00641
00642 $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
00643
00644 if (!$this->objDefinition->allowLink($object->getType()))
00645 {
00646 $no_link[] = $object->getType();
00647 }
00648 }
00649
00650
00651 if (count($no_cut))
00652 {
00653 $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
00654 implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
00655 }
00656
00657 if (count($no_link))
00658 {
00659 $no_link = array_unique($no_link);
00660
00661 foreach ($no_link as $type)
00662 {
00663 $txt_objs[] = $this->lng->txt("objs_".$type);
00664 }
00665
00666 $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
00667
00668
00669
00670 }
00671
00672
00673 $clipboard["parent"] = $_GET["ref_id"];
00674 $clipboard["cmd"] = key($_POST["cmd"]);
00675
00676 foreach ($_POST["id"] as $ref_id)
00677 {
00678 $clipboard["ref_ids"][] = $ref_id;
00679 }
00680
00681 $_SESSION["clipboard"] = $clipboard;
00682
00683 sendinfo($this->lng->txt("msg_link_clipboard"),true);
00684
00685 ilUtil::redirect($this->getReturnLocation("link","adm_object.php?ref_id=".$_GET["ref_id"]));
00686
00687 }
00688
00689
00695 function clearObject()
00696 {
00697 unset($_SESSION["clipboard"]);
00698 unset($_SESSION["il_rep_clipboard"]);
00699
00700
00701
00702 if (isset($_POST["cmd"]["clear"]))
00703 {
00704 sendinfo($this->lng->txt("msg_clear_clipboard"),true);
00705
00706
00707 ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
00708 }
00709 }
00710
00717 function pasteObject()
00718 {
00719 global $rbacsystem, $rbacadmin, $rbacreview, $log;
00720
00721
00722 if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
00723 {
00724 $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
00725 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00726 }
00727
00728
00729 foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
00730 {
00731 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
00732
00733
00734 if (!$rbacsystem->checkAccess('create', $_GET["ref_id"], $obj_data->getType()))
00735 {
00736 $no_paste[] = $ref_id;
00737 }
00738
00739
00740 if ($_GET["ref_id"] == $this->tree->getParentId($obj_data->getRefId()))
00741 {
00742 $exists[] = $ref_id;
00743 break;
00744 }
00745
00746
00747 if ($this->tree->isGrandChild($ref_id,$_GET["ref_id"]))
00748 {
00749 $is_child[] = $ref_id;
00750 }
00751
00752
00753 $obj_type = $obj_data->getType();
00754
00755 if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
00756 {
00757 $not_allowed_subobject[] = $obj_data->getType();
00758 }
00759 }
00760
00762
00763 if (count($exists))
00764 {
00765 $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
00766 }
00767
00768 if (count($is_child))
00769 {
00770 $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
00771 $this->ilias->error_obj->MESSAGE);
00772 }
00773
00774 if (count($not_allowed_subobject))
00775 {
00776 $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
00777 $this->ilias->error_obj->MESSAGE);
00778 }
00779
00780 if (count($no_paste))
00781 {
00782 $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
00783 implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
00784 }
00785
00786
00787 $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
00788
00790
00791
00792
00793 $ref_ids = $_SESSION["clipboard"]["ref_ids"];
00794 unset($_SESSION["clipboard"]["ref_ids"]);
00795
00796
00797 if ($_SESSION["clipboard"]["cmd"] == "copy")
00798 {
00799
00800 $this->cloneObject($ref_ids);
00801 }
00802
00803
00804 if ($_SESSION["clipboard"]["cmd"] == "cut")
00805 {
00806
00807 foreach($ref_ids as $ref_id)
00808 {
00809
00810 $top_node = $this->tree->getNodeData($ref_id);
00811
00812
00813 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
00814 }
00815
00816
00817 $log->write("ilObjectGUI::pasteObject(), (1/3) move subtrees to trash");
00818
00819 foreach($ref_ids as $ref_id)
00820 {
00821 $tnodes = $this->tree->getSubtree($this->tree->getNodeData($ref_id));
00822
00823 foreach ($tnodes as $tnode)
00824 {
00825 $rbacadmin->revokePermission($tnode["child"]);
00826 $affected_users = ilUtil::removeItemFromDesktops($tnode["child"]);
00827 }
00828
00829 $this->tree->saveSubTree($ref_id);
00830 $this->tree->deleteTree($this->tree->getNodeData($ref_id));
00831 }
00832
00833
00834
00835 $log->write("ilObjectGUI::pasteObject(), (2/3) move subtrees to new location");
00836
00837
00838 foreach ($subnodes as $key => $subnode)
00839 {
00840
00841 $rbacadmin->revokePermission($key);
00842 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
00843 $obj_data->putInTree($_GET["ref_id"]);
00844 $obj_data->setPermissions($key);
00845
00846
00847 $log->write("ilObjectGUI::pasteObject(), inserted top node. ref_id: $key,".
00848 " rgt: ".$subnode[0]["rgt"].", lft: ".$subnode[0]["lft"].", parent: ".$subnode[0]["parent"].",".
00849 " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
00850 ", title: ".$obj_data->getTitle());
00851
00852
00853 array_shift($subnode);
00854
00855
00856 if (count($subnode) > 0)
00857 {
00858 foreach ($subnode as $node)
00859 {
00860 $rbacadmin->revokePermission($node["child"]);
00861 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
00862 $obj_data->putInTree($node["parent"]);
00863 $obj_data->setPermissions($node["parent"]);
00864
00865
00866 $log->write("ilObjectGUI::pasteObject(), inserted subnode. ref_id: ".$node["child"].",".
00867 " rgt: ".$node["rgt"].", lft: ".$node["lft"].", parent: ".$node["parent"].",".
00868 " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
00869 ", title: ".$obj_data->getTitle());
00870 }
00871 }
00872 }
00873
00874
00875 $log->write("ilObjectGUI::pasteObject(), (3/3) remove trashed subtrees from system");
00876
00877 foreach ($ref_ids as $ref_id)
00878 {
00879
00880 $saved_tree = new ilTree(-(int)$ref_id);
00881 $node_data = $saved_tree->getNodeData($ref_id);
00882 $subtree_nodes = $saved_tree->getSubTree($node_data);
00883
00884
00885 $checked[] = -(int) $ref_id;
00886
00887
00888 $this->removeDeletedNodes($ref_id, $checked, false);
00889
00890
00891 $this->tree->deleteTree($node_data);
00892
00893
00894 $log->write("ilObjectGUI::pasteObject(), deleted tree, tree_id: ".$node_data["tree"].
00895 ", child: ".$node_data["child"]);
00896 }
00897
00898
00899 $log->write("ilObjectGUI::pasteObject(), cut finished");
00900
00901
00902
00903
00904
00905
00906 $tmp_object = $this->ilias->obj_factory->getInstanceByRefId($_SESSION["clipboard"]["parent"]);
00907
00908 unset($tmp_object);
00909 }
00910
00911
00912 if ($_SESSION["clipboard"]["cmd"] == "link")
00913 {
00914 foreach ($ref_ids as $ref_id)
00915 {
00916
00917 $top_node = $this->tree->getNodeData($ref_id);
00918
00919
00920 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
00921 }
00922
00923
00924 foreach ($subnodes as $key => $subnode)
00925 {
00926
00927 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
00928 $new_ref_id = $obj_data->createReference();
00929 $obj_data->putInTree($_GET["ref_id"]);
00930 $obj_data->setPermissions($_GET["ref_id"]);
00931
00932
00933 array_shift($subnode);
00934
00935
00936 $mapping[$new_ref_id] = $key;
00937
00938
00939 $old_ref_id = $obj_data->getRefId();
00940 $obj_data->setRefId($new_ref_id);
00941 $obj_data->initDefaultRoles();
00942 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
00943
00944 if (isset($rolf_data["child"]))
00945 {
00946
00947 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
00948
00949
00950
00951
00952 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
00953
00954
00955 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
00956 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
00957 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
00958
00959 }
00960
00961
00962 if (count($subnode) > 0)
00963 {
00964 foreach ($subnode as $node)
00965 {
00966 if ($node["type"] != 'rolf')
00967 {
00968 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
00969 $new_ref_id = $obj_data->createReference();
00970
00971
00972 $new_parent = array_search($node["parent"],$mapping);
00973
00974 $mapping[$new_ref_id] = (int) $node["child"];
00975
00976 $obj_data->putInTree($new_parent);
00977 $obj_data->setPermissions($new_parent);
00978
00979
00980 $old_ref_id = $obj_data->getRefId();
00981 $obj_data->setRefId($new_ref_id);
00982 $obj_data->initDefaultRoles();
00983 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
00984
00985 if (isset($rolf_data["child"]))
00986 {
00987
00988 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
00989
00990
00991
00992
00993 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
00994
00995
00996 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
00997 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
00998 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
00999
01000 }
01001 }
01002
01003
01004 foreach ($subnodes as $old_ref => $subnode)
01005 {
01006 $new_ref = array_search($old_ref,$mapping);
01007
01008 foreach ($subnode as $node)
01009 {
01010 $node["child"] = array_search($node["child"],$mapping);
01011 $node["parent"] = array_search($node["parent"],$mapping);
01012 $new_subnodes[$ref_id][] = $node;
01013 }
01014 }
01015
01016 }
01017 }
01018 }
01019
01020 $log->write("ilObjectGUI::pasteObject(), link finished");
01021
01022
01023
01024 }
01025
01026
01027 $last_cmd = $_SESSION["clipboard"]["cmd"];
01028
01029
01030
01031 $this->clearObject();
01032
01033 if ($last_cmd == "cut")
01034 {
01035 sendInfo($this->lng->txt("msg_cut_copied"),true);
01036 }
01037 else
01038 {
01039 sendInfo($this->lng->txt("msg_linked"),true);
01040 }
01041
01042 ilUtil::redirect($this->getReturnLocation("paste",$this->ctrl->getLinkTarget($this)),get_class($this));
01043
01044
01045 }
01046
01047
01048
01052 function clipboardObject()
01053 {
01054 global $ilErr,$ilLog;
01055
01056
01057 if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
01058 {
01059 $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
01060 $ilLog->write($message,$ilLog->FATAL);
01061 $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
01062 }
01063
01064 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html");
01065
01066
01067 $counter = 0;
01068 $f_result = array();
01069
01070 foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
01071 {
01072 if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
01073 {
01074 continue;
01075 }
01076
01077
01078 $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
01079 $f_result[$counter][] = $tmp_obj->getTitle();
01080
01081 $f_result[$counter][] = ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]);
01082
01083 unset($tmp_obj);
01084 ++$counter;
01085 }
01086
01087 $this->__showClipboardTable($f_result, "clipboardObject");
01088
01089 return true;
01090 }
01091
01092 function isActiveAdministrationPanel()
01093 {
01094 return $_SESSION["il_cont_admin_panel"];
01095 }
01096 }
01097 ?>