ILIAS  release_4-3 Revision
 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 "./Services/Object/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 
89  protected function getEditFormValues()
90  {
91  $values = parent::getEditFormValues();
92 
93  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
94  $values['didactic_type'] =
95  'dtpl_'.ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
96 
97  return $values;
98  }
99 
103  protected function afterUpdate()
104  {
105  // check if template is changed
106  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
107  $current_tpl_id = (int) ilDidacticTemplateObjSettings::lookupTemplateId(
108  $this->object->getRefId()
109  );
110  $new_tpl_id = (int) $this->getDidacticTemplateVar('dtpl');
111 
112  if($new_tpl_id != $current_tpl_id)
113  {
114  $_REQUEST['tplid'] = $new_tpl_id;
115 
116  // redirect to didactic template confirmation
117  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
118  $this->ctrl->setReturn($this,'edit');
119  $this->ctrl->setCmdClass('ildidactictemplategui');
120  $this->ctrl->setCmd('confirmTemplateSwitch');
121  $dtpl_gui = new ilDidacticTemplateGUI($this);
122  return $this->ctrl->forwardCommand($dtpl_gui);
123  }
125  }
126 
127 
132  {
133  global $ilCtrl, $ilTabs;
134 
135  $ilTabs->clearTargets();
136 
137  $cmd = $ilCtrl->getCmd();
138  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
139  $this->ctrl->setReturn($this, "editStyleProperties");
140  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
141  $style_gui->omitLocator();
142  if ($cmd == "create" || $_GET["new_type"]=="sty")
143  {
144  $style_gui->setCreationMode(true);
145  }
146 
147  if ($cmd == "confirmedDelete")
148  {
149  $this->object->setStyleSheetId(0);
150  $this->object->update();
151  }
152 
153  $ret = $this->ctrl->forwardCommand($style_gui);
154 
155  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
156  {
157  $style_id = $ret;
158  $this->object->setStyleSheetId($style_id);
159  $this->object->update();
160  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
161  }
162  }
163 
164 
169  {
170  global $lng, $ilTabs, $ilCtrl;
171 
172  $cmd = $ilCtrl->getCmd();
173 
174  if (in_array($cmd, array("displayMediaFullscreen", "downloadFile")))
175  {
176  $this->checkPermission("read");
177  }
178  else
179  {
180  $this->checkPermission("write");
181  }
182 
183  $ilTabs->clearTargets();
184 
185  if ($_GET["redirectSource"] == "ilinternallinkgui")
186  {
187  exit;
188  }
189 
190  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
191  "xhtml_page");
192  if ($xpage_id > 0)
193  {
194  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
195  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
196  }
197  else
198  {
199  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
200  $this->object->getRefId(), "_top");
201  }
202 
203  // page object
204  include_once("./Services/COPage/classes/class.ilPageObject.php");
205  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
206 
207  $lng->loadLanguageModule("content");
208 
209  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
210  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
211  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
212 //echo "-".ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())."-";
213  $this->tpl->setCurrentBlock("SyntaxStyle");
214  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
216  $this->tpl->parseCurrentBlock();
217 
218  if (!ilPageObject::_exists($this->object->getType(),
219  $this->object->getId()))
220  {
221  // doesn't exist -> create new one
222  $new_page_object = new ilPageObject($this->object->getType());
223  $new_page_object->setParentId($this->object->getId());
224  $new_page_object->setId($this->object->getId());
225  $new_page_object->createFromXML();
226  }
227 
228  // get page object
229 // $page_object = new ilPageObject($this->object->getType(),
230 // $this->object->getId(), 0, true);
231  $this->ctrl->setReturnByClass("ilpageobjectgui", "edit");
232  //$page_object =& $this->obj->getPageObject();
233 // $page_object->buildDom();
234  //$page_object->addUpdateListener($this, "updateHistory");
235 // $int_links = $page_object->getInternalLinks();
236  //$link_xml = $this->getLinkXML($int_links);
237  $page_gui =& new ilPageObjectGUI($this->object->getType(),
238  $this->object->getId());
239  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
240  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
241  $this->object->getStyleSheetId(), $this->object->getType()));
242 //echo "--".$this->object->getStyleSheetId()."-";
243  // $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
244  //$page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId(),
245  // $view_frame);
246 
247  $page_gui->setIntLinkHelpDefault("RepositoryItem", $_GET["ref_id"]);
248  $page_gui->setTemplateTargetVar("ADM_CONTENT");
249  $page_gui->setLinkXML($link_xml);
250  //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
251  $page_gui->setFileDownloadLink("");
252  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
253  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
254 // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
255  $page_gui->setPresentationTitle("");
256  $page_gui->setTemplateOutput(false);
257  //$page_gui->setLocator($contObjLocator);
258  $page_gui->setHeader("");
259  $page_gui->setEnabledRepositoryObjects(true);
260  $page_gui->setEnabledFileLists(false);
261  $page_gui->setEnabledMaps(true);
262  $page_gui->setEnabledPCTabs(true);
263  $page_gui->setEnabledInternalLinks(true);
264  $page_gui->getPageConfig()->addIntLinkFilter("File");
265 
266  // old editor information text
267  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
268  "xhtml_page");
269  if ($xpage_id > 0)
270  {
271  $wtpl = new ilTemplate("tpl.cntr_old_editor_message.html", true,
272  true, "Services/Container");
273  $wtpl->setVariable("ALT_WARNING", $lng->txt("warning"));
274  $wtpl->setVariable("IMG_WARNING",
275  ilUtil::getImagePath("icon_alert_s.png"));
276  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
277  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
278  $wtpl->setVariable("HREF_SWITCH_TO_NEW_EDITOR",
279  $ilCtrl->getLinkTarget($this, "useNewEditor"));
280  $wtpl->setVariable("TXT_MIGRATION_SWITCH",
281  $lng->txt("cntr_switch_to_new_editor_cmd"));
282  $page_gui->setPrependingHtml($wtpl->get());
283  }
284 
285  // style tab
286  $page_gui->setTabHook($this, "addPageTabs");
287 
288  $ret =& $this->ctrl->forwardCommand($page_gui);
289 
290  //$ret =& $page_gui->executeCommand();
291  return $ret;
292  }
293 
297  function addPageTabs()
298  {
299  global $ilTabs, $ilCtrl;
300 
301  $ilTabs->addTarget("obj_sty",
302  $ilCtrl->getLinkTarget($this, 'editStyleProperties'), "editStyleProperties");
303  }
304 
309  {
310  global $ilSetting;
311 
312  if (!$ilSetting->get("enable_cat_page_edit"))
313  {
314  return;
315  }
316 
317  // old page editor content
318  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
319  "xhtml_page");
320  if ($xpage_id > 0)
321  {
322  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
323  $xpage = new ilXHTMLPage($xpage_id);
324  return $xpage->getContent();
325  }
326 
327 
328  // page object
329 
330 
331  // if page does not exist, return nothing
332  include_once("./Services/COPage/classes/class.ilPageUtil.php");
333  if (!ilPageUtil::_existsAndNotEmpty($this->object->getType(),
334  $this->object->getId()))
335  {
336  return "";
337  }
338  include_once("./Services/COPage/classes/class.ilPageObject.php");
339  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
340 
341  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
342  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
343  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
344  $this->tpl->setCurrentBlock("SyntaxStyle");
345  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
347  $this->tpl->parseCurrentBlock();
348 
349  // get page object
350  $page_gui =& new ilPageObjectGUI($this->object->getType(),
351  $this->object->getId());
352  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
353  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
354  $this->object->getStyleSheetId(), $this->object->getType()));
355 
356  $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
357  $page_gui->setFileDownloadLink("");
358  //$page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
359  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
360 // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
361  $page_gui->setPresentationTitle("");
362  $page_gui->setTemplateOutput(false);
363  //$page_gui->setLocator($contObjLocator);
364  $page_gui->setHeader("");
365  $page_gui->setEnabledRepositoryObjects(true);
366  $page_gui->setEnabledFileLists(false);
367  $page_gui->setEnabledPCTabs(true);
368  $page_gui->setEnabledMaps(true);
369  $ret = $page_gui->showPage();
370 
371  //$ret =& $page_gui->executeCommand();
372  return $ret;
373  }
374 
378  function prepareOutput($a_show_subobjects = true)
379  {
380  if (parent::prepareOutput()) // return false in admin mode
381  {
382  if ($this->getCreationMode() != true && $a_show_subobjects)
383  {
384  // This method is called directly from ilContainerGUI::renderObject
385  #$this->showPossibleSubObjects();
386  $this->showTreeFlatIcon();
387 
388  // Member view
389  include_once './Services/Container/classes/class.ilMemberViewGUI.php';
390  ilMemberViewGUI::showMemberViewSwitch($this->object->getRefId());
391  }
392  }
393  }
394 
395  function showTreeFlatIcon()
396  {
397  global $tpl;
398 
399  // dont show icon, if role (permission gui->rolegui) is edited
400  if ($_GET["obj_id"] != "")
401  {
402  return;
403  }
404  // hide for member view
405  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
406  if(ilMemberViewSettings::getInstance()->isActive())
407  {
408  return;
409  }
410 
411  $mode = ($_SESSION["il_rep_mode"] == "flat")
412  ? "tree"
413  : "flat";
414  $link = "ilias.php?baseClass=ilRepositoryGUI&amp;cmd=frameset&amp;set_mode=".$mode."&amp;ref_id=".$this->object->getRefId();
415  $tpl->setTreeFlatIcon($link, $mode);
416  }
417 
422  {
423  global $ilias;
424 
425  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
426  {
427  $this->tpl->setTitle($this->object->getTitle());
428  $this->tpl->setDescription($this->object->getLongDescription());
429 
430  // set tile icon
431  $icon = ilUtil::getImagePath("icon_".$this->object->getType()."_b.png");
432  if ($ilias->getSetting("custom_icons") &&
433  in_array($this->object->getType(), array("cat","grp","crs", "root")))
434  {
435  require_once("./Services/Container/classes/class.ilContainer.php");
436  if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
437  {
438  $icon = $path;
439  }
440  }
441  $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
442 
443  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
444  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
445  $lgui->initItem($this->object->getRefId(), $this->object->getId());
446  $this->tpl->setAlertProperties($lgui->getAlertProperties());
447  }
448  }
449 
450 
455  {
456  global $ilAccess,$ilCtrl,$lng;
457 
458  $found = false;
459  $cmd = ($this->cmd != "")
460  ? $this->cmd
461  : $this->ctrl->getCmd();
462 
463  $type = $this->object->getType();
464 
465  $d = $this->objDefinition->getCreatableSubObjects($type);
466  include_once("./Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php");
467 
468  /* is done in ilObjectDefinition::readDefinitionData()
469  if ($type != "icrs")
470  {
471  $d = ilRepositoryObjectPluginSlot::addCreatableSubObjects($d);
472  }
473  */
474 
475  if (count($d) > 0)
476  {
477  foreach ($d as $row)
478  {
479  $count = 0;
480 
481  if ($row["max"] == "" || $count < $row["max"])
482  {
483  if (!in_array($row["name"], array("rolf")))
484  {
485  if ($this->rbacsystem->checkAccess("create", $this->object->getRefId(), $row["name"]))
486  {
487  if ($row["plugin"])
488  {
489  include_once("./Services/Component/classes/class.ilPlugin.php");
490  $title = ilPlugin::lookupTxt("rep_robj", $row["name"], "obj_".$row["name"]);
491  }
492  else
493  {
494  // #13088
495  $title = $this->lng->txt("obj_".$row["name"]);
496  }
497 
498  $subobj[] = array("value" => $row["name"],
499  "title" => $title,
500  "img" => ilObject::_getIcon("", "tiny", $row["name"]),
501  "alt" => $title);
502  }
503  }
504  }
505  }
506  }
507 
508  if (is_array($subobj))
509  {
510  $formaction = "ilias.php?baseClass=ilRepositoryGUI&ref_id=".$this->object->getRefId()."&cmd=post";
511  $formaction = $ilCtrl->appendRequestTokenParameterString($formaction);
512  $formaction = $this->ctrl->getFormAction($this);
513  //$opts = ilUtil::formSelect("", "new_type", $subobj);
514  $this->tpl->setCreationSelector($formaction,
515  $subobj, "create", $this->lng->txt("add"));
516  }
517  }
518 
525  function getContentGUI()
526  {
527  switch ($this->object->getViewMode())
528  {
529  // all items in one block
531  include_once("./Services/Container/classes/class.ilContainerSimpleContentGUI.php");
532  $container_view = new ilContainerSimpleContentGUI($this);
533  break;
534 
536  include_once('./Services/Container/classes/class.ilContainerObjectiveGUI.php');
537  $container_view = new ilContainerObjectiveGUI($this);
538  break;
539 
540  // all items in one block
542  case IL_CRS_VIEW_TIMING: // not nice this workaround
543  include_once("./Services/Container/classes/class.ilContainerSessionsContentGUI.php");
544  $container_view = new ilContainerSessionsContentGUI($this);
545  break;
546 
547  // ILinc courses
549  include_once 'Services/Container/classes/class.ilContainerILincContentGUI.php';
550  $container_view = new ilContainerILincContentGUI($this);
551  break;
552 
553  // all items in one block
555  default:
556  include_once("./Services/Container/classes/class.ilContainerByTypeContentGUI.php");
557  $container_view = new ilContainerByTypeContentGUI($this);
558  break;
559  }
560 
561  return $container_view;
562  }
563 
564 
565 
569  function renderObject()
570  {
571  global $ilDB, $tpl, $ilTabs, $ilCtrl, $ilSetting;
572 
573  $container_view = $this->getContentGUI();
574 
575  $this->setContentSubTabs();
576  if ($this->isActiveAdministrationPanel())
577  {
578  $ilTabs->activateSubTab("manage");
579  }
580  else
581  {
582  $ilTabs->activateSubTab("view_content");
583  }
584 
585  $container_view->setOutput();
586 
587  $this->adminCommands = $container_view->adminCommands;
588 
589  // it is important not to show the subobjects/admin panel here, since
590  // we will create nested forms in case, e.g. a news/calendar item is added
591  if ($ilCtrl->getNextClass() != "ilcolumngui")
592  {
593  $this->showAdministrationPanel($tpl);
594  $this->showPossibleSubObjects();
595  }
596 
597  $this->showPermanentLink($tpl);
598 
599  // add tree updater javascript
600  if ((int) $_GET["ref_id"] > 1 && $ilSetting->get("rep_tree_synchronize"))
601  {
602  $ilCtrl->setParameter($this, "active_node", (int) $_GET["ref_id"]);
603  $tpl->addOnloadCode("
604  if (parent && parent.tree && parent.tree.updater)
605  {
606  parent.tree.updater('tree_div', '".
607  $ilCtrl->getLinkTarget($this, "showTree", "", true, false)
608  ."');
609  }");
610  }
611  }
612 
616  function setContentSubTabs()
617  {
619  }
620 
625  {
626  global $ilAccess, $ilSetting;
627  global $ilUser, $lng;
628 
629  $lng->loadLanguageModule('cntr');
630 
631  if ($this->isActiveAdministrationPanel())
632  {
633  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
634  $toolbar = new ilToolbarGUI();
635  $this->ctrl->setParameter($this, "type", "");
636  $this->ctrl->setParameter($this, "item_ref_id", "");
637 
638  if (!$_SESSION["clipboard"])
639  {
640  if ($this->object->gotItems())
641  {
642  $toolbar->setLeadingImage(
643  ilUtil::getImagePath("arrow_upright.png"),
644  $lng->txt("actions")
645  );
646  $toolbar->addFormButton(
647  $this->lng->txt('delete_selected_items'),
648  'delete'
649  );
650  $toolbar->addFormButton(
651  $this->lng->txt('move_selected_items'),
652  'cut'
653  );
654  $toolbar->addFormButton(
655  $this->lng->txt('link_selected_items'),
656  'link'
657  );
658 
659  }
660  if($this->object->getType() == 'crs')
661  {
662  if($this->object->gotItems())
663  {
664  $toolbar->addSeparator();
665  }
666 
667  $toolbar->addButton(
668  $this->lng->txt('cntr_adopt_content'),
669  $this->ctrl->getLinkTargetByClass(
670  'ilObjectCopyGUI',
671  'initSourceSelection')
672  );
673  }
674  }
675  else
676  {
677  /*$GLOBALS["tpl"]->addAdminPanelCommand("paste",
678  $this->lng->txt("paste_clipboard_items"));
679 
680  if($_SESSION["clipboard"]["cmd"] == "link")
681  {
682  $GLOBALS["tpl"]->addAdminPanelCommand("initAndDisplayLinkIntoMultipleObjects",
683  $this->lng->txt("paste_clipboard_items_into_multiple_objects"));
684  }*/
685  $toolbar->addFormButton(
686  $this->lng->txt('clear_clipboard'),
687  'clear'
688  );
689  }
690  $GLOBALS['tpl']->addAdminPanelToolbar(
691  $toolbar,
692  $this->object->gotItems() ? true : false,
693  $this->object->gotItems() ? true : false
694  );
695 
696  // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
697  if ($this->object->gotItems())
698  {
699  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
700  }
701  }
702  if ($this->edit_order)
703  {
704  if($this->object->gotItems() and $ilAccess->checkAccess("write", "", $this->object->getRefId()))
705  {
706  include_once('./Services/Container/classes/class.ilContainer.php');
707 
708  if ($this->object->getOrderType() == ilContainer::SORT_MANUAL)
709  {
710  $GLOBALS["tpl"]->addAdminPanelCommand("saveSorting",
711  $this->lng->txt('sorting_save'));
712 
713  // button should appear at bottom, too
714  $GLOBALS["tpl"]->admin_panel_bottom = true;
715  }
716  }
717  }
718  }
719 
721  {
722  global $tree;
723 
724  if(!$tree->checkForParentType($this->object->getRefId(),'crs'))
725  {
726  return false;
727  }
728  $tpl->setCurrentBlock("custom_button");
729  $tpl->setVariable("ADMIN_MODE_LINK",$this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editTimings'));
730  $tpl->setVariable("TXT_ADMIN_MODE",$this->lng->txt('timings_edit'));
731  $tpl->parseCurrentBlock();
732  return true;
733  }
738  {
739  $GLOBALS["tpl"]->setPermanentLink($this->object->getType(),
740  $this->object->getRefId(), "", "_top");
741  }
742 
747  {
748  global $ilCtrl;
749 
750  $_SESSION["il_cntr_editor"] = "std";
751  $ilCtrl->redirect($this, "editPageFrame");
752  }
753 
758  {
759  global $ilCtrl;
760 
761  $_SESSION["il_cntr_editor"] = "old";
762  $ilCtrl->redirect($this, "editPageFrame");
763  }
764 
769  {
770  global $ilCtrl, $ilAccess, $lng, $ilCtrl;
771 
772  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
773  {
774  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
775 
776  /* keep old page content for now...
777  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
778  "xhtml_page");
779  if ($xpage_id)
780  {
781  $xpage = new ilXHTMLPage($xpage_id);
782  }
783  */
784 
785  ilContainer::_writeContainerSetting($this->object->getId(),
786  "xhtml_page", 0);
787 
788  ilUtil::sendSuccess($lng->txt("cntr_switched_editor"), true);
789  }
790 
791  $ilCtrl->redirect($this, "editPageFrame");
792  }
793 
798  {
799  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
800  $fs_gui = new ilFramesetGUI();
801 
802  $fs_gui->setFramesetTitle($this->object->getTitle());
803  $fs_gui->setMainFrameName("content");
804  $fs_gui->setSideFrameName("tree");
805 
806  // old tiny stuff
807  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
808  "xhtml_page");
809  if ($xpage_id > 0 && $_SESSION["il_cntr_editor"] != "std")
810  {
811  $fs_gui->setMainFrameSource(
812  $this->ctrl->getLinkTarget(
813  $this, "editPageContent"));
814  $fs_gui->setSideFrameSource(
815  $this->ctrl->getLinkTarget($this, "showLinkList"));
816  }
817  else
818  {
819  $this->ctrl->redirectByClass(array("ilpageobjectgui"), "edit");
820  exit;
821  }
822 
823  $fs_gui->show();
824  exit;
825  }
826 
833  {
834  global $rbacsystem, $tpl, $lng, $ilCtrl;
835 
836  if (!$rbacsystem->checkAccess("write", $this->ref_id))
837  {
838  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
839  }
840 
841  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
842  "xhtml_page");
843  if ($xpage_id > 0)
844  {
845  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
846  $xpage = new ilXHTMLPage($xpage_id);
847  $content = $xpage->getContent();
848  }
849 
850  // get template
851  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.container_edit_page_content.html",
852  "Services/Container");
853  $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
854  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
855  $tpl->setVariable("TXT_EDIT_PAGE_CONTENT",
856  $this->lng->txt("edit_page_content"));
857  $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
858  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
859  $tpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_old_editor_warning"));
860  $tpl->setVariable("TXT_MIGRATION_OPEN_STD_EDITOR", $lng->txt("cntr_old_editor_open_standard_editor"));
861  $tpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert_s.png"));
862  $tpl->setVariable("HREF_OPEN_STD_EDITOR", $ilCtrl->getLinkTarget($this, "switchToStdEditor"));
863  $tpl->setVariable("ALT_WARNING", $lng->txt("warning"));
864 
865  include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
866  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
867  //$ta = new ilTextAreaInputGUI();
868  //$tags = $ta->getRteTagSet("extended_table_img");
869 
870  // add rte support
871  include_once "./Services/RTE/classes/class.ilRTE.php";
872  $rtestring = ilRTE::_getRTEClassname();
873  include_once "./Services/RTE/classes/class.$rtestring.php";
874  $rte = new $rtestring();
875  //$rte->addPlugin("latex");
876  include_once "./Services/Object/classes/class.ilObject.php";
878  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
879  $rte->addRTESupport($obj_id, $obj_type);
880  //$rte->setStyleSelect(true);
881  //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
882  }
883 
885  {
886  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
887  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
888  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
889  "xhtml_page");
890 
891  /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
892  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
893  $ta = new ilTextAreaInputGUI();
894  $ta->setRteTagSet("extended_table_img");
895  $tags = $ta->getRteTagString();*/
896 
897  //$text = ilUtil::stripSlashes($_POST["page_content"],
898  // true,
899  // $tags);
900 
901  $text = ilUtil::stripSlashes($_POST["page_content"],
902  true,
904  if ($xpage_id > 0)
905  {
906  $xpage = new ilXHTMLPage($xpage_id);
907  $xpage->setContent($text);
908  $xpage->save();
909  }
910  else
911  {
912  $xpage = new ilXHTMLPage();
913  $xpage->setContent($text);
914  $xpage->save();
915  ilContainer::_writeContainerSetting($this->object->getId(),
916  "xhtml_page", $xpage->getId());
917  }
918 
919  include_once("Services/RTE/classes/class.ilRTE.php");
920  ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType().":html",
921  $this->object->getId());
922 
923  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
924  $this->ctrl->redirect($this, "");
925  }
926 
928  {
929  $this->ctrl->redirect($this, "");
930  }
931 
932  function renderItemList($a_type = "all")
933  {
935 
936  include_once("Services/Object/classes/class.ilObjectListGUIFactory.php");
937 
938  $output_html = "";
940 
941  $type_grps = $this->object->getGroupedObjTypes();
942 
943  switch ($a_type)
944  {
945  // render all items list
946  case "all":
947 
948  // new behaviour
949  $output_html.= $this->getContainerPageHTML();
950 
951  // all item types
952  /*
953  $type_ordering = array(
954  "cat", "fold", "crs","rcrs", "icrs", "icla", "grp", "chat", "frm", "lres",
955  "glo", "webr", "mcst", "wiki", "file", "exc",
956  "tst", "svy", "mep", "qpl", "spl");*/
957 
958  $cur_obj_type = "";
959  $overall_tpl =& $this->newBlockTemplate();
960  $this->type_template = array();
961  $first = true;
962 
963  // iterate all types
964  foreach ($type_grps as $type => $v)
965  {
966  // set template (overall or type specific)
967  if (is_int(strpos($output_html, "[list-".$type."]")))
968  {
969  $tpl =& $this->newBlockTemplate();
970  $overall = false; // individual
971  }
972  else
973  {
974  $tpl =& $overall_tpl;
975  $overall = true; // put to the rest
976  }
977 
978  if (is_array($this->items[$type]))
979  {
980 
981  $item_html = array();
982 
983  foreach($this->items[$type] as $key => $item)
984  {
985  // get list gui class for each object type
986  if ($cur_obj_type != $item["type"])
987  {
988  $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
989  $item_list_gui->setContainerObject($this);
990  }
991  // render item row
992  $ilBench->start("ilContainerGUI", "0210_getListHTML");
993 
994  // show administration command buttons (or not)
995  if (!$this->isActiveAdministrationPanel())
996  {
997  $item_list_gui->enableDelete(false);
998  $item_list_gui->enableLink(false);
999  $item_list_gui->enableCut(false);
1000  $item_list_gui->enableCopy(false);
1001  }
1002 
1003  // activate common social commands
1004  $item_list_gui->enableComments(true);
1005  $item_list_gui->enableNotes(true);
1006  $item_list_gui->enableTags(true);
1007 
1008  $html = $item_list_gui->getListItemHTML($item["ref_id"],
1009  $item["obj_id"], $item["title"], $item["description"]);
1010 
1011  // check whether any admin command is allowed for
1012  // the items
1013  $this->determineAdminCommands($item["ref_id"],
1014  $item_list_gui->adminCommandsIncluded());
1015  $ilBench->stop("ilContainerGUI", "0210_getListHTML");
1016  if ($html != "")
1017  {
1018  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
1019  $item_html[] = array(
1020  "html" => $html,
1021  "item_ref_id" => $item["ref_id"],
1022  "item_obj_id" => $item["obj_id"],
1023  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
1024  $item_list_gui->getIconImageType() :
1025  $item['type']
1026  );
1027  // END WebDAV: Use $item_list_gui to determine icon image type
1028  }
1029  }
1030 
1031  // output block for resource type
1032  if (count($item_html) > 0)
1033  {
1034  // separator row
1035  if (!$first && $overall)
1036  {
1037  $this->addSeparatorRow($tpl);
1038  }
1039 
1040  if ($overall)
1041  {
1042  $first = false;
1043  }
1044 
1045  // add a header for each resource type
1046  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
1047  {
1048  $this->addHeaderRow($tpl, $type, false);
1049  }
1050  else
1051  {
1052  $this->addHeaderRow($tpl, $type);
1053  }
1054  $this->resetRowType();
1055 
1056  // content row
1057  $this->current_position = 1;
1058  foreach($item_html as $item)
1059  {
1060  // BEGIN WebDAV: Use $item_list_gui to determine image type
1061  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $item['item_icon_image_type']);
1062  // END WebDAV: Use $item_list_gui to determine image type
1063  }
1064 
1065  // store type specific templates in array
1066  if (is_int(strpos($output_html, "[list-".$type."]")))
1067  {
1068  $this->type_template[$type] = $tpl;
1069  }
1070  }
1071  else
1072  {
1073  // [list-...] tag available, but no item of type accessible
1074  if (!$overall)
1075  {
1076  $this->addHeaderRow($tpl, $type);
1077  $this->resetRowType();
1078  $this->addMessageRow($tpl,
1079  $this->lng->txt("msg_no_type_accessible"), $type);
1080  $this->type_template[$type] = $tpl;
1081  }
1082  }
1083  }
1084  else
1085  {
1086  // [list-...] tag available, but no item of type exists
1087  if (!$overall)
1088  {
1089  $this->addHeaderRow($tpl, $type);
1090  $this->resetRowType();
1091  $this->addMessageRow($tpl,
1092  $this->lng->txt("msg_no_type_available"), $type);
1093  $this->type_template[$type] = $tpl;
1094  }
1095  }
1096 
1097  }
1098 
1099 
1100  // I don't know why but executing this
1101  // line before the following foreach loop seems to be crucial
1102  if ($output_html != "")
1103  {
1104  //$output_html.= "<br /><br />";
1105  }
1106  $output_html.= $overall_tpl->get();
1107  //$output_html = str_replace("<br>++", "++", $output_html);
1108  //$output_html = str_replace("<br>++", "++", $output_html);
1109  //$output_html = str_replace("++<br>", "++", $output_html);
1110  //$output_html = str_replace("++<br>", "++", $output_html);
1111  foreach ($this->type_template as $type => $tpl)
1112  {
1113  $output_html = eregi_replace("\[list-".$type."\]",
1114  "</p>".$tpl->get()."<p class=\"ilc_Standard\">",
1115  $output_html);
1116  }
1117 
1118  //if (ilPageObject::_exists($this->object->getType(),
1119  // $this->object->getId()))
1120  if ($xpage_id > 0)
1121  {
1122  $page_block = new ilTemplate("tpl.container_page_block.html", false, false,
1123  "Services/Container");
1124  $page_block->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
1125  $output_html = $page_block->get();
1126  }
1127 
1128  break;
1129 
1130  default:
1131  // to do:
1132  break;
1133  }
1134  return $output_html;
1135  }
1136 
1138  {
1139  global $lng, $tree;
1140 
1141  $tpl = new ilTemplate("tpl.container_link_help.html", true, true,
1142  "Services/Container");
1143 
1144  $type_ordering = array(
1145  "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
1146  "glo", "webr", "file", "exc",
1147  "tst", "svy", "mep", "qpl", "spl");
1148 
1149  $childs = $tree->getChilds($_GET["ref_id"]);
1150  foreach($childs as $child)
1151  {
1152  if (in_array($child["type"], array("lm", "dbk", "sahs", "htlm")))
1153  {
1154  $cnt["lres"]++;
1155  }
1156  else
1157  {
1158  $cnt[$child["type"]]++;
1159  }
1160  }
1161 
1162  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1163  $tpl->setVariable("TXT_HELP_HEADER", $lng->txt("help"));
1164  foreach($type_ordering as $type)
1165  {
1166  $tpl->setCurrentBlock("row");
1167  $tpl->setVariable("ROWCOL", "tblrow".((($i++)%2)+1));
1168  if ($type != "lres")
1169  {
1170  $tpl->setVariable("TYPE", $lng->txt("objs_".$type).
1171  " (".((int)$cnt[$type]).")");
1172  }
1173  else
1174  {
1175  $tpl->setVariable("TYPE", $lng->txt("learning_resources").
1176  " (".((int)$cnt["lres"]).")");
1177  }
1178  $tpl->setVariable("TXT_LINK", "[list-".$type."]");
1179  $tpl->parseCurrentBlock();
1180  }
1181  $tpl->show();
1182  exit;
1183 
1184  }
1185 
1190  {
1191  $this->adminCommands = false;
1192  }
1193 
1197 /* function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
1198  {
1199  if (!$this->adminCommands)
1200  {
1201  if (!$this->isActiveAdministrationPanel())
1202  {
1203  if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
1204  {
1205  $this->adminCommands = true;
1206  }
1207  }
1208  else
1209  {
1210  $this->adminCommands = $a_admin_com_included_in_list;
1211  }
1212  }
1213  }*/
1214 
1221  function &newBlockTemplate()
1222  {
1223  $tpl = new ilTemplate("tpl.container_list_block.html", true, true,
1224  "Services/Container");
1225  $this->cur_row_type = "row_type_1";
1226  return $tpl;
1227  }
1228 
1236  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1237  {
1238  $icon = ilUtil::getImagePath("icon_".$a_type.".png");
1239  $title = $this->lng->txt("objs_".$a_type);
1240 
1241  if ($a_show_image)
1242  {
1243  $a_tpl->setCurrentBlock("container_header_row_image");
1244  $a_tpl->setVariable("HEADER_IMG", $icon);
1245  $a_tpl->setVariable("HEADER_ALT", $title);
1246  }
1247  else
1248  {
1249  $a_tpl->setCurrentBlock("container_header_row");
1250  }
1251 
1252  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1253  $a_tpl->parseCurrentBlock();
1254  $a_tpl->touchBlock("container_row");
1255  }
1256 
1264  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1265  $a_image_type = "")
1266  {
1267  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1268  ? "row_type_2"
1269  : "row_type_1";
1270 
1271  $a_tpl->touchBlock($this->cur_row_type);
1272 
1273  $nbsp = true;
1274  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
1275  {
1276  $icon = ilUtil::getImagePath("icon_".$a_image_type.".png");
1277  $alt = $this->lng->txt("obj_".$a_image_type);
1278 
1279  // custom icon
1280  if ($this->ilias->getSetting("custom_icons") &&
1281  in_array($a_image_type, array("cat","grp","crs")))
1282  {
1283  require_once("./Services/Container/classes/class.ilContainer.php");
1284  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1285  {
1286  $icon = $path;
1287  }
1288  }
1289 
1290  $a_tpl->setCurrentBlock("block_row_image");
1291  $a_tpl->setVariable("ROW_IMG", $icon);
1292  $a_tpl->setVariable("ROW_ALT", $alt);
1293  $a_tpl->parseCurrentBlock();
1294  $nbsp = false;
1295  }
1296 
1297  if ($this->isActiveAdministrationPanel())
1298  {
1299  $a_tpl->setCurrentBlock("block_row_check");
1300  $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
1301  $a_tpl->parseCurrentBlock();
1302  $nbsp = false;
1303  }
1304  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1305  if($this->isActiveAdministrationPanel() &&
1307  {
1308  $a_tpl->setCurrentBlock('block_position');
1309  $a_tpl->setVariable('POS_TYPE',$a_image_type);
1310  $a_tpl->setVariable('POS_ID',$a_item_ref_id);
1311  $a_tpl->setVariable('POSITION',sprintf('%.1f',$this->current_position++));
1312  $a_tpl->parseCurrentBlock();
1313  }
1314  if ($nbsp)
1315  {
1316  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1317  }
1318  $a_tpl->setCurrentBlock("container_standard_row");
1319  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1320  $a_tpl->parseCurrentBlock();
1321  $a_tpl->touchBlock("container_row");
1322  }
1323 
1327  function addMessageRow(&$a_tpl, $a_message, $a_type)
1328  {
1329  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1330  ? "row_type_2"
1331  : "row_type_1";
1332 
1333  $a_tpl->touchBlock($this->cur_row_type);
1334 
1335  $type = $this->lng->txt("obj_".$a_type);
1336  $a_message = str_replace("[type]", $type, $a_message);
1337 
1338  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1339 
1340  $a_tpl->setCurrentBlock("container_standard_row");
1341  $a_tpl->setVariable("BLOCK_ROW_CONTENT",
1342  $a_message);
1343  $a_tpl->parseCurrentBlock();
1344  $a_tpl->touchBlock("container_row");
1345  }
1346 
1347  function resetRowType()
1348  {
1349  $this->cur_row_type = "";
1350  }
1351 
1352 
1357  {
1358  global $lng;
1359 
1360  if (!$this->isActiveAdministrationPanel()
1361  || strtolower($this->ctrl->getCmdClass()) != "ilpageobjectgui")
1362  {
1363  return;
1364  }
1365 
1366  $lng->loadLanguageModule("content");
1367  //$tabs_gui = new ilTabsGUI();
1368  //$tabs_gui->setSubTabs();
1369 
1370  // back to upper context
1371  $this->tabs_gui->setBackTarget($this->lng->txt("obj_cat"),
1372  $this->ctrl->getLinkTarget($this, "frameset"),
1373  ilFrameTargetInfo::_getFrame("MainContent"));
1374 
1375  $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view")
1376  , array("", "view"), "ilpageobjectgui");
1377 
1378  //$this->tpl->setTabs($tabs_gui->getHTML());
1379  }
1380 
1384  function addStandardContainerSubTabs($a_include_view = true)
1385  {
1386  global $ilTabs, $ilAccess, $lng, $ilCtrl, $ilUser, $ilSetting;
1387 
1388  if (!is_object($this->object))
1389  {
1390  return;
1391  }
1392 
1393  if ($a_include_view && $ilAccess->checkAccess("read", "", $this->object->getRefId()))
1394  {
1395  if (!$this->isActiveAdministrationPanel())
1396  {
1397  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, ""));
1398  }
1399  else
1400  {
1401  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "disableAdministrationPanel"));
1402  }
1403  }
1404 
1405  if ( $ilUser->getId() != ANONYMOUS_USER_ID &&
1406  ($this->adminCommands ||
1407  (is_object($this->object) &&
1408  ($ilAccess->checkAccess("write", "", $this->object->getRefId())))
1409  ||
1410  (is_object($this->object) &&
1411  ($this->object->getHiddenFilesFound())) ||
1412  $_SESSION["clipboard"]
1413  )
1414  )
1415  {
1416  if ($this->isActiveAdministrationPanel())
1417  {
1418  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, ""));
1419  }
1420  else
1421  {
1422  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, "enableAdministrationPanel"));
1423  }
1424  }
1425  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1426  is_object($this->object) &&
1427  $ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
1428  $this->object->getOrderType() == ilContainer::SORT_MANUAL
1429  )
1430  {
1431  $ilTabs->addSubTab("ordering", $lng->txt("cntr_ordering"), $ilCtrl->getLinkTarget($this, "editOrder"));
1432  }
1433  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1434  is_object($this->object) &&
1435  $ilAccess->checkAccess("write", "", $this->object->getRefId())
1436  )
1437  {
1438  if ($ilSetting->get("enable_cat_page_edit"))
1439  {
1440  $ilTabs->addSubTab("page_editor", $lng->txt("cntr_text_media_editor"), $ilCtrl->getLinkTarget($this, "editPageFrame"),
1441  ilFrameTargetInfo::_getFrame("MainContent"));
1442  }
1443  }
1444  }
1445 
1446 
1451  function getTabs(&$tabs_gui)
1452  {
1453  global $rbacsystem, $ilCtrl;
1454 
1455  // edit permissions
1456  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
1457  {
1458  $tabs_gui->addTarget("perm_settings",
1459  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1460  array("perm","info","owner"), 'ilpermissiongui');
1461  if ($ilCtrl->getNextClass() == "ilpermissiongui")
1462  {
1463  $tabs_gui->activateTab("perm_settings");
1464  }
1465  }
1466 
1467  // show clipboard
1468  if (strtolower($_GET["baseClass"]) == "ilrepositorygui" && !empty($_SESSION["clipboard"]))
1469  {
1470  $tabs_gui->addTarget("clipboard",
1471  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
1472  }
1473 
1474  }
1475 
1476  //*****************
1477  // COMMON METHODS (may be overwritten in derived classes
1478  // if special handling is necessary)
1479  //*****************
1480 
1485  {
1486  $_SESSION["il_cont_admin_panel"] = true;
1487  $this->ctrl->redirect($this, "render");
1488  }
1489 
1494  {
1495  $_SESSION["il_cont_admin_panel"] = false;
1496  $this->ctrl->redirect($this, "render");
1497  }
1498 
1502  function editOrderObject()
1503  {
1504  global $ilTabs;
1505 
1506  $this->edit_order = true;
1507  $_SESSION["il_cont_admin_panel"] = false;
1508  $this->renderObject();
1509 
1510  $ilTabs->activateSubTab("ordering");
1511  }
1512 
1517  public function isActiveOrdering()
1518  {
1519  return $this->edit_order ? true : false;
1520  }
1521 
1522 
1523 
1527  public function addToDeskObject()
1528  {
1529  global $ilSetting, $lng;
1530 
1531  if((int)$ilSetting->get('disable_my_offers'))
1532  {
1533  return $this->renderObject();
1534  }
1535 
1536  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1538  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
1539  $this->renderObject();
1540  }
1541 
1545  public function removeFromDeskObject()
1546  {
1547  global $ilSetting, $lng;
1548 
1549  if((int)$ilSetting->get('disable_my_offers'))
1550  {
1551  return $this->renderObject();
1552  }
1553 
1554  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1556  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
1557  $this->renderObject();
1558  }
1559 
1560  // BEGIN WebDAV: Lock/Unlock objects
1561  function lockObject()
1562  {
1563  global $tree, $ilUser, $rbacsystem;
1564 
1565  if (!$rbacsystem->checkAccess("write",$_GET['item_ref_id']))
1566  {
1567  $this->ilErr->raiseError($this->lng->txt('err_no_permission'),$this->ilErr->MESSAGE);
1568  }
1569 
1570 
1571  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1573  {
1574  require_once 'Services/WebDAV/classes/class.ilDAVLocks.php';
1575  $locks = new ilDAVLocks();
1576 
1577  $result = $locks->lockRef($_GET['item_ref_id'],
1578  $ilUser->getId(), $ilUser->getLogin(),
1579  'ref_'.$_GET['item_ref_id'].'_usr_'.$ilUser->getId(),
1580  time() + /*30*24*60**/60, 0, 'exclusive'
1581  );
1582 
1584  $this->lng->txt(
1585  ($result === true) ? 'object_locked' : $result
1586  ),
1587  true);
1588  }
1589  $this->renderObject();
1590  }
1591  // END WebDAV: Lock/Unlock objects
1592 
1599  function cutObject()
1600  {
1601  global $rbacsystem, $ilCtrl;
1602 
1603  if ($_GET["item_ref_id"] != "")
1604  {
1605  $_POST["id"] = array($_GET["item_ref_id"]);
1606  }
1607 
1608  //$this->ilias->raiseError("move operation does not work at the moment and is disabled",$this->ilias->error_obj->MESSAGE);
1609 
1610 //echo "CUT";
1611 //echo $_SESSION["referer"];
1612  if (!isset($_POST["id"]))
1613  {
1614  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1615  }
1616 
1617  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1618  foreach ($_POST["id"] as $ref_id)
1619  {
1620  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1621  $node_data = $this->tree->getNodeData($ref_id);
1622  $subtree_nodes = $this->tree->getSubTree($node_data);
1623 
1624  $all_node_data[] = $node_data;
1625  $all_subtree_nodes[] = $subtree_nodes;
1626 
1627  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1628  foreach ($subtree_nodes as $node)
1629  {
1630  if($node['type'] == 'rolf')
1631  {
1632  continue;
1633  }
1634 
1635  if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
1636  {
1637  $no_cut[] = $node["ref_id"];
1638  }
1639  }
1640  }
1641  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1642  if (count($no_cut))
1643  {
1644  $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
1645  $this->ilias->error_obj->MESSAGE);
1646  }
1647  //echo "GET";var_dump($_GET);echo "POST";var_dump($_POST);
1648  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1649  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1650 //echo "-".$clipboard["cmd"]."-";
1651  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1652 //echo "-".$_SESSION["clipboard"]["cmd"]."-";
1653 
1654  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"),true);
1655 
1656  return $this->initAndDisplayMoveIntoObjectObject();
1657  } // END CUT
1658 
1659 
1666  function linkObject()
1667  {
1668  global $clipboard, $rbacsystem, $rbacadmin, $ilCtrl;
1669 
1670  if ($_GET["item_ref_id"] != "")
1671  {
1672  $_POST["id"] = array($_GET["item_ref_id"]);
1673  }
1674 
1675  if (!isset($_POST["id"]))
1676  {
1677  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1678  }
1679 
1680  // CHECK ACCESS
1681  foreach ($_POST["id"] as $ref_id)
1682  {
1683  if (!$rbacsystem->checkAccess('delete',$ref_id))
1684  {
1685  $no_cut[] = $ref_id;
1686  }
1687 
1688  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1689 
1690  if (!$this->objDefinition->allowLink($object->getType()))
1691  {
1692  $no_link[] = $object->getType();
1693  }
1694  }
1695 
1696  // NO ACCESS
1697  if (count($no_cut))
1698  {
1699  $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
1700  implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
1701  }
1702 
1703  if (count($no_link))
1704  {
1705  $no_link = array_unique($no_link);
1706 
1707  foreach ($no_link as $type)
1708  {
1709  $txt_objs[] = $this->lng->txt("objs_".$type);
1710  }
1711 
1712  $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
1713 
1714  //$this->ilias->raiseError($this->lng->txt("msg_not_possible_link")." ".
1715  // implode(',',$no_link),$this->ilias->error_obj->MESSAGE);
1716  }
1717 
1718  // WRITE TO CLIPBOARD
1719  $clipboard["parent"] = $_GET["ref_id"];
1720  $clipboard["cmd"] = $ilCtrl->getCmd();
1721 
1722  foreach ($_POST["id"] as $ref_id)
1723  {
1724  $clipboard["ref_ids"][] = $ref_id;
1725  }
1726 
1727  $_SESSION["clipboard"] = $clipboard;
1728 
1729  ilUtil::sendInfo($this->lng->txt("msg_link_clipboard"),true);
1730 
1732 
1733  } // END LINK
1734 
1735 
1741  function clearObject()
1742  {
1743  unset($_SESSION["clipboard"]);
1744  unset($_SESSION["il_rep_clipboard"]);
1745 
1746  //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1747 
1748  // only redirect if clipboard was cleared
1749  if (isset($_POST["cmd"]["clear"]))
1750  {
1751  ilUtil::sendSuccess($this->lng->txt("msg_clear_clipboard"),true);
1752 
1753  //$this->ctrl->returnToParent($this);
1754  //ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1756  }
1757  }
1758 
1760  {
1761  global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree, $ilObjDataCache, $ilUser;
1762 
1763  if(!in_array($_SESSION['clipboard']['cmd'], array('cut', 'link')))
1764  {
1765  $message = __METHOD__.": cmd was neither 'cut' nor 'link'; may be a hack attempt!";
1766  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
1767  }
1768 
1769  if($_SESSION['clipboard']['cmd'] == 'cut')
1770  {
1771  if(isset($_POST['node']) && (int)$_POST['node'])
1772  $_POST['nodes'] = array($_POST['node']);
1773  }
1774 
1775  if(!is_array($_POST['nodes']) || !count($_POST['nodes']))
1776  {
1777  ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'));
1778  if($_SESSION['clipboard']['cmd'] == 'cut')
1780  else
1782  return;
1783  }
1784 
1785  // this loop does all checks
1786  $folder_objects_cache = array();
1787  foreach($_SESSION['clipboard']['ref_ids'] as $ref_id)
1788  {
1789  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
1790  $current_parent_id = $tree->getParentId($obj_data->getRefId());
1791 
1792  foreach($_POST['nodes'] as $folder_ref_id)
1793  {
1794  if(!array_key_exists($folder_ref_id, $folder_objects_cache))
1795  {
1796  $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id);
1797  }
1798 
1799  // CHECK ACCESS
1800  if(!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType()))
1801  {
1802  $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().']');
1803  }
1804 
1805  // CHECK IF REFERENCE ALREADY EXISTS
1806  if($folder_ref_id == $current_parent_id)
1807  {
1808  $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().']');
1809  }
1810 
1811  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1812  if($tree->isGrandChild($ref_id, $folder_ref_id))
1813  {
1814  $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle().' ['.$obj_data->getRefId().']');
1815  }
1816 
1817  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
1818  if(!in_array($obj_data->getType(), array_keys($this->objDefinition->getSubObjects($folder_objects_cache[$folder_ref_id]->getType()))))
1819  {
1820  $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().']',
1821  $GLOBALS['lng']->txt('obj_'.$obj_data->getType()));
1822  }
1823  }
1824  }
1825 
1827  // process checking results
1828  if(count($exists))
1829  {
1830  $error .= implode('<br />', $exists);
1831  }
1832 
1833  if(count($is_child))
1834  {
1835  $error .= $error != '' ? '<br />' : '';
1836  $error .= implode('<br />', $is_child);
1837  }
1838 
1839  if(count($not_allowed_subobject))
1840  {
1841  $error .= $error != '' ? '<br />' : '';
1842  $error .= implode('<br />', $not_allowed_subobject);
1843  }
1844 
1845  if(count($no_paste))
1846  {
1847  $error .= $error != '' ? '<br />' : '';
1848  $error .= implode('<br />', $no_paste);
1849  }
1850 
1851  if($error != '')
1852  {
1853  ilUtil::sendFailure($error);
1854  if($_SESSION['clipboard']['cmd'] == 'cut')
1856  else
1858  return;
1859  }
1860 
1861  // log pasteObject call
1862  $log->write(__METHOD__.", cmd: ".$_SESSION["clipboard"]["cmd"]);
1863 
1865  // everything ok: now paste the objects to new location
1866 
1867  // to prevent multiple actions via back/reload button
1868  $ref_ids = $_SESSION['clipboard']['ref_ids'];
1869  unset($_SESSION['clipboard']['ref_ids']);
1870 
1871  // BEGIN ChangeEvent: Record paste event.
1872  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1873  // END ChangeEvent: Record paste event.
1874 
1875  // process CUT command
1876  if($_SESSION['clipboard']['cmd'] == 'cut')
1877  {
1878  foreach($_POST['nodes'] as $folder_ref_id)
1879  {
1880  foreach($ref_ids as $ref_id)
1881  {
1882  // Store old parent
1883  $old_parent = $tree->getParentId($ref_id);
1884  $tree->moveTree($ref_id, $folder_ref_id);
1885  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1886 
1887  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
1889 
1890  // BEGIN ChangeEvent: Record cut event.
1891  $node_data = $tree->getNodeData($ref_id);
1892  $old_parent_data = $tree->getNodeData($old_parent);
1893  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
1894  $old_parent_data['obj_id']);
1895  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
1896  $ilObjDataCache->lookupObjId($folder_ref_id));
1897  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
1898  // END PATCH ChangeEvent: Record cut event.
1899  }
1900 
1901  // prevent multiple iterations for cut cmommand
1902  break;
1903  }
1904 
1905  ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
1906  } // END CUT
1907 
1908  // process LINK command
1909  if($_SESSION['clipboard']['cmd'] == 'link')
1910  {
1911  $linked_to_folders = array();
1912 
1913  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1914  $rbac_log_active = ilRbacLog::isActive();
1915 
1916  foreach($_POST['nodes'] as $folder_ref_id)
1917  {
1918  $linked_to_folders[] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id));
1919 
1920  foreach($ref_ids as $ref_id)
1921  {
1922  // get node data
1923  $top_node = $tree->getNodeData($ref_id);
1924 
1925  // get subnodes of top nodes
1926  $subnodes[$ref_id] = $tree->getSubtree($top_node);
1927  }
1928 
1929  // now move all subtrees to new location
1930  foreach($subnodes as $key => $subnode)
1931  {
1932  // first paste top_node....
1933  $obj_data = ilObjectFactory::getInstanceByRefId($key);
1934  $new_ref_id = $obj_data->createReference();
1935  $obj_data->putInTree($folder_ref_id);
1936  $obj_data->setPermissions($folder_ref_id);
1937 
1938  // rbac log
1939  if($rbac_log_active)
1940  {
1941  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
1942  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
1943  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, $key);
1944  }
1945 
1946  // BEGIN ChangeEvent: Record link event.
1947  $node_data = $tree->getNodeData($new_ref_id);
1948  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
1949  $ilObjDataCache->lookupObjId($folder_ref_id));
1950  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
1951  // END PATCH ChangeEvent: Record link event.
1952  }
1953 
1954  $log->write(__METHOD__.', link finished');
1955  }
1956 
1957  ilUtil::sendSuccess(sprintf($this->lng->txt('mgs_objects_linked_to_the_following_folders'), implode(', ', $linked_to_folders)), true);
1958  } // END LINK
1959 
1960  // clear clipboard
1961  $this->clearObject();
1962 
1963  $this->ctrl->returnToParent($this);
1964  }
1965 
1967  {
1968  global $tree;
1969 
1970  // empty session on init
1971  $_SESSION['paste_linked_repexpand'] = array();
1972 
1973  // copy opend nodes from repository explorer
1974  $_SESSION['paste_linked_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
1975 
1976  // open current position
1977  $path = $tree->getPathId((int)$_GET['ref_id']);
1978  foreach((array)$path as $node_id)
1979  {
1980  if(!in_array($node_id, $_SESSION['paste_linked_repexpand']))
1981  $_SESSION['paste_linked_repexpand'][] = $node_id;
1982  }
1983 
1984  return $this->showLinkIntoMultipleObjectsTreeObject();
1985  }
1986 
1988  {
1989  global $ilTabs, $ilToolbar;
1990 
1991  $ilTabs->setTabActive('view_content');
1992 
1993  if(!in_array($_SESSION['clipboard']['cmd'], array('link')))
1994  {
1995  $message = __METHOD__.": cmd was not 'link'; may be a hack attempt!";
1996  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
1997  }
1998 
1999  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
2000  "Services/Object");
2001 
2002  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2004  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_linked_repexpand');
2005  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showLinkIntoMultipleObjectsTree'));
2006  $exp->setTargetGet('ref_id');
2007  $exp->setPostVar('nodes[]');
2008  $exp->highlightNode($_GET['ref_id']);
2009  is_array($_POST['nodes']) ? $exp->setCheckedItems((array)$_POST['nodes']) : $exp->setCheckedItems(array());
2010 
2011  if($_GET['paste_linked_repexpand'] == '')
2012  {
2013  $expanded = $this->tree->readRootId();
2014  }
2015  else
2016  {
2017  $expanded = $_GET['paste_linked_repexpand'];
2018  }
2019 
2020  $this->tpl->setVariable('FORM_TARGET', '_top');
2021  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2022 
2023  $exp->setExpand($expanded);
2024  // build html-output
2025  $exp->setOutput(0);
2026  $output = $exp->getOutput();
2027 
2028  $this->tpl->setVariable('OBJECT_TREE', $output);
2029 
2030  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2031  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
2032 
2033  $ilToolbar->addButton($this->lng->txt('cancel'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2034  }
2035 
2040  public function cancelMoveLinkObject()
2041  {
2042  unset($_SESSION['clipboard']);
2043  $GLOBALS['ilCtrl']->returnToParent($this);
2044  }
2045 
2047  {
2048  global $tree;
2049 
2050  // empty session on init
2051  $_SESSION['paste_cut_repexpand'] = array();
2052 
2053  // copy opend nodes from repository explorer
2054  $_SESSION['paste_cut_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2055 
2056  // open current position
2057  $path = $tree->getPathId((int)$_GET['ref_id']);
2058  foreach((array)$path as $node_id)
2059  {
2060  if(!in_array($node_id, $_SESSION['paste_cut_repexpand']))
2061  $_SESSION['paste_cut_repexpand'][] = $node_id;
2062  }
2063 
2064  return $this->showMoveIntoObjectTreeObject();
2065  }
2066 
2068  {
2069  global $ilTabs, $ilToolbar;
2070 
2071  $ilTabs->setTabActive('view_content');
2072 
2073  if(!in_array($_SESSION['clipboard']['cmd'], array('cut')))
2074  {
2075  $message = __METHOD__.": cmd was not 'cut'; may be a hack attempt!";
2076  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2077  }
2078 
2079  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
2080  "Services/Object");
2081 
2082  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2084  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_cut_repexpand');
2085  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showMoveIntoObjectTree'));
2086  $exp->setTargetGet('ref_id');
2087  $exp->setPostVar('node');
2088  $exp->setCheckedItems(array((int)$_POST['node']));
2089  $exp->highlightNode($_GET['ref_id']);
2090 
2091  if($_GET['paste_cut_repexpand'] == '')
2092  {
2093  $expanded = $this->tree->readRootId();
2094  }
2095  else
2096  {
2097  $expanded = $_GET['paste_cut_repexpand'];
2098  }
2099 
2100  $this->tpl->setVariable('FORM_TARGET', '_top');
2101  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2102 
2103  $exp->setExpand($expanded);
2104  // build html-output
2105  $exp->setOutput(0);
2106  $output = $exp->getOutput();
2107 
2108  $this->tpl->setVariable('OBJECT_TREE', $output);
2109 
2110  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2111  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
2112 
2113  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2114  }
2115 
2122  function pasteObject()
2123  {
2124  global $rbacsystem, $rbacadmin, $rbacreview, $log,$tree;
2125  global $ilUser, $lng;
2126 
2127  // BEGIN ChangeEvent: Record paste event.
2128  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2129  // END ChangeEvent: Record paste event.
2130 
2131 //var_dump($_SESSION["clipboard"]);exit;
2132  if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
2133  {
2134  $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
2135  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
2136  }
2137 
2138  // this loop does all checks
2139  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2140  {
2141  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
2142 
2143  // CHECK ACCESS
2144  if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
2145  {
2146  $no_paste[] = $ref_id;
2147  $no_paste_titles[] = $obj_data->getTitle();
2148  }
2149 
2150  // CHECK IF REFERENCE ALREADY EXISTS
2151  if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
2152  {
2153  $exists[] = $ref_id;
2154  break;
2155  }
2156 
2157  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
2158  if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
2159  {
2160  $is_child[] = $ref_id;
2161  }
2162 
2163  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
2164  $obj_type = $obj_data->getType();
2165 
2166  if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
2167  {
2168  $not_allowed_subobject[] = $obj_data->getType();
2169  }
2170  }
2171 
2173  // process checking results
2174  // BEGIN WebDAV: Copying an object into the same container is allowed
2175  if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy")
2176  // END WebDAV: Copying an object into the same container is allowed
2177  {
2178  $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
2179  }
2180 
2181  if (count($is_child))
2182  {
2183  $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
2184  $this->ilias->error_obj->MESSAGE);
2185  }
2186 
2187  if (count($not_allowed_subobject))
2188  {
2189  $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
2190  $this->ilias->error_obj->MESSAGE);
2191  }
2192 
2193  if (count($no_paste))
2194  {
2195  $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
2196  implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
2197  }
2198 
2199  // log pasteObject call
2200  $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
2201 
2203  // everything ok: now paste the objects to new location
2204 
2205  // to prevent multiple actions via back/reload button
2206  $ref_ids = $_SESSION["clipboard"]["ref_ids"];
2207  unset($_SESSION["clipboard"]["ref_ids"]);
2208 
2209  // BEGIN WebDAV: Support a copy command in the repository
2210  // process COPY command
2211  if ($_SESSION["clipboard"]["cmd"] == "copy")
2212  {
2213  foreach($ref_ids as $ref_id)
2214  {
2215  $revIdMapping = array();
2216 
2217  $oldNode_data = $tree->getNodeData($ref_id);
2218  if ($oldNode_data['parent'] == $this->object->getRefId())
2219  {
2220  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2221  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
2222  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
2223  }
2224  else
2225  {
2226  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
2227  }
2228 
2229  // BEGIN ChangeEvent: Record copy event.
2230  $old_parent_data = $tree->getParentNodeData($ref_id);
2231  $newNode_data = $tree->getNodeData($newRef);
2232  ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
2233  $oldNode_data['obj_id'], $ilUser->getId());
2234  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
2235  $this->object->getId());
2236  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2237  // END ChangeEvent: Record copy event.
2238  }
2239  $log->write("ilObjectGUI::pasteObject(), copy finished");
2240  }
2241  // END WebDAV: Support a Copy command in the repository
2242 
2243  // process CUT command
2244  if ($_SESSION["clipboard"]["cmd"] == "cut")
2245  {
2246 
2247  foreach($ref_ids as $ref_id)
2248  {
2249  // Store old parent
2250  $old_parent = $tree->getParentId($ref_id);
2251  $this->tree->moveTree($ref_id,$this->object->getRefId());
2252  $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
2253 
2254  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
2256 
2257  // BEGIN ChangeEvent: Record cut event.
2258  $node_data = $tree->getNodeData($ref_id);
2259  $old_parent_data = $tree->getNodeData($old_parent);
2260  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
2261  $old_parent_data['obj_id']);
2262  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2263  $this->object->getId());
2264  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2265  // END PATCH ChangeEvent: Record cut event.
2266  }
2267  } // END CUT
2268 
2269  // process LINK command
2270  if ($_SESSION["clipboard"]["cmd"] == "link")
2271  {
2272  foreach ($ref_ids as $ref_id)
2273  {
2274  // get node data
2275  $top_node = $this->tree->getNodeData($ref_id);
2276 
2277  // get subnodes of top nodes
2278  $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
2279  }
2280 
2281  // now move all subtrees to new location
2282  foreach ($subnodes as $key => $subnode)
2283  {
2284  // first paste top_node....
2285  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
2286  $new_ref_id = $obj_data->createReference();
2287  $obj_data->putInTree($_GET["ref_id"]);
2288  $obj_data->setPermissions($_GET["ref_id"]);
2289 
2290  // BEGIN ChangeEvent: Record link event.
2291  $node_data = $tree->getNodeData($new_ref_id);
2292  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2293  $this->object->getId());
2294  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2295  // END PATCH ChangeEvent: Record link event.
2296  }
2297 
2298  $log->write("ilObjectGUI::pasteObject(), link finished");
2299 
2300  // inform other objects in hierarchy about link operation
2301  //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
2302  } // END LINK
2303 
2304  // save cmd for correct message output after clearing the clipboard
2305  $last_cmd = $_SESSION["clipboard"]["cmd"];
2306 
2307 
2308  // clear clipboard
2309  $this->clearObject();
2310 
2311  if ($last_cmd == "cut")
2312  {
2313  ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"),true);
2314  }
2315  // BEGIN WebDAV: Support a copy command in repository
2316  else if ($last_cmd == "copy")
2317  {
2318  ilUtil::sendSuccess($this->lng->txt("msg_cloned"),true);
2319  }
2320  else if ($last_cmd == 'link')
2321  // END WebDAV: Support copy command in repository
2322  {
2323  ilUtil::sendSuccess($this->lng->txt("msg_linked"),true);
2324  }
2325 
2326  $this->ctrl->returnToParent($this);
2327 
2328  } // END PASTE
2329 
2330 
2331  // BEGIN WebDAV: Support a copy command in repository
2332 
2340  function copyObject()
2341  {
2342  global $ilAccess,$ilObjDefinition;
2343 
2344  if(!$ilAccess->checkAccess('copy','',$_GET['item_ref_id']))
2345  {
2347 
2348  ilUtil::sendFailure($this->lng->txt('msg_no_perm_copy').' '.$title,true);
2349  $this->ctrl->returnToParent($this);
2350  }
2351 
2352  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2353  $_SESSION["clipboard"]["cmd"] = 'copy';
2354 
2355  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2356  return $this->initAndDisplayCopyIntoObjectObject();
2357 
2358 
2359 
2360 
2361 
2362 
2363  // FOR ALL OBJECTS THAT SHOULD BE COPIED
2364  foreach ($_POST["id"] as $ref_id)
2365  {
2366  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
2367  $node_data = $this->tree->getNodeData($ref_id);
2368  $subtree_nodes = $this->tree->getSubTree($node_data);
2369 
2370  $all_node_data[] = $node_data;
2371  $all_subtree_nodes[] = $subtree_nodes;
2372 
2373  // CHECK VIEW, READ AND COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
2374  foreach ($subtree_nodes as $node)
2375  {
2376  if($node['type'] == 'rolf')
2377  {
2378  continue;
2379  }
2380 
2381  if (!$rbacsystem->checkAccess('visible,read,copy',$node["ref_id"]))
2382  {
2383  $no_copy[] = $node["ref_id"];
2384  }
2385  }
2386  }
2387  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'view,read'
2388  if (count($no_copy))
2389  {
2390  $this->ilias->raiseError($this->lng->txt("msg_no_perm_copy")." ".implode(',',$this->getTitlesByRefId($no_copy)),
2391  $this->ilias->error_obj->MESSAGE);
2392  }
2393  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2394  $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
2395  ? $_GET["cmd"]
2396  : key($_POST["cmd"]);
2397  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
2398 
2399  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2400 
2401  $this->ctrl->returnToParent($this);
2402 
2403  } // END COPY
2404  // BEGIN WebDAV: Support copy command in repository
2405 
2406 
2410  function clipboardObject()
2411  {
2412  global $ilErr,$ilLog;
2413 
2414  // function should not be called if clipboard is empty
2415  if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
2416  {
2417  $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
2418  $ilLog->write($message,$ilLog->FATAL);
2419  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
2420  }
2421 
2422  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html",
2423  "Services/Container");
2424 
2425  // FORMAT DATA
2426  $counter = 0;
2427  $f_result = array();
2428 
2429  foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2430  {
2431  if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
2432  {
2433  continue;
2434  }
2435 
2436  //$f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
2437  $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
2438  $f_result[$counter][] = $tmp_obj->getTitle();
2439  //$f_result[$counter][] = $tmp_obj->getDescription();
2440  $f_result[$counter][] = ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]);
2441 
2442  unset($tmp_obj);
2443  ++$counter;
2444  }
2445 
2446  $this->__showClipboardTable($f_result, "clipboardObject");
2447 
2448  return true;
2449  }
2450 
2451 
2456  function showCustomIconsEditing($a_input_colspan = 1, ilPropertyFormGUI $a_form = null, $a_as_section = true)
2457  {
2458  if ($this->ilias->getSetting("custom_icons"))
2459  {
2460  if(!$a_form)
2461  {
2462  $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
2463  "tpl.container_icon_settings.html", "Services/Container");
2464 
2465  if (($big_icon = $this->object->getBigIconPath()) != "")
2466  {
2467  $this->tpl->setCurrentBlock("big_icon");
2468  $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
2469  $this->tpl->parseCurrentBlock();
2470  }
2471  if ($this->object->getType() != "root")
2472  {
2473  if (($small_icon = $this->object->getSmallIconPath()) != "")
2474  {
2475  $this->tpl->setCurrentBlock("small_icon");
2476  $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
2477  $this->tpl->parseCurrentBlock();
2478  }
2479  $this->tpl->setCurrentBlock("small_icon_row");
2480  $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("standard_icon"));
2481  $this->tpl->setVariable("SMALL_SIZE", "(".
2482  $this->ilias->getSetting("custom_icon_small_width")."x".
2483  $this->ilias->getSetting("custom_icon_small_height").")");
2484  $this->tpl->setVariable("TXT_REMOVE_S", $this->lng->txt("remove"));
2485  $this->tpl->parseCurrentBlock();
2486  }
2487  if (($tiny_icon = $this->object->getTinyIconPath()) != "")
2488  {
2489  $this->tpl->setCurrentBlock("tiny_icon");
2490  $this->tpl->setVariable("SRC_TINY_ICON", $tiny_icon);
2491  $this->tpl->parseCurrentBlock();
2492  }
2493  $this->tpl->setCurrentBlock("container_icon_settings");
2494  $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
2495  $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
2496  $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
2497  $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
2498  $this->tpl->setVariable("TINY_ICON", $this->lng->txt("tiny_icon"));
2499  $this->tpl->setVariable("BIG_SIZE", "(".
2500  $this->ilias->getSetting("custom_icon_big_width")."x".
2501  $this->ilias->getSetting("custom_icon_big_height").")");
2502  $this->tpl->setVariable("TINY_SIZE", "(".
2503  $this->ilias->getSetting("custom_icon_tiny_width")."x".
2504  $this->ilias->getSetting("custom_icon_tiny_height").")");
2505  $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
2506  $this->tpl->parseCurrentBlock();
2507  }
2508  else
2509  {
2510  $big_icon = $this->object->getBigIconPath();
2511  $small_icon = $this->object->getSmallIconPath();
2512  $tiny_icon = $this->object->getTinyIconPath();
2513 
2514  if($a_as_section)
2515  {
2517  $title->setTitle($this->lng->txt("icon_settings"));
2518  }
2519  else
2520  {
2521  $title = new ilCustomInputGUI($this->lng->txt("icon_settings"), "");
2522  }
2523  $a_form->addItem($title);
2524 
2525  // big
2526  $caption = $this->lng->txt("big_icon")." (".
2527  $this->ilias->getSetting("custom_icon_big_width")."x".
2528  $this->ilias->getSetting("custom_icon_big_height").")";
2529  $icon = new ilImageFileInputGUI($caption, "cont_big_icon");
2530  $icon->setImage($big_icon);
2531  if($a_as_section)
2532  {
2533  $a_form->addItem($icon);
2534  }
2535  else
2536  {
2537  $title->addSubItem($icon);
2538  }
2539 
2540  // small/standard
2541  if ($this->object->getType() != "root")
2542  {
2543  $caption = $this->lng->txt("standard_icon")." (".
2544  $this->ilias->getSetting("custom_icon_small_width")."x".
2545  $this->ilias->getSetting("custom_icon_small_height").")";
2546  $icon = new ilImageFileInputGUI($caption, "cont_small_icon");
2547  $icon->setImage($small_icon);
2548  if($a_as_section)
2549  {
2550  $a_form->addItem($icon);
2551  }
2552  else
2553  {
2554  $title->addSubItem($icon);
2555  }
2556  }
2557 
2558  // tiny
2559  $caption = $this->lng->txt("tiny_icon")." (".
2560  $this->ilias->getSetting("custom_icon_tiny_width")."x".
2561  $this->ilias->getSetting("custom_icon_tiny_height").")";
2562  $icon = new ilImageFileInputGUI($caption, "cont_tiny_icon");
2563  $icon->setImage($tiny_icon);
2564  if($a_as_section)
2565  {
2566  $a_form->addItem($icon);
2567  }
2568  else
2569  {
2570  $title->addSubItem($icon);
2571  }
2572  }
2573  }
2574  }
2575 
2577  {
2578  global $ilAccess;
2579 
2580  // #10081
2581  if($_SESSION["il_cont_admin_panel"] &&
2582  $this->object->getRefId() &&
2583  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
2584  {
2585  return false;
2586  }
2587 
2588  return $_SESSION["il_cont_admin_panel"];
2589  }
2590 
2594  function setColumnSettings($column_gui)
2595  {
2596  global $ilAccess;
2597  parent::setColumnSettings($column_gui);
2598 
2599  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
2600  $this->isActiveAdministrationPanel() &&
2601  $this->allowBlocksMoving())
2602  {
2603  $column_gui->setEnableMovement(true);
2604  }
2605 
2606  $column_gui->setRepositoryItems(
2607  $this->object->getSubItems($this->isActiveAdministrationPanel(), true));
2608 
2609  //if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
2610  // && $this->allowBlocksConfigure())
2611  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
2612  {
2613  $column_gui->setBlockProperty("news", "settings", true);
2614  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
2615  $column_gui->setBlockProperty("news", "default_visibility_option", true);
2616  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
2617  }
2618 
2619  if ($this->isActiveAdministrationPanel())
2620  {
2621  $column_gui->setAdminCommands(true);
2622  }
2623  }
2624 
2629  {
2630  true;
2631  }
2632 
2637  {
2638  true;
2639  }
2640 
2648  public function cloneWizardPageTreeObject()
2649  {
2650  $this->cloneWizardPageObject(true);
2651  }
2652 
2660  public function cloneWizardPageListObject()
2661  {
2662  $this->cloneWizardPageObject(false);
2663  }
2664 
2671  public function cloneWizardPageObject($a_tree_view = true)
2672  {
2673  include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
2674 
2675  global $ilObjDataCache,$tree;
2676 
2677  if(!$_REQUEST['clone_source'])
2678  {
2679  ilUtil::sendFailure($this->lng->txt('select_one'));
2680  if(isset($_SESSION['wizard_search_title']))
2681  {
2682  $this->searchCloneSourceObject();
2683  }
2684  else
2685  {
2686  $this->createObject();
2687  }
2688  return false;
2689  }
2690  $source_id = $_REQUEST['clone_source'];
2691  $new_type = $_REQUEST['new_type'];
2692  $this->ctrl->setParameter($this,'clone_source',(int) $_REQUEST['clone_source']);
2693  $this->ctrl->setParameter($this,'new_type',$new_type);
2694 
2695 
2696  // Generell JavaScript
2697  $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
2698  $this->tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
2699 
2700 
2701  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.container_wizard_page.html',
2702  "Services/Container");
2703  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
2704  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$new_type.'.png'));
2705  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$new_type));
2706  $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt($new_type.'_wizard_page'));
2707  $this->tpl->setVariable('INFO_DUPLICATE',$this->lng->txt($new_type.'_copy_threads_info'));
2708  $this->tpl->setVariable('BTN_COPY',$this->lng->txt('obj_'.$new_type.'_duplicate'));
2709  $this->tpl->setVariable('BTN_BACK',$this->lng->txt('btn_back'));
2710  if(isset($_SESSION['wizard_search_title']))
2711  {
2712  $this->tpl->setVariable('CMD_BACK','searchCloneSource');
2713  }
2714  else
2715  {
2716  $this->tpl->setVariable('CMD_BACK','create');
2717  }
2718 
2719  $this->tpl->setVariable('BTN_TREE',$this->lng->txt('treeview'));
2720  $this->tpl->setVariable('BTN_LIST',$this->lng->txt('flatview'));
2721 
2722  // Fill item rows
2723  // tree view
2724  if($a_tree_view)
2725  {
2726  $first = true;
2727  $has_items = false;
2728  foreach($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id),true) as $node)
2729  {
2730  if($first == true)
2731  {
2732  $first = false;
2733  continue;
2734  }
2735 
2736  if($node['type'] == 'rolf')
2737  {
2738  continue;
2739  }
2740 
2741  $has_items = true;
2742 
2743  for($i = $source_node['depth'];$i < $node['depth']; $i++)
2744  {
2745  $this->tpl->touchBlock('padding');
2746  $this->tpl->touchBlock('end_padding');
2747  }
2748  // fill options
2749  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$node['type']);
2750  $copy_wizard_page->fillTreeSelection($node['ref_id'],$node['type'],$node['depth']);
2751 
2752  $this->tpl->setCurrentBlock('tree_row');
2753  $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'_s.png'));
2754  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$node['type']));
2755  $this->tpl->setVariable('TREE_TITLE',$node['title']);
2756  $this->tpl->parseCurrentBlock();
2757  }
2758  if(!$has_items)
2759  {
2760  $this->tpl->setCurrentBlock('no_content');
2761  $this->tpl->setVariable('TXT_NO_CONTENT',$this->lng->txt('container_no_items'));
2762  $this->tpl->parseCurrentBlock();
2763  }
2764  else
2765  {
2766  $this->tpl->setCurrentBlock('tree_footer');
2767  $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
2768  $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
2769  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
2770  $this->tpl->parseCurrentBlock();
2771 
2772  }
2773  }
2774  else
2775  {
2776  foreach($tree->getSubTreeTypes($source_id,array('rolf','crs')) as $type)
2777  {
2778  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$type);
2779  if(strlen($html = $copy_wizard_page->getWizardPageBlockHTML()))
2780  {
2781  $this->tpl->setCurrentBlock('obj_row');
2782  $this->tpl->setVariable('ITEM_BLOCK',$html);
2783  $this->tpl->parseCurrentBlock();
2784  }
2785  }
2786  }
2787  }
2788 
2796  public function cloneAllObject()
2797  {
2798  global $ilLog, $ilCtrl;
2799 
2800  include_once('./Services/Link/classes/class.ilLink.php');
2801  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
2802 
2803  global $ilAccess,$ilErr,$rbacsystem,$tree,$ilUser;
2804 
2805  $new_type = $_REQUEST['new_type'];
2806  $ref_id = (int) $_GET['ref_id'];
2807  $clone_source = (int) $_REQUEST['clone_source'];
2808 
2809  if(!$rbacsystem->checkAccess('create', $ref_id,$new_type))
2810  {
2811  $ilErr->raiseError($this->lng->txt('permission_denied'));
2812  }
2813  if(!$clone_source)
2814  {
2815  ilUtil::sendFailure($this->lng->txt('select_one'));
2816  $this->createObject();
2817  return false;
2818  }
2819  if(!$ilAccess->checkAccess('write','', $clone_source,$new_type))
2820  {
2821  $ilErr->raiseError($this->lng->txt('permission_denied'));
2822  }
2823 
2824  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
2825  $orig = ilObjectFactory::getInstanceByRefId($clone_source);
2826  $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
2827 
2828  // Check if copy is in progress
2829  if ($result == $ref_id)
2830  {
2831  ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"),true);
2832  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
2833  $ilCtrl->redirectByClass("ilrepositorygui", "");
2834  }
2835  else
2836  {
2837  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
2838  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $result);
2839  $ilCtrl->redirectByClass("ilrepositorygui", "");
2840  }
2841  }
2842 
2843 
2851  public function saveSortingObject()
2852  {
2853  include_once('Services/Container/classes/class.ilContainerSorting.php');
2854  $sorting = ilContainerSorting::_getInstance($this->object->getId());
2855 
2856  // Allow comma
2857  $positions = str_replace(',','.',$_POST['position']);
2858 
2859  $sorting->savePost($positions);
2860  ilUtil::sendSuccess($this->lng->txt('cntr_saved_sorting'), true);
2861  $this->ctrl->redirect($this, "editOrder");
2862  }
2863 
2864  // BEGIN WebDAV: Support a copy command in the repository
2875  function cloneNodes($srcRef,$dstRef,&$mapping, $newName=null)
2876  {
2877  global $tree;
2878  global $ilias;
2879 
2880  // clone the source node
2881  $srcObj =& $ilias->obj_factory->getInstanceByRefId($srcRef);
2882  error_log(__METHOD__.' cloning srcRef='.$srcRef.' dstRef='.$dstRef.'...');
2883  $newRef = $srcObj->cloneObject($dstRef)->getRefId();
2884  error_log(__METHOD__.' ...cloning... newRef='.$newRef.'...');
2885 
2886  // We must immediately apply a new name to the object, to
2887  // prevent confusion of WebDAV clients about having two objects with identical
2888  // name in the repository.
2889  if (! is_null($newName))
2890  {
2891  $newObj =& $ilias->obj_factory->getInstanceByRefId($newRef);
2892  $newObj->setTitle($newName);
2893  $newObj->update();
2894  unset($newObj);
2895  }
2896  unset($srcObj);
2897  $mapping[$newRef] = $srcRef;
2898 
2899  // clone all children of the source node
2900  $children = $tree->getChilds($srcRef);
2901  foreach ($tree->getChilds($srcRef) as $child)
2902  {
2903  // Don't clone role folders, because it does not make sense to clone local roles
2904  // FIXME - Maybe it does make sense (?)
2905  if ($child["type"] != 'rolf')
2906  {
2907  $this->cloneNodes($child["ref_id"],$newRef,$mapping);
2908  }
2909  else
2910  {
2911  if (count($rolf = $tree->getChildsByType($newRef,"rolf")))
2912  {
2913  $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
2914  }
2915  }
2916  }
2917  error_log(__METHOD__.' ...cloned srcRef='.$srcRef.' dstRef='.$dstRef.' newRef='.$newRef);
2918  return $newRef;
2919  }
2920  // END PATCH WebDAV: Support a copy command in the repository
2921 
2925  function modifyItemGUI(&$a_item_list_gui, $a_item_data, $a_show_path)
2926  {
2927  global $lng;
2928 
2929  if($a_show_path)
2930  {
2931  $a_item_list_gui->addCustomProperty($lng->txt('path'),
2932  ilContainer::buildPath($a_item_data['ref_id'], $this->object->getRefId()),
2933  false, true);
2934  }
2935  }
2936 
2940  static function _buildPath($a_ref_id, $a_course_ref_id)
2941  {
2942  global $tree;
2943 
2944  $path_arr = $tree->getPathFull($a_ref_id, $a_course_ref_id);
2945  $counter = 0;
2946  foreach($path_arr as $data)
2947  {
2948  if($counter++)
2949  {
2950  $path .= " > ";
2951  }
2952  $path .= $data['title'];
2953  }
2954 
2955  return $path;
2956  }
2957 
2958  //
2959  // Style editing
2960  //
2961 
2966  {
2967  global $ilTabs, $tpl;
2968 
2969  $this->checkPermission("write");
2970 
2971  $this->initStylePropertiesForm();
2972  $tpl->setContent($this->form->getHTML());
2973 
2974  $ilTabs->activateTab("obj_sty");
2975  }
2976 
2981  {
2982  global $ilCtrl, $lng, $ilTabs, $ilSetting, $tpl;
2983 
2984  $tpl->setTreeFlatIcon("", "");
2985  $ilTabs->clearTargets();
2986  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
2987  "xhtml_page");
2988  if ($xpage_id > 0)
2989  {
2990  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
2991  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
2992  }
2993  else
2994  {
2995  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
2996  $this->object->getRefId(), "_top");
2997  }
2998 
2999  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
3000  $page_gui =& new ilPageObjectGUI($this->object->getType(),
3001  $this->object->getId());
3002  $style_id = $this->object->getStyleSheetId();
3003  if (ilObject::_lookupType($style_id) == "sty")
3004  {
3005  $page_gui->setStyleId($style_id);
3006  }
3007  else
3008  {
3009  $style_id = 0;
3010  }
3011  $page_gui->setTabHook($this, "addPageTabs");
3012 // $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg_b.png"));
3013 // $tpl->setTitle($this->lng->txt("page").": ".$this->obj->getTitle());
3014  $ilCtrl->getHTML($page_gui);
3015  $ilTabs->setTabActive("obj_sty");
3016 
3017  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3018  $lng->loadLanguageModule("style");
3019 
3020  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3021  $this->form = new ilPropertyFormGUI();
3022 
3023  $fixed_style = $ilSetting->get("fixed_content_style_id");
3024 // $style_id = $this->object->getStyleSheetId();
3025 
3026  if ($fixed_style > 0)
3027  {
3028  $st = new ilNonEditableValueGUI($lng->txt("wiki_current_style"));
3029  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
3030  $this->lng->txt("global_fixed").")");
3031  $this->form->addItem($st);
3032  }
3033  else
3034  {
3035  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
3036  $_GET["ref_id"]);
3037 
3038  $st_styles[0] = $this->lng->txt("default");
3039  ksort($st_styles);
3040 
3041  if ($style_id > 0)
3042  {
3043  // individual style
3044  if (!ilObjStyleSheet::_lookupStandard($style_id))
3045  {
3046  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
3047  $st->setValue(ilObject::_lookupTitle($style_id));
3048  $this->form->addItem($st);
3049 
3050 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
3051 
3052  // delete command
3053  $this->form->addCommandButton("editStyle",
3054  $lng->txt("style_edit_style"));
3055  $this->form->addCommandButton("deleteStyle",
3056  $lng->txt("style_delete_style"));
3057 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
3058  }
3059  }
3060 
3061  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
3062  {
3063  $style_sel = ilUtil::formSelect ($style_id, "style_id",
3064  $st_styles, false, true);
3065  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
3066  $style_sel->setOptions($st_styles);
3067  $style_sel->setValue($style_id);
3068  $this->form->addItem($style_sel);
3069 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
3070  $this->form->addCommandButton("saveStyleSettings",
3071  $lng->txt("save"));
3072  $this->form->addCommandButton("createStyle",
3073  $lng->txt("sty_create_ind_style"));
3074  }
3075  }
3076  $this->form->setTitle($lng->txt("obj_sty"));
3077  $this->form->setFormAction($ilCtrl->getFormAction($this));
3078  }
3079 
3084  {
3085  global $ilCtrl;
3086 
3087  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
3088  }
3089 
3093  function editStyleObject()
3094  {
3095  global $ilCtrl;
3096 
3097  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
3098  }
3099 
3104  {
3105  global $ilCtrl;
3106 
3107  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
3108  }
3109 
3114  {
3115  global $ilSetting;
3116 
3117  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3118  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3119  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3120  || $this->object->getStyleSheetId() == 0))
3121  {
3122  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
3123  $this->object->update();
3124  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3125  }
3126  $this->ctrl->redirect($this, "editStyleProperties");
3127  }
3128 
3133  {
3134  global $ilCtrl;
3135 
3136  $ref_id = $_GET["cmdrefid"];
3138  $type = ilObject::_lookupType($obj_id);
3139 
3140  // this should be done via container-object->getSubItem in the future
3141  $data = array("child" => $ref_id, "ref_id" => $ref_id, "obj_id" => $obj_id,
3142  "type" => $type);
3143  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
3144  $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($type);
3145  $item_list_gui->setContainerObject($this);
3146 
3147  $item_list_gui->enableComments(true);
3148  $item_list_gui->enableNotes(true);
3149  $item_list_gui->enableTags(true);
3150 
3151  $this->modifyItemGUI($item_list_gui, $data, false);
3152  $html = $item_list_gui->getListItemHTML($ref_id,
3153  $obj_id, "", "", true, true);
3154 
3155  // include plugin slot for async item list
3156  global $ilPluginAdmin;
3157  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
3158  foreach ($pl_names as $pl)
3159  {
3160  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
3161  $gui_class = $ui_plugin->getUIClassInstance();
3162  $resp = $gui_class->getHTML("Services/Container", "async_item_list", array("html" => $html));
3163  if ($resp["mode"] != ilUIHookPluginGUI::KEEP)
3164  {
3165  $html = $gui_class->modifyHTML($html, $resp);
3166  }
3167  }
3168 
3169  echo $html;
3170  exit;
3171  }
3172 
3177  protected function showPasswordInstructionObject($a_init = true)
3178  {
3179  global $tpl,$ilToolbar;
3180 
3181  if($a_init)
3182  {
3183  ilUtil::sendInfo($this->lng->txt('webdav_pwd_instruction'));
3184  $this->initFormPasswordInstruction();
3185  }
3186 
3187  include_once ('Services/WebDAV/classes/class.ilDAVServer.php');
3188  $davServer = ilDAVServer::getInstance();
3189  $ilToolbar->addButton(
3190  $this->lng->txt('mount_webfolder'),
3191  $davServer->getMountURI($this->object->getRefId()),
3192  '_blank',
3193  '',
3194  $davServer->getFolderURI($this->object->getRefId())
3195  );
3196 
3197  $tpl->setContent($this->form->getHTML());
3198  }
3199 
3204  protected function initFormPasswordInstruction()
3205  {
3206  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3207  $this->form = new ilPropertyFormGUI();
3208  $this->form->setFormAction($this->ctrl->getFormAction($this));
3209 
3210  // new password
3211  $ipass = new ilPasswordInputGUI($this->lng->txt("desired_password"), "new_password");
3212  $ipass->setRequired(true);
3213 
3214  $this->form->addItem($ipass);
3215  $this->form->addCommandButton("savePassword", $this->lng->txt("save"));
3216  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
3217 
3218  $this->form->setTitle($this->lng->txt("chg_ilias_and_webfolder_password"));
3219  $this->form->setFormAction($this->ctrl->getFormAction($this));
3220 
3221  return $this->form;
3222  }
3223 
3228  protected function savePasswordObject()
3229  {
3230  global $ilUser;
3231 
3232  $form = $this->initFormPasswordInstruction();
3233  if($form->checkInput())
3234  {
3235  $ilUser->resetPassword($this->form->getInput('new_password'),$this->form->getInput('new_password'));
3236  ilUtil::sendSuccess($this->lng->txt('webdav_pwd_instruction_success'),true);
3237  $this->showPasswordInstructionObject(false);
3238  return true;
3239  }
3240  $form->setValuesByPost();
3242  }
3243 
3251  {
3252  $item_data = $this->object->getSubItems(false, false, (int) $_GET["child_ref_id"]);
3253  $container_view = $this->getContentGUI();
3254  foreach ($this->object->items["_all"] as $id)
3255  {
3256  if ($id["child"] == (int) $_GET["child_ref_id"])
3257  {
3258  $html = $container_view->renderItem($id);
3259  echo $html;
3260  exit;
3261  }
3262  }
3263  }
3264 
3265  // begin-patch fm
3272  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
3273  {
3274  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
3275 
3276  // begin-patch fm
3277  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
3278  if(ilFMSettings::getInstance()->isEnabled())
3279  {
3280  if($lg instanceof ilObjectListGUI)
3281  {
3282  $lg->addCustomCommand($this->ctrl->getLinkTarget($this,'fileManagerLaunch'), 'fm_start','_blank');
3283  }
3284  }
3285  // end-patch fm
3286  return $lg;
3287  }
3288 
3292  protected function fileManagerLaunchObject()
3293  {
3294  global $ilUser;
3295 
3296  $tpl = new ilTemplate('tpl.fm_launch_ws.html',false,false,'Services/WebServices/FileManager');
3297  $tpl->setVariable('JNLP_URL',ILIAS_HTTP_PATH.'/Services/WebServices/FileManager/lib/dist/FileManager.jnlp');
3298  $tpl->setVariable('SESSION_ID', $_COOKIE['PHPSESSID'].'::'.CLIENT_ID);
3299  $tpl->setVariable('UID',$ilUser->getId());
3300  $tpl->setVariable('REF_ID', $this->object->getRefId());
3301  $tpl->setVariable('WSDL_URI', ILIAS_HTTP_PATH.'/webservice/soap/server.php?wsdl');
3302  $tpl->setVariable('LOCAL_FRAME', ilFMSettings::getInstance()->isLocalFSEnabled() ? 1 : 0);
3303  $tpl->setVariable('REST_URI',ILIAS_HTTP_PATH.'/Services/WebServices/Rest/server.php');
3304  $tpl->setVariable('FILE_LOCKS',0);
3305  $tpl->setVariable('UPLOAD_FILESIZE', ilFMSettings::getInstance()->getMaxFileSize());
3306 
3307  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
3308  $header_top_title = ilObjSystemFolder::_getHeaderTitle();
3309  $tpl->setVariable('HEADER_TITLE',$header_top_title ? $header_top_title : '');
3310  echo $tpl->get();
3311  exit;
3312  }
3313  // begin-patch fm
3314 
3320  public function trashObject()
3321  {
3322  global $tpl;
3323 
3324  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3325  $ru = new ilRepUtilGUI($this);
3326  $ru->showTrashTable($_GET["ref_id"]);
3327  }
3328 
3334  public function removeFromSystemObject()
3335  {
3336  global $log, $ilAppEventHandler, $lng;
3337 
3338  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3339  $ru = new ilRepUtilGUI($this);
3340  $ru->removeObjectsFromSystem($_POST["trash_id"]);
3341  $this->ctrl->redirect($this, "trash");
3342  }
3343 
3347  public function undeleteObject()
3348  {
3349  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3350  $ru = new ilRepUtilGUI($this);
3351  $ru->restoreObjects($_GET["ref_id"], $_POST["trash_id"]);
3352  $this->ctrl->redirect($this, "trash");
3353  }
3354 
3359  {
3360  global $lng;
3361  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3362 
3363  if(!isset($_POST["trash_id"]))
3364  {
3365  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3366  $this->ctrl->redirect($this, "trash");
3367  }
3368 
3369  $ru = new ilRepUtilGUI($this);
3370  $ru->confirmRemoveFromSystemObject($_POST["trash_id"]);
3371  }
3372 }
3373 ?>