ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-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
23 
28  function ilContainerGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
29  {
30  global $rbacsystem, $lng, $tree;
31 
32  $this->rbacsystem =& $rbacsystem;
33 
34  $lng->loadLanguageModule("cntr");
35 
36  //$this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
37 
38  // Activate tree cache when rendering the container to improve performance
39  //$tree->useCache(false);
40 
41  // prepare output things should generally be made in executeCommand
42  // method (maybe dependent on current class/command
43  $this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
44  }
45 
50  function &executeCommand()
51  {
52  global $tpl;
53 
54  $next_class = $this->ctrl->getNextClass();
55  $cmd = $this->ctrl->getCmd("render");
56 
57  switch($next_class)
58  {
59  // page editing
60  case "ilcontainerpagegui":
61  if ($_GET["redirectSource"] != "ilinternallinkgui")
62  {
63  $ret = $this->forwardToPageObject();
64  $tpl->setContent($ret);
65  }
66  else
67  {
68  return "";
69  }
70  break;
71 
72  case "ilobjstylesheetgui":
73  $this->forwardToStyleSheet();
74  break;
75 
76  default:
77  $this->prepareOutput();
78  $cmd .= "Object";
79  $this->$cmd();
80  break;
81  }
82  return true;
83  }
84 
90  protected function getEditFormValues()
91  {
92  $values = parent::getEditFormValues();
93 
94  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
95  $values['didactic_type'] =
96  'dtpl_'.ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
97 
98  return $values;
99  }
100 
104  protected function afterUpdate()
105  {
106  // check if template is changed
107  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
108  $current_tpl_id = (int) ilDidacticTemplateObjSettings::lookupTemplateId(
109  $this->object->getRefId()
110  );
111  $new_tpl_id = (int) $this->getDidacticTemplateVar('dtpl');
112 
113  if($new_tpl_id != $current_tpl_id)
114  {
115  $_REQUEST['tplid'] = $new_tpl_id;
116 
117  // redirect to didactic template confirmation
118  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
119  $this->ctrl->setReturn($this,'edit');
120  $this->ctrl->setCmdClass('ildidactictemplategui');
121  $this->ctrl->setCmd('confirmTemplateSwitch');
122  $dtpl_gui = new ilDidacticTemplateGUI($this);
123  return $this->ctrl->forwardCommand($dtpl_gui);
124  }
126  }
127 
128 
133  {
134  global $ilCtrl, $ilTabs;
135 
136  $ilTabs->clearTargets();
137 
138  $cmd = $ilCtrl->getCmd();
139  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
140  $this->ctrl->setReturn($this, "editStyleProperties");
141  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
142  $style_gui->omitLocator();
143  if ($cmd == "create" || $_GET["new_type"]=="sty")
144  {
145  $style_gui->setCreationMode(true);
146  }
147 
148  if ($cmd == "confirmedDelete")
149  {
150  $this->object->setStyleSheetId(0);
151  $this->object->update();
152  }
153 
154  $ret = $this->ctrl->forwardCommand($style_gui);
155 
156  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
157  {
158  $style_id = $ret;
159  $this->object->setStyleSheetId($style_id);
160  $this->object->update();
161  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
162  }
163  }
164 
165 
170  {
171  global $lng, $ilTabs, $ilCtrl;
172 
173  $cmd = $ilCtrl->getCmd();
174 
175  if (in_array($cmd, array("displayMediaFullscreen", "downloadFile")))
176  {
177  $this->checkPermission("read");
178  }
179  else
180  {
181  $this->checkPermission("write");
182  }
183 
184  $ilTabs->clearTargets();
185 
186  if ($_GET["redirectSource"] == "ilinternallinkgui")
187  {
188  exit;
189  }
190 
191  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
192  "xhtml_page");
193  if ($xpage_id > 0)
194  {
195  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
196  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
197  }
198  else
199  {
200  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
201  $this->object->getRefId(), "_top");
202  }
203 
204  // page object
205  include_once("./Services/Container/classes/class.ilContainerPage.php");
206  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
207 
208  $lng->loadLanguageModule("content");
209 
210  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
211  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
212  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
213  $this->tpl->setCurrentBlock("SyntaxStyle");
214  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
216  $this->tpl->parseCurrentBlock();
217 
218  if (!ilContainerPage::_exists("cont",
219  $this->object->getId()))
220  {
221  // doesn't exist -> create new one
222  $new_page_object = new ilContainerPage();
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  $this->ctrl->setReturnByClass("ilcontainerpagegui", "edit");
230  $page_gui = new ilContainerPageGUI($this->object->getId());
231  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
232  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
233  $this->object->getStyleSheetId(), $this->object->getType()));
234 
235  $page_gui->setTemplateTargetVar("ADM_CONTENT");
236  $page_gui->setLinkXML($link_xml);
237  $page_gui->setFileDownloadLink("");
238  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
239  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
240  $page_gui->setPresentationTitle("");
241  $page_gui->setTemplateOutput(false);
242 
243  // old editor information text
244  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
245  "xhtml_page");
246  if ($xpage_id > 0)
247  {
248  $wtpl = new ilTemplate("tpl.cntr_old_editor_message.html", true,
249  true, "Services/Container");
250  $wtpl->setVariable("ALT_WARNING", $lng->txt("warning"));
251  $wtpl->setVariable("IMG_WARNING",
252  ilUtil::getImagePath("icon_alert_s.png"));
253  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
254  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
255  $wtpl->setVariable("HREF_SWITCH_TO_NEW_EDITOR",
256  $ilCtrl->getLinkTarget($this, "useNewEditor"));
257  $wtpl->setVariable("TXT_MIGRATION_SWITCH",
258  $lng->txt("cntr_switch_to_new_editor_cmd"));
259  $page_gui->setPrependingHtml($wtpl->get());
260  }
261 
262  // style tab
263  $page_gui->setTabHook($this, "addPageTabs");
264 
265  $ret =& $this->ctrl->forwardCommand($page_gui);
266 
267  //$ret =& $page_gui->executeCommand();
268  return $ret;
269  }
270 
274  function addPageTabs()
275  {
276  global $ilTabs, $ilCtrl;
277 
278  $ilTabs->addTarget("obj_sty",
279  $ilCtrl->getLinkTarget($this, 'editStyleProperties'), "editStyleProperties");
280  }
281 
286  {
287  global $ilSetting, $ilUser;
288 
289  if (!$ilSetting->get("enable_cat_page_edit"))
290  {
291  return;
292  }
293 
294  // old page editor content
295  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
296  "xhtml_page");
297  if ($xpage_id > 0)
298  {
299  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
300  $xpage = new ilXHTMLPage($xpage_id);
301  return $xpage->getContent();
302  }
303 
304 
305  // page object
306 
307 
308  // if page does not exist, return nothing
309  include_once("./Services/COPage/classes/class.ilPageUtil.php");
310  if (!ilPageUtil::_existsAndNotEmpty("cont",
311  $this->object->getId()))
312  {
313  return "";
314  }
315  include_once("./Services/Container/classes/class.ilContainerPage.php");
316  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
317 
318  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
319  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
320  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
321  $this->tpl->setCurrentBlock("SyntaxStyle");
322  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
324  $this->tpl->parseCurrentBlock();
325 
326  // get page object
327  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
328  $ot = ilObjectTranslation::getInstance($this->object->getId());
329  $lang = $ot->getEffectiveContentLang($ilUser->getCurrentLanguage(), "cont");
330  $page_gui = new ilContainerPageGUI($this->object->getId(), 0, $lang);
331  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
332  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
333  $this->object->getStyleSheetId(), $this->object->getType()));
334 
335  $page_gui->setPresentationTitle("");
336  $page_gui->setTemplateOutput(false);
337  $page_gui->setHeader("");
338  $ret = $page_gui->showPage();
339 
340  //$ret =& $page_gui->executeCommand();
341  return $ret;
342  }
343 
347  function prepareOutput($a_show_subobjects = true)
348  {
349  if (parent::prepareOutput()) // return false in admin mode
350  {
351  if ($this->getCreationMode() != true && $a_show_subobjects)
352  {
353  // This method is called directly from ilContainerGUI::renderObject
354  #$this->showPossibleSubObjects();
355  $this->showTreeFlatIcon();
356 
357  // Member view
358  include_once './Services/Container/classes/class.ilMemberViewGUI.php';
359  ilMemberViewGUI::showMemberViewSwitch($this->object->getRefId());
360  }
361  }
362  }
363 
364  function showTreeFlatIcon()
365  {
366  global $tpl;
367 
368  // dont show icon, if role (permission gui->rolegui) is edited
369  if ($_GET["obj_id"] != "")
370  {
371  return;
372  }
373  // hide for member view
374  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
375  if(ilMemberViewSettings::getInstance()->isActive())
376  {
377  return;
378  }
379 
380  $mode = ($_SESSION["il_rep_mode"] == "flat")
381  ? "tree"
382  : "flat";
383  $link = "ilias.php?baseClass=ilRepositoryGUI&amp;cmd=frameset&amp;set_mode=".$mode."&amp;ref_id=".$this->object->getRefId();
384  $tpl->setTreeFlatIcon($link, $mode);
385  }
386 
391  {
392  global $ilias;
393 
394  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
395  {
396  $this->tpl->setTitle($this->object->getTitle());
397  $this->tpl->setDescription($this->object->getLongDescription());
398 
399  // set tile icon
400  $icon = ilObject::_getIcon($this->object->getId(), "big", $this->object->getType());
401  if ($ilias->getSetting("custom_icons") &&
402  in_array($this->object->getType(), array("cat","grp","crs", "root")))
403  {
404  require_once("./Services/Container/classes/class.ilContainer.php");
405  if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
406  {
407  $icon = $path;
408  }
409  }
410  $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
411 
412  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
413  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
414  $lgui->initItem($this->object->getRefId(), $this->object->getId());
415  $this->tpl->setAlertProperties($lgui->getAlertProperties());
416  }
417  }
418 
423  {
424  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
425  $gui = new ilObjectAddNewItemGUI($this->object->getRefId());
426  $gui->render();
427  }
428 
435  function getContentGUI()
436  {
437  switch ($this->object->getViewMode())
438  {
439  // all items in one block
441  include_once("./Services/Container/classes/class.ilContainerSimpleContentGUI.php");
442  $container_view = new ilContainerSimpleContentGUI($this);
443  break;
444 
446  include_once('./Services/Container/classes/class.ilContainerObjectiveGUI.php');
447  $container_view = new ilContainerObjectiveGUI($this);
448  break;
449 
450  // all items in one block
452  case IL_CRS_VIEW_TIMING: // not nice this workaround
453  include_once("./Services/Container/classes/class.ilContainerSessionsContentGUI.php");
454  $container_view = new ilContainerSessionsContentGUI($this);
455  break;
456 
457  // ILinc courses
459  include_once 'Services/Container/classes/class.ilContainerILincContentGUI.php';
460  $container_view = new ilContainerILincContentGUI($this);
461  break;
462 
463  // all items in one block
465  default:
466  include_once("./Services/Container/classes/class.ilContainerByTypeContentGUI.php");
467  $container_view = new ilContainerByTypeContentGUI($this);
468  break;
469  }
470 
471  return $container_view;
472  }
473 
474 
475 
479  function renderObject()
480  {
481  global $ilDB, $tpl, $ilTabs, $ilCtrl, $ilSetting;
482 
483  $container_view = $this->getContentGUI();
484 
485  $this->setContentSubTabs();
486  if ($this->isActiveAdministrationPanel())
487  {
488  $ilTabs->activateSubTab("manage");
489  }
490  else
491  {
492  $ilTabs->activateSubTab("view_content");
493  }
494 
495  $container_view->setOutput();
496 
497  $this->adminCommands = $container_view->adminCommands;
498 
499  // it is important not to show the subobjects/admin panel here, since
500  // we will create nested forms in case, e.g. a news/calendar item is added
501  if ($ilCtrl->getNextClass() != "ilcolumngui")
502  {
503  $this->showAdministrationPanel($tpl);
504  $this->showPossibleSubObjects();
505  }
506 
507  $this->showPermanentLink($tpl);
508 
509  // add tree updater javascript
510  if ((int) $_GET["ref_id"] > 1 && $ilSetting->get("rep_tree_synchronize"))
511  {
512  $ilCtrl->setParameter($this, "active_node", (int) $_GET["ref_id"]);
513  /*$tpl->addOnloadCode("
514  if (parent && parent.tree && parent.tree.updater)
515  {
516  parent.tree.updater('tree_div', '".
517  $ilCtrl->getLinkTarget($this, "showTree", "", true, false)
518  ."');
519  }");*/
520  }
521  }
522 
526  function setContentSubTabs()
527  {
529  }
530 
535  {
536  global $ilAccess, $lng;
537 
538  $lng->loadLanguageModule('cntr');
539 
540  if ($this->isActiveAdministrationPanel())
541  {
542  // #11545
543  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
544 
545  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
546  $toolbar = new ilToolbarGUI();
547  $this->ctrl->setParameter($this, "type", "");
548  $this->ctrl->setParameter($this, "item_ref_id", "");
549 
550  if (!$_SESSION["clipboard"])
551  {
552  if ($this->object->gotItems())
553  {
554  $toolbar->setLeadingImage(
555  ilUtil::getImagePath("arrow_upright.png"),
556  $lng->txt("actions")
557  );
558  $toolbar->addFormButton(
559  $this->lng->txt('delete_selected_items'),
560  'delete'
561  );
562  $toolbar->addFormButton(
563  $this->lng->txt('move_selected_items'),
564  'cut'
565  );
566  $toolbar->addFormButton(
567  $this->lng->txt('copy_selected_items'),
568  'copy'
569  );
570  $toolbar->addFormButton(
571  $this->lng->txt('link_selected_items'),
572  'link'
573  );
574  // add download button if multi download enabled
575  $folder_set = new ilSetting("fold");
576  if ($folder_set->get("enable_multi_download") == true)
577  {
578  $toolbar->addSeparator();
579  $toolbar->addFormButton(
580  $this->lng->txt('download_selected_items'),
581  'download'
582  );
583  }
584  }
585  if($this->object->getType() == 'crs')
586  {
587  if($this->object->gotItems())
588  {
589  $toolbar->addSeparator();
590  }
591 
592  $toolbar->addButton(
593  $this->lng->txt('cntr_adopt_content'),
594  $this->ctrl->getLinkTargetByClass(
595  'ilObjectCopyGUI',
596  'initSourceSelection')
597  );
598  }
599  }
600  else
601  {
602  //$GLOBALS["tpl"]->addAdminPanelCommand("paste",
603  // $this->lng->txt("paste_clipboard_items"));
604 
605  $toolbar->addFormButton(
606  $this->lng->txt('paste_clipboard_items'),
607  'paste'
608  );
609 
610  if($_SESSION["clipboard"]["cmd"] == "link")
611  {
612  //$GLOBALS["tpl"]->addAdminPanelCommand("initAndDisplayLinkIntoMultipleObjects",
613  // $this->lng->txt("paste_clipboard_items_into_multiple_objects"));
614  /*$toolbar->addFormButton(
615  $this->lng->txt('paste_clipboard_items_into_multiple_objects'),
616  'initAndDisplayLinkIntoMultipleObjects'
617  );*/
618  }
619 
620  $toolbar->addFormButton(
621  $this->lng->txt('clear_clipboard'),
622  'clear'
623  );
624 
625  if ($this->isMultiDownloadEnabled())
626  {
627  $toolbar->addSeparator();
628  $toolbar->addFormButton(
629  $this->lng->txt('download_selected_items'),
630  'download'
631  );
632  }
633  }
634 
635  $GLOBALS['tpl']->addAdminPanelToolbar(
636  $toolbar,
637  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false,
638  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false
639  );
640 
641  // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
642  if ($this->object->gotItems())
643  {
644  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
645  }
646  }
647  else
648  {
649  if ($this->edit_order)
650  {
651  if($this->object->gotItems() and $ilAccess->checkAccess("write", "", $this->object->getRefId()))
652  {
653  include_once('./Services/Container/classes/class.ilContainer.php');
654 
655  if ($this->object->getOrderType() == ilContainer::SORT_MANUAL)
656  {
657  // #11843
658  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
659 
660  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
661  $toolbar = new ilToolbarGUI();
662  $this->ctrl->setParameter($this, "type", "");
663  $this->ctrl->setParameter($this, "item_ref_id", "");
664 
665  $toolbar->addFormButton(
666  $this->lng->txt('sorting_save'),
667  'saveSorting'
668  );
669 
670  $GLOBALS['tpl']->addAdminPanelToolbar($toolbar, true, false);
671 
672  /*
673  $GLOBALS["tpl"]->addAdminPanelCommand("saveSorting",
674  $this->lng->txt('sorting_save'));
675 
676  // button should appear at bottom, too
677  $GLOBALS["tpl"]->admin_panel_bottom = true;
678  */
679  }
680  }
681  }
682  else if ($this->isMultiDownloadEnabled())
683  {
684  // #11843
685  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
686 
687  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
688  $toolbar = new ilToolbarGUI();
689  $this->ctrl->setParameter($this, "type", "");
690  $this->ctrl->setParameter($this, "item_ref_id", "");
691 
692  $toolbar->addFormButton(
693  $this->lng->txt('download_selected_items'),
694  'download'
695  );
696 
697  $GLOBALS['tpl']->addAdminPanelToolbar(
698  $toolbar,
699  $this->object->gotItems() ? true : false,
700  $this->object->gotItems() ? true : false
701  );
702  }
703  }
704  }
705 
707  {
708  global $tree;
709 
710  if(!$tree->checkForParentType($this->object->getRefId(),'crs'))
711  {
712  return false;
713  }
714  $tpl->setCurrentBlock("custom_button");
715  $tpl->setVariable("ADMIN_MODE_LINK",$this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editTimings'));
716  $tpl->setVariable("TXT_ADMIN_MODE",$this->lng->txt('timings_edit'));
717  $tpl->parseCurrentBlock();
718  return true;
719  }
724  {
725  $GLOBALS["tpl"]->setPermanentLink($this->object->getType(),
726  $this->object->getRefId(), "", "_top");
727  }
728 
733  {
734  global $ilCtrl;
735 
736  $_SESSION["il_cntr_editor"] = "std";
737  $ilCtrl->redirect($this, "editPageFrame");
738  }
739 
744  {
745  global $ilCtrl;
746 
747  $_SESSION["il_cntr_editor"] = "old";
748  $ilCtrl->redirect($this, "editPageFrame");
749  }
750 
755  {
756  global $ilCtrl, $ilAccess, $lng, $ilCtrl;
757 
758  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
759  {
760  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
761 
762  /* keep old page content for now...
763  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
764  "xhtml_page");
765  if ($xpage_id)
766  {
767  $xpage = new ilXHTMLPage($xpage_id);
768  }
769  */
770 
771  ilContainer::_writeContainerSetting($this->object->getId(),
772  "xhtml_page", 0);
773 
774  ilUtil::sendSuccess($lng->txt("cntr_switched_editor"), true);
775  }
776 
777  $ilCtrl->redirect($this, "editPageFrame");
778  }
779 
784  {
785  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
786  $fs_gui = new ilFramesetGUI();
787 
788  $fs_gui->setFramesetTitle($this->object->getTitle());
789  $fs_gui->setMainFrameName("content");
790  $fs_gui->setSideFrameName("tree");
791 
792  // old tiny stuff
793  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
794  "xhtml_page");
795  if ($xpage_id > 0 && $_SESSION["il_cntr_editor"] != "std")
796  {
797  $fs_gui->setMainFrameSource(
798  $this->ctrl->getLinkTarget(
799  $this, "editPageContent"));
800  $fs_gui->setSideFrameSource(
801  $this->ctrl->getLinkTarget($this, "showLinkList"));
802  }
803  else
804  {
805  $this->ctrl->redirectByClass(array("ilcontainerpagegui"), "edit");
806  exit;
807  }
808 
809  $fs_gui->show();
810  exit;
811  }
812 
819  {
820  global $rbacsystem, $tpl, $lng, $ilCtrl;
821 
822  if (!$rbacsystem->checkAccess("write", $this->ref_id))
823  {
824  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
825  }
826 
827  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
828  "xhtml_page");
829  if ($xpage_id > 0)
830  {
831  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
832  $xpage = new ilXHTMLPage($xpage_id);
833  $content = $xpage->getContent();
834  }
835 
836  // get template
837  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.container_edit_page_content.html",
838  "Services/Container");
839  $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
840  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
841  $tpl->setVariable("TXT_EDIT_PAGE_CONTENT",
842  $this->lng->txt("edit_page_content"));
843  $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
844  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
845  $tpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_old_editor_warning"));
846  $tpl->setVariable("TXT_MIGRATION_OPEN_STD_EDITOR", $lng->txt("cntr_old_editor_open_standard_editor"));
847  $tpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert_s.png"));
848  $tpl->setVariable("HREF_OPEN_STD_EDITOR", $ilCtrl->getLinkTarget($this, "switchToStdEditor"));
849  $tpl->setVariable("ALT_WARNING", $lng->txt("warning"));
850 
851  include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
852  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
853  //$ta = new ilTextAreaInputGUI();
854  //$tags = $ta->getRteTagSet("extended_table_img");
855 
856  // add rte support
857  include_once "./Services/RTE/classes/class.ilRTE.php";
858  $rtestring = ilRTE::_getRTEClassname();
859  include_once "./Services/RTE/classes/class.$rtestring.php";
860  $rte = new $rtestring();
861  //$rte->addPlugin("latex");
862  include_once "./Services/Object/classes/class.ilObject.php";
864  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
865  $rte->addRTESupport($obj_id, $obj_type);
866  //$rte->setStyleSelect(true);
867  //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
868  }
869 
871  {
872  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
873  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
874  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
875  "xhtml_page");
876 
877  /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
878  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
879  $ta = new ilTextAreaInputGUI();
880  $ta->setRteTagSet("extended_table_img");
881  $tags = $ta->getRteTagString();*/
882 
883  //$text = ilUtil::stripSlashes($_POST["page_content"],
884  // true,
885  // $tags);
886 
887  $text = ilUtil::stripSlashes($_POST["page_content"],
888  true,
890  if ($xpage_id > 0)
891  {
892  $xpage = new ilXHTMLPage($xpage_id);
893  $xpage->setContent($text);
894  $xpage->save();
895  }
896  else
897  {
898  $xpage = new ilXHTMLPage();
899  $xpage->setContent($text);
900  $xpage->save();
901  ilContainer::_writeContainerSetting($this->object->getId(),
902  "xhtml_page", $xpage->getId());
903  }
904 
905  include_once("Services/RTE/classes/class.ilRTE.php");
906  ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType().":html",
907  $this->object->getId());
908 
909  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
910  $this->ctrl->redirect($this, "");
911  }
912 
914  {
915  $this->ctrl->redirect($this, "");
916  }
917 
918  function renderItemList($a_type = "all")
919  {
921 
922  include_once("Services/Object/classes/class.ilObjectListGUIFactory.php");
923 
924  $output_html = "";
926 
927  $type_grps = $this->object->getGroupedObjTypes();
928 
929  switch ($a_type)
930  {
931  // render all items list
932  case "all":
933 
934  // new behaviour
935  $output_html.= $this->getContainerPageHTML();
936 
937  // all item types
938  /*
939  $type_ordering = array(
940  "cat", "fold", "crs","rcrs", "icrs", "icla", "grp", "chat", "frm", "lres",
941  "glo", "webr", "mcst", "wiki", "file", "exc",
942  "tst", "svy", "mep", "qpl", "spl");*/
943 
944  $cur_obj_type = "";
945  $overall_tpl =& $this->newBlockTemplate();
946  $this->type_template = array();
947  $first = true;
948 
949  // iterate all types
950  foreach ($type_grps as $type => $v)
951  {
952  // set template (overall or type specific)
953  if (is_int(strpos($output_html, "[list-".$type."]")))
954  {
955  $tpl =& $this->newBlockTemplate();
956  $overall = false; // individual
957  }
958  else
959  {
960  $tpl =& $overall_tpl;
961  $overall = true; // put to the rest
962  }
963 
964  if (is_array($this->items[$type]))
965  {
966 
967  $item_html = array();
968 
969  foreach($this->items[$type] as $key => $item)
970  {
971  // get list gui class for each object type
972  if ($cur_obj_type != $item["type"])
973  {
974  $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
975  $item_list_gui->setContainerObject($this);
976  }
977  // render item row
978  $ilBench->start("ilContainerGUI", "0210_getListHTML");
979 
980  // show administration command buttons (or not)
981  if (!$this->isActiveAdministrationPanel())
982  {
983  $item_list_gui->enableDelete(false);
984  $item_list_gui->enableLink(false);
985  $item_list_gui->enableCut(false);
986  $item_list_gui->enableCopy(false);
987  }
988 
989  // activate common social commands
990  $item_list_gui->enableComments(true);
991  $item_list_gui->enableNotes(true);
992  $item_list_gui->enableTags(true);
993  $item_list_gui->enableRating(true);
994 
995  $html = $item_list_gui->getListItemHTML($item["ref_id"],
996  $item["obj_id"], $item["title"], $item["description"]);
997 
998  // check whether any admin command is allowed for
999  // the items
1000  $this->determineAdminCommands($item["ref_id"],
1001  $item_list_gui->adminCommandsIncluded());
1002  $ilBench->stop("ilContainerGUI", "0210_getListHTML");
1003  if ($html != "")
1004  {
1005  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
1006  $item_html[] = array(
1007  "html" => $html,
1008  "item_ref_id" => $item["ref_id"],
1009  "item_obj_id" => $item["obj_id"],
1010  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
1011  $item_list_gui->getIconImageType() :
1012  $item['type']
1013  );
1014  // END WebDAV: Use $item_list_gui to determine icon image type
1015  }
1016  }
1017 
1018  // output block for resource type
1019  if (count($item_html) > 0)
1020  {
1021  // separator row
1022  if (!$first && $overall)
1023  {
1024  $this->addSeparatorRow($tpl);
1025  }
1026 
1027  if ($overall)
1028  {
1029  $first = false;
1030  }
1031 
1032  // add a header for each resource type
1033  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
1034  {
1035  $this->addHeaderRow($tpl, $type, false);
1036  }
1037  else
1038  {
1039  $this->addHeaderRow($tpl, $type);
1040  }
1041  $this->resetRowType();
1042 
1043  // content row
1044  $this->current_position = 1;
1045  foreach($item_html as $item)
1046  {
1047  // BEGIN WebDAV: Use $item_list_gui to determine image type
1048  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $item['item_icon_image_type']);
1049  // END WebDAV: Use $item_list_gui to determine image type
1050  }
1051 
1052  // store type specific templates in array
1053  if (is_int(strpos($output_html, "[list-".$type."]")))
1054  {
1055  $this->type_template[$type] = $tpl;
1056  }
1057  }
1058  else
1059  {
1060  // [list-...] tag available, but no item of type accessible
1061  if (!$overall)
1062  {
1063  $this->addHeaderRow($tpl, $type);
1064  $this->resetRowType();
1065  $this->addMessageRow($tpl,
1066  $this->lng->txt("msg_no_type_accessible"), $type);
1067  $this->type_template[$type] = $tpl;
1068  }
1069  }
1070  }
1071  else
1072  {
1073  // [list-...] tag available, but no item of type exists
1074  if (!$overall)
1075  {
1076  $this->addHeaderRow($tpl, $type);
1077  $this->resetRowType();
1078  $this->addMessageRow($tpl,
1079  $this->lng->txt("msg_no_type_available"), $type);
1080  $this->type_template[$type] = $tpl;
1081  }
1082  }
1083 
1084  }
1085 
1086 
1087  // I don't know why but executing this
1088  // line before the following foreach loop seems to be crucial
1089  if ($output_html != "")
1090  {
1091  //$output_html.= "<br /><br />";
1092  }
1093  $output_html.= $overall_tpl->get();
1094  //$output_html = str_replace("<br>++", "++", $output_html);
1095  //$output_html = str_replace("<br>++", "++", $output_html);
1096  //$output_html = str_replace("++<br>", "++", $output_html);
1097  //$output_html = str_replace("++<br>", "++", $output_html);
1098  foreach ($this->type_template as $type => $tpl)
1099  {
1100  $output_html = eregi_replace("\[list-".$type."\]",
1101  "</p>".$tpl->get()."<p class=\"ilc_Standard\">",
1102  $output_html);
1103  }
1104 
1105  if ($xpage_id > 0)
1106  {
1107  $page_block = new ilTemplate("tpl.container_page_block.html", false, false,
1108  "Services/Container");
1109  $page_block->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
1110  $output_html = $page_block->get();
1111  }
1112 
1113  break;
1114 
1115  default:
1116  // to do:
1117  break;
1118  }
1119  return $output_html;
1120  }
1121 
1123  {
1124  global $lng, $tree;
1125 
1126  $tpl = new ilTemplate("tpl.container_link_help.html", true, true,
1127  "Services/Container");
1128 
1129  $type_ordering = array(
1130  "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
1131  "glo", "webr", "file", "exc",
1132  "tst", "svy", "mep", "qpl", "spl");
1133 
1134  $childs = $tree->getChilds($_GET["ref_id"]);
1135  foreach($childs as $child)
1136  {
1137  if (in_array($child["type"], array("lm", "dbk", "sahs", "htlm")))
1138  {
1139  $cnt["lres"]++;
1140  }
1141  else
1142  {
1143  $cnt[$child["type"]]++;
1144  }
1145  }
1146 
1147  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1148  $tpl->setVariable("TXT_HELP_HEADER", $lng->txt("help"));
1149  foreach($type_ordering as $type)
1150  {
1151  $tpl->setCurrentBlock("row");
1152  $tpl->setVariable("ROWCOL", "tblrow".((($i++)%2)+1));
1153  if ($type != "lres")
1154  {
1155  $tpl->setVariable("TYPE", $lng->txt("objs_".$type).
1156  " (".((int)$cnt[$type]).")");
1157  }
1158  else
1159  {
1160  $tpl->setVariable("TYPE", $lng->txt("learning_resources").
1161  " (".((int)$cnt["lres"]).")");
1162  }
1163  $tpl->setVariable("TXT_LINK", "[list-".$type."]");
1164  $tpl->parseCurrentBlock();
1165  }
1166  $tpl->show();
1167  exit;
1168 
1169  }
1170 
1175  {
1176  $this->adminCommands = false;
1177  }
1178 
1182 /* function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
1183  {
1184  if (!$this->adminCommands)
1185  {
1186  if (!$this->isActiveAdministrationPanel())
1187  {
1188  if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
1189  {
1190  $this->adminCommands = true;
1191  }
1192  }
1193  else
1194  {
1195  $this->adminCommands = $a_admin_com_included_in_list;
1196  }
1197  }
1198  }*/
1199 
1206  function &newBlockTemplate()
1207  {
1208  $tpl = new ilTemplate("tpl.container_list_block.html", true, true,
1209  "Services/Container");
1210  $this->cur_row_type = "row_type_1";
1211  return $tpl;
1212  }
1213 
1221  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1222  {
1223  $icon = ilUtil::getImagePath("icon_".$a_type.".png");
1224  $title = $this->lng->txt("objs_".$a_type);
1225 
1226  if ($a_show_image)
1227  {
1228  $a_tpl->setCurrentBlock("container_header_row_image");
1229  $a_tpl->setVariable("HEADER_IMG", $icon);
1230  $a_tpl->setVariable("HEADER_ALT", $title);
1231  }
1232  else
1233  {
1234  $a_tpl->setCurrentBlock("container_header_row");
1235  }
1236 
1237  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1238  $a_tpl->parseCurrentBlock();
1239  $a_tpl->touchBlock("container_row");
1240  }
1241 
1249  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1250  $a_image_type = "")
1251  {
1252  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1253  ? "row_type_2"
1254  : "row_type_1";
1255 
1256  $a_tpl->touchBlock($this->cur_row_type);
1257 
1258  $nbsp = true;
1259  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
1260  {
1261  $icon = ilUtil::getImagePath("icon_".$a_image_type.".png");
1262  $alt = $this->lng->txt("obj_".$a_image_type);
1263 
1264  // custom icon
1265  if ($this->ilias->getSetting("custom_icons") &&
1266  in_array($a_image_type, array("cat","grp","crs")))
1267  {
1268  require_once("./Services/Container/classes/class.ilContainer.php");
1269  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1270  {
1271  $icon = $path;
1272  }
1273  }
1274 
1275  $a_tpl->setCurrentBlock("block_row_image");
1276  $a_tpl->setVariable("ROW_IMG", $icon);
1277  $a_tpl->setVariable("ROW_ALT", $alt);
1278  $a_tpl->parseCurrentBlock();
1279  $nbsp = false;
1280  }
1281 
1282  if ($this->isActiveAdministrationPanel())
1283  {
1284  $a_tpl->setCurrentBlock("block_row_check");
1285  $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
1286  $a_tpl->parseCurrentBlock();
1287  $nbsp = false;
1288  }
1289  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1290  if($this->isActiveAdministrationPanel() &&
1292  {
1293  $a_tpl->setCurrentBlock('block_position');
1294  $a_tpl->setVariable('POS_TYPE',$a_image_type);
1295  $a_tpl->setVariable('POS_ID',$a_item_ref_id);
1296  $a_tpl->setVariable('POSITION',sprintf('%.1f',$this->current_position++));
1297  $a_tpl->parseCurrentBlock();
1298  }
1299  if ($nbsp)
1300  {
1301  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1302  }
1303  $a_tpl->setCurrentBlock("container_standard_row");
1304  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1305  $a_tpl->parseCurrentBlock();
1306  $a_tpl->touchBlock("container_row");
1307  }
1308 
1312  function addMessageRow(&$a_tpl, $a_message, $a_type)
1313  {
1314  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1315  ? "row_type_2"
1316  : "row_type_1";
1317 
1318  $a_tpl->touchBlock($this->cur_row_type);
1319 
1320  $type = $this->lng->txt("obj_".$a_type);
1321  $a_message = str_replace("[type]", $type, $a_message);
1322 
1323  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1324 
1325  $a_tpl->setCurrentBlock("container_standard_row");
1326  $a_tpl->setVariable("BLOCK_ROW_CONTENT",
1327  $a_message);
1328  $a_tpl->parseCurrentBlock();
1329  $a_tpl->touchBlock("container_row");
1330  }
1331 
1332  function resetRowType()
1333  {
1334  $this->cur_row_type = "";
1335  }
1336 
1337 
1342  {
1343  global $lng;
1344 
1345  if (!$this->isActiveAdministrationPanel()
1346  || strtolower($this->ctrl->getCmdClass()) != "ilcontainerpagegui")
1347  {
1348  return;
1349  }
1350 
1351  $lng->loadLanguageModule("content");
1352  //$tabs_gui = new ilTabsGUI();
1353  //$tabs_gui->setSubTabs();
1354 
1355  // back to upper context
1356  $this->tabs_gui->setBackTarget($this->lng->txt("obj_cat"),
1357  $this->ctrl->getLinkTarget($this, "frameset"),
1358  ilFrameTargetInfo::_getFrame("MainContent"));
1359 
1360  $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilcontainerpagegui", "view")
1361  , array("", "view"), "ilcontainerpagegui");
1362 
1363  //$this->tpl->setTabs($tabs_gui->getHTML());
1364  }
1365 
1369  function addStandardContainerSubTabs($a_include_view = true)
1370  {
1371  global $ilTabs, $ilAccess, $lng, $ilCtrl, $ilUser, $ilSetting;
1372 
1373  if (!is_object($this->object))
1374  {
1375  return;
1376  }
1377 
1378  if ($a_include_view && $ilAccess->checkAccess("read", "", $this->object->getRefId()))
1379  {
1380  if (!$this->isActiveAdministrationPanel())
1381  {
1382  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, ""));
1383  }
1384  else
1385  {
1386  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "disableAdministrationPanel"));
1387  }
1388  }
1389 
1390  if ( $ilUser->getId() != ANONYMOUS_USER_ID &&
1391  ($this->adminCommands ||
1392  (is_object($this->object) &&
1393  ($ilAccess->checkAccess("write", "", $this->object->getRefId())))
1394  ||
1395  (is_object($this->object) &&
1396  ($this->object->getHiddenFilesFound())) ||
1397  $_SESSION["clipboard"]
1398  )
1399  )
1400  {
1401  if ($this->isActiveAdministrationPanel())
1402  {
1403  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, ""));
1404  }
1405  else
1406  {
1407  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, "enableAdministrationPanel"));
1408  }
1409  }
1410  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1411  is_object($this->object) &&
1412  $ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
1413  $this->object->getOrderType() == ilContainer::SORT_MANUAL
1414  )
1415  {
1416  $ilTabs->addSubTab("ordering", $lng->txt("cntr_ordering"), $ilCtrl->getLinkTarget($this, "editOrder"));
1417  }
1418  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1419  is_object($this->object) &&
1420  $ilAccess->checkAccess("write", "", $this->object->getRefId())
1421  )
1422  {
1423  if ($ilSetting->get("enable_cat_page_edit"))
1424  {
1425  $ilTabs->addSubTab("page_editor", $lng->txt("cntr_text_media_editor"), $ilCtrl->getLinkTarget($this, "editPageFrame"),
1426  ilFrameTargetInfo::_getFrame("MainContent"));
1427  }
1428  }
1429  }
1430 
1431 
1436  function getTabs(&$tabs_gui)
1437  {
1438  global $rbacsystem, $ilCtrl;
1439 
1440  // edit permissions
1441  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
1442  {
1443  $tabs_gui->addTarget("perm_settings",
1444  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1445  array("perm","info","owner"), 'ilpermissiongui');
1446  if ($ilCtrl->getNextClass() == "ilpermissiongui")
1447  {
1448  $tabs_gui->activateTab("perm_settings");
1449  }
1450  }
1451 
1452  // show clipboard
1453  if (strtolower($_GET["baseClass"]) == "ilrepositorygui" && !empty($_SESSION["clipboard"]))
1454  {
1455  $tabs_gui->addTarget("clipboard",
1456  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
1457  }
1458 
1459  }
1460 
1461  //*****************
1462  // COMMON METHODS (may be overwritten in derived classes
1463  // if special handling is necessary)
1464  //*****************
1465 
1470  {
1471  $_SESSION["il_cont_admin_panel"] = true;
1472  $this->ctrl->redirect($this, "render");
1473  }
1474 
1479  {
1480  $_SESSION["il_cont_admin_panel"] = false;
1481  $this->ctrl->redirect($this, "render");
1482  }
1483 
1487  function editOrderObject()
1488  {
1489  global $ilTabs;
1490 
1491  $this->edit_order = true;
1492  $_SESSION["il_cont_admin_panel"] = false;
1493  $this->renderObject();
1494 
1495  $ilTabs->activateSubTab("ordering");
1496  }
1497 
1502  public function isActiveOrdering()
1503  {
1504  return $this->edit_order ? true : false;
1505  }
1506 
1507 
1508 
1512  public function addToDeskObject()
1513  {
1514  global $ilSetting, $lng;
1515 
1516  if((int)$ilSetting->get('disable_my_offers'))
1517  {
1518  return $this->renderObject();
1519  }
1520 
1521  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1523  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
1524  $this->renderObject();
1525  }
1526 
1530  public function removeFromDeskObject()
1531  {
1532  global $ilSetting, $lng;
1533 
1534  if((int)$ilSetting->get('disable_my_offers'))
1535  {
1536  return $this->renderObject();
1537  }
1538 
1539  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1541  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
1542  $this->renderObject();
1543  }
1544 
1546  {
1547  $this->multi_download_enabled = true;
1548  $this->renderObject();
1549  }
1550 
1552  {
1554  }
1555 
1556  // BEGIN WebDAV: Lock/Unlock objects
1557  function lockObject()
1558  {
1559  global $tree, $ilUser, $rbacsystem;
1560 
1561  if (!$rbacsystem->checkAccess("write",$_GET['item_ref_id']))
1562  {
1563  $this->ilErr->raiseError($this->lng->txt('err_no_permission'),$this->ilErr->MESSAGE);
1564  }
1565 
1566 
1567  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1569  {
1570  require_once 'Services/WebDAV/classes/class.ilDAVLocks.php';
1571  $locks = new ilDAVLocks();
1572 
1573  $result = $locks->lockRef($_GET['item_ref_id'],
1574  $ilUser->getId(), $ilUser->getLogin(),
1575  'ref_'.$_GET['item_ref_id'].'_usr_'.$ilUser->getId(),
1576  time() + /*30*24*60**/60, 0, 'exclusive'
1577  );
1578 
1580  $this->lng->txt(
1581  ($result === true) ? 'object_locked' : $result
1582  ),
1583  true);
1584  }
1585  $this->renderObject();
1586  }
1587  // END WebDAV: Lock/Unlock objects
1588 
1595  function cutObject()
1596  {
1597  global $rbacsystem, $ilCtrl;
1598 
1599  if ($_GET["item_ref_id"] != "")
1600  {
1601  $_POST["id"] = array($_GET["item_ref_id"]);
1602  }
1603 
1604  //$this->ilias->raiseError("move operation does not work at the moment and is disabled",$this->ilias->error_obj->MESSAGE);
1605 
1606  if (!isset($_POST["id"]))
1607  {
1608  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1609  }
1610 
1611  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1612  foreach ($_POST["id"] as $ref_id)
1613  {
1614  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1615  $node_data = $this->tree->getNodeData($ref_id);
1616  $subtree_nodes = $this->tree->getSubTree($node_data);
1617 
1618  $all_node_data[] = $node_data;
1619  $all_subtree_nodes[] = $subtree_nodes;
1620 
1621  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1622  foreach ($subtree_nodes as $node)
1623  {
1624  if($node['type'] == 'rolf')
1625  {
1626  continue;
1627  }
1628 
1629  if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
1630  {
1631  $no_cut[] = $node["ref_id"];
1632  }
1633  }
1634  }
1635  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1636  if (count($no_cut))
1637  {
1638  $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
1639  $this->ilias->error_obj->MESSAGE);
1640  }
1641  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1642  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1643  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1644 
1645  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"),true);
1646 
1647  return $this->initAndDisplayMoveIntoObjectObject();
1648  } // END CUT
1649 
1657  function copyObject()
1658  {
1659  global $rbacsystem, $ilCtrl, $objDefinition;
1660 
1661  if ($_GET["item_ref_id"] != "")
1662  {
1663  $_POST["id"] = array($_GET["item_ref_id"]);
1664  }
1665 
1666  if (!isset($_POST["id"]))
1667  {
1668  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1669  }
1670 
1671  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1672  $containers = 0;
1673  foreach ($_POST["id"] as $ref_id)
1674  {
1675  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1676  $node_data = $this->tree->getNodeData($ref_id);
1677 
1678  // count containers
1679  if ($objDefinition->isContainer($node_data["type"]))
1680  {
1681  $containers++;
1682  }
1683 
1684  $subtree_nodes = $this->tree->getSubTree($node_data);
1685 
1686  $all_node_data[] = $node_data;
1687  $all_subtree_nodes[] = $subtree_nodes;
1688 
1689  // CHECK COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1690  foreach ($subtree_nodes as $node)
1691  {
1692  if($node['type'] == 'rolf')
1693  {
1694  continue;
1695  }
1696 
1697  if (!$rbacsystem->checkAccess('visible,read,copy',$node["ref_id"]))
1698  {
1699  $no_copy[] = $node["ref_id"];
1700  }
1701  }
1702  }
1703 
1704  if ($containers > 0 && count($_POST["id"]) > 1)
1705  {
1706  $this->ilias->raiseError($this->lng->txt("cntr_container_only_on_their_own"), $this->ilias->error_obj->MESSAGE);
1707  }
1708 
1709  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1710  if (count($no_copy))
1711  {
1712  $this->ilias->raiseError(
1713  $this->lng->txt("msg_no_perm_copy") . " " . implode(',',$this->getTitlesByRefId($no_copy)),
1714  $this->ilias->error_obj->MESSAGE);
1715  }
1716 
1717  // if we have a single container, set it as source id and redirect to ilObjectCopyGUI
1718  if (count($_POST["id"]) == 1)
1719  {
1720  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $_POST["id"][0]);
1721  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1722  }
1723  else
1724  {
1725  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($_POST["id"],"_"));
1726  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1727  }
1728 
1729  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1730  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1731  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1732 
1733  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"), true);
1734 
1736  } // END COPY
1737 
1738  function downloadObject()
1739  {
1740  global $rbacsystem, $ilCtrl;
1741 
1742  if ($_GET["item_ref_id"] != "")
1743  {
1744  $_POST["id"] = array($_GET["item_ref_id"]);
1745  }
1746 
1747  if (!isset($_POST["id"]))
1748  {
1749  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1750  }
1751 
1752  // FOR ALL OBJECTS THAT SHOULD BE DOWNLOADED
1753  foreach ($_POST["id"] as $ref_id)
1754  {
1755  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1756  $obj_type = $object->getType();
1757  if (!in_array($obj_type, array("fold", "file")))
1758  {
1759  $no_download[] = $object->getType();
1760  }
1761  else if (!$rbacsystem->checkAccess('read', $ref_id))
1762  {
1763  $no_perm[] = $ref_id;
1764  }
1765  }
1766 
1767  // IF THERE IS ANY OBJECT THAT CANNOT BE DOWNLOADED
1768  if (count($no_download))
1769  {
1770  $no_download = array_unique($no_download);
1771  foreach ($no_download as $type)
1772  {
1773  $txt_objs[] = $this->lng->txt("objs_".$type);
1774  }
1775  $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_download"),$this->ilias->error_obj->MESSAGE);
1776  }
1777 
1778  // NO ACCESS
1779  if (count($no_perm))
1780  {
1781  $this->ilias->raiseError(
1782  $this->lng->txt("msg_obj_perm_download")." ".implode(',',$no_perm),
1783  $this->ilias->error_obj->MESSAGE);
1784  }
1785 
1786  // download the objects
1787  $this->downloadMultipleObjects($_POST["id"]);
1788  }
1789 
1790  private function downloadMultipleObjects($a_ref_ids)
1791  {
1792  global $lng, $rbacsystem, $ilAccess;
1793 
1794  include_once "./Services/Utilities/classes/class.ilUtil.php";
1795  include_once 'Modules/Folder/classes/class.ilObjFolder.php';
1796  include_once 'Modules/File/classes/class.ilObjFile.php';
1797  include_once 'Modules/File/classes/class.ilFileException.php';
1798 
1799  // create temporary file to download
1800  $zip = PATH_TO_ZIP;
1801  $tmpdir = ilUtil::ilTempnam();
1802  ilUtil::makeDir($tmpdir);
1803 
1804  try
1805  {
1806  // copy each selected object
1807  foreach ($a_ref_ids as $ref_id)
1808  {
1809  if (!$ilAccess->checkAccess("read", "", $ref_id))
1810  continue;
1811 
1812  if (ilObject::_isInTrash($ref_id))
1813  continue;
1814 
1815  // get object
1816  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1817  $obj_type = $object->getType();
1818  if ($obj_type == "fold")
1819  {
1820  // copy folder to temp directory
1821  self::recurseFolder($ref_id, $object->getTitle(), $tmpdir);
1822  }
1823  else if ($obj_type == "file")
1824  {
1825  // copy file to temp directory
1826  self::copyFile($object->getId(), $object->getTitle(), $tmpdir);
1827  }
1828  }
1829 
1830  // compress the folder
1831  $deliverFilename = ilUtil::getAsciiFilename($this->object->getTitle()) . ".zip";
1832  $tmpzipfile = ilUtil::ilTempnam() . ".zip";
1833  ilUtil::zip($tmpdir, $tmpzipfile, true);
1834  ilUtil::delDir($tmpdir);
1835  ilUtil::deliverFile($tmpzipfile, $deliverFilename, '', false, true, true);
1836  }
1837  catch (ilFileException $e)
1838  {
1839  ilUtil::sendInfo($e->getMessage(), true);
1840  }
1841  }
1842 
1851  private static function recurseFolder($refid, $title, $tmpdir)
1852  {
1853  global $rbacsystem, $tree, $ilAccess;
1854 
1855  $tmpdir = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1856  ilUtil::makeDir($tmpdir);
1857 
1858  $subtree = $tree->getChildsByTypeFilter($refid, array("fold","file"));
1859 
1860  foreach ($subtree as $child)
1861  {
1862  if (!$ilAccess->checkAccess("read", "", $child["ref_id"]))
1863  continue;
1864 
1865  if (ilObject::_isInTrash($child["ref_id"]))
1866  continue;
1867 
1868  if ($child["type"] == "fold")
1869  self::recurseFolder($child["ref_id"], $child["title"], $tmpdir);
1870  else
1871  self::copyFile($child["obj_id"], $child["title"], $tmpdir);
1872  }
1873  }
1874 
1875  private static function copyFile($obj_id, $title, $tmpdir)
1876  {
1877  $newFilename = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1878 
1879  // copy to temporary directory
1880  $oldFilename = ilObjFile::_lookupAbsolutePath($obj_id);
1881  if (!copy($oldFilename, $newFilename))
1882  throw new ilFileException("Could not copy ".$oldFilename." to ".$newFilename);
1883 
1884  touch($newFilename, filectime($oldFilename));
1885  }
1886 
1893  function linkObject()
1894  {
1895  global $clipboard, $rbacsystem, $rbacadmin, $ilCtrl;
1896 
1897  if ($_GET["item_ref_id"] != "")
1898  {
1899  $_POST["id"] = array($_GET["item_ref_id"]);
1900  }
1901 
1902  if (!isset($_POST["id"]))
1903  {
1904  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1905  }
1906 
1907  // CHECK ACCESS
1908  foreach ($_POST["id"] as $ref_id)
1909  {
1910  if (!$rbacsystem->checkAccess('delete',$ref_id))
1911  {
1912  $no_cut[] = $ref_id;
1913  }
1914 
1915  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1916 
1917  if (!$this->objDefinition->allowLink($object->getType()))
1918  {
1919  $no_link[] = $object->getType();
1920  }
1921  }
1922 
1923  // NO ACCESS
1924  if (count($no_cut))
1925  {
1926  $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
1927  implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
1928  }
1929 
1930  if (count($no_link))
1931  {
1932  //#12203
1933  $this->ilias->raiseError($this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
1934 
1935  //$this->ilias->raiseError($this->lng->txt("msg_not_possible_link")." ".
1936  // implode(',',$no_link),$this->ilias->error_obj->MESSAGE);
1937  }
1938 
1939  // WRITE TO CLIPBOARD
1940  $clipboard["parent"] = $_GET["ref_id"];
1941  $clipboard["cmd"] = $ilCtrl->getCmd();
1942 
1943  foreach ($_POST["id"] as $ref_id)
1944  {
1945  $clipboard["ref_ids"][] = $ref_id;
1946  }
1947 
1948  $_SESSION["clipboard"] = $clipboard;
1949 
1950  ilUtil::sendInfo($this->lng->txt("msg_link_clipboard"),true);
1951 
1953 
1954  } // END LINK
1955 
1956 
1962  function clearObject()
1963  {
1964  unset($_SESSION["clipboard"]);
1965  unset($_SESSION["il_rep_clipboard"]);
1966 
1967  //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1968 
1969  // only redirect if clipboard was cleared
1970  if (isset($_POST["cmd"]["clear"]))
1971  {
1972  ilUtil::sendSuccess($this->lng->txt("msg_clear_clipboard"),true);
1973 
1974  //$this->ctrl->returnToParent($this);
1975  //ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1977  }
1978  }
1979 
1981  {
1982  global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree, $ilObjDataCache, $ilUser;
1983 
1984  $command = $_SESSION['clipboard']['cmd'];
1985  if(!in_array($command, array('cut', 'link', 'copy')))
1986  {
1987  $message = __METHOD__.": cmd was neither 'cut', 'link' nor 'copy'; may be a hack attempt!";
1988  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
1989  }
1990 
1991  if($command == 'cut')
1992  {
1993  if(isset($_POST['node']) && (int)$_POST['node'])
1994  $_POST['nodes'] = array($_POST['node']);
1995  }
1996 
1997  if(!is_array($_POST['nodes']) || !count($_POST['nodes']))
1998  {
1999  ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'));
2000  switch ($command)
2001  {
2002  case 'cut':
2003  $this->showPasteTreeObject();
2004  break;
2005  case 'copy':
2006  $this->showPasteTreeObject();
2007  break;
2008  case 'link':
2009  $this->showPasteTreeObject();
2010  break;
2011  }
2012  return;
2013  }
2014 
2015  // this loop does all checks
2016  $folder_objects_cache = array();
2017  foreach($_SESSION['clipboard']['ref_ids'] as $ref_id)
2018  {
2019  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
2020  $current_parent_id = $tree->getParentId($obj_data->getRefId());
2021 
2022  foreach($_POST['nodes'] as $folder_ref_id)
2023  {
2024  if(!array_key_exists($folder_ref_id, $folder_objects_cache))
2025  {
2026  $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id);
2027  }
2028 
2029  // CHECK ACCESS
2030  if(!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType()))
2031  {
2032  $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().']');
2033  }
2034 
2035  // CHECK IF REFERENCE ALREADY EXISTS
2036  if($folder_ref_id == $current_parent_id)
2037  {
2038  $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().']');
2039  }
2040 
2041  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
2042  if ($tree->isGrandChild($ref_id, $folder_ref_id) ||
2043  $ref_id == $folder_ref_id)
2044  {
2045  $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle().' ['.$obj_data->getRefId().']');
2046  }
2047 
2048  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
2049  if(!in_array($obj_data->getType(), array_keys($this->objDefinition->getSubObjects($folder_objects_cache[$folder_ref_id]->getType()))))
2050  {
2051  $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().']',
2052  $GLOBALS['lng']->txt('obj_'.$obj_data->getType()));
2053  }
2054  }
2055  }
2056 
2058  // process checking results
2059  if(count($exists) && $command != "copy")
2060  {
2061  $error .= implode('<br />', $exists);
2062  }
2063 
2064  if(count($is_child))
2065  {
2066  $error .= $error != '' ? '<br />' : '';
2067  $error .= implode('<br />', $is_child);
2068  }
2069 
2070  if(count($not_allowed_subobject))
2071  {
2072  $error .= $error != '' ? '<br />' : '';
2073  $error .= implode('<br />', $not_allowed_subobject);
2074  }
2075 
2076  if(count($no_paste))
2077  {
2078  $error .= $error != '' ? '<br />' : '';
2079  $error .= implode('<br />', $no_paste);
2080  }
2081 
2082  if($error != '')
2083  {
2084  ilUtil::sendFailure($error);
2085  switch ($command)
2086  {
2087  case 'cut':
2088  $this->showPasteTreeObject();
2089  break;
2090  case 'copy':
2091  $this->showPasteTreeObject();
2092  break;
2093  case 'link':
2094  $this->showPasteTreeObject();
2095  break;
2096  }
2097  return;
2098  }
2099 
2100  // log pasteObject call
2101  $log->write(__METHOD__.", cmd: ".$command);
2102 
2104  // everything ok: now paste the objects to new location
2105 
2106  // to prevent multiple actions via back/reload button
2107  $ref_ids = $_SESSION['clipboard']['ref_ids'];
2108  unset($_SESSION['clipboard']['ref_ids']);
2109 
2110  // BEGIN ChangeEvent: Record paste event.
2111  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2112  // END ChangeEvent: Record paste event.
2113 
2114  // process COPY command
2115  if($command == 'copy')
2116  {
2117  foreach($_POST['nodes'] as $folder_ref_id)
2118  {
2119  foreach($ref_ids as $ref_id)
2120  {
2121  $revIdMapping = array();
2122 
2123  $oldNode_data = $tree->getNodeData($ref_id);
2124  if ($oldNode_data['parent'] == $folder_ref_id)
2125  {
2126  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2127  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
2128  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, $newTitle);
2129  }
2130  else
2131  {
2132  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, null);
2133  }
2134 
2135  // BEGIN ChangeEvent: Record copy event.
2136  $old_parent_data = $tree->getParentNodeData($ref_id);
2137  $newNode_data = $tree->getNodeData($newRef);
2138  ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
2139  $oldNode_data['obj_id'], $ilUser->getId());
2140  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
2141  $ilObjDataCache->lookupObjId($folder_ref_id));
2142  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2143  // END PATCH ChangeEvent: Record cut event.
2144  }
2145  }
2146 
2147  ilUtil::sendSuccess($this->lng->txt('msg_cloned'), true);
2148  } // END COPY
2149 
2150  // process CUT command
2151  if($command == 'cut')
2152  {
2153  foreach($_POST['nodes'] as $folder_ref_id)
2154  {
2155  foreach($ref_ids as $ref_id)
2156  {
2157  // Store old parent
2158  $old_parent = $tree->getParentId($ref_id);
2159  $tree->moveTree($ref_id, $folder_ref_id);
2160  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
2161 
2162  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
2164 
2165  // BEGIN ChangeEvent: Record cut event.
2166  $node_data = $tree->getNodeData($ref_id);
2167  $old_parent_data = $tree->getNodeData($old_parent);
2168  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
2169  $old_parent_data['obj_id']);
2170  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2171  $ilObjDataCache->lookupObjId($folder_ref_id));
2172  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2173  // END PATCH ChangeEvent: Record cut event.
2174  }
2175 
2176  // prevent multiple iterations for cut cmommand
2177  break;
2178  }
2179 
2180  ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
2181  } // END CUT
2182 
2183  // process LINK command
2184  if($command == 'link')
2185  {
2186  $linked_to_folders = array();
2187 
2188  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
2189  $rbac_log_active = ilRbacLog::isActive();
2190 
2191  foreach($_POST['nodes'] as $folder_ref_id)
2192  {
2193  $linked_to_folders[] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id));
2194 
2195  foreach($ref_ids as $ref_id)
2196  {
2197  // get node data
2198  $top_node = $tree->getNodeData($ref_id);
2199 
2200  // get subnodes of top nodes
2201  $subnodes[$ref_id] = $tree->getSubtree($top_node);
2202  }
2203 
2204  // now move all subtrees to new location
2205  foreach($subnodes as $key => $subnode)
2206  {
2207  // first paste top_node....
2208  $obj_data = ilObjectFactory::getInstanceByRefId($key);
2209  $new_ref_id = $obj_data->createReference();
2210  $obj_data->putInTree($folder_ref_id);
2211  $obj_data->setPermissions($folder_ref_id);
2212 
2213  // rbac log
2214  if($rbac_log_active)
2215  {
2216  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
2217  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
2218  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, $key);
2219  }
2220 
2221  // BEGIN ChangeEvent: Record link event.
2222  $node_data = $tree->getNodeData($new_ref_id);
2223  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2224  $ilObjDataCache->lookupObjId($folder_ref_id));
2225  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2226  // END PATCH ChangeEvent: Record link event.
2227  }
2228 
2229  $log->write(__METHOD__.', link finished');
2230  }
2231 
2232  ilUtil::sendSuccess(sprintf($this->lng->txt('mgs_objects_linked_to_the_following_folders'), implode(', ', $linked_to_folders)), true);
2233  } // END LINK
2234 
2235  // clear clipboard
2236  $this->clearObject();
2237 
2238  $this->ctrl->returnToParent($this);
2239  }
2240 
2242  {
2243  global $tree;
2244 
2245  // empty session on init
2246  $_SESSION['paste_linked_repexpand'] = array();
2247 
2248  // copy opend nodes from repository explorer
2249  $_SESSION['paste_linked_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2250 
2251  // open current position
2252  $path = $tree->getPathId((int)$_GET['ref_id']);
2253  foreach((array)$path as $node_id)
2254  {
2255  if(!in_array($node_id, $_SESSION['paste_linked_repexpand']))
2256  $_SESSION['paste_linked_repexpand'][] = $node_id;
2257  }
2258 
2259  return $this->showPasteTreeObject();
2260  }
2261 
2265  public function showPasteTreeObject()
2266  {
2267  global $ilTabs, $ilToolbar;
2268 
2269  $ilTabs->setTabActive('view_content');
2270 
2271  if(!in_array($_SESSION['clipboard']['cmd'], array('link', 'copy', 'cut')))
2272  {
2273  $message = __METHOD__.": Unknown action.";
2274  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2275  }
2276  $cmd = $_SESSION['clipboard']['cmd'];
2277 
2278  //
2279  include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
2280  $exp = new ilRepositorySelectorExplorerGUI($this, "showPasteTree");
2281  $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "fold"));
2282  if ($cmd == "link")
2283  {
2284  $exp->setSelectMode("nodes", true);
2285  }
2286  else
2287  {
2288  $exp->setSelectMode("nodes[]", false);
2289  }
2290  if ($exp->handleCommand())
2291  {
2292  return;
2293  }
2294  $output = $exp->getHTML();
2295 
2296  $txt_var = ($cmd == "copy")
2297  ? "copy"
2298  : "paste";
2299 
2300  // toolbars
2301  $t = new ilToolbarGUI();
2302  $t->setFormAction($this->ctrl->getFormAction($this, "performPasteIntoMultipleObjects"));
2303  $t->addFormButton($this->lng->txt($txt_var), "performPasteIntoMultipleObjects");
2304  $t->addSeparator();
2305  $t->addFormButton($this->lng->txt("obj_insert_into_clipboard"), "keepObjectsInClipboard");
2306  $t->addFormButton($this->lng->txt("cancel"), "cancelMoveLink");
2307  $t->setCloseFormTag(false);
2308  $t->setLeadingImage(ilUtil::getImagePath("arrow_upright.png"), " ");
2309  $output = $t->getHTML().$output;
2310  $t->setLeadingImage(ilUtil::getImagePath("arrow_downright.png"), " ");
2311  $t->setCloseFormTag(true);
2312  $t->setOpenFormTag(false);
2313  $output.= "<br />".$t->getHTML();
2314 
2315  $this->tpl->setContent($output);
2316  }
2317 
2318 
2319 
2320 /* public function showLinkIntoMultipleObjectsTreeObject()
2321  {
2322  global $ilTabs, $ilToolbar;
2323 
2324  $ilTabs->setTabActive('view_content');
2325 
2326  if(!in_array($_SESSION['clipboard']['cmd'], array('link')))
2327  {
2328  $message = __METHOD__.": cmd was not 'link'; may be a hack attempt!";
2329  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2330  }
2331 
2332  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
2333  "Services/Object");
2334 
2335  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2336  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_CHECK,
2337  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_linked_repexpand');
2338  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showLinkIntoMultipleObjectsTree'));
2339  $exp->setTargetGet('ref_id');
2340  $exp->setPostVar('nodes[]');
2341  $exp->highlightNode($_GET['ref_id']);
2342  is_array($_POST['nodes']) ? $exp->setCheckedItems((array)$_POST['nodes']) : $exp->setCheckedItems(array());
2343 
2344  if($_GET['paste_linked_repexpand'] == '')
2345  {
2346  $expanded = $this->tree->readRootId();
2347  }
2348  else
2349  {
2350  $expanded = $_GET['paste_linked_repexpand'];
2351  }
2352 
2353  $this->tpl->setVariable('FORM_TARGET', '_top');
2354  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2355 
2356  $exp->setExpand($expanded);
2357  // build html-output
2358  $exp->setOutput(0);
2359  $output = $exp->getOutput();
2360 
2361  $this->tpl->setVariable('OBJECT_TREE', $output);
2362 
2363  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2364  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
2365 
2366  $ilToolbar->addButton($this->lng->txt('cancel'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2367  }*/
2368 
2373  public function cancelMoveLinkObject()
2374  {
2375  unset($_SESSION['clipboard']);
2376  $GLOBALS['ilCtrl']->returnToParent($this);
2377  }
2378 
2383  {
2384  ilUtil::sendSuccess($this->lng->txt("obj_inserted_clipboard"), true);
2385  $GLOBALS['ilCtrl']->returnToParent($this);
2386  }
2387 
2388 
2390  {
2391  global $tree;
2392 
2393  // empty session on init
2394  $_SESSION['paste_copy_repexpand'] = array();
2395 
2396  // copy opend nodes from repository explorer
2397  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2398 
2399  // open current position
2400  $path = $tree->getPathId((int)$_GET['ref_id']);
2401  foreach((array)$path as $node_id)
2402  {
2403  if(!in_array($node_id, $_SESSION['paste_copy_repexpand']))
2404  $_SESSION['paste_copy_repexpand'][] = $node_id;
2405  }
2406 
2407  return $this->showPasteTreeObject();
2408  }
2409 
2410  /*public function showCopyIntoMultipleObjectsTreeObject()
2411  {
2412  global $ilTabs, $ilToolbar;
2413 
2414  $ilTabs->setTabActive('view_content');
2415 
2416  if(!in_array($_SESSION['clipboard']['cmd'], array('copy')))
2417  {
2418  $message = __METHOD__.": cmd was not 'copy'; may be a hack attempt!";
2419  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2420  }
2421 
2422  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html', "Services/Object");
2423 
2424  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2425  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_CHECK,
2426  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_copy_repexpand');
2427  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showCopyIntoMultipleObjectsTree'));
2428  $exp->setTargetGet('ref_id');
2429  $exp->setPostVar('nodes[]');
2430  $exp->highlightNode($_GET['ref_id']);
2431  is_array($_POST['nodes']) ? $exp->setCheckedItems((array)$_POST['nodes']) : $exp->setCheckedItems(array());
2432 
2433  if($_GET['paste_copy_repexpand'] == '')
2434  {
2435  $expanded = $this->tree->readRootId();
2436  }
2437  else
2438  {
2439  $expanded = $_GET['paste_copy_repexpand'];
2440  }
2441 
2442  $this->tpl->setVariable('FORM_TARGET', '_top');
2443  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2444 
2445  $exp->setExpand($expanded);
2446  // build html-output
2447  $exp->setOutput(0);
2448  $output = $exp->getOutput();
2449 
2450  $this->tpl->setVariable('OBJECT_TREE', $output);
2451 
2452  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2453  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('copy'));
2454 
2455  $ilToolbar->addButton($this->lng->txt('cancel'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2456  }*/
2457 
2459  {
2460  global $tree;
2461 
2462  // empty session on init
2463  $_SESSION['paste_cut_repexpand'] = array();
2464 
2465  // copy opend nodes from repository explorer
2466  $_SESSION['paste_cut_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2467 
2468  // open current position
2469  $path = $tree->getPathId((int)$_GET['ref_id']);
2470  foreach((array)$path as $node_id)
2471  {
2472  if(!in_array($node_id, $_SESSION['paste_cut_repexpand']))
2473  $_SESSION['paste_cut_repexpand'][] = $node_id;
2474  }
2475 
2476  return $this->showPasteTreeObject();
2477  }
2478 
2479  /*public function showMoveIntoObjectTreeObject()
2480  {
2481  global $ilTabs, $ilToolbar;
2482 
2483  $ilTabs->setTabActive('view_content');
2484 
2485  if(!in_array($_SESSION['clipboard']['cmd'], array('cut')))
2486  {
2487  $message = __METHOD__.": cmd was not 'cut'; may be a hack attempt!";
2488  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2489  }
2490 
2491  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
2492  "Services/Object");
2493 
2494  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2495  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_RADIO,
2496  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_cut_repexpand');
2497  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showMoveIntoObjectTree'));
2498  $exp->setTargetGet('ref_id');
2499  $exp->setPostVar('node');
2500  $exp->setCheckedItems(array((int)$_POST['node']));
2501  $exp->highlightNode($_GET['ref_id']);
2502 
2503  if($_GET['paste_cut_repexpand'] == '')
2504  {
2505  $expanded = $this->tree->readRootId();
2506  }
2507  else
2508  {
2509  $expanded = $_GET['paste_cut_repexpand'];
2510  }
2511 
2512  $this->tpl->setVariable('FORM_TARGET', '_top');
2513  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2514 
2515  $exp->setExpand($expanded);
2516  // build html-output
2517  $exp->setOutput(0);
2518  $output = $exp->getOutput();
2519 
2520  $this->tpl->setVariable('OBJECT_TREE', $output);
2521 
2522  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2523  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
2524 
2525  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2526  }*/
2527 
2534  function pasteObject()
2535  {
2536  global $rbacsystem, $rbacadmin, $rbacreview, $log,$tree;
2537  global $ilUser, $lng, $ilCtrl;
2538 
2539  // BEGIN ChangeEvent: Record paste event.
2540  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2541  // END ChangeEvent: Record paste event.
2542 
2543 //var_dump($_SESSION["clipboard"]);exit;
2544  if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
2545  {
2546  $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
2547  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
2548  }
2549 
2550  // this loop does all checks
2551  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2552  {
2553  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
2554 
2555  // CHECK ACCESS
2556  if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
2557  {
2558  $no_paste[] = $ref_id;
2559  $no_paste_titles[] = $obj_data->getTitle();
2560  }
2561 
2562  // CHECK IF REFERENCE ALREADY EXISTS
2563  if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
2564  {
2565  $exists[] = $ref_id;
2566  break;
2567  }
2568 
2569  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
2570  if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
2571  {
2572  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2573  }
2574 
2575  if ($ref_id == $this->object->getRefId())
2576  {
2577  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2578  }
2579 
2580  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
2581  $obj_type = $obj_data->getType();
2582 
2583  if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
2584  {
2585  $not_allowed_subobject[] = $obj_data->getType();
2586  }
2587  }
2588 
2590  // process checking results
2591  // BEGIN WebDAV: Copying an object into the same container is allowed
2592  if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy")
2593  // END WebDAV: Copying an object into the same container is allowed
2594  {
2595  $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
2596  }
2597 
2598  if (count($is_child))
2599  {
2600  $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
2601  $this->ilias->error_obj->MESSAGE);
2602  }
2603 
2604  if (count($not_allowed_subobject))
2605  {
2606  $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
2607  $this->ilias->error_obj->MESSAGE);
2608  }
2609 
2610  if (count($no_paste))
2611  {
2612  $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
2613  implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
2614  }
2615 
2616  // log pasteObject call
2617  $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
2618 
2620  // everything ok: now paste the objects to new location
2621 
2622  // to prevent multiple actions via back/reload button
2623  $ref_ids = $_SESSION["clipboard"]["ref_ids"];
2624  unset($_SESSION["clipboard"]["ref_ids"]);
2625 
2626  // BEGIN WebDAV: Support a copy command in the repository
2627  // process COPY command
2628  if ($_SESSION["clipboard"]["cmd"] == "copy")
2629  {
2630  unset($_SESSION["clipboard"]["cmd"]);
2631 
2632  // new implementation, redirects to ilObjectCopyGUI
2633  if (count($ref_ids) == 1)
2634  {
2635  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2636  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $ref_ids[0]);
2637  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2638  }
2639  else
2640  {
2641  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2642  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($ref_ids, "_"));
2643  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2644  }
2645 
2646 
2647 
2648  /* old implementation
2649 
2650  foreach($ref_ids as $ref_id)
2651  {
2652  $revIdMapping = array();
2653 
2654  $oldNode_data = $tree->getNodeData($ref_id);
2655  if ($oldNode_data['parent'] == $this->object->getRefId())
2656  {
2657  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2658  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
2659  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
2660  }
2661  else
2662  {
2663  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
2664  }
2665 
2666  // BEGIN ChangeEvent: Record copy event.
2667  $old_parent_data = $tree->getParentNodeData($ref_id);
2668  $newNode_data = $tree->getNodeData($newRef);
2669  ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
2670  $oldNode_data['obj_id'], $ilUser->getId());
2671  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
2672  $this->object->getId());
2673  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2674  // END ChangeEvent: Record copy event.
2675  }*/
2676 
2677  $log->write("ilObjectGUI::pasteObject(), copy finished");
2678  }
2679  // END WebDAV: Support a Copy command in the repository
2680 
2681  // process CUT command
2682  if ($_SESSION["clipboard"]["cmd"] == "cut")
2683  {
2684 
2685  foreach($ref_ids as $ref_id)
2686  {
2687  // Store old parent
2688  $old_parent = $tree->getParentId($ref_id);
2689  $this->tree->moveTree($ref_id,$this->object->getRefId());
2690  $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
2691 
2692  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
2694 
2695  // BEGIN ChangeEvent: Record cut event.
2696  $node_data = $tree->getNodeData($ref_id);
2697  $old_parent_data = $tree->getNodeData($old_parent);
2698  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
2699  $old_parent_data['obj_id']);
2700  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2701  $this->object->getId());
2702  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2703  // END PATCH ChangeEvent: Record cut event.
2704  }
2705  } // END CUT
2706 
2707  // process LINK command
2708  if ($_SESSION["clipboard"]["cmd"] == "link")
2709  {
2710  foreach ($ref_ids as $ref_id)
2711  {
2712  // get node data
2713  $top_node = $this->tree->getNodeData($ref_id);
2714 
2715  // get subnodes of top nodes
2716  $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
2717  }
2718 
2719  // now move all subtrees to new location
2720  foreach ($subnodes as $key => $subnode)
2721  {
2722  // first paste top_node....
2723  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
2724  $new_ref_id = $obj_data->createReference();
2725  $obj_data->putInTree($_GET["ref_id"]);
2726  $obj_data->setPermissions($_GET["ref_id"]);
2727 
2728  // BEGIN ChangeEvent: Record link event.
2729  $node_data = $tree->getNodeData($new_ref_id);
2730  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2731  $this->object->getId());
2732  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2733  // END PATCH ChangeEvent: Record link event.
2734  }
2735 
2736  $log->write("ilObjectGUI::pasteObject(), link finished");
2737 
2738  // inform other objects in hierarchy about link operation
2739  //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
2740  } // END LINK
2741 
2742  // save cmd for correct message output after clearing the clipboard
2743  $last_cmd = $_SESSION["clipboard"]["cmd"];
2744 
2745 
2746  // clear clipboard
2747  $this->clearObject();
2748 
2749  if ($last_cmd == "cut")
2750  {
2751  ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"),true);
2752  }
2753  // BEGIN WebDAV: Support a copy command in repository
2754  else if ($last_cmd == "copy")
2755  {
2756  ilUtil::sendSuccess($this->lng->txt("msg_cloned"),true);
2757  }
2758  else if ($last_cmd == 'link')
2759  // END WebDAV: Support copy command in repository
2760  {
2761  ilUtil::sendSuccess($this->lng->txt("msg_linked"),true);
2762  }
2763 
2764  $this->ctrl->returnToParent($this);
2765 
2766  } // END PASTE
2767 
2768 
2769  // BEGIN WebDAV: Support a copy command in repository
2770 
2778  // stefan.born@phzh.ch (01.07.2013):
2779  // UNCOMMENTED DUE NEW copyObject FUNCTION AND BECAUSE IT SEEMS THIS FUNCTION IS NOT USED ANYWHERE
2780  /*function copyObject()
2781  {
2782  global $ilAccess,$ilObjDefinition;
2783 
2784  if(!$ilAccess->checkAccess('copy','',$_GET['item_ref_id']))
2785  {
2786  $title = ilObject::_lookupTitle(ilObject::_lookupObjId($_GET['item_ref_id']));
2787 
2788  ilUtil::sendFailure($this->lng->txt('msg_no_perm_copy').' '.$title,true);
2789  $this->ctrl->returnToParent($this);
2790  }
2791 
2792  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2793  $_SESSION["clipboard"]["cmd"] = 'copy';
2794 
2795  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2796 
2797  // THIS FUNCTION DOES NOT EXIST!
2798  return $this->initAndDisplayCopyIntoObjectObject();
2799 
2800 
2801 
2802 
2803 
2804 
2805  // FOR ALL OBJECTS THAT SHOULD BE COPIED
2806  foreach ($_POST["id"] as $ref_id)
2807  {
2808  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
2809  $node_data = $this->tree->getNodeData($ref_id);
2810  $subtree_nodes = $this->tree->getSubTree($node_data);
2811 
2812  $all_node_data[] = $node_data;
2813  $all_subtree_nodes[] = $subtree_nodes;
2814 
2815  // CHECK VIEW, READ AND COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
2816  foreach ($subtree_nodes as $node)
2817  {
2818  if($node['type'] == 'rolf')
2819  {
2820  continue;
2821  }
2822 
2823  if (!$rbacsystem->checkAccess('visible,read,copy',$node["ref_id"]))
2824  {
2825  $no_copy[] = $node["ref_id"];
2826  }
2827  }
2828  }
2829  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'view,read'
2830  if (count($no_copy))
2831  {
2832  $this->ilias->raiseError($this->lng->txt("msg_no_perm_copy")." ".implode(',',$this->getTitlesByRefId($no_copy)),
2833  $this->ilias->error_obj->MESSAGE);
2834  }
2835  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2836  $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
2837  ? $_GET["cmd"]
2838  : key($_POST["cmd"]);
2839  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
2840 
2841  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2842 
2843  $this->ctrl->returnToParent($this);
2844 
2845  } // END COPY
2846  */
2847  // BEGIN WebDAV: Support copy command in repository
2848 
2849 
2853  function clipboardObject()
2854  {
2855  global $ilErr, $ilLog, $ilTabs, $tpl, $ilToolbar, $ilCtrl, $lng;
2856 
2857  $ilTabs->activateTab("clipboard");
2858 
2859  // function should not be called if clipboard is empty
2860  if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
2861  {
2862  $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
2863  $ilLog->write($message,$ilLog->FATAL);
2864  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
2865  }
2866 
2867  $data = array();
2868  foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2869  {
2870  if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
2871  {
2872  continue;
2873  }
2874 
2875  $data[] = array(
2876  "type" => $tmp_obj->getType(),
2877  "type_txt" => $this->lng->txt("obj_".$tmp_obj->getType()),
2878  "title" => $tmp_obj->getTitle(),
2879  "cmd" => ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]),
2880  "ref_id" => $ref_id,
2881  "obj_id" => $tmp_obj->getId()
2882  );
2883 
2884  unset($tmp_obj);
2885  }
2886 
2887  include_once("./Services/Object/classes/class.ilObjClipboardTableGUI.php");
2888  $tab = new ilObjClipboardTableGUI($this, "clipboard");
2889  $tab->setData($data);
2890  $tpl->setContent($tab->getHTML());
2891 
2892  if (count($data) > 0)
2893  {
2894  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
2895  $ilToolbar->addFormButton($lng->txt("insert_object_here"),
2896  "paste");
2897  $ilToolbar->addFormButton($lng->txt("clear_clipboard"),
2898  "clear");
2899  }
2900 
2901  return true;
2902  }
2903 
2904 
2909  function showCustomIconsEditing($a_input_colspan = 1, ilPropertyFormGUI $a_form = null, $a_as_section = true)
2910  {
2911  if ($this->ilias->getSetting("custom_icons"))
2912  {
2913  if(!$a_form)
2914  {
2915  $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
2916  "tpl.container_icon_settings.html", "Services/Container");
2917 
2918  if (($big_icon = $this->object->getBigIconPath()) != "")
2919  {
2920  $this->tpl->setCurrentBlock("big_icon");
2921  $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
2922  $this->tpl->parseCurrentBlock();
2923  }
2924  if ($this->object->getType() != "root")
2925  {
2926  if (($small_icon = $this->object->getSmallIconPath()) != "")
2927  {
2928  $this->tpl->setCurrentBlock("small_icon");
2929  $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
2930  $this->tpl->parseCurrentBlock();
2931  }
2932  $this->tpl->setCurrentBlock("small_icon_row");
2933  $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("standard_icon"));
2934  $this->tpl->setVariable("SMALL_SIZE", "(".
2935  $this->ilias->getSetting("custom_icon_small_width")."x".
2936  $this->ilias->getSetting("custom_icon_small_height").")");
2937  $this->tpl->setVariable("TXT_REMOVE_S", $this->lng->txt("remove"));
2938  $this->tpl->parseCurrentBlock();
2939  }
2940  if (($tiny_icon = $this->object->getTinyIconPath()) != "")
2941  {
2942  $this->tpl->setCurrentBlock("tiny_icon");
2943  $this->tpl->setVariable("SRC_TINY_ICON", $tiny_icon);
2944  $this->tpl->parseCurrentBlock();
2945  }
2946  $this->tpl->setCurrentBlock("container_icon_settings");
2947  $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
2948  $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
2949  $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
2950  $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
2951  $this->tpl->setVariable("TINY_ICON", $this->lng->txt("tiny_icon"));
2952  $this->tpl->setVariable("BIG_SIZE", "(".
2953  $this->ilias->getSetting("custom_icon_big_width")."x".
2954  $this->ilias->getSetting("custom_icon_big_height").")");
2955  $this->tpl->setVariable("TINY_SIZE", "(".
2956  $this->ilias->getSetting("custom_icon_tiny_width")."x".
2957  $this->ilias->getSetting("custom_icon_tiny_height").")");
2958  $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
2959  $this->tpl->parseCurrentBlock();
2960  }
2961  else
2962  {
2963  $big_icon = $this->object->getBigIconPath();
2964  $small_icon = $this->object->getSmallIconPath();
2965  $tiny_icon = $this->object->getTinyIconPath();
2966 
2967  if($a_as_section)
2968  {
2969  $title = new ilFormSectionHeaderGUI();
2970  $title->setTitle($this->lng->txt("icon_settings"));
2971  }
2972  else
2973  {
2974  $title = new ilCustomInputGUI($this->lng->txt("icon_settings"), "");
2975  }
2976  $a_form->addItem($title);
2977 
2978  // big
2979  $caption = $this->lng->txt("big_icon")." (".
2980  $this->ilias->getSetting("custom_icon_big_width")."x".
2981  $this->ilias->getSetting("custom_icon_big_height").")";
2982  $icon = new ilImageFileInputGUI($caption, "cont_big_icon");
2983  $icon->setImage($big_icon);
2984  if($a_as_section)
2985  {
2986  $a_form->addItem($icon);
2987  }
2988  else
2989  {
2990  $title->addSubItem($icon);
2991  }
2992 
2993  // small/standard
2994  if ($this->object->getType() != "root")
2995  {
2996  $caption = $this->lng->txt("standard_icon")." (".
2997  $this->ilias->getSetting("custom_icon_small_width")."x".
2998  $this->ilias->getSetting("custom_icon_small_height").")";
2999  $icon = new ilImageFileInputGUI($caption, "cont_small_icon");
3000  $icon->setImage($small_icon);
3001  if($a_as_section)
3002  {
3003  $a_form->addItem($icon);
3004  }
3005  else
3006  {
3007  $title->addSubItem($icon);
3008  }
3009  }
3010 
3011  // tiny
3012  $caption = $this->lng->txt("tiny_icon")." (".
3013  $this->ilias->getSetting("custom_icon_tiny_width")."x".
3014  $this->ilias->getSetting("custom_icon_tiny_height").")";
3015  $icon = new ilImageFileInputGUI($caption, "cont_tiny_icon");
3016  $icon->setImage($tiny_icon);
3017  if($a_as_section)
3018  {
3019  $a_form->addItem($icon);
3020  }
3021  else
3022  {
3023  $title->addSubItem($icon);
3024  }
3025  }
3026  }
3027  }
3028 
3030  {
3031  global $ilAccess;
3032 
3033  // #10081
3034  if($_SESSION["il_cont_admin_panel"] &&
3035  $this->object->getRefId() &&
3036  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
3037  {
3038  return false;
3039  }
3040 
3041  return $_SESSION["il_cont_admin_panel"];
3042  }
3043 
3047  function setColumnSettings($column_gui)
3048  {
3049  global $ilAccess;
3050  parent::setColumnSettings($column_gui);
3051 
3052  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
3053  $this->isActiveAdministrationPanel() &&
3054  $this->allowBlocksMoving())
3055  {
3056  $column_gui->setEnableMovement(true);
3057  }
3058 
3059  $column_gui->setRepositoryItems(
3060  $this->object->getSubItems($this->isActiveAdministrationPanel(), true));
3061 
3062  //if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
3063  // && $this->allowBlocksConfigure())
3064  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
3065  {
3066  $column_gui->setBlockProperty("news", "settings", true);
3067  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
3068  $column_gui->setBlockProperty("news", "default_visibility_option", true);
3069  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
3070  }
3071 
3072  if ($this->isActiveAdministrationPanel())
3073  {
3074  $column_gui->setAdminCommands(true);
3075  }
3076  }
3077 
3082  {
3083  true;
3084  }
3085 
3090  {
3091  true;
3092  }
3093 
3101  public function cloneWizardPageTreeObject()
3102  {
3103  $this->cloneWizardPageObject(true);
3104  }
3105 
3113  public function cloneWizardPageListObject()
3114  {
3115  $this->cloneWizardPageObject(false);
3116  }
3117 
3124  public function cloneWizardPageObject($a_tree_view = true)
3125  {
3126  include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
3127 
3128  global $ilObjDataCache,$tree;
3129 
3130  if(!$_REQUEST['clone_source'])
3131  {
3132  ilUtil::sendFailure($this->lng->txt('select_one'));
3133  if(isset($_SESSION['wizard_search_title']))
3134  {
3135  $this->searchCloneSourceObject();
3136  }
3137  else
3138  {
3139  $this->createObject();
3140  }
3141  return false;
3142  }
3143  $source_id = $_REQUEST['clone_source'];
3144  $new_type = $_REQUEST['new_type'];
3145  $this->ctrl->setParameter($this,'clone_source',(int) $_REQUEST['clone_source']);
3146  $this->ctrl->setParameter($this,'new_type',$new_type);
3147 
3148 
3149  // Generell JavaScript
3150  $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
3151  $this->tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
3152 
3153 
3154  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.container_wizard_page.html',
3155  "Services/Container");
3156  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
3157  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$new_type.'.png'));
3158  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$new_type));
3159  $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt($new_type.'_wizard_page'));
3160  $this->tpl->setVariable('INFO_DUPLICATE',$this->lng->txt($new_type.'_copy_threads_info'));
3161  $this->tpl->setVariable('BTN_COPY',$this->lng->txt('obj_'.$new_type.'_duplicate'));
3162  $this->tpl->setVariable('BTN_BACK',$this->lng->txt('btn_back'));
3163  if(isset($_SESSION['wizard_search_title']))
3164  {
3165  $this->tpl->setVariable('CMD_BACK','searchCloneSource');
3166  }
3167  else
3168  {
3169  $this->tpl->setVariable('CMD_BACK','create');
3170  }
3171 
3172  $this->tpl->setVariable('BTN_TREE',$this->lng->txt('treeview'));
3173  $this->tpl->setVariable('BTN_LIST',$this->lng->txt('flatview'));
3174 
3175  // Fill item rows
3176  // tree view
3177  if($a_tree_view)
3178  {
3179  $first = true;
3180  $has_items = false;
3181  foreach($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id),true) as $node)
3182  {
3183  if($first == true)
3184  {
3185  $first = false;
3186  continue;
3187  }
3188 
3189  if($node['type'] == 'rolf')
3190  {
3191  continue;
3192  }
3193 
3194  $has_items = true;
3195 
3196  for($i = $source_node['depth'];$i < $node['depth']; $i++)
3197  {
3198  $this->tpl->touchBlock('padding');
3199  $this->tpl->touchBlock('end_padding');
3200  }
3201  // fill options
3202  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$node['type']);
3203  $copy_wizard_page->fillTreeSelection($node['ref_id'],$node['type'],$node['depth']);
3204 
3205  $this->tpl->setCurrentBlock('tree_row');
3206  $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'_s.png'));
3207  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$node['type']));
3208  $this->tpl->setVariable('TREE_TITLE',$node['title']);
3209  $this->tpl->parseCurrentBlock();
3210  }
3211  if(!$has_items)
3212  {
3213  $this->tpl->setCurrentBlock('no_content');
3214  $this->tpl->setVariable('TXT_NO_CONTENT',$this->lng->txt('container_no_items'));
3215  $this->tpl->parseCurrentBlock();
3216  }
3217  else
3218  {
3219  $this->tpl->setCurrentBlock('tree_footer');
3220  $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
3221  $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
3222  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
3223  $this->tpl->parseCurrentBlock();
3224 
3225  }
3226  }
3227  else
3228  {
3229  foreach($tree->getSubTreeTypes($source_id,array('rolf','crs')) as $type)
3230  {
3231  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$type);
3232  if(strlen($html = $copy_wizard_page->getWizardPageBlockHTML()))
3233  {
3234  $this->tpl->setCurrentBlock('obj_row');
3235  $this->tpl->setVariable('ITEM_BLOCK',$html);
3236  $this->tpl->parseCurrentBlock();
3237  }
3238  }
3239  }
3240  }
3241 
3249  public function cloneAllObject()
3250  {
3251  global $ilLog, $ilCtrl;
3252 
3253  include_once('./Services/Link/classes/class.ilLink.php');
3254  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
3255 
3256  global $ilAccess,$ilErr,$rbacsystem,$tree,$ilUser;
3257 
3258  $new_type = $_REQUEST['new_type'];
3259  $ref_id = (int) $_GET['ref_id'];
3260  $clone_source = (int) $_REQUEST['clone_source'];
3261 
3262  if(!$rbacsystem->checkAccess('create', $ref_id,$new_type))
3263  {
3264  $ilErr->raiseError($this->lng->txt('permission_denied'));
3265  }
3266  if(!$clone_source)
3267  {
3268  ilUtil::sendFailure($this->lng->txt('select_one'));
3269  $this->createObject();
3270  return false;
3271  }
3272  if(!$ilAccess->checkAccess('write','', $clone_source,$new_type))
3273  {
3274  $ilErr->raiseError($this->lng->txt('permission_denied'));
3275  }
3276 
3277  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
3278  $orig = ilObjectFactory::getInstanceByRefId($clone_source);
3279  $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
3280 
3281  // Check if copy is in progress
3282  if ($result == $ref_id)
3283  {
3284  ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"),true);
3285  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
3286  $ilCtrl->redirectByClass("ilrepositorygui", "");
3287  }
3288  else
3289  {
3290  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
3291  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $result);
3292  $ilCtrl->redirectByClass("ilrepositorygui", "");
3293  }
3294  }
3295 
3296 
3304  public function saveSortingObject()
3305  {
3306  include_once('Services/Container/classes/class.ilContainerSorting.php');
3307  $sorting = ilContainerSorting::_getInstance($this->object->getId());
3308 
3309  // Allow comma
3310  $positions = str_replace(',','.',$_POST['position']);
3311 
3312  $sorting->savePost($positions);
3313  ilUtil::sendSuccess($this->lng->txt('cntr_saved_sorting'), true);
3314  $this->ctrl->redirect($this, "editOrder");
3315  }
3316 
3317  // BEGIN WebDAV: Support a copy command in the repository
3328  function cloneNodes($srcRef,$dstRef,&$mapping, $newName=null)
3329  {
3330  global $tree;
3331  global $ilias;
3332 
3333  // clone the source node
3334  $srcObj =& $ilias->obj_factory->getInstanceByRefId($srcRef);
3335  error_log(__METHOD__.' cloning srcRef='.$srcRef.' dstRef='.$dstRef.'...');
3336  $newRef = $srcObj->cloneObject($dstRef)->getRefId();
3337  error_log(__METHOD__.' ...cloning... newRef='.$newRef.'...');
3338 
3339  // We must immediately apply a new name to the object, to
3340  // prevent confusion of WebDAV clients about having two objects with identical
3341  // name in the repository.
3342  if (! is_null($newName))
3343  {
3344  $newObj =& $ilias->obj_factory->getInstanceByRefId($newRef);
3345  $newObj->setTitle($newName);
3346  $newObj->update();
3347  unset($newObj);
3348  }
3349  unset($srcObj);
3350  $mapping[$newRef] = $srcRef;
3351 
3352  // clone all children of the source node
3353  $children = $tree->getChilds($srcRef);
3354  foreach ($tree->getChilds($srcRef) as $child)
3355  {
3356  // Don't clone role folders, because it does not make sense to clone local roles
3357  // FIXME - Maybe it does make sense (?)
3358  if ($child["type"] != 'rolf')
3359  {
3360  $this->cloneNodes($child["ref_id"],$newRef,$mapping);
3361  }
3362  else
3363  {
3364  if (count($rolf = $tree->getChildsByType($newRef,"rolf")))
3365  {
3366  $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
3367  }
3368  }
3369  }
3370  error_log(__METHOD__.' ...cloned srcRef='.$srcRef.' dstRef='.$dstRef.' newRef='.$newRef);
3371  return $newRef;
3372  }
3373  // END PATCH WebDAV: Support a copy command in the repository
3374 
3378  function modifyItemGUI(&$a_item_list_gui, $a_item_data, $a_show_path)
3379  {
3380  global $lng;
3381 
3382  if($a_show_path)
3383  {
3384  $a_item_list_gui->addCustomProperty($lng->txt('path'),
3385  ilContainer::buildPath($a_item_data['ref_id'], $this->object->getRefId()),
3386  false, true);
3387  }
3388  }
3389 
3393  static function _buildPath($a_ref_id, $a_course_ref_id)
3394  {
3395  global $tree;
3396 
3397  $path_arr = $tree->getPathFull($a_ref_id, $a_course_ref_id);
3398  $counter = 0;
3399  foreach($path_arr as $data)
3400  {
3401  if($counter++)
3402  {
3403  $path .= " > ";
3404  }
3405  $path .= $data['title'];
3406  }
3407 
3408  return $path;
3409  }
3410 
3411  //
3412  // Style editing
3413  //
3414 
3419  {
3420  global $ilTabs, $tpl;
3421 
3422  $this->checkPermission("write");
3423 
3424  $this->initStylePropertiesForm();
3425  $tpl->setContent($this->form->getHTML());
3426 
3427  $ilTabs->activateTab("obj_sty");
3428  }
3429 
3434  {
3435  global $ilCtrl, $lng, $ilTabs, $ilSetting, $tpl;
3436 
3437  $tpl->setTreeFlatIcon("", "");
3438  $ilTabs->clearTargets();
3439  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
3440  "xhtml_page");
3441  if ($xpage_id > 0)
3442  {
3443  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
3444  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
3445  }
3446  else
3447  {
3448  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
3449  $this->object->getRefId(), "_top");
3450  }
3451 
3452  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
3453  $page_gui = new ilContainerPageGUI($this->object->getId());
3454  $style_id = $this->object->getStyleSheetId();
3455  if (ilObject::_lookupType($style_id) == "sty")
3456  {
3457  $page_gui->setStyleId($style_id);
3458  }
3459  else
3460  {
3461  $style_id = 0;
3462  }
3463  $page_gui->setTabHook($this, "addPageTabs");
3464 // $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg_b.png"));
3465 // $tpl->setTitle($this->lng->txt("page").": ".$this->obj->getTitle());
3466  $ilCtrl->getHTML($page_gui);
3467  $ilTabs->setTabActive("obj_sty");
3468 
3469  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3470  $lng->loadLanguageModule("style");
3471 
3472  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3473  $this->form = new ilPropertyFormGUI();
3474 
3475  $fixed_style = $ilSetting->get("fixed_content_style_id");
3476 // $style_id = $this->object->getStyleSheetId();
3477 
3478  if ($fixed_style > 0)
3479  {
3480  $st = new ilNonEditableValueGUI($lng->txt("wiki_current_style"));
3481  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
3482  $this->lng->txt("global_fixed").")");
3483  $this->form->addItem($st);
3484  }
3485  else
3486  {
3487  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
3488  $_GET["ref_id"]);
3489 
3490  $st_styles[0] = $this->lng->txt("default");
3491  ksort($st_styles);
3492 
3493  if ($style_id > 0)
3494  {
3495  // individual style
3496  if (!ilObjStyleSheet::_lookupStandard($style_id))
3497  {
3498  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
3499  $st->setValue(ilObject::_lookupTitle($style_id));
3500  $this->form->addItem($st);
3501 
3502 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
3503 
3504  // delete command
3505  $this->form->addCommandButton("editStyle",
3506  $lng->txt("style_edit_style"));
3507  $this->form->addCommandButton("deleteStyle",
3508  $lng->txt("style_delete_style"));
3509 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
3510  }
3511  }
3512 
3513  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
3514  {
3515  $style_sel = ilUtil::formSelect ($style_id, "style_id",
3516  $st_styles, false, true);
3517  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
3518  $style_sel->setOptions($st_styles);
3519  $style_sel->setValue($style_id);
3520  $this->form->addItem($style_sel);
3521 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
3522  $this->form->addCommandButton("saveStyleSettings",
3523  $lng->txt("save"));
3524  $this->form->addCommandButton("createStyle",
3525  $lng->txt("sty_create_ind_style"));
3526  }
3527  }
3528  $this->form->setTitle($lng->txt("obj_sty"));
3529  $this->form->setFormAction($ilCtrl->getFormAction($this));
3530  }
3531 
3536  {
3537  global $ilCtrl;
3538 
3539  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
3540  }
3541 
3545  function editStyleObject()
3546  {
3547  global $ilCtrl;
3548 
3549  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
3550  }
3551 
3556  {
3557  global $ilCtrl;
3558 
3559  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
3560  }
3561 
3566  {
3567  global $ilSetting;
3568 
3569  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3570  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3571  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3572  || $this->object->getStyleSheetId() == 0))
3573  {
3574  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
3575  $this->object->update();
3576  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3577  }
3578  $this->ctrl->redirect($this, "editStyleProperties");
3579  }
3580 
3585  {
3586  global $ilCtrl;
3587 
3588  $ref_id = $_GET["cmdrefid"];
3590  $type = ilObject::_lookupType($obj_id);
3591 
3592  // this should be done via container-object->getSubItem in the future
3593  $data = array("child" => $ref_id, "ref_id" => $ref_id, "obj_id" => $obj_id,
3594  "type" => $type);
3595  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
3596  $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($type);
3597  $item_list_gui->setContainerObject($this);
3598 
3599  $item_list_gui->enableComments(true);
3600  $item_list_gui->enableNotes(true);
3601  $item_list_gui->enableTags(true);
3602 
3603  $this->modifyItemGUI($item_list_gui, $data, false);
3604  $html = $item_list_gui->getListItemHTML($ref_id,
3605  $obj_id, "", "", true, true);
3606 
3607  // include plugin slot for async item list
3608  global $ilPluginAdmin;
3609  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
3610  foreach ($pl_names as $pl)
3611  {
3612  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
3613  $gui_class = $ui_plugin->getUIClassInstance();
3614  $resp = $gui_class->getHTML("Services/Container", "async_item_list", array("html" => $html));
3615  if ($resp["mode"] != ilUIHookPluginGUI::KEEP)
3616  {
3617  $html = $gui_class->modifyHTML($html, $resp);
3618  }
3619  }
3620 
3621  echo $html;
3622  exit;
3623  }
3624 
3629  protected function showPasswordInstructionObject($a_init = true)
3630  {
3631  global $tpl,$ilToolbar;
3632 
3633  if($a_init)
3634  {
3635  ilUtil::sendInfo($this->lng->txt('webdav_pwd_instruction'));
3636  $this->initFormPasswordInstruction();
3637  }
3638 
3639  include_once ('Services/WebDAV/classes/class.ilDAVServer.php');
3640  $davServer = ilDAVServer::getInstance();
3641  $ilToolbar->addButton(
3642  $this->lng->txt('mount_webfolder'),
3643  $davServer->getMountURI($this->object->getRefId()),
3644  '_blank',
3645  '',
3646  $davServer->getFolderURI($this->object->getRefId())
3647  );
3648 
3649  $tpl->setContent($this->form->getHTML());
3650  }
3651 
3656  protected function initFormPasswordInstruction()
3657  {
3658  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3659  $this->form = new ilPropertyFormGUI();
3660  $this->form->setFormAction($this->ctrl->getFormAction($this));
3661 
3662  // new password
3663  $ipass = new ilPasswordInputGUI($this->lng->txt("desired_password"), "new_password");
3664  $ipass->setRequired(true);
3665 
3666  $this->form->addItem($ipass);
3667  $this->form->addCommandButton("savePassword", $this->lng->txt("save"));
3668  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
3669 
3670  $this->form->setTitle($this->lng->txt("chg_ilias_and_webfolder_password"));
3671  $this->form->setFormAction($this->ctrl->getFormAction($this));
3672 
3673  return $this->form;
3674  }
3675 
3680  protected function savePasswordObject()
3681  {
3682  global $ilUser;
3683 
3684  $form = $this->initFormPasswordInstruction();
3685  if($form->checkInput())
3686  {
3687  $ilUser->resetPassword($this->form->getInput('new_password'),$this->form->getInput('new_password'));
3688  ilUtil::sendSuccess($this->lng->txt('webdav_pwd_instruction_success'),true);
3689  $this->showPasswordInstructionObject(false);
3690  return true;
3691  }
3692  $form->setValuesByPost();
3694  }
3695 
3703  {
3704  global $tpl;
3705 
3706  $html = null;
3707 
3708  $item_data = $this->object->getSubItems(false, false, (int) $_GET["child_ref_id"]);
3709  $container_view = $this->getContentGUI();
3710 
3711  // list item is session material (not part of "_all"-items - see below)
3712  include_once './Modules/Session/classes/class.ilEventItems.php';
3713  $event_items = ilEventItems::_getItemsOfContainer($this->object->getRefId());
3714  if(in_array((int)$_GET["child_ref_id"], $event_items))
3715  {
3716  include_once('./Services/Object/classes/class.ilObjectActivation.php');
3717  foreach ($this->object->items["sess"] as $id)
3718  {
3719  $items = ilObjectActivation::getItemsByEvent($id['obj_id']);
3720  foreach($items as $event_item)
3721  {
3722  if ($event_item["child"] == (int)$_GET["child_ref_id"])
3723  {
3724  // sessions
3725  if((int)$_GET["parent_ref_id"])
3726  {
3727  $event_item["parent"] = (int)$_GET["parent_ref_id"];
3728  }
3729  $html = $container_view->renderItem($event_item);
3730  }
3731  }
3732  }
3733  }
3734 
3735  // "normal" list item
3736  if(!$html)
3737  {
3738  foreach ($this->object->items["_all"] as $id)
3739  {
3740  if ($id["child"] == (int) $_GET["child_ref_id"])
3741  {
3742  $html = $container_view->renderItem($id);
3743  }
3744  }
3745  }
3746 
3747  if($html)
3748  {
3749  echo $html;
3750 
3751  // we need to add onload code manually (rating, comments, etc.)
3752  echo $tpl->getOnLoadCodeForAsynch();
3753  }
3754 
3755  exit;
3756  }
3757 
3758  // begin-patch fm
3765  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
3766  {
3767  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
3768 
3769  // begin-patch fm
3770  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
3771  if(ilFMSettings::getInstance()->isEnabled())
3772  {
3773  if($lg instanceof ilObjectListGUI)
3774  {
3775  $lg->addCustomCommand($this->ctrl->getLinkTarget($this,'fileManagerLaunch'), 'fm_start','_blank');
3776  }
3777  }
3778  // end-patch fm
3779  return $lg;
3780  }
3781 
3785  protected function fileManagerLaunchObject()
3786  {
3787  global $ilUser;
3788 
3789  $tpl = new ilTemplate('tpl.fm_launch_ws.html',false,false,'Services/WebServices/FileManager');
3790  $tpl->setVariable('JNLP_URL',ILIAS_HTTP_PATH.'/Services/WebServices/FileManager/lib/dist/FileManager.jnlp');
3791  $tpl->setVariable('SESSION_ID', $_COOKIE['PHPSESSID'].'::'.CLIENT_ID);
3792  $tpl->setVariable('UID',$ilUser->getId());
3793  $tpl->setVariable('REF_ID', $this->object->getRefId());
3794  $tpl->setVariable('WSDL_URI', ILIAS_HTTP_PATH.'/webservice/soap/server.php?wsdl');
3795  $tpl->setVariable('LOCAL_FRAME', ilFMSettings::getInstance()->isLocalFSEnabled() ? 1 : 0);
3796  $tpl->setVariable('REST_URI',ILIAS_HTTP_PATH.'/Services/WebServices/Rest/server.php');
3797  $tpl->setVariable('FILE_LOCKS',0);
3798  $tpl->setVariable('UPLOAD_FILESIZE', ilFMSettings::getInstance()->getMaxFileSize());
3799 
3800  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
3801  $header_top_title = ilObjSystemFolder::_getHeaderTitle();
3802  $tpl->setVariable('HEADER_TITLE',$header_top_title ? $header_top_title : '');
3803  echo $tpl->get();
3804  exit;
3805  }
3806  // begin-patch fm
3807 
3814  function showRepTree($a_initial_call = false)
3815  {
3816  global $tpl, $ilUser, $ilSetting, $ilCtrl;
3817 
3818  // set current repository view mode
3819  if (!empty($_GET["set_mode"]))
3820  {
3821  $_SESSION["il_rep_mode"] = $_GET["set_mode"];
3822  if ($ilUser->getId() != ANONYMOUS_USER_ID)
3823  {
3824  $ilUser->writePref("il_rep_mode", $_GET["set_mode"]);
3825  }
3826  }
3827 
3828  // get user setting
3829  if ($_SESSION["il_rep_mode"] == "")
3830  {
3831  if ($ilUser->getId() != ANONYMOUS_USER_ID)
3832  {
3833  $_SESSION["il_rep_mode"] = $ilUser->getPref("il_rep_mode");
3834  }
3835  }
3836 
3837  // if nothing set, get default view
3838  if ($_SESSION["il_rep_mode"] == "")
3839  {
3840  $_SESSION["il_rep_mode"] = $ilSetting->get("default_repository_view");
3841  }
3842 
3843  $mode = ($_SESSION["il_rep_mode"] != "")
3844  ? $_SESSION["il_rep_mode"]
3845  : "flat";
3846 
3847  if ($mode == "tree")
3848  {
3849  include_once("./Services/Repository/classes/class.ilRepositoryExplorerGUI.php");
3850  $exp = new ilRepositoryExplorerGUI($this, "showRepTree");
3851  if (!$exp->handleCommand())
3852  {
3853  $tpl->setLeftNavContent($exp->getHTML());
3854  }
3855  }
3856  }
3857 
3858 
3864  public function trashObject()
3865  {
3866  global $tpl;
3867 
3868  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3869  $ru = new ilRepUtilGUI($this);
3870  $ru->showTrashTable($_GET["ref_id"]);
3871  }
3872 
3878  public function removeFromSystemObject()
3879  {
3880  global $log, $ilAppEventHandler, $lng;
3881 
3882  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3883  $ru = new ilRepUtilGUI($this);
3884  $ru->removeObjectsFromSystem($_POST["trash_id"]);
3885  $this->ctrl->redirect($this, "trash");
3886  }
3887 
3891  public function undeleteObject()
3892  {
3893  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3894  $ru = new ilRepUtilGUI($this);
3895  $ru->restoreObjects($_GET["ref_id"], $_POST["trash_id"]);
3896  $this->ctrl->redirect($this, "trash");
3897  }
3898 
3903  {
3904  global $lng;
3905  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3906 
3907  if(!isset($_POST["trash_id"]))
3908  {
3909  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3910  $this->ctrl->redirect($this, "trash");
3911  }
3912 
3913  $ru = new ilRepUtilGUI($this);
3914  $ru->confirmRemoveFromSystemObject($_POST["trash_id"]);
3915  }
3916 }
3917 ?>