ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./classes/class.ilObjectGUI.php";
5 require_once "./Services/Container/classes/class.ilContainer.php";
6 include_once './Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
7 
20 {
21  var $bl_cnt = 1; // block counter
22 
27  function ilContainerGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
28  {
29  global $rbacsystem, $lng, $tree;
30 
31  $this->rbacsystem =& $rbacsystem;
32 
33  $lng->loadLanguageModule("cntr");
34 
35  //$this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
36 
37  // Activate tree cache when rendering the container to improve performance
38  //$tree->useCache(false);
39 
40  // prepare output things should generally be made in executeCommand
41  // method (maybe dependent on current class/command
42  $this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
43  }
44 
49  function &executeCommand()
50  {
51  global $tpl;
52 
53  $next_class = $this->ctrl->getNextClass();
54  $cmd = $this->ctrl->getCmd("render");
55 
56  switch($next_class)
57  {
58  // page editing
59  case "ilpageobjectgui":
60  $ret = $this->forwardToPageObject();
61  $tpl->setContent($ret);
62  break;
63 
64  case "ilobjstylesheetgui":
65  $this->forwardToStyleSheet();
66  break;
67 
68  default:
69  $this->prepareOutput();
70  $cmd .= "Object";
71  $this->$cmd();
72  break;
73  }
74  return true;
75  }
76 
81  {
82  global $ilCtrl, $ilTabs;
83 
84  $ilTabs->clearTargets();
85 
86  $cmd = $ilCtrl->getCmd();
87  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
88  $this->ctrl->setReturn($this, "editStyleProperties");
89  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
90  $style_gui->omitLocator();
91  if ($cmd == "create" || $_GET["new_type"]=="sty")
92  {
93  $style_gui->setCreationMode(true);
94  }
95 
96  if ($cmd == "confirmedDelete")
97  {
98  $this->object->setStyleSheetId(0);
99  $this->object->update();
100  }
101 
102  $ret = $this->ctrl->forwardCommand($style_gui);
103 
104  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
105  {
106  $style_id = $ret;
107  $this->object->setStyleSheetId($style_id);
108  $this->object->update();
109  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
110  }
111  }
112 
113 
118  {
119  global $lng, $ilTabs, $ilCtrl;
120 
121  $cmd = $ilCtrl->getCmd();
122 
123  if (in_array($cmd, array("displayMediaFullscreen")))
124  {
125  $this->checkPermission("read");
126  }
127  else
128  {
129  $this->checkPermission("write");
130  }
131 
132  $ilTabs->clearTargets();
133 
134  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
135  "xhtml_page");
136  if ($xpage_id > 0)
137  {
138  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
139  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
140  }
141  else
142  {
143  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
144  $this->object->getRefId(), "_top");
145  }
146 
147  // page object
148  include_once("./Services/COPage/classes/class.ilPageObject.php");
149  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
150 
151  $lng->loadLanguageModule("content");
152 
153  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
154  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
155  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
156 //echo "-".ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())."-";
157  $this->tpl->setCurrentBlock("SyntaxStyle");
158  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
160  $this->tpl->parseCurrentBlock();
161 
162  if (!ilPageObject::_exists($this->object->getType(),
163  $this->object->getId()))
164  {
165  // doesn't exist -> create new one
166  $new_page_object = new ilPageObject($this->object->getType());
167  $new_page_object->setParentId($this->object->getId());
168  $new_page_object->setId($this->object->getId());
169  $new_page_object->createFromXML();
170  }
171 
172  // get page object
173 // $page_object = new ilPageObject($this->object->getType(),
174 // $this->object->getId(), 0, true);
175  $this->ctrl->setReturnByClass("ilpageobjectgui", "edit");
176  //$page_object =& $this->obj->getPageObject();
177 // $page_object->buildDom();
178  //$page_object->addUpdateListener($this, "updateHistory");
179 // $int_links = $page_object->getInternalLinks();
180  //$link_xml = $this->getLinkXML($int_links);
181  $page_gui =& new ilPageObjectGUI($this->object->getType(),
182  $this->object->getId());
183  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
184  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
185  $this->object->getStyleSheetId(), $this->object->getType()));
186 //echo "--".$this->object->getStyleSheetId()."-";
187  // $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
188  //$page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId(),
189  // $view_frame);
190 
191  $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
192  $page_gui->setTemplateTargetVar("ADM_CONTENT");
193  $page_gui->setLinkXML($link_xml);
194  //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
195  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
196  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
197  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
198 // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
199  $page_gui->setPresentationTitle("");
200  $page_gui->setTemplateOutput(false);
201  //$page_gui->setLocator($contObjLocator);
202  $page_gui->setHeader("");
203  $page_gui->setEnabledRepositoryObjects(true);
204  $page_gui->setEnabledFileLists(false);
205  $page_gui->setEnabledMaps(true);
206  $page_gui->setEnabledPCTabs(true);
207 
208  // old editor information text
209  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
210  "xhtml_page");
211  if ($xpage_id > 0)
212  {
213  $wtpl = new ilTemplate("tpl.cntr_old_editor_message.html", true,
214  true, "Services/Container");
215  $wtpl->setVariable("ALT_WARNING", $lng->txt("warning"));
216  $wtpl->setVariable("IMG_WARNING",
217  ilUtil::getImagePath("icon_alert_s.gif"));
218  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
219  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
220  $wtpl->setVariable("HREF_SWITCH_TO_NEW_EDITOR",
221  $ilCtrl->getLinkTarget($this, "useNewEditor"));
222  $wtpl->setVariable("TXT_MIGRATION_SWITCH",
223  $lng->txt("cntr_switch_to_new_editor_cmd"));
224  $page_gui->setPrependingHtml($wtpl->get());
225  }
226 
227  // style tab
228  $page_gui->setTabHook($this, "addPageTabs");
229 
230  $ret =& $this->ctrl->forwardCommand($page_gui);
231 
232  //$ret =& $page_gui->executeCommand();
233  return $ret;
234  }
235 
239  function addPageTabs()
240  {
241  global $ilTabs, $ilCtrl;
242 
243  $ilTabs->addTarget("obj_sty",
244  $ilCtrl->getLinkTarget($this, 'editStyleProperties'), "editStyleProperties");
245  }
246 
251  {
252  global $ilSetting;
253 
254  if (!$ilSetting->get("enable_cat_page_edit"))
255  {
256  return;
257  }
258 
259  // old page editor content
260  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
261  "xhtml_page");
262  if ($xpage_id > 0)
263  {
264  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
265  $xpage = new ilXHTMLPage($xpage_id);
266  return $xpage->getContent();
267  }
268 
269 
270  // page object
271 
272 
273  // if page does not exist, return nothing
274  include_once("./Services/COPage/classes/class.ilPageUtil.php");
275  if (!ilPageUtil::_existsAndNotEmpty($this->object->getType(),
276  $this->object->getId()))
277  {
278  return "";
279  }
280  include_once("./Services/COPage/classes/class.ilPageObject.php");
281  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
282 
283  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
284  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
285  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
286  $this->tpl->setCurrentBlock("SyntaxStyle");
287  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
289  $this->tpl->parseCurrentBlock();
290 
291  // get page object
292  $page_gui =& new ilPageObjectGUI($this->object->getType(),
293  $this->object->getId());
294  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
295  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
296  $this->object->getStyleSheetId(), $this->object->getType()));
297 
298  $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
299  //$page_gui->setTemplateTargetVar("ADM_CONTENT");
300  $page_gui->setLinkXML($link_xml);
301  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
302  //$page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
303  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
304 // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
305  $page_gui->setPresentationTitle("");
306  $page_gui->setTemplateOutput(false);
307  //$page_gui->setLocator($contObjLocator);
308  $page_gui->setHeader("");
309  $page_gui->setEnabledRepositoryObjects(true);
310  $page_gui->setEnabledFileLists(false);
311  $page_gui->setEnabledPCTabs(true);
312  $page_gui->setEnabledMaps(true);
313  $ret = $page_gui->showPage();
314 
315  //$ret =& $page_gui->executeCommand();
316  return $ret;
317  }
318 
322  function prepareOutput($a_show_subobjects = true)
323  {
324  if (parent::prepareOutput()) // return false in admin mode
325  {
326  if ($this->getCreationMode() != true && $a_show_subobjects)
327  {
328  // This method is called directly from ilContainerGUI::renderObject
329  #$this->showPossibleSubObjects();
330  $this->showTreeFlatIcon();
331 
332  // Member view
333  include_once './Services/Container/classes/class.ilMemberViewGUI.php';
334  ilMemberViewGUI::showMemberViewSwitch($this->object->getRefId());
335  }
336  }
337  }
338 
339  function showTreeFlatIcon()
340  {
341  global $tpl;
342 
343  // dont show icon, if role (permission gui->rolegui) is edited
344  if ($_GET["obj_id"] != "")
345  {
346  return;
347  }
348  // hide for member view
349  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
350  if(ilMemberViewSettings::getInstance()->isActive())
351  {
352  return;
353  }
354 
355  $mode = ($_SESSION["il_rep_mode"] == "flat")
356  ? "tree"
357  : "flat";
358  $link = "repository.php?cmd=frameset&set_mode=".$mode."&ref_id=".$this->object->getRefId();
359  $tpl->setTreeFlatIcon($link, $mode);
360  }
361 
366  {
367  global $ilias;
368 
369  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
370  {
371  $this->tpl->setTitle($this->object->getTitle());
372  $this->tpl->setDescription($this->object->getLongDescription());
373 
374  // set tile icon
375  $icon = ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif");
376  if ($ilias->getSetting("custom_icons") &&
377  in_array($this->object->getType(), array("cat","grp","crs", "root")))
378  {
379  require_once("./Services/Container/classes/class.ilContainer.php");
380  if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
381  {
382  $icon = $path;
383  }
384  }
385  $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
386  }
387  }
388 
389 
394  {
395  global $ilAccess,$ilCtrl,$lng;
396 
397  $found = false;
398  $cmd = ($this->cmd != "")
399  ? $this->cmd
400  : $this->ctrl->getCmd();
401 
402  $type = $this->object->getType();
403 
404  $d = $this->objDefinition->getCreatableSubObjects($type);
405  include_once("./Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php");
406 
407  if ($type != "icrs")
408  {
410  }
411  if (count($d) > 0)
412  {
413  foreach ($d as $row)
414  {
415  $count = 0;
416 
417  if ($row["max"] == "" || $count < $row["max"])
418  {
419  if (!in_array($row["name"], array("rolf")))
420  {
421  if ($this->rbacsystem->checkAccess("create", $this->object->getRefId(), $row["name"]))
422  {
423  if (!$row["plugin"])
424  {
425  $subobj[] = array("value" => $row["name"],
426  "title" => $lng->txt("obj_".$row["name"]),
427  "img" => ilObject::_getIcon("", "tiny", $row["name"]),
428  "alt" => $lng->txt("obj_".$row["name"]));
429  }
430  else
431  {
432  include_once("./Services/Component/classes/class.ilPlugin.php");
433  $subobj[] = array("value" => $row["name"],
434  "title" => ilPlugin::lookupTxt("rep_robj", $row["name"], "obj_".$row["name"]),
435  "img" => ilObject::_getIcon("", "tiny", $row["name"]),
436  "alt" => $lng->txt("obj_".$row["name"]));
437  }
438  }
439  }
440  }
441  }
442  }
443 
444  if (is_array($subobj))
445  {
446  $formaction = "repository.php?ref_id=".$this->object->getRefId()."&cmd=post";
447  $formaction = $ilCtrl->appendRequestTokenParameterString($formaction);
448  $formaction = $this->ctrl->getFormAction($this);
449  //$opts = ilUtil::formSelect("", "new_type", $subobj);
450  $this->tpl->setCreationSelector($formaction,
451  $subobj, "create", $this->lng->txt("add"));
452  }
453  }
454 
458  function renderObject()
459  {
460  global $ilDB, $tpl, $ilTabs, $ilCtrl;
461 
462  switch ($this->object->getViewMode())
463  {
464  // all items in one block
466  include_once("./Services/Container/classes/class.ilContainerSimpleContentGUI.php");
467  $container_view = new ilContainerSimpleContentGUI($this);
468  break;
469 
471  include_once('./Services/Container/classes/class.ilContainerObjectiveGUI.php');
472  $container_view = new ilContainerObjectiveGUI($this);
473  break;
474 
475  // all items in one block
477  case IL_CRS_VIEW_TIMING: // not nice this workaround
478  include_once("./Services/Container/classes/class.ilContainerSessionsContentGUI.php");
479  $container_view = new ilContainerSessionsContentGUI($this);
480  break;
481 
482  // ILinc courses
484  include_once 'Services/Container/classes/class.ilContainerILincContentGUI.php';
485  $container_view = new ilContainerILincContentGUI($this);
486  break;
487 
488  // all items in one block
490  default:
491  include_once("./Services/Container/classes/class.ilContainerByTypeContentGUI.php");
492  $container_view = new ilContainerByTypeContentGUI($this);
493  break;
494  }
495 
496  $container_view->setOutput();
497 
498  $this->adminCommands = $container_view->adminCommands;
499 
500  // it is important not to show the subobjects/admin panel here, since
501  // we will create nested forms in case, e.g. a news/calendar item is added
502  if ($ilCtrl->getNextClass() != "ilcolumngui")
503  {
504  $this->showAdministrationPanel($tpl);
505  $this->showPossibleSubObjects();
506  }
507 
508  $this->showPermanentLink($tpl);
509  $this->setContentSubTabs();
510  if ($this->isActiveAdministrationPanel())
511  {
512  $ilTabs->activateSubTab("manage");
513  }
514  else
515  {
516  $ilTabs->activateSubTab("view_content");
517  }
518 
519  }
520 
524  function setContentSubTabs()
525  {
527  }
528 
533  {
534  global $ilAccess, $ilSetting;
535  global $ilUser, $lng;
536 
537  if ($this->isActiveAdministrationPanel())
538  {
539 
540  if (!$_SESSION["clipboard"])
541  {
542  if ($this->object->gotItems())
543  {
544  $GLOBALS["tpl"]->addAdminPanelCommand("delete",
545  $this->lng->txt("delete_selected_items"), true);
546  $GLOBALS["tpl"]->addAdminPanelCommand("cut",
547  $this->lng->txt("move_selected_items"));
548  $GLOBALS["tpl"]->addAdminPanelCommand("link",
549  $this->lng->txt("link_selected_items"));
550  }
551  }
552  else
553  {
554  /*$GLOBALS["tpl"]->addAdminPanelCommand("paste",
555  $this->lng->txt("paste_clipboard_items"));
556 
557  if($_SESSION["clipboard"]["cmd"] == "link")
558  {
559  $GLOBALS["tpl"]->addAdminPanelCommand("initAndDisplayLinkIntoMultipleObjects",
560  $this->lng->txt("paste_clipboard_items_into_multiple_objects"));
561  }*/
562 
563  $GLOBALS["tpl"]->addAdminPanelCommand("clear",
564  $this->lng->txt("clear_clipboard"));
565  }
566 
567  $this->ctrl->setParameter($this, "type", "");
568  $this->ctrl->setParameter($this, "item_ref_id", "");
569  $GLOBALS["tpl"]->setPageFormAction($this->ctrl->getFormAction($this));
570  }
571  if ($this->edit_order)
572  {
573  if($this->object->gotItems() and $ilAccess->checkAccess("write", "", $this->object->getRefId()))
574  {
575  include_once('./Services/Container/classes/class.ilContainer.php');
576 
577  if ($this->object->getOrderType() == ilContainer::SORT_MANUAL)
578  {
579  $GLOBALS["tpl"]->addAdminPanelCommand("saveSorting",
580  $this->lng->txt('sorting_save'));
581  }
582  }
583  }
584  }
585 
587  {
588  global $tree;
589 
590  if(!$tree->checkForParentType($this->object->getRefId(),'crs'))
591  {
592  return false;
593  }
594  $tpl->setCurrentBlock("custom_button");
595  $tpl->setVariable("ADMIN_MODE_LINK",$this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editTimings'));
596  $tpl->setVariable("TXT_ADMIN_MODE",$this->lng->txt('timings_edit'));
597  $tpl->parseCurrentBlock();
598  return true;
599  }
604  {
605  $GLOBALS["tpl"]->setPermanentLink($this->object->getType(),
606  $this->object->getRefId(), "", "_top");
607  }
608 
613  {
614  global $ilCtrl;
615 
616  $_SESSION["il_cntr_editor"] = "std";
617  $ilCtrl->redirect($this, "editPageFrame");
618  }
619 
624  {
625  global $ilCtrl;
626 
627  $_SESSION["il_cntr_editor"] = "old";
628  $ilCtrl->redirect($this, "editPageFrame");
629  }
630 
635  {
636  global $ilCtrl, $ilAccess, $lng, $ilCtrl;
637 
638  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
639  {
640  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
641 
642  /* keep old page content for now...
643  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
644  "xhtml_page");
645  if ($xpage_id)
646  {
647  $xpage = new ilXHTMLPage($xpage_id);
648  }
649  */
650 
651  ilContainer::_writeContainerSetting($this->object->getId(),
652  "xhtml_page", 0);
653 
654  ilUtil::sendSuccess($lng->txt("cntr_switched_editor"), true);
655  }
656 
657  $ilCtrl->redirect($this, "editPageFrame");
658  }
659 
664  {
665  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
666  $fs_gui = new ilFramesetGUI();
667 
668  $fs_gui->setFramesetTitle($this->object->getTitle());
669  $fs_gui->setMainFrameName("content");
670  $fs_gui->setSideFrameName("link_list");
671 
672  // old tiny stuff
673  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
674  "xhtml_page");
675  if ($xpage_id > 0 && $_SESSION["il_cntr_editor"] != "std")
676  {
677  $fs_gui->setMainFrameSource(
678  $this->ctrl->getLinkTarget(
679  $this, "editPageContent"));
680  $fs_gui->setSideFrameSource(
681  $this->ctrl->getLinkTarget($this, "showLinkList"));
682  }
683  else
684  {
685  $fs_gui->setMainWidth("100%");
686  $fs_gui->setSideWidth("0");
687 
688  // to do: check this
689  $fs_gui->setSideFrameSource("");
690 
691  // page object stuff
692  $fs_gui->setMainFrameSource(
693  $this->ctrl->getLinkTargetByClass(
694  array("ilpageobjectgui"), "edit"));
695  }
696 
697  $fs_gui->show();
698  exit;
699  }
700 
707  {
708  global $rbacsystem, $tpl, $lng, $ilCtrl;
709 
710  if (!$rbacsystem->checkAccess("write", $this->ref_id))
711  {
712  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
713  }
714 
715  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
716  "xhtml_page");
717  if ($xpage_id > 0)
718  {
719  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
720  $xpage = new ilXHTMLPage($xpage_id);
721  $content = $xpage->getContent();
722  }
723 
724  // get template
725  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.container_edit_page_content.html",
726  "Services/Container");
727  $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
728  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
729  $tpl->setVariable("TXT_EDIT_PAGE_CONTENT",
730  $this->lng->txt("edit_page_content"));
731  $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
732  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
733  $tpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_old_editor_warning"));
734  $tpl->setVariable("TXT_MIGRATION_OPEN_STD_EDITOR", $lng->txt("cntr_old_editor_open_standard_editor"));
735  $tpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert_s.gif"));
736  $tpl->setVariable("HREF_OPEN_STD_EDITOR", $ilCtrl->getLinkTarget($this, "switchToStdEditor"));
737  $tpl->setVariable("ALT_WARNING", $lng->txt("warning"));
738 
739  include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
740  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
741  //$ta = new ilTextAreaInputGUI();
742  //$tags = $ta->getRteTagSet("extended_table_img");
743 
744  // add rte support
745  include_once "./Services/RTE/classes/class.ilRTE.php";
746  $rtestring = ilRTE::_getRTEClassname();
747  include_once "./Services/RTE/classes/class.$rtestring.php";
748  $rte = new $rtestring();
749  //$rte->addPlugin("latex");
750  include_once "./classes/class.ilObject.php";
752  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
753  $rte->addRTESupport($obj_id, $obj_type);
754  //$rte->setStyleSelect(true);
755  //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
756  }
757 
759  {
760  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
761  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
762  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
763  "xhtml_page");
764 
765  /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
766  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
767  $ta = new ilTextAreaInputGUI();
768  $ta->setRteTagSet("extended_table_img");
769  $tags = $ta->getRteTagString();*/
770 
771  //$text = ilUtil::stripSlashes($_POST["page_content"],
772  // true,
773  // $tags);
774 
775  $text = ilUtil::stripSlashes($_POST["page_content"],
776  true,
778  if ($xpage_id > 0)
779  {
780  $xpage = new ilXHTMLPage($xpage_id);
781  $xpage->setContent($text);
782  $xpage->save();
783  }
784  else
785  {
786  $xpage = new ilXHTMLPage();
787  $xpage->setContent($text);
788  $xpage->save();
789  ilContainer::_writeContainerSetting($this->object->getId(),
790  "xhtml_page", $xpage->getId());
791  }
792 
793  include_once("Services/RTE/classes/class.ilRTE.php");
794  ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType().":html",
795  $this->object->getId());
796 
797  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
798  $this->ctrl->redirect($this, "");
799  }
800 
802  {
803  $this->ctrl->redirect($this, "");
804  }
805 
806  function renderItemList($a_type = "all")
807  {
809 
810  include_once("classes/class.ilObjectListGUIFactory.php");
811 
812  $output_html = "";
814 
815  $type_grps = $this->object->getGroupedObjTypes();
816 
817  switch ($a_type)
818  {
819  // render all items list
820  case "all":
821 
822  // new behaviour
823  $output_html.= $this->getContainerPageHTML();
824 
825  // all item types
826  /*
827  $type_ordering = array(
828  "cat", "fold", "crs","rcrs", "icrs", "icla", "grp", "chat", "frm", "lres",
829  "glo", "webr", "mcst", "wiki", "file", "exc",
830  "tst", "svy", "mep", "qpl", "spl");*/
831 
832  $cur_obj_type = "";
833  $overall_tpl =& $this->newBlockTemplate();
834  $this->type_template = array();
835  $first = true;
836 
837  // iterate all types
838  foreach ($type_grps as $type => $v)
839  {
840  // set template (overall or type specific)
841  if (is_int(strpos($output_html, "[list-".$type."]")))
842  {
843  $tpl =& $this->newBlockTemplate();
844  $overall = false; // individual
845  }
846  else
847  {
848  $tpl =& $overall_tpl;
849  $overall = true; // put to the rest
850  }
851 
852  if (is_array($this->items[$type]))
853  {
854 
855  $item_html = array();
856 
857  foreach($this->items[$type] as $key => $item)
858  {
859  // get list gui class for each object type
860  if ($cur_obj_type != $item["type"])
861  {
862  $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
863  $item_list_gui->setContainerObject($this);
864  }
865  // render item row
866  $ilBench->start("ilContainerGUI", "0210_getListHTML");
867 
868  // show administration command buttons (or not)
869  if (!$this->isActiveAdministrationPanel())
870  {
871  $item_list_gui->enableDelete(false);
872  $item_list_gui->enableLink(false);
873  $item_list_gui->enableCut(false);
874  $item_list_gui->enableCopy(false);
875  }
876 
877  $html = $item_list_gui->getListItemHTML($item["ref_id"],
878  $item["obj_id"], $item["title"], $item["description"]);
879 
880  // check whether any admin command is allowed for
881  // the items
882  $this->determineAdminCommands($item["ref_id"],
883  $item_list_gui->adminCommandsIncluded());
884  $ilBench->stop("ilContainerGUI", "0210_getListHTML");
885  if ($html != "")
886  {
887  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
888  $item_html[] = array(
889  "html" => $html,
890  "item_ref_id" => $item["ref_id"],
891  "item_obj_id" => $item["obj_id"],
892  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
893  $item_list_gui->getIconImageType() :
894  $item['type']
895  );
896  // END WebDAV: Use $item_list_gui to determine icon image type
897  }
898  }
899 
900  // output block for resource type
901  if (count($item_html) > 0)
902  {
903  // separator row
904  if (!$first && $overall)
905  {
906  $this->addSeparatorRow($tpl);
907  }
908 
909  if ($overall)
910  {
911  $first = false;
912  }
913 
914  // add a header for each resource type
915  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
916  {
917  $this->addHeaderRow($tpl, $type, false);
918  }
919  else
920  {
921  $this->addHeaderRow($tpl, $type);
922  }
923  $this->resetRowType();
924 
925  // content row
926  $this->current_position = 1;
927  foreach($item_html as $item)
928  {
929  // BEGIN WebDAV: Use $item_list_gui to determine image type
930  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $item['item_icon_image_type']);
931  // END WebDAV: Use $item_list_gui to determine image type
932  }
933 
934  // store type specific templates in array
935  if (is_int(strpos($output_html, "[list-".$type."]")))
936  {
937  $this->type_template[$type] = $tpl;
938  }
939  }
940  else
941  {
942  // [list-...] tag available, but no item of type accessible
943  if (!$overall)
944  {
945  $this->addHeaderRow($tpl, $type);
946  $this->resetRowType();
947  $this->addMessageRow($tpl,
948  $this->lng->txt("msg_no_type_accessible"), $type);
949  $this->type_template[$type] = $tpl;
950  }
951  }
952  }
953  else
954  {
955  // [list-...] tag available, but no item of type exists
956  if (!$overall)
957  {
958  $this->addHeaderRow($tpl, $type);
959  $this->resetRowType();
960  $this->addMessageRow($tpl,
961  $this->lng->txt("msg_no_type_available"), $type);
962  $this->type_template[$type] = $tpl;
963  }
964  }
965 
966  }
967 
968 
969  // I don't know why but executing this
970  // line before the following foreach loop seems to be crucial
971  if ($output_html != "")
972  {
973  //$output_html.= "<br /><br />";
974  }
975  $output_html.= $overall_tpl->get();
976  //$output_html = str_replace("<br>++", "++", $output_html);
977  //$output_html = str_replace("<br>++", "++", $output_html);
978  //$output_html = str_replace("++<br>", "++", $output_html);
979  //$output_html = str_replace("++<br>", "++", $output_html);
980  foreach ($this->type_template as $type => $tpl)
981  {
982  $output_html = eregi_replace("\[list-".$type."\]",
983  "</p>".$tpl->get()."<p class=\"ilc_Standard\">",
984  $output_html);
985  }
986 
987  //if (ilPageObject::_exists($this->object->getType(),
988  // $this->object->getId()))
989  if ($xpage_id > 0)
990  {
991  $page_block = new ilTemplate("tpl.container_page_block.html", false, false,
992  "Services/Container");
993  $page_block->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
994  $output_html = $page_block->get();
995  }
996 
997  break;
998 
999  default:
1000  // to do:
1001  break;
1002  }
1003  return $output_html;
1004  }
1005 
1007  {
1008  global $lng, $tree;
1009 
1010  $tpl = new ilTemplate("tpl.container_link_help.html", true, true);
1011 
1012  $type_ordering = array(
1013  "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
1014  "glo", "webr", "file", "exc",
1015  "tst", "svy", "mep", "qpl", "spl");
1016 
1017  $childs = $tree->getChilds($_GET["ref_id"]);
1018  foreach($childs as $child)
1019  {
1020  if (in_array($child["type"], array("lm", "dbk", "sahs", "htlm")))
1021  {
1022  $cnt["lres"]++;
1023  }
1024  else
1025  {
1026  $cnt[$child["type"]]++;
1027  }
1028  }
1029 
1030  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1031  $tpl->setVariable("TXT_HELP_HEADER", $lng->txt("help"));
1032  foreach($type_ordering as $type)
1033  {
1034  $tpl->setCurrentBlock("row");
1035  $tpl->setVariable("ROWCOL", "tblrow".((($i++)%2)+1));
1036  if ($type != "lres")
1037  {
1038  $tpl->setVariable("TYPE", $lng->txt("objs_".$type).
1039  " (".((int)$cnt[$type]).")");
1040  }
1041  else
1042  {
1043  $tpl->setVariable("TYPE", $lng->txt("learning_resources").
1044  " (".((int)$cnt["lres"]).")");
1045  }
1046  $tpl->setVariable("TXT_LINK", "[list-".$type."]");
1047  $tpl->parseCurrentBlock();
1048  }
1049  $tpl->show();
1050  exit;
1051 
1052  }
1053 
1058  {
1059  $this->adminCommands = false;
1060  }
1061 
1065 /* function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
1066  {
1067  if (!$this->adminCommands)
1068  {
1069  if (!$this->isActiveAdministrationPanel())
1070  {
1071  if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
1072  {
1073  $this->adminCommands = true;
1074  }
1075  }
1076  else
1077  {
1078  $this->adminCommands = $a_admin_com_included_in_list;
1079  }
1080  }
1081  }*/
1082 
1089  function &newBlockTemplate()
1090  {
1091  $tpl = new ilTemplate ("tpl.container_list_block.html", true, true,
1092  "Services/Container");
1093  $this->cur_row_type = "row_type_1";
1094  return $tpl;
1095  }
1096 
1104  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1105  {
1106  $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
1107  $title = $this->lng->txt("objs_".$a_type);
1108 
1109  if ($a_show_image)
1110  {
1111  $a_tpl->setCurrentBlock("container_header_row_image");
1112  $a_tpl->setVariable("HEADER_IMG", $icon);
1113  $a_tpl->setVariable("HEADER_ALT", $title);
1114  }
1115  else
1116  {
1117  $a_tpl->setCurrentBlock("container_header_row");
1118  }
1119 
1120  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1121  $a_tpl->parseCurrentBlock();
1122  $a_tpl->touchBlock("container_row");
1123  }
1124 
1132  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1133  $a_image_type = "")
1134  {
1135  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1136  ? "row_type_2"
1137  : "row_type_1";
1138 
1139  $a_tpl->touchBlock($this->cur_row_type);
1140 
1141  $nbsp = true;
1142  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
1143  {
1144  $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
1145  $alt = $this->lng->txt("obj_".$a_image_type);
1146 
1147  // custom icon
1148  if ($this->ilias->getSetting("custom_icons") &&
1149  in_array($a_image_type, array("cat","grp","crs")))
1150  {
1151  require_once("./Services/Container/classes/class.ilContainer.php");
1152  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1153  {
1154  $icon = $path;
1155  }
1156  }
1157 
1158  $a_tpl->setCurrentBlock("block_row_image");
1159  $a_tpl->setVariable("ROW_IMG", $icon);
1160  $a_tpl->setVariable("ROW_ALT", $alt);
1161  $a_tpl->parseCurrentBlock();
1162  $nbsp = false;
1163  }
1164 
1165  if ($this->isActiveAdministrationPanel())
1166  {
1167  $a_tpl->setCurrentBlock("block_row_check");
1168  $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
1169  $a_tpl->parseCurrentBlock();
1170  $nbsp = false;
1171  }
1172  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1173  if($this->isActiveAdministrationPanel() &&
1175  {
1176  $a_tpl->setCurrentBlock('block_position');
1177  $a_tpl->setVariable('POS_TYPE',$a_image_type);
1178  $a_tpl->setVariable('POS_ID',$a_item_ref_id);
1179  $a_tpl->setVariable('POSITION',sprintf('%.1f',$this->current_position++));
1180  $a_tpl->parseCurrentBlock();
1181  }
1182  if ($nbsp)
1183  {
1184  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1185  }
1186  $a_tpl->setCurrentBlock("container_standard_row");
1187  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1188  $a_tpl->parseCurrentBlock();
1189  $a_tpl->touchBlock("container_row");
1190  }
1191 
1195  function addMessageRow(&$a_tpl, $a_message, $a_type)
1196  {
1197  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1198  ? "row_type_2"
1199  : "row_type_1";
1200 
1201  $a_tpl->touchBlock($this->cur_row_type);
1202 
1203  $type = $this->lng->txt("obj_".$a_type);
1204  $a_message = str_replace("[type]", $type, $a_message);
1205 
1206  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1207 
1208  $a_tpl->setCurrentBlock("container_standard_row");
1209  $a_tpl->setVariable("BLOCK_ROW_CONTENT",
1210  $a_message);
1211  $a_tpl->parseCurrentBlock();
1212  $a_tpl->touchBlock("container_row");
1213  }
1214 
1215  function resetRowType()
1216  {
1217  $this->cur_row_type = "";
1218  }
1219 
1220 
1225  {
1226  global $lng;
1227 
1228  if (!$this->isActiveAdministrationPanel()
1229  || strtolower($this->ctrl->getCmdClass()) != "ilpageobjectgui")
1230  {
1231  return;
1232  }
1233 
1234  $lng->loadLanguageModule("content");
1235  //$tabs_gui = new ilTabsGUI();
1236  //$tabs_gui->setSubTabs();
1237 
1238  // back to upper context
1239  $this->tabs_gui->setBackTarget($this->lng->txt("obj_cat"),
1240  $this->ctrl->getLinkTarget($this, "frameset"),
1241  ilFrameTargetInfo::_getFrame("MainContent"));
1242 
1243  $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view")
1244  , array("", "view"), "ilpageobjectgui");
1245 
1246  //$this->tpl->setTabs($tabs_gui->getHTML());
1247  }
1248 
1252  function addStandardContainerSubTabs($a_include_view = true)
1253  {
1254  global $ilTabs, $ilAccess, $lng, $ilCtrl, $ilUser, $ilSetting;
1255 
1256  if (!is_object($this->object))
1257  {
1258  return;
1259  }
1260 
1261  if ($a_include_view && $ilAccess->checkAccess("read", "", $this->object->getRefId()))
1262  {
1263  if (!$this->isActiveAdministrationPanel())
1264  {
1265  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, ""));
1266  }
1267  else
1268  {
1269  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "disableAdministrationPanel"));
1270  }
1271  }
1272 
1273  if ( $ilUser->getId() != ANONYMOUS_USER_ID &&
1274  ($this->adminCommands ||
1275  (is_object($this->object) &&
1276  ($ilAccess->checkAccess("write", "", $this->object->getRefId())))
1277  ||
1278  (is_object($this->object) &&
1279  ($this->object->getHiddenFilesFound())) ||
1280  $_SESSION["clipboard"]
1281  )
1282  )
1283  {
1284  if ($this->isActiveAdministrationPanel())
1285  {
1286  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, ""));
1287  }
1288  else
1289  {
1290  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, "enableAdministrationPanel"));
1291  }
1292  }
1293  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1294  is_object($this->object) &&
1295  $ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
1296  $this->object->getOrderType() == ilContainer::SORT_MANUAL
1297  )
1298  {
1299  $ilTabs->addSubTab("ordering", $lng->txt("cntr_ordering"), $ilCtrl->getLinkTarget($this, "editOrder"));
1300  }
1301  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1302  is_object($this->object) &&
1303  $ilAccess->checkAccess("write", "", $this->object->getRefId())
1304  )
1305  {
1306  if ($ilSetting->get("enable_cat_page_edit"))
1307  {
1308  $ilTabs->addSubTab("page_editor", $lng->txt("cntr_text_media_editor"), $ilCtrl->getLinkTarget($this, "editPageFrame"),
1309  ilFrameTargetInfo::_getFrame("MainContent"));
1310  }
1311  }
1312  }
1313 
1314 
1319  function getTabs(&$tabs_gui)
1320  {
1321  global $rbacsystem, $ilCtrl;
1322 
1323  // edit permissions
1324  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
1325  {
1326  $tabs_gui->addTarget("perm_settings",
1327  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1328  array("perm","info","owner"), 'ilpermissiongui');
1329  if ($ilCtrl->getNextClass() == "ilpermissiongui")
1330  {
1331  $tabs_gui->activateTab("perm_settings");
1332  }
1333  }
1334 
1335  // show clipboard
1336  if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION["clipboard"]))
1337  {
1338  $tabs_gui->addTarget("clipboard",
1339  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
1340  }
1341 
1342  }
1343 
1344  //*****************
1345  // COMMON METHODS (may be overwritten in derived classes
1346  // if special handling is necessary)
1347  //*****************
1348 
1353  {
1354  $_SESSION["il_cont_admin_panel"] = true;
1355  $this->ctrl->redirect($this, "render");
1356  }
1357 
1362  {
1363  $_SESSION["il_cont_admin_panel"] = false;
1364  $this->ctrl->redirect($this, "render");
1365  }
1366 
1370  function editOrderObject()
1371  {
1372  global $ilTabs;
1373 
1374  $this->edit_order = true;
1375  $_SESSION["il_cont_admin_panel"] = false;
1376  $this->renderObject();
1377 
1378  $ilTabs->activateSubTab("ordering");
1379  }
1380 
1385  public function isActiveOrdering()
1386  {
1387  return $this->edit_order ? true : false;
1388  }
1389 
1390 
1391 
1395  public function addToDeskObject()
1396  {
1397  global $ilSetting;
1398 
1399  if((int)$ilSetting->get('disable_my_offers'))
1400  {
1401  return $this->renderObject();
1402  }
1403 
1404  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1406  $this->renderObject();
1407  }
1408 
1412  public function removeFromDeskObject()
1413  {
1414  global $ilSetting;
1415 
1416  if((int)$ilSetting->get('disable_my_offers'))
1417  {
1418  return $this->renderObject();
1419  }
1420 
1421  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1423  $this->renderObject();
1424  }
1425 
1426  // BEGIN WebDAV: Lock/Unlock objects
1427  function lockObject()
1428  {
1429  global $tree, $ilUser, $rbacsystem;
1430 
1431  if (!$rbacsystem->checkAccess("write",$_GET['item_ref_id']))
1432  {
1433  $this->ilErr->raiseError($this->lng->txt('err_no_permission'),$this->ilErr->MESSAGE);
1434  }
1435 
1436 
1437  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1439  {
1440  require_once 'Services/WebDAV/classes/class.ilDAVLocks.php';
1441  $locks = new ilDAVLocks();
1442 
1443  $result = $locks->lockRef($_GET['item_ref_id'],
1444  $ilUser->getId(), $ilUser->getLogin(),
1445  'ref_'.$_GET['item_ref_id'].'_usr_'.$ilUser->getId(),
1446  time() + /*30*24*60**/60, 0, 'exclusive'
1447  );
1448 
1450  $this->lng->txt(
1451  ($result === true) ? 'object_locked' : $result
1452  ),
1453  true);
1454  }
1455  $this->renderObject();
1456  }
1457  // END WebDAV: Lock/Unlock objects
1458 
1465  function cutObject()
1466  {
1467  global $rbacsystem, $ilCtrl;
1468 
1469  if ($_GET["item_ref_id"] != "")
1470  {
1471  $_POST["id"] = array($_GET["item_ref_id"]);
1472  }
1473 
1474  //$this->ilias->raiseError("move operation does not work at the moment and is disabled",$this->ilias->error_obj->MESSAGE);
1475 
1476 //echo "CUT";
1477 //echo $_SESSION["referer"];
1478  if (!isset($_POST["id"]))
1479  {
1480  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1481  }
1482 
1483  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1484  foreach ($_POST["id"] as $ref_id)
1485  {
1486  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1487  $node_data = $this->tree->getNodeData($ref_id);
1488  $subtree_nodes = $this->tree->getSubTree($node_data);
1489 
1490  $all_node_data[] = $node_data;
1491  $all_subtree_nodes[] = $subtree_nodes;
1492 
1493  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1494  foreach ($subtree_nodes as $node)
1495  {
1496  if($node['type'] == 'rolf')
1497  {
1498  continue;
1499  }
1500 
1501  if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
1502  {
1503  $no_cut[] = $node["ref_id"];
1504  }
1505  }
1506  }
1507  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1508  if (count($no_cut))
1509  {
1510  $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
1511  $this->ilias->error_obj->MESSAGE);
1512  }
1513  //echo "GET";var_dump($_GET);echo "POST";var_dump($_POST);
1514  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1515  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1516 //echo "-".$clipboard["cmd"]."-";
1517  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1518 //echo "-".$_SESSION["clipboard"]["cmd"]."-";
1519 
1520  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"),true);
1521 
1522  return $this->initAndDisplayMoveIntoObjectObject();
1523  } // END CUT
1524 
1525 
1532  function linkObject()
1533  {
1534  global $clipboard, $rbacsystem, $rbacadmin, $ilCtrl;
1535 
1536  if ($_GET["item_ref_id"] != "")
1537  {
1538  $_POST["id"] = array($_GET["item_ref_id"]);
1539  }
1540 
1541  if (!isset($_POST["id"]))
1542  {
1543  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1544  }
1545 
1546  // CHECK ACCESS
1547  foreach ($_POST["id"] as $ref_id)
1548  {
1549  if (!$rbacsystem->checkAccess('delete',$ref_id))
1550  {
1551  $no_cut[] = $ref_id;
1552  }
1553 
1554  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1555 
1556  if (!$this->objDefinition->allowLink($object->getType()))
1557  {
1558  $no_link[] = $object->getType();
1559  }
1560  }
1561 
1562  // NO ACCESS
1563  if (count($no_cut))
1564  {
1565  $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
1566  implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
1567  }
1568 
1569  if (count($no_link))
1570  {
1571  $no_link = array_unique($no_link);
1572 
1573  foreach ($no_link as $type)
1574  {
1575  $txt_objs[] = $this->lng->txt("objs_".$type);
1576  }
1577 
1578  $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
1579 
1580  //$this->ilias->raiseError($this->lng->txt("msg_not_possible_link")." ".
1581  // implode(',',$no_link),$this->ilias->error_obj->MESSAGE);
1582  }
1583 
1584  // WRITE TO CLIPBOARD
1585  $clipboard["parent"] = $_GET["ref_id"];
1586  $clipboard["cmd"] = $ilCtrl->getCmd();
1587 
1588  foreach ($_POST["id"] as $ref_id)
1589  {
1590  $clipboard["ref_ids"][] = $ref_id;
1591  }
1592 
1593  $_SESSION["clipboard"] = $clipboard;
1594 
1595  ilUtil::sendInfo($this->lng->txt("msg_link_clipboard"),true);
1596 
1598 
1599  } // END LINK
1600 
1601 
1607  function clearObject()
1608  {
1609  unset($_SESSION["clipboard"]);
1610  unset($_SESSION["il_rep_clipboard"]);
1611  //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1612 
1613  // only redirect if clipboard was cleared
1614  if (isset($_POST["cmd"]["clear"]))
1615  {
1616  ilUtil::sendSuccess($this->lng->txt("msg_clear_clipboard"),true);
1617 
1618  $this->ctrl->returnToParent($this);
1619  //ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1620  }
1621  }
1622 
1624  {
1625  global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree, $ilObjDataCache, $ilUser;
1626 
1627  if(!in_array($_SESSION['clipboard']['cmd'], array('cut', 'link')))
1628  {
1629  $message = __METHOD__.": cmd was neither 'cut' nor 'link'; may be a hack attempt!";
1630  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
1631  }
1632 
1633  if($_SESSION['clipboard']['cmd'] == 'cut')
1634  {
1635  if(isset($_POST['node']) && (int)$_POST['node'])
1636  $_POST['nodes'] = array($_POST['node']);
1637  }
1638 
1639  if(!is_array($_POST['nodes']) || !count($_POST['nodes']))
1640  {
1641  ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'));
1642  if($_SESSION['clipboard']['cmd'] == 'cut')
1644  else
1646  return;
1647  }
1648 
1649  // this loop does all checks
1650  $folder_objects_cache = array();
1651  foreach($_SESSION['clipboard']['ref_ids'] as $ref_id)
1652  {
1653  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
1654  $current_parent_id = $tree->getParentId($obj_data->getRefId());
1655 
1656  foreach($_POST['nodes'] as $folder_ref_id)
1657  {
1658  if(!array_key_exists($folder_ref_id, $folder_objects_cache))
1659  {
1660  $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id);
1661  }
1662 
1663  // CHECK ACCESS
1664  if(!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType()))
1665  {
1666  $no_paste[] = sprintf($this->lng->txt('msg_no_perm_paste_object_in_folder'), $obj_data->getTitle().' ['.$obj_data->getRefId().']', $folder_objects_cache[$folder_ref_id]->getTitle().' ['.$folder_objects_cache[$folder_ref_id]->getRefId().']');
1667  }
1668 
1669  // CHECK IF REFERENCE ALREADY EXISTS
1670  if($folder_ref_id == $current_parent_id)
1671  {
1672  $exists[] = sprintf($this->lng->txt('msg_obj_exists_in_folder'), $obj_data->getTitle().' ['.$obj_data->getRefId().']', $folder_objects_cache[$folder_ref_id]->getTitle().' ['.$folder_objects_cache[$folder_ref_id]->getRefId().']');
1673  }
1674 
1675  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1676  if($tree->isGrandChild($ref_id, $folder_ref_id))
1677  {
1678  $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle().' ['.$obj_data->getRefId().']');
1679  }
1680 
1681  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
1682  if(!in_array($obj_data->getType(), array_keys($this->objDefinition->getSubObjects($folder_objects_cache[$folder_ref_id]->getType()))))
1683  {
1684  $not_allowed_subobject[] = sprintf($this->lng->txt('msg_obj_may_not_contain_objects_of_type'), $folder_objects_cache[$folder_ref_id]->getTitle().' ['.$folder_objects_cache[$folder_ref_id]->getRefId().']', $obj_data->getType());
1685  }
1686  }
1687  }
1688 
1690  // process checking results
1691  if(count($exists))
1692  {
1693  $error .= implode('<br />', $exists);
1694  }
1695 
1696  if(count($is_child))
1697  {
1698  $error .= $error != '' ? '<br />' : '';
1699  $error .= implode('<br />', $is_child);
1700  }
1701 
1702  if(count($not_allowed_subobject))
1703  {
1704  $error .= $error != '' ? '<br />' : '';
1705  $error .= implode('<br />', $not_allowed_subobject);
1706  }
1707 
1708  if(count($no_paste))
1709  {
1710  $error .= $error != '' ? '<br />' : '';
1711  $error .= implode('<br />', $no_paste);
1712  }
1713 
1714  if($error != '')
1715  {
1717  if($_SESSION['clipboard']['cmd'] == 'cut')
1719  else
1721  return;
1722  }
1723 
1724  // log pasteObject call
1725  $log->write(__METHOD__.", cmd: ".$_SESSION["clipboard"]["cmd"]);
1726 
1728  // everything ok: now paste the objects to new location
1729 
1730  // to prevent multiple actions via back/reload button
1731  $ref_ids = $_SESSION['clipboard']['ref_ids'];
1732  unset($_SESSION['clipboard']['ref_ids']);
1733 
1734  // process CUT command
1735  if($_SESSION['clipboard']['cmd'] == 'cut')
1736  {
1737  foreach($_POST['nodes'] as $folder_ref_id)
1738  {
1739  foreach($ref_ids as $ref_id)
1740  {
1741  // Store old parent
1742  $old_parent = $tree->getParentId($ref_id);
1743  $tree->moveTree($ref_id, $folder_ref_id);
1744  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1745 
1746  include_once('classes/class.ilConditionHandler.php');
1748 
1749  // BEGIN ChangeEvent: Record cut event.
1751  {
1752  $node_data = $tree->getNodeData($ref_id);
1753  $old_parent_data = $tree->getNodeData($old_parent);
1754  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
1755  $old_parent_data['obj_id']);
1756  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
1757  $ilObjDataCache->lookupObjId($folder_ref_id));
1758  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
1759  }
1760  // END PATCH ChangeEvent: Record cut event.
1761  }
1762 
1763  // prevent multiple iterations for cut cmommand
1764  break;
1765  }
1766 
1767  ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
1768  } // END CUT
1769 
1770  // process LINK command
1771  if($_SESSION['clipboard']['cmd'] == 'link')
1772  {
1773  $linked_to_folders = array();
1774 
1775  foreach($_POST['nodes'] as $folder_ref_id)
1776  {
1777  $linked_to_folders[] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id));
1778 
1779  foreach($ref_ids as $ref_id)
1780  {
1781  // get node data
1782  $top_node = $tree->getNodeData($ref_id);
1783 
1784  // get subnodes of top nodes
1785  $subnodes[$ref_id] = $tree->getSubtree($top_node);
1786  }
1787 
1788  // now move all subtrees to new location
1789  foreach($subnodes as $key => $subnode)
1790  {
1791  // first paste top_node....
1793  $new_ref_id = $obj_data->createReference();
1794  $obj_data->putInTree($folder_ref_id);
1795  $obj_data->setPermissions($folder_ref_id);
1796 
1797  // ... remove top_node from list ...
1798  array_shift($subnode);
1799 
1800  // ... store mapping of old ref_id => new_ref_id in hash array ...
1801  $mapping[$new_ref_id] = $key;
1802 
1803  // save old ref_id & create rolefolder if applicable
1804  $old_ref_id = $obj_data->getRefId();
1805  $obj_data->setRefId($new_ref_id);
1806  $obj_data->initDefaultRoles();
1807  $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
1808 
1809  if(isset($rolf_data['child']))
1810  {
1811  // a role folder was created, so map it to old role folder
1812  $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
1813 
1814  // ... use mapping array to find out the correct new parent node where to put in the node...
1815  //$new_parent = array_search($node["parent"],$mapping);
1816  // ... append node to mapping for further possible subnodes ...
1817  $mapping[$rolf_data['child']] = (int)$rolf_data_old['child'];
1818 
1819  // log creation of role folder
1820  $log->write(__METHOD__.", created role folder (ref_id): ".$rolf_data['child'].
1821  ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
1822  ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
1823 
1824  }
1825 
1826  // BEGIN ChangeEvent: Record link event.
1828  {
1829  $node_data = $tree->getNodeData($new_ref_id);
1830  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
1831  $ilObjDataCache->lookupObjId($folder_ref_id));
1832  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
1833  }
1834  // END PATCH ChangeEvent: Record link event.
1835 
1836  // ... insert subtree of top_node if any subnodes exist ...
1837  if(count($subnode) > 0)
1838  {
1839  foreach($subnode as $node)
1840  {
1841  if($node['type'] != 'rolf')
1842  {
1843  $obj_data = ilObjectFactory::getInstanceByRefId($node['child']);
1844  $new_ref_id = $obj_data->createReference();
1845 
1846  // ... use mapping array to find out the correct new parent node where to put in the node...
1847  $new_parent = array_search($node["parent"],$mapping);
1848  // ... append node to mapping for further possible subnodes ...
1849  $mapping[$new_ref_id] = (int)$node['child'];
1850 
1851  $obj_data->putInTree($new_parent);
1852  $obj_data->setPermissions($new_parent);
1853 
1854  // save old ref_id & create rolefolder if applicable
1855  $old_ref_id = $obj_data->getRefId();
1856  $obj_data->setRefId($new_ref_id);
1857  $obj_data->initDefaultRoles();
1858  $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
1859 
1860  if(isset($rolf_data['child']))
1861  {
1862  // a role folder was created, so map it to old role folder
1863  $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
1864 
1865  // ... use mapping array to find out the correct new parent node where to put in the node...
1866  //$new_parent = array_search($node["parent"],$mapping);
1867  // ... append node to mapping for further possible subnodes ...
1868  $mapping[$rolf_data['child']] = (int)$rolf_data_old['child'];
1869 
1870  // log creation of role folder
1871  $log->write(__METHOD__.", created role folder (ref_id): ".$rolf_data['child'].
1872  ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
1873  ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
1874 
1875  }
1876  }
1877 
1878  // re-map $subnodes
1879  foreach($subnodes as $old_ref => $subnode)
1880  {
1881  $new_ref = array_search($old_ref, $mapping);
1882 
1883  foreach($subnode as $node)
1884  {
1885  $node['child'] = array_search($node['child'], $mapping);
1886  $node['parent'] = array_search($node['parent'], $mapping);
1887  $new_subnodes[$ref_id][] = $node;
1888  }
1889  }
1890 
1891  }
1892  }
1893  }
1894 
1895  $log->write(__METHOD__.', link finished');
1896  }
1897 
1898  ilUtil::sendSuccess(sprintf($this->lng->txt('mgs_objects_linked_to_the_following_folders'), implode(', ', $linked_to_folders)), true);
1899  } // END LINK
1900 
1901  // clear clipboard
1902  $this->clearObject();
1903 
1904  $this->ctrl->returnToParent($this);
1905  }
1906 
1908  {
1909  global $tree;
1910 
1911  // empty session on init
1912  $_SESSION['paste_linked_repexpand'] = array();
1913 
1914  // copy opend nodes from repository explorer
1915  $_SESSION['paste_linked_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
1916 
1917  // open current position
1918  $path = $tree->getPathId((int)$_GET['ref_id']);
1919  foreach((array)$path as $node_id)
1920  {
1921  if(!in_array($node_id, $_SESSION['paste_linked_repexpand']))
1922  $_SESSION['paste_linked_repexpand'][] = $node_id;
1923  }
1924 
1925  return $this->showLinkIntoMultipleObjectsTreeObject();
1926  }
1927 
1929  {
1930  global $ilTabs, $ilToolbar;
1931 
1932  $ilTabs->setTabActive('view_content');
1933 
1934  if(!in_array($_SESSION['clipboard']['cmd'], array('link')))
1935  {
1936  $message = __METHOD__.": cmd was not 'link'; may be a hack attempt!";
1937  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
1938  }
1939 
1940  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html');
1941 
1942  require_once 'classes/class.ilPasteIntoMultipleItemsExplorer.php';
1943  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_CHECK, 'repository.php?cmd=goto', 'paste_linked_repexpand');
1944  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showLinkIntoMultipleObjectsTree'));
1945  $exp->setTargetGet('ref_id');
1946  $exp->setPostVar('nodes[]');
1947  is_array($_POST['nodes']) ? $exp->setCheckedItems((array)$_POST['nodes']) : $exp->setCheckedItems(array());
1948 
1949  if($_GET['paste_linked_repexpand'] == '')
1950  {
1951  $expanded = $this->tree->readRootId();
1952  }
1953  else
1954  {
1955  $expanded = $_GET['paste_linked_repexpand'];
1956  }
1957 
1958  $this->tpl->setVariable('FORM_TARGET', '_top');
1959  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
1960 
1961  $exp->setExpand($expanded);
1962  // build html-output
1963  $exp->setOutput(0);
1964  $output = $exp->getOutput();
1965 
1966  $this->tpl->setVariable('OBJECT_TREE', $output);
1967 
1968  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
1969  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
1970 
1971  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getParentReturnByClass(get_class($this)));
1972  }
1973 
1975  {
1976  global $tree;
1977 
1978  // empty session on init
1979  $_SESSION['paste_cut_repexpand'] = array();
1980 
1981  // copy opend nodes from repository explorer
1982  $_SESSION['paste_cut_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
1983 
1984  // open current position
1985  $path = $tree->getPathId((int)$_GET['ref_id']);
1986  foreach((array)$path as $node_id)
1987  {
1988  if(!in_array($node_id, $_SESSION['paste_cut_repexpand']))
1989  $_SESSION['paste_cut_repexpand'][] = $node_id;
1990  }
1991 
1992  return $this->showMoveIntoObjectTreeObject();
1993  }
1994 
1996  {
1997  global $ilTabs, $ilToolbar;
1998 
1999  $ilTabs->setTabActive('view_content');
2000 
2001  if(!in_array($_SESSION['clipboard']['cmd'], array('cut')))
2002  {
2003  $message = __METHOD__.": cmd was not 'cut'; may be a hack attempt!";
2004  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2005  }
2006 
2007  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html');
2008 
2009  require_once 'classes/class.ilPasteIntoMultipleItemsExplorer.php';
2010  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_RADIO, 'repository.php?cmd=goto', 'paste_cut_repexpand');
2011  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showMoveIntoObjectTree'));
2012  $exp->setTargetGet('ref_id');
2013  $exp->setPostVar('node');
2014  $exp->setCheckedItems(array((int)$_POST['node']));
2015 
2016  if($_GET['paste_cut_repexpand'] == '')
2017  {
2018  $expanded = $this->tree->readRootId();
2019  }
2020  else
2021  {
2022  $expanded = $_GET['paste_cut_repexpand'];
2023  }
2024 
2025  $this->tpl->setVariable('FORM_TARGET', '_top');
2026  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2027 
2028  $exp->setExpand($expanded);
2029  // build html-output
2030  $exp->setOutput(0);
2031  $output = $exp->getOutput();
2032 
2033  $this->tpl->setVariable('OBJECT_TREE', $output);
2034 
2035  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2036  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
2037 
2038  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getParentReturnByClass(get_class($this)));
2039  }
2040 
2047  function pasteObject()
2048  {
2049  global $rbacsystem, $rbacadmin, $rbacreview, $log,$tree;
2050  global $ilUser, $lng;
2051 
2052  // BEGIN ChangeEvent: Record paste event.
2053  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2054  // END ChangeEvent: Record paste event.
2055 
2056 //var_dump($_SESSION["clipboard"]);exit;
2057  if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
2058  {
2059  $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
2060  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
2061  }
2062 
2063  // this loop does all checks
2064  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2065  {
2066  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
2067 
2068  // CHECK ACCESS
2069  if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
2070  {
2071  $no_paste[] = $ref_id;
2072  $no_paste_titles[] = $obj_data->getTitle();
2073  }
2074 
2075  // CHECK IF REFERENCE ALREADY EXISTS
2076  if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
2077  {
2078  $exists[] = $ref_id;
2079  break;
2080  }
2081 
2082  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
2083  if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
2084  {
2085  $is_child[] = $ref_id;
2086  }
2087 
2088  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
2089  $obj_type = $obj_data->getType();
2090 
2091  if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
2092  {
2093  $not_allowed_subobject[] = $obj_data->getType();
2094  }
2095  }
2096 
2098  // process checking results
2099  // BEGIN WebDAV: Copying an object into the same container is allowed
2100  if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy")
2101  // END WebDAV: Copying an object into the same container is allowed
2102  {
2103  $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
2104  }
2105 
2106  if (count($is_child))
2107  {
2108  $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
2109  $this->ilias->error_obj->MESSAGE);
2110  }
2111 
2112  if (count($not_allowed_subobject))
2113  {
2114  $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
2115  $this->ilias->error_obj->MESSAGE);
2116  }
2117 
2118  if (count($no_paste))
2119  {
2120  $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
2121  implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
2122  }
2123 
2124  // log pasteObject call
2125  $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
2126 
2128  // everything ok: now paste the objects to new location
2129 
2130  // to prevent multiple actions via back/reload button
2131  $ref_ids = $_SESSION["clipboard"]["ref_ids"];
2132  unset($_SESSION["clipboard"]["ref_ids"]);
2133 
2134  // BEGIN WebDAV: Support a copy command in the repository
2135  // process COPY command
2136  if ($_SESSION["clipboard"]["cmd"] == "copy")
2137  {
2138  foreach($ref_ids as $ref_id)
2139  {
2140  $revIdMapping = array();
2141 
2142  $oldNode_data = $tree->getNodeData($ref_id);
2143  if ($oldNode_data['parent'] == $this->object->getRefId())
2144  {
2145  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2146  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
2147  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
2148  }
2149  else
2150  {
2151  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
2152  }
2153 
2154 
2155  // BEGIN ChangeEvent: Record copy event.
2156  if (ilChangeEvent::_isActive() )
2157  {
2158  $old_parent_data = $tree->getParentNodeData($ref_id);
2159  $newNode_data = $tree->getNodeData($newRef);
2160  ilChangeEvent::_recordReadEvent($oldNode_data['obj_id'], $ilUser->getId());
2161  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
2162  $this->object->getId());
2163  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2164  }
2165  // END ChangeEvent: Record copy event.
2166  }
2167  $log->write("ilObjectGUI::pasteObject(), copy finished");
2168  }
2169  // END WebDAV: Support a Copy command in the repository
2170 
2171  // process CUT command
2172  if ($_SESSION["clipboard"]["cmd"] == "cut")
2173  {
2174 
2175  foreach($ref_ids as $ref_id)
2176  {
2177  // Store old parent
2178  $old_parent = $tree->getParentId($ref_id);
2179  $this->tree->moveTree($ref_id,$this->object->getRefId());
2180  $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
2181 
2182  include_once('classes/class.ilConditionHandler.php');
2184 
2185  // BEGIN ChangeEvent: Record cut event.
2186  if (ilChangeEvent::_isActive() )
2187  {
2188  $node_data = $tree->getNodeData($ref_id);
2189  $old_parent_data = $tree->getNodeData($old_parent);
2190  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
2191  $old_parent_data['obj_id']);
2192  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2193  $this->object->getId());
2194  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2195  }
2196  // END PATCH ChangeEvent: Record cut event.
2197  }
2198  } // END CUT
2199 
2200  // process LINK command
2201  if ($_SESSION["clipboard"]["cmd"] == "link")
2202  {
2203  foreach ($ref_ids as $ref_id)
2204  {
2205  // get node data
2206  $top_node = $this->tree->getNodeData($ref_id);
2207 
2208  // get subnodes of top nodes
2209  $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
2210  }
2211 
2212  // now move all subtrees to new location
2213  foreach ($subnodes as $key => $subnode)
2214  {
2215  // first paste top_node....
2216  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
2217  $new_ref_id = $obj_data->createReference();
2218  $obj_data->putInTree($_GET["ref_id"]);
2219  $obj_data->setPermissions($_GET["ref_id"]);
2220 
2221  // ... remove top_node from list ...
2222  array_shift($subnode);
2223 
2224  // ... store mapping of old ref_id => new_ref_id in hash array ...
2225  $mapping[$new_ref_id] = $key;
2226 
2227  // save old ref_id & create rolefolder if applicable
2228 // old ref is wrongly set here... see next comments (Alex, 26.11.2008)
2229  $old_ref_id = $obj_data->getRefId();
2230  $obj_data->setRefId($new_ref_id);
2231  $obj_data->initDefaultRoles();
2232  $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
2233 
2234  if (isset($rolf_data["child"]))
2235  {
2236  // a role folder was created, so map it to old role folder
2237 // rolf_data_old is wrongly set here... see next comments (Alex, 26.11.2008)
2238  $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
2239 
2240  // ... use mapping array to find out the correct new parent node where to put in the node...
2241  //$new_parent = array_search($node["parent"],$mapping);
2242  // ... append node to mapping for further possible subnodes ...
2243  $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
2244 
2245  // log creation of role folder
2246  $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
2247  ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
2248  ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
2249 
2250  }
2251  // BEGIN ChangeEvent: Record link event.
2252  if (ilChangeEvent::_isActive() )
2253  {
2254  $node_data = $tree->getNodeData($new_ref_id);
2255  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2256  $this->object->getId());
2257  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2258  }
2259  // END PATCH ChangeEvent: Record link event.
2260 
2261 // The following part is never executed (ILIAS 3.10) since ILIAS does not allow
2262 // to link container. This means the only $subnode could be a role folder.
2263 // But role folders are not tackled (if ($node[type] != 'rolf')).
2264 // Alex, 26.11.2008
2265  // ... insert subtree of top_node if any subnodes exist ...
2266 /*
2267  if (count($subnode) > 0)
2268  {
2269  foreach ($subnode as $node)
2270  {
2271  if ($node["type"] != 'rolf')
2272  {
2273  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
2274  $new_ref_id = $obj_data->createReference();
2275 
2276  // ... use mapping array to find out the correct new parent node where to put in the node...
2277  $new_parent = array_search($node["parent"],$mapping);
2278  // ... append node to mapping for further possible subnodes ...
2279  $mapping[$new_ref_id] = (int) $node["child"];
2280 
2281  $obj_data->putInTree($new_parent);
2282  $obj_data->setPermissions($new_parent);
2283 
2284  // save old ref_id & create rolefolder if applicable
2285  $old_ref_id = $obj_data->getRefId();
2286  $obj_data->setRefId($new_ref_id);
2287  $obj_data->initDefaultRoles();
2288  $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
2289 
2290  if (isset($rolf_data["child"]))
2291  {
2292  // a role folder was created, so map it to old role folder
2293  $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
2294 
2295  // ... use mapping array to find out the correct new parent node where to put in the node...
2296  //$new_parent = array_search($node["parent"],$mapping);
2297  // ... append node to mapping for further possible subnodes ...
2298  $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
2299 
2300  // log creation of role folder
2301  $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
2302  ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
2303  ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
2304 
2305  }
2306  }
2307 
2308  // re-map $subnodes
2309  foreach ($subnodes as $old_ref => $subnode)
2310  {
2311  $new_ref = array_search($old_ref,$mapping);
2312 
2313  foreach ($subnode as $node)
2314  {
2315  $node["child"] = array_search($node["child"],$mapping);
2316  $node["parent"] = array_search($node["parent"],$mapping);
2317  $new_subnodes[$ref_id][] = $node;
2318  }
2319  }
2320 
2321  }
2322  }
2323 */
2324  }
2325 
2326  $log->write("ilObjectGUI::pasteObject(), link finished");
2327 
2328  // inform other objects in hierarchy about link operation
2329  //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
2330  } // END LINK
2331 
2332  // save cmd for correct message output after clearing the clipboard
2333  $last_cmd = $_SESSION["clipboard"]["cmd"];
2334 
2335 
2336  // clear clipboard
2337  $this->clearObject();
2338 
2339  if ($last_cmd == "cut")
2340  {
2341  ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"),true);
2342  }
2343  // BEGIN WebDAV: Support a copy command in repository
2344  else if ($last_cmd == "copy")
2345  {
2346  ilUtil::sendSuccess($this->lng->txt("msg_cloned"),true);
2347  }
2348  else if ($last_command == 'link')
2349  // END WebDAV: Support copy command in repository
2350  {
2351  ilUtil::sendSuccess($this->lng->txt("msg_linked"),true);
2352  }
2353 
2354  $this->ctrl->returnToParent($this);
2355 
2356  } // END PASTE
2357 
2358 
2359  // BEGIN WebDAV: Support a copy command in repository
2360 
2368  function copyObject()
2369  {
2370  global $ilAccess,$ilObjDefinition;
2371 
2372  if(!$ilAccess->checkAccess('copy','',$_GET['item_ref_id']))
2373  {
2375 
2376  ilUtil::sendFailure($this->lng->txt('msg_no_perm_copy').' '.$title,true);
2377  $this->ctrl->returnToParent($this);
2378  }
2379 
2380  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2381  $_SESSION["clipboard"]["cmd"] = 'copy';
2382 
2383  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2384  return $this->initAndDisplayCopyIntoObjectObject();
2385 
2386 
2387 
2388 
2389 
2390 
2391  // FOR ALL OBJECTS THAT SHOULD BE COPIED
2392  foreach ($_POST["id"] as $ref_id)
2393  {
2394  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
2395  $node_data = $this->tree->getNodeData($ref_id);
2396  $subtree_nodes = $this->tree->getSubTree($node_data);
2397 
2398  $all_node_data[] = $node_data;
2399  $all_subtree_nodes[] = $subtree_nodes;
2400 
2401  // CHECK VIEW, READ AND COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
2402  foreach ($subtree_nodes as $node)
2403  {
2404  if($node['type'] == 'rolf')
2405  {
2406  continue;
2407  }
2408 
2409  if (!$rbacsystem->checkAccess('visible,read,copy',$node["ref_id"]))
2410  {
2411  $no_copy[] = $node["ref_id"];
2412  }
2413  }
2414  }
2415  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'view,read'
2416  if (count($no_copy))
2417  {
2418  $this->ilias->raiseError($this->lng->txt("msg_no_perm_copy")." ".implode(',',$this->getTitlesByRefId($no_copy)),
2419  $this->ilias->error_obj->MESSAGE);
2420  }
2421  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2422  $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
2423  ? $_GET["cmd"]
2424  : key($_POST["cmd"]);
2425  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
2426 
2427  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2428 
2429  $this->ctrl->returnToParent($this);
2430 
2431  } // END COPY
2432  // BEGIN WebDAV: Support copy command in repository
2433 
2434 
2438  function clipboardObject()
2439  {
2440  global $ilErr,$ilLog;
2441 
2442  // function should not be called if clipboard is empty
2443  if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
2444  {
2445  $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
2446  $ilLog->write($message,$ilLog->FATAL);
2447  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
2448  }
2449 
2450  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html");
2451 
2452  // FORMAT DATA
2453  $counter = 0;
2454  $f_result = array();
2455 
2456  foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2457  {
2458  if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
2459  {
2460  continue;
2461  }
2462 
2463  //$f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
2464  $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
2465  $f_result[$counter][] = $tmp_obj->getTitle();
2466  //$f_result[$counter][] = $tmp_obj->getDescription();
2467  $f_result[$counter][] = ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]);
2468 
2469  unset($tmp_obj);
2470  ++$counter;
2471  }
2472 
2473  $this->__showClipboardTable($f_result, "clipboardObject");
2474 
2475  return true;
2476  }
2477 
2478 
2483  function showCustomIconsEditing($a_input_colspan = 1)
2484  {
2485  if ($this->ilias->getSetting("custom_icons"))
2486  {
2487  $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
2488  "tpl.container_icon_settings.html");
2489 
2490  if (($big_icon = $this->object->getBigIconPath()) != "")
2491  {
2492  $this->tpl->setCurrentBlock("big_icon");
2493  $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
2494  $this->tpl->parseCurrentBlock();
2495  }
2496  if ($this->object->getType() != "root")
2497  {
2498  if (($small_icon = $this->object->getSmallIconPath()) != "")
2499  {
2500  $this->tpl->setCurrentBlock("small_icon");
2501  $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
2502  $this->tpl->parseCurrentBlock();
2503  }
2504  $this->tpl->setCurrentBlock("small_icon_row");
2505  $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("standard_icon"));
2506  $this->tpl->setVariable("SMALL_SIZE", "(".
2507  $this->ilias->getSetting("custom_icon_small_width")."x".
2508  $this->ilias->getSetting("custom_icon_small_height").")");
2509  $this->tpl->setVariable("TXT_REMOVE_S", $this->lng->txt("remove"));
2510  $this->tpl->parseCurrentBlock();
2511  }
2512  if (($tiny_icon = $this->object->getTinyIconPath()) != "")
2513  {
2514  $this->tpl->setCurrentBlock("tiny_icon");
2515  $this->tpl->setVariable("SRC_TINY_ICON", $tiny_icon);
2516  $this->tpl->parseCurrentBlock();
2517  }
2518  $this->tpl->setCurrentBlock("container_icon_settings");
2519  $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
2520  $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
2521  $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
2522  $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
2523  $this->tpl->setVariable("TINY_ICON", $this->lng->txt("tiny_icon"));
2524  $this->tpl->setVariable("BIG_SIZE", "(".
2525  $this->ilias->getSetting("custom_icon_big_width")."x".
2526  $this->ilias->getSetting("custom_icon_big_height").")");
2527  $this->tpl->setVariable("TINY_SIZE", "(".
2528  $this->ilias->getSetting("custom_icon_tiny_width")."x".
2529  $this->ilias->getSetting("custom_icon_tiny_height").")");
2530  $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
2531  $this->tpl->parseCurrentBlock();
2532  }
2533  }
2534 
2536  {
2537  return $_SESSION["il_cont_admin_panel"];
2538  }
2539 
2543  function setColumnSettings($column_gui)
2544  {
2545  global $ilAccess;
2546  parent::setColumnSettings($column_gui);
2547 
2548  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
2549  $this->isActiveAdministrationPanel() &&
2550  $this->allowBlocksMoving())
2551  {
2552  $column_gui->setEnableMovement(true);
2553  }
2554 
2555  $column_gui->setRepositoryItems(
2556  $this->object->getSubItems($this->isActiveAdministrationPanel(), true));
2557 
2558  //if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
2559  // && $this->allowBlocksConfigure())
2560  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
2561  {
2562  $column_gui->setBlockProperty("news", "settings", true);
2563  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
2564  $column_gui->setBlockProperty("news", "default_visibility_option", true);
2565  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
2566  }
2567 
2568  if ($this->isActiveAdministrationPanel())
2569  {
2570  $column_gui->setAdminCommands(true);
2571  }
2572  }
2573 
2578  {
2579  true;
2580  }
2581 
2586  {
2587  true;
2588  }
2589 
2597  public function cloneWizardPageTreeObject()
2598  {
2599  $this->cloneWizardPageObject(true);
2600  }
2601 
2609  public function cloneWizardPageListObject()
2610  {
2611  $this->cloneWizardPageObject(false);
2612  }
2613 
2620  public function cloneWizardPageObject($a_tree_view = true)
2621  {
2622  include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
2623 
2624  global $ilObjDataCache,$tree;
2625 
2626  if(!$_REQUEST['clone_source'])
2627  {
2628  ilUtil::sendFailure($this->lng->txt('select_one'));
2629  if(isset($_SESSION['wizard_search_title']))
2630  {
2631  $this->searchCloneSourceObject();
2632  }
2633  else
2634  {
2635  $this->createObject();
2636  }
2637  return false;
2638  }
2639  $source_id = $_REQUEST['clone_source'];
2640  $new_type = $_REQUEST['new_type'];
2641  $this->ctrl->setParameter($this,'clone_source',(int) $_REQUEST['clone_source']);
2642  $this->ctrl->setParameter($this,'new_type',$new_type);
2643 
2644 
2645  // Generell JavaScript
2646  $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
2647  $this->tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
2648 
2649 
2650  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.container_wizard_page.html');
2651  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
2652  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$new_type.'.gif'));
2653  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$new_type));
2654  $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt($new_type.'_wizard_page'));
2655  $this->tpl->setVariable('INFO_DUPLICATE',$this->lng->txt($new_type.'_copy_threads_info'));
2656  $this->tpl->setVariable('BTN_COPY',$this->lng->txt('obj_'.$new_type.'_duplicate'));
2657  $this->tpl->setVariable('BTN_BACK',$this->lng->txt('btn_back'));
2658  if(isset($_SESSION['wizard_search_title']))
2659  {
2660  $this->tpl->setVariable('CMD_BACK','searchCloneSource');
2661  }
2662  else
2663  {
2664  $this->tpl->setVariable('CMD_BACK','create');
2665  }
2666 
2667  $this->tpl->setVariable('BTN_TREE',$this->lng->txt('treeview'));
2668  $this->tpl->setVariable('BTN_LIST',$this->lng->txt('flatview'));
2669 
2670  // Fill item rows
2671  // tree view
2672  if($a_tree_view)
2673  {
2674  $first = true;
2675  $has_items = false;
2676  foreach($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id),true) as $node)
2677  {
2678  if($first == true)
2679  {
2680  $first = false;
2681  continue;
2682  }
2683 
2684  if($node['type'] == 'rolf')
2685  {
2686  continue;
2687  }
2688 
2689  $has_items = true;
2690 
2691  for($i = $source_node['depth'];$i < $node['depth']; $i++)
2692  {
2693  $this->tpl->touchBlock('padding');
2694  $this->tpl->touchBlock('end_padding');
2695  }
2696  // fill options
2697  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$node['type']);
2698  $copy_wizard_page->fillTreeSelection($node['ref_id'],$node['type'],$node['depth']);
2699 
2700  $this->tpl->setCurrentBlock('tree_row');
2701  $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'_s.gif'));
2702  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$node['type']));
2703  $this->tpl->setVariable('TREE_TITLE',$node['title']);
2704  $this->tpl->parseCurrentBlock();
2705  }
2706  if(!$has_items)
2707  {
2708  $this->tpl->setCurrentBlock('no_content');
2709  $this->tpl->setVariable('TXT_NO_CONTENT',$this->lng->txt('container_no_items'));
2710  $this->tpl->parseCurrentBlock();
2711  }
2712  else
2713  {
2714  $this->tpl->setCurrentBlock('tree_footer');
2715  $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
2716  $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
2717  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
2718  $this->tpl->parseCurrentBlock();
2719 
2720  }
2721  }
2722  else
2723  {
2724  foreach($tree->getSubTreeTypes($source_id,array('rolf','crs')) as $type)
2725  {
2726  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$type);
2727  if(strlen($html = $copy_wizard_page->getWizardPageBlockHTML()))
2728  {
2729  $this->tpl->setCurrentBlock('obj_row');
2730  $this->tpl->setVariable('ITEM_BLOCK',$html);
2731  $this->tpl->parseCurrentBlock();
2732  }
2733  }
2734  }
2735  }
2736 
2744  public function cloneAllObject()
2745  {
2746  global $ilLog;
2747 
2748  include_once('classes/class.ilLink.php');
2749  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
2750 
2751  global $ilAccess,$ilErr,$rbacsystem,$tree,$ilUser;
2752 
2753  $new_type = $_REQUEST['new_type'];
2754  $ref_id = (int) $_GET['ref_id'];
2755  $clone_source = (int) $_REQUEST['clone_source'];
2756 
2757  if(!$rbacsystem->checkAccess('create', $ref_id,$new_type))
2758  {
2759  $ilErr->raiseError($this->lng->txt('permission_denied'));
2760  }
2761  if(!$clone_source)
2762  {
2763  ilUtil::sendFailure($this->lng->txt('select_one'));
2764  $this->createObject();
2765  return false;
2766  }
2767  if(!$ilAccess->checkAccess('write','', $clone_source,$new_type))
2768  {
2769  $ilErr->raiseError($this->lng->txt('permission_denied'));
2770  }
2771 
2772  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
2773  $orig = ilObjectFactory::getInstanceByRefId($clone_source);
2774  $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
2775 
2776  // Check if copy is in progress
2777  if ($result == $ref_id)
2778  {
2779  ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"),true);
2780  ilUtil::redirect('repository.php?ref_id='.$ref_id);
2781  }
2782  else
2783  {
2784  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
2785  ilUtil::redirect('repository.php?ref_id='.$result);
2786  }
2787  }
2788 
2796  public function copyWizardHasOptions($a_mode)
2797  {
2798  switch($a_mode)
2799  {
2800  case self::COPY_WIZARD_NEEDS_PAGE:
2801  return true;
2802 
2803  default:
2804  return false;
2805  }
2806  }
2807 
2815  public function saveSortingObject()
2816  {
2817  include_once('Services/Container/classes/class.ilContainerSorting.php');
2818  $sorting = ilContainerSorting::_getInstance($this->object->getId());
2819  $sorting->savePost($_POST['position']);
2820  ilUtil::sendSuccess($this->lng->txt('cntr_saved_sorting'), true);
2821  $this->ctrl->redirect($this, "editOrder");
2822  }
2823 
2824  // BEGIN WebDAV: Support a copy command in the repository
2835  function cloneNodes($srcRef,$dstRef,&$mapping, $newName=null)
2836  {
2837  global $tree;
2838  global $ilias;
2839 
2840  // clone the source node
2841  $srcObj =& $ilias->obj_factory->getInstanceByRefId($srcRef);
2842  error_log(__METHOD__.' cloning srcRef='.$srcRef.' dstRef='.$dstRef.'...');
2843  $newRef = $srcObj->cloneObject($dstRef)->getRefId();
2844  error_log(__METHOD__.' ...cloning... newRef='.$newRef.'...');
2845 
2846  // We must immediately apply a new name to the object, to
2847  // prevent confusion of WebDAV clients about having two objects with identical
2848  // name in the repository.
2849  if (! is_null($newName))
2850  {
2851  $newObj =& $ilias->obj_factory->getInstanceByRefId($newRef);
2852  $newObj->setTitle($newName);
2853  $newObj->update();
2854  unset($newObj);
2855  }
2856  unset($srcObj);
2857  $mapping[$newRef] = $srcRef;
2858 
2859  // clone all children of the source node
2860  $children = $tree->getChilds($srcRef);
2861  foreach ($tree->getChilds($srcRef) as $child)
2862  {
2863  // Don't clone role folders, because it does not make sense to clone local roles
2864  // FIXME - Maybe it does make sense (?)
2865  if ($child["type"] != 'rolf')
2866  {
2867  $this->cloneNodes($child["ref_id"],$newRef,$mapping);
2868  }
2869  else
2870  {
2871  if (count($rolf = $tree->getChildsByType($newRef,"rolf")))
2872  {
2873  $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
2874  }
2875  }
2876  }
2877  error_log(__METHOD__.' ...cloned srcRef='.$srcRef.' dstRef='.$dstRef.' newRef='.$newRef);
2878  return $newRef;
2879  }
2880  // END PATCH WebDAV: Support a copy command in the repository
2881 
2885  function modifyItemGUI(&$a_item_list_gui, $a_item_data, $a_show_path)
2886  {
2887  global $lng;
2888 
2889  if($a_show_path)
2890  {
2891  $a_item_list_gui->addCustomProperty($lng->txt('path'),
2892  ilContainer_buildPath($a_item_data['ref_id'], $this->object->getRefId()),
2893  false, true);
2894  }
2895  }
2896 
2900  static function _buildPath($a_ref_id, $a_course_ref_id)
2901  {
2902  global $tree;
2903 
2904  $path_arr = $tree->getPathFull($a_ref_id, $a_course_ref_id);
2905  $counter = 0;
2906  foreach($path_arr as $data)
2907  {
2908  if($counter++)
2909  {
2910  $path .= " > ";
2911  }
2912  $path .= $data['title'];
2913  }
2914 
2915  return $path;
2916  }
2917 
2918  //
2919  // Style editing
2920  //
2921 
2926  {
2927  global $ilTabs, $tpl;
2928 
2929  $this->checkPermission("write");
2930 
2931  $this->initStylePropertiesForm();
2932  $tpl->setContent($this->form->getHTML());
2933 
2934  $ilTabs->activateTab("obj_sty");
2935  }
2936 
2941  {
2942  global $ilCtrl, $lng, $ilTabs, $ilSetting, $tpl;
2943 
2944  $tpl->setTreeFlatIcon("", "");
2945  $ilTabs->clearTargets();
2946  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
2947  "xhtml_page");
2948  if ($xpage_id > 0)
2949  {
2950  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
2951  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
2952  }
2953  else
2954  {
2955  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
2956  $this->object->getRefId(), "_top");
2957  }
2958 
2959  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
2960  $page_gui =& new ilPageObjectGUI($this->object->getType(),
2961  $this->object->getId());
2962  $page_gui->setStyleId($this->object->getStyleSheetId());
2963  $page_gui->setTabHook($this, "addPageTabs");
2964 // $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg_b.gif"));
2965 // $tpl->setTitle($this->lng->txt("page").": ".$this->obj->getTitle());
2966  $ilCtrl->getHTML($page_gui);
2967  $ilTabs->setTabActive("obj_sty");
2968 
2969  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2970  $lng->loadLanguageModule("style");
2971 
2972  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2973  $this->form = new ilPropertyFormGUI();
2974 
2975  $fixed_style = $ilSetting->get("fixed_content_style_id");
2976  $style_id = $this->object->getStyleSheetId();
2977 
2978  if ($fixed_style > 0)
2979  {
2980  $st = new ilNonEditableValueGUI($lng->txt("wiki_current_style"));
2981  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
2982  $this->lng->txt("global_fixed").")");
2983  $this->form->addItem($st);
2984  }
2985  else
2986  {
2987  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
2988  $_GET["ref_id"]);
2989 
2990  $st_styles[0] = $this->lng->txt("default");
2991  ksort($st_styles);
2992 
2993  if ($style_id > 0)
2994  {
2995  // individual style
2996  if (!ilObjStyleSheet::_lookupStandard($style_id))
2997  {
2998  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
2999  $st->setValue(ilObject::_lookupTitle($style_id));
3000  $this->form->addItem($st);
3001 
3002 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
3003 
3004  // delete command
3005  $this->form->addCommandButton("editStyle",
3006  $lng->txt("style_edit_style"));
3007  $this->form->addCommandButton("deleteStyle",
3008  $lng->txt("style_delete_style"));
3009 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
3010  }
3011  }
3012 
3013  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
3014  {
3015  $style_sel = ilUtil::formSelect ($style_id, "style_id",
3016  $st_styles, false, true);
3017  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
3018  $style_sel->setOptions($st_styles);
3019  $style_sel->setValue($style_id);
3020  $this->form->addItem($style_sel);
3021 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
3022  $this->form->addCommandButton("saveStyleSettings",
3023  $lng->txt("save"));
3024  $this->form->addCommandButton("createStyle",
3025  $lng->txt("sty_create_ind_style"));
3026  }
3027  }
3028  $this->form->setTitle($lng->txt("obj_sty"));
3029  $this->form->setFormAction($ilCtrl->getFormAction($this));
3030  }
3031 
3036  {
3037  global $ilCtrl;
3038 
3039  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
3040  }
3041 
3045  function editStyleObject()
3046  {
3047  global $ilCtrl;
3048 
3049  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
3050  }
3051 
3056  {
3057  global $ilCtrl;
3058 
3059  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
3060  }
3061 
3066  {
3067  global $ilSetting;
3068 
3069  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3070  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3071  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3072  || $this->object->getStyleSheetId() == 0))
3073  {
3074  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
3075  $this->object->update();
3076  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3077  }
3078  $this->ctrl->redirect($this, "editStyleProperties");
3079  }
3080 
3085  {
3086  global $ilCtrl;
3087 
3088  $ref_id = $_GET["cmdrefid"];
3091 
3092  // this should be done via container-object->getSubItem in the future
3093  $data = array("child" => $ref_id, "ref_id" => $ref_id, "obj_id" => $obj_id,
3094  "type" => $type);
3095  include_once './classes/class.ilObjectListGUIFactory.php';
3097  $item_list_gui->setContainerObject($this);
3098  $this->modifyItemGUI($item_list_gui, $data, false);
3099  $html = $item_list_gui->getListItemHTML($ref_id,
3100  $obj_id, "", "", true, true);
3101  echo $html;
3102  exit;
3103  }
3104 
3105 }
3106 ?>