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