ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-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", "displayMedia")))
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.svg"));
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 = "<div style='background-color: white; padding:5px; margin-bottom: 30px;'>".$ret."</div>";
341 
342  //$ret =& $page_gui->executeCommand();
343  return $ret;
344  }
345 
349  function prepareOutput($a_show_subobjects = true)
350  {
351  if (parent::prepareOutput()) // return false in admin mode
352  {
353  if ($this->getCreationMode() != true && $a_show_subobjects)
354  {
355  // This method is called directly from ilContainerGUI::renderObject
356  #$this->showPossibleSubObjects();
357  $this->showTreeFlatIcon();
358 
359  // Member view
360  include_once './Services/Container/classes/class.ilMemberViewGUI.php';
361  ilMemberViewGUI::showMemberViewSwitch($this->object->getRefId());
362  }
363  }
364  }
365 
366  function showTreeFlatIcon()
367  {
368  global $tpl;
369 
370  // dont show icon, if role (permission gui->rolegui) is edited
371  if ($_GET["obj_id"] != "")
372  {
373  return;
374  }
375  // hide for member view
376  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
377  if(ilMemberViewSettings::getInstance()->isActive())
378  {
379  return;
380  }
381 
382  $mode = ($_SESSION["il_rep_mode"] == "flat")
383  ? "tree"
384  : "flat";
385  $link = "ilias.php?baseClass=ilRepositoryGUI&amp;cmd=frameset&amp;set_mode=".$mode."&amp;ref_id=".$this->object->getRefId();
386  $tpl->setTreeFlatIcon($link, $mode);
387  }
388 
393  {
394  global $ilias;
395 
396  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
397  {
398  $this->tpl->setTitle($this->object->getTitle());
399  $this->tpl->setDescription($this->object->getLongDescription());
400 
401  // set tile icon
402  $icon = ilObject::_getIcon($this->object->getId(), "big", $this->object->getType());
403  if ($ilias->getSetting("custom_icons") &&
404  in_array($this->object->getType(), array("cat","grp","crs", "root")))
405  {
406  require_once("./Services/Container/classes/class.ilContainer.php");
407  if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
408  {
409  $icon = $path;
410  }
411  }
412  $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
413 
414  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
415  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
416  $lgui->initItem($this->object->getRefId(), $this->object->getId());
417  $this->tpl->setAlertProperties($lgui->getAlertProperties());
418  }
419  }
420 
425  {
426  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
427  $gui = new ilObjectAddNewItemGUI($this->object->getRefId());
428  $gui->render();
429  }
430 
437  function getContentGUI()
438  {
439  switch ($this->object->getViewMode())
440  {
441  // all items in one block
443  include_once("./Services/Container/classes/class.ilContainerSimpleContentGUI.php");
444  $container_view = new ilContainerSimpleContentGUI($this);
445  break;
446 
448  include_once('./Services/Container/classes/class.ilContainerObjectiveGUI.php');
449  $container_view = new ilContainerObjectiveGUI($this);
450  break;
451 
452  // all items in one block
454  case IL_CRS_VIEW_TIMING: // not nice this workaround
455  include_once("./Services/Container/classes/class.ilContainerSessionsContentGUI.php");
456  $container_view = new ilContainerSessionsContentGUI($this);
457  break;
458 
459  // ILinc courses
461  include_once 'Services/Container/classes/class.ilContainerILincContentGUI.php';
462  $container_view = new ilContainerILincContentGUI($this);
463  break;
464 
465  // all items in one block
467  default:
468  include_once("./Services/Container/classes/class.ilContainerByTypeContentGUI.php");
469  $container_view = new ilContainerByTypeContentGUI($this);
470  break;
471  }
472 
473  return $container_view;
474  }
475 
476 
477 
481  function renderObject()
482  {
483  global $ilDB, $tpl, $ilTabs, $ilCtrl, $ilSetting;
484 
485  $container_view = $this->getContentGUI();
486 
487  $this->setContentSubTabs();
488  if ($this->isActiveAdministrationPanel())
489  {
490  $ilTabs->activateSubTab("manage");
491  }
492  else
493  {
494  $ilTabs->activateSubTab("view_content");
495  }
496 
497  $container_view->setOutput();
498 
499  $this->adminCommands = $container_view->adminCommands;
500 
501  // it is important not to show the subobjects/admin panel here, since
502  // we will create nested forms in case, e.g. a news/calendar item is added
503  if ($ilCtrl->getNextClass() != "ilcolumngui")
504  {
505  $this->showAdministrationPanel($tpl);
506  $this->showPossibleSubObjects();
507  }
508 
509  $this->showPermanentLink($tpl);
510 
511  // add tree updater javascript
512  if ((int) $_GET["ref_id"] > 1 && $ilSetting->get("rep_tree_synchronize"))
513  {
514  $ilCtrl->setParameter($this, "active_node", (int) $_GET["ref_id"]);
515  /*$tpl->addOnloadCode("
516  if (parent && parent.tree && parent.tree.updater)
517  {
518  parent.tree.updater('tree_div', '".
519  $ilCtrl->getLinkTarget($this, "showTree", "", true, false)
520  ."');
521  }");*/
522  }
523  }
524 
528  function setContentSubTabs()
529  {
531  }
532 
537  {
538  global $ilAccess, $lng;
539 
540  $lng->loadLanguageModule('cntr');
541 
542  if ($this->isActiveAdministrationPanel())
543  {
544  // #11545
545  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
546 
547  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
548  $toolbar = new ilToolbarGUI();
549  $this->ctrl->setParameter($this, "type", "");
550  $this->ctrl->setParameter($this, "item_ref_id", "");
551 
552  if (!$_SESSION["clipboard"])
553  {
554  if ($this->object->gotItems())
555  {
556  $toolbar->setLeadingImage(
557  ilUtil::getImagePath("arrow_upright.svg"),
558  $lng->txt("actions")
559  );
560  $toolbar->addFormButton(
561  $this->lng->txt('delete_selected_items'),
562  'delete'
563  );
564  $toolbar->addFormButton(
565  $this->lng->txt('move_selected_items'),
566  'cut'
567  );
568  $toolbar->addFormButton(
569  $this->lng->txt('copy_selected_items'),
570  'copy'
571  );
572  $toolbar->addFormButton(
573  $this->lng->txt('link_selected_items'),
574  'link'
575  );
576  // add download button if multi download enabled
577  $folder_set = new ilSetting("fold");
578  if ($folder_set->get("enable_multi_download") == true)
579  {
580  $toolbar->addSeparator();
581  $toolbar->addFormButton(
582  $this->lng->txt('download_selected_items'),
583  'download'
584  );
585  }
586  }
587  if($this->object->getType() == 'crs')
588  {
589  if($this->object->gotItems())
590  {
591  $toolbar->addSeparator();
592  }
593 
594  $toolbar->addButton(
595  $this->lng->txt('cntr_adopt_content'),
596  $this->ctrl->getLinkTargetByClass(
597  'ilObjectCopyGUI',
598  'initSourceSelection')
599  );
600  }
601  }
602  else
603  {
604  //$GLOBALS["tpl"]->addAdminPanelCommand("paste",
605  // $this->lng->txt("paste_clipboard_items"));
606 
607  $toolbar->addFormButton(
608  $this->lng->txt('paste_clipboard_items'),
609  'paste'
610  );
611 
612  if($_SESSION["clipboard"]["cmd"] == "link")
613  {
614  //$GLOBALS["tpl"]->addAdminPanelCommand("initAndDisplayLinkIntoMultipleObjects",
615  // $this->lng->txt("paste_clipboard_items_into_multiple_objects"));
616  /*$toolbar->addFormButton(
617  $this->lng->txt('paste_clipboard_items_into_multiple_objects'),
618  'initAndDisplayLinkIntoMultipleObjects'
619  );*/
620  }
621 
622  $toolbar->addFormButton(
623  $this->lng->txt('clear_clipboard'),
624  'clear'
625  );
626 
627  if ($this->isMultiDownloadEnabled())
628  {
629  $toolbar->addSeparator();
630  $toolbar->addFormButton(
631  $this->lng->txt('download_selected_items'),
632  'download'
633  );
634  }
635  }
636 
637  $GLOBALS['tpl']->addAdminPanelToolbar(
638  $toolbar,
639  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false,
640  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false
641  );
642 
643  // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
644  if ($this->object->gotItems())
645  {
646  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
647  }
648  }
649  else
650  {
651  if ($this->edit_order)
652  {
653  if($this->object->gotItems() and $ilAccess->checkAccess("write", "", $this->object->getRefId()))
654  {
655  include_once('./Services/Container/classes/class.ilContainer.php');
656 
657  if ($this->isActiveOrdering())
658  {
659  // #11843
660  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
661 
662  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
663  $toolbar = new ilToolbarGUI();
664  $this->ctrl->setParameter($this, "type", "");
665  $this->ctrl->setParameter($this, "item_ref_id", "");
666 
667  $toolbar->addFormButton(
668  $this->lng->txt('sorting_save'),
669  'saveSorting'
670  );
671 
672  $GLOBALS['tpl']->addAdminPanelToolbar($toolbar, true, false);
673 
674  /*
675  $GLOBALS["tpl"]->addAdminPanelCommand("saveSorting",
676  $this->lng->txt('sorting_save'));
677 
678  // button should appear at bottom, too
679  $GLOBALS["tpl"]->admin_panel_bottom = true;
680  */
681  }
682  }
683  }
684  else if ($this->isMultiDownloadEnabled())
685  {
686  // #11843
687  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
688 
689  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
690  $toolbar = new ilToolbarGUI();
691  $this->ctrl->setParameter($this, "type", "");
692  $this->ctrl->setParameter($this, "item_ref_id", "");
693 
694  $toolbar->addFormButton(
695  $this->lng->txt('download_selected_items'),
696  'download'
697  );
698 
699  $GLOBALS['tpl']->addAdminPanelToolbar(
700  $toolbar,
701  $this->object->gotItems() ? true : false,
702  $this->object->gotItems() ? true : false
703  );
704  }
705  }
706  }
707 
709  {
710  global $tree;
711 
712  if(!$tree->checkForParentType($this->object->getRefId(),'crs'))
713  {
714  return false;
715  }
716  $tpl->setCurrentBlock("custom_button");
717  $tpl->setVariable("ADMIN_MODE_LINK",$this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editTimings'));
718  $tpl->setVariable("TXT_ADMIN_MODE",$this->lng->txt('timings_edit'));
719  $tpl->parseCurrentBlock();
720  return true;
721  }
726  {
727  $GLOBALS["tpl"]->setPermanentLink($this->object->getType(),
728  $this->object->getRefId(), "", "_top");
729  }
730 
735  {
736  global $ilCtrl;
737 
738  $_SESSION["il_cntr_editor"] = "std";
739  $ilCtrl->redirect($this, "editPageFrame");
740  }
741 
746  {
747  global $ilCtrl;
748 
749  $_SESSION["il_cntr_editor"] = "old";
750  $ilCtrl->redirect($this, "editPageFrame");
751  }
752 
757  {
758  global $ilCtrl, $ilAccess, $lng, $ilCtrl;
759 
760  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
761  {
762  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
763 
764  /* keep old page content for now...
765  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
766  "xhtml_page");
767  if ($xpage_id)
768  {
769  $xpage = new ilXHTMLPage($xpage_id);
770  }
771  */
772 
773  ilContainer::_writeContainerSetting($this->object->getId(),
774  "xhtml_page", 0);
775 
776  ilUtil::sendSuccess($lng->txt("cntr_switched_editor"), true);
777  }
778 
779  $ilCtrl->redirect($this, "editPageFrame");
780  }
781 
786  {
787  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
788  $fs_gui = new ilFramesetGUI();
789 
790  $fs_gui->setFramesetTitle($this->object->getTitle());
791  $fs_gui->setMainFrameName("content");
792  $fs_gui->setSideFrameName("tree");
793 
794  // old tiny stuff
795  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
796  "xhtml_page");
797  if ($xpage_id > 0 && $_SESSION["il_cntr_editor"] != "std")
798  {
799  $fs_gui->setMainFrameSource(
800  $this->ctrl->getLinkTarget(
801  $this, "editPageContent"));
802  $fs_gui->setSideFrameSource(
803  $this->ctrl->getLinkTarget($this, "showLinkList"));
804  }
805  else
806  {
807  $this->ctrl->redirectByClass(array("ilcontainerpagegui"), "edit");
808  exit;
809  }
810 
811  $fs_gui->show();
812  exit;
813  }
814 
821  {
822  global $rbacsystem, $tpl, $lng, $ilCtrl;
823 
824  if (!$rbacsystem->checkAccess("write", $this->ref_id))
825  {
826  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
827  }
828 
829  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
830  "xhtml_page");
831  if ($xpage_id > 0)
832  {
833  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
834  $xpage = new ilXHTMLPage($xpage_id);
835  $content = $xpage->getContent();
836  }
837 
838  // get template
839  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.container_edit_page_content.html",
840  "Services/Container");
841  $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
842  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
843  $tpl->setVariable("TXT_EDIT_PAGE_CONTENT",
844  $this->lng->txt("edit_page_content"));
845  $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
846  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
847  $tpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_old_editor_warning"));
848  $tpl->setVariable("TXT_MIGRATION_OPEN_STD_EDITOR", $lng->txt("cntr_old_editor_open_standard_editor"));
849  $tpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert.svg"));
850  $tpl->setVariable("HREF_OPEN_STD_EDITOR", $ilCtrl->getLinkTarget($this, "switchToStdEditor"));
851  $tpl->setVariable("ALT_WARNING", $lng->txt("warning"));
852 
853  include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
854  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
855  //$ta = new ilTextAreaInputGUI();
856  //$tags = $ta->getRteTagSet("extended_table_img");
857 
858  // add rte support
859  include_once "./Services/RTE/classes/class.ilRTE.php";
860  $rtestring = ilRTE::_getRTEClassname();
861  include_once "./Services/RTE/classes/class.$rtestring.php";
862  $rte = new $rtestring();
863  //$rte->addPlugin("latex");
864  include_once "./Services/Object/classes/class.ilObject.php";
866  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
867  $rte->addRTESupport($obj_id, $obj_type);
868  //$rte->setStyleSelect(true);
869  //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
870  }
871 
873  {
874  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
875  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
876  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
877  "xhtml_page");
878 
879  /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
880  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
881  $ta = new ilTextAreaInputGUI();
882  $ta->setRteTagSet("extended_table_img");
883  $tags = $ta->getRteTagString();*/
884 
885  //$text = ilUtil::stripSlashes($_POST["page_content"],
886  // true,
887  // $tags);
888 
889  $text = ilUtil::stripSlashes($_POST["page_content"],
890  true,
892  if ($xpage_id > 0)
893  {
894  $xpage = new ilXHTMLPage($xpage_id);
895  $xpage->setContent($text);
896  $xpage->save();
897  }
898  else
899  {
900  $xpage = new ilXHTMLPage();
901  $xpage->setContent($text);
902  $xpage->save();
903  ilContainer::_writeContainerSetting($this->object->getId(),
904  "xhtml_page", $xpage->getId());
905  }
906 
907  include_once("Services/RTE/classes/class.ilRTE.php");
908  ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType().":html",
909  $this->object->getId());
910 
911  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
912  $this->ctrl->redirect($this, "");
913  }
914 
916  {
917  $this->ctrl->redirect($this, "");
918  }
919 
921  {
922  global $lng, $tree;
923 
924  $tpl = new ilTemplate("tpl.container_link_help.html", true, true,
925  "Services/Container");
926 
927  $type_ordering = array(
928  "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
929  "glo", "webr", "file", "exc",
930  "tst", "svy", "mep", "qpl", "spl");
931 
932  $childs = $tree->getChilds($_GET["ref_id"]);
933  foreach($childs as $child)
934  {
935  if (in_array($child["type"], array("lm", "dbk", "sahs", "htlm")))
936  {
937  $cnt["lres"]++;
938  }
939  else
940  {
941  $cnt[$child["type"]]++;
942  }
943  }
944 
945  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
946  $tpl->setVariable("TXT_HELP_HEADER", $lng->txt("help"));
947  foreach($type_ordering as $type)
948  {
949  $tpl->setCurrentBlock("row");
950  $tpl->setVariable("ROWCOL", "tblrow".((($i++)%2)+1));
951  if ($type != "lres")
952  {
953  $tpl->setVariable("TYPE", $lng->txt("objs_".$type).
954  " (".((int)$cnt[$type]).")");
955  }
956  else
957  {
958  $tpl->setVariable("TYPE", $lng->txt("learning_resources").
959  " (".((int)$cnt["lres"]).")");
960  }
961  $tpl->setVariable("TXT_LINK", "[list-".$type."]");
962  $tpl->parseCurrentBlock();
963  }
964  $tpl->show();
965  exit;
966 
967  }
968 
973  {
974  $this->adminCommands = false;
975  }
976 
980 /* function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
981  {
982  if (!$this->adminCommands)
983  {
984  if (!$this->isActiveAdministrationPanel())
985  {
986  if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
987  {
988  $this->adminCommands = true;
989  }
990  }
991  else
992  {
993  $this->adminCommands = $a_admin_com_included_in_list;
994  }
995  }
996  }*/
997 
1004  function &newBlockTemplate()
1005  {
1006  $tpl = new ilTemplate("tpl.container_list_block.html", true, true,
1007  "Services/Container");
1008  $this->cur_row_type = "row_type_1";
1009  return $tpl;
1010  }
1011 
1019  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1020  {
1021  $icon = ilUtil::getImagePath("icon_".$a_type.".svg");
1022  $title = $this->lng->txt("objs_".$a_type);
1023 
1024  if ($a_show_image)
1025  {
1026  $a_tpl->setCurrentBlock("container_header_row_image");
1027  $a_tpl->setVariable("HEADER_IMG", $icon);
1028  $a_tpl->setVariable("HEADER_ALT", $title);
1029  }
1030  else
1031  {
1032  $a_tpl->setCurrentBlock("container_header_row");
1033  }
1034 
1035  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1036  $a_tpl->parseCurrentBlock();
1037  $a_tpl->touchBlock("container_row");
1038  }
1039 
1047  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1048  $a_image_type = "")
1049  {
1050  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1051  ? "row_type_2"
1052  : "row_type_1";
1053 
1054  $a_tpl->touchBlock($this->cur_row_type);
1055 
1056  $nbsp = true;
1057  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
1058  {
1059  $icon = ilUtil::getImagePath("icon_".$a_image_type.".svg");
1060  $alt = $this->lng->txt("obj_".$a_image_type);
1061 
1062  // custom icon
1063  if ($this->ilias->getSetting("custom_icons") &&
1064  in_array($a_image_type, array("cat","grp","crs")))
1065  {
1066  require_once("./Services/Container/classes/class.ilContainer.php");
1067  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1068  {
1069  $icon = $path;
1070  }
1071  }
1072 
1073  $a_tpl->setCurrentBlock("block_row_image");
1074  $a_tpl->setVariable("ROW_IMG", $icon);
1075  $a_tpl->setVariable("ROW_ALT", $alt);
1076  $a_tpl->parseCurrentBlock();
1077  $nbsp = false;
1078  }
1079 
1080  if ($this->isActiveAdministrationPanel())
1081  {
1082  $a_tpl->setCurrentBlock("block_row_check");
1083  $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
1084  $a_tpl->parseCurrentBlock();
1085  $nbsp = false;
1086  }
1087  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1088  if($this->isActiveAdministrationPanel() &&
1090  {
1091  $a_tpl->setCurrentBlock('block_position');
1092  $a_tpl->setVariable('POS_TYPE',$a_image_type);
1093  $a_tpl->setVariable('POS_ID',$a_item_ref_id);
1094  $a_tpl->setVariable('POSITION',sprintf('%.1f',$this->current_position++));
1095  $a_tpl->parseCurrentBlock();
1096  }
1097  if ($nbsp)
1098  {
1099  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1100  }
1101  $a_tpl->setCurrentBlock("container_standard_row");
1102  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1103  $a_tpl->parseCurrentBlock();
1104  $a_tpl->touchBlock("container_row");
1105  }
1106 
1110  function addMessageRow(&$a_tpl, $a_message, $a_type)
1111  {
1112  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1113  ? "row_type_2"
1114  : "row_type_1";
1115 
1116  $a_tpl->touchBlock($this->cur_row_type);
1117 
1118  $type = $this->lng->txt("obj_".$a_type);
1119  $a_message = str_replace("[type]", $type, $a_message);
1120 
1121  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1122 
1123  $a_tpl->setCurrentBlock("container_standard_row");
1124  $a_tpl->setVariable("BLOCK_ROW_CONTENT",
1125  $a_message);
1126  $a_tpl->parseCurrentBlock();
1127  $a_tpl->touchBlock("container_row");
1128  }
1129 
1130  function resetRowType()
1131  {
1132  $this->cur_row_type = "";
1133  }
1134 
1135 
1140  {
1141  global $lng;
1142 
1143  if (!$this->isActiveAdministrationPanel()
1144  || strtolower($this->ctrl->getCmdClass()) != "ilcontainerpagegui")
1145  {
1146  return;
1147  }
1148 
1149  $lng->loadLanguageModule("content");
1150  //$tabs_gui = new ilTabsGUI();
1151  //$tabs_gui->setSubTabs();
1152 
1153  // back to upper context
1154  $this->tabs_gui->setBackTarget($this->lng->txt("obj_cat"),
1155  $this->ctrl->getLinkTarget($this, "frameset"),
1156  ilFrameTargetInfo::_getFrame("MainContent"));
1157 
1158  $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilcontainerpagegui", "view")
1159  , array("", "view"), "ilcontainerpagegui");
1160 
1161  //$this->tpl->setTabs($tabs_gui->getHTML());
1162  }
1163 
1167  function addStandardContainerSubTabs($a_include_view = true)
1168  {
1169  global $ilTabs, $ilAccess, $lng, $ilCtrl, $ilUser, $ilSetting;
1170 
1171  if (!is_object($this->object))
1172  {
1173  return;
1174  }
1175 
1176  if ($a_include_view && $ilAccess->checkAccess("read", "", $this->object->getRefId()))
1177  {
1178  if (!$this->isActiveAdministrationPanel())
1179  {
1180  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, ""));
1181  }
1182  else
1183  {
1184  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "disableAdministrationPanel"));
1185  }
1186  }
1187 
1188  if ( $ilUser->getId() != ANONYMOUS_USER_ID &&
1189  ($this->adminCommands ||
1190  (is_object($this->object) &&
1191  ($ilAccess->checkAccess("write", "", $this->object->getRefId())))
1192  ||
1193  (is_object($this->object) &&
1194  ($this->object->getHiddenFilesFound())) ||
1195  $_SESSION["clipboard"]
1196  )
1197  )
1198  {
1199  if ($this->isActiveAdministrationPanel())
1200  {
1201  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, ""));
1202  }
1203  else
1204  {
1205  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, "enableAdministrationPanel"));
1206  }
1207  }
1208  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1209  is_object($this->object) &&
1210  $ilAccess->checkAccess("write", "", $this->object->getRefId()) /* &&
1211  $this->object->getOrderType() == ilContainer::SORT_MANUAL */ // always on because of custom block order
1212  )
1213  {
1214  $ilTabs->addSubTab("ordering", $lng->txt("cntr_ordering"), $ilCtrl->getLinkTarget($this, "editOrder"));
1215  }
1216  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1217  is_object($this->object) &&
1218  $ilAccess->checkAccess("write", "", $this->object->getRefId())
1219  )
1220  {
1221  if ($ilSetting->get("enable_cat_page_edit"))
1222  {
1223  $ilTabs->addSubTab("page_editor", $lng->txt("cntr_text_media_editor"), $ilCtrl->getLinkTarget($this, "editPageFrame"),
1224  ilFrameTargetInfo::_getFrame("MainContent"));
1225  }
1226  }
1227  }
1228 
1229 
1234  function getTabs(&$tabs_gui)
1235  {
1236  global $rbacsystem, $ilCtrl;
1237 
1238  // edit permissions
1239  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
1240  {
1241  $tabs_gui->addTarget("perm_settings",
1242  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1243  array("perm","info","owner"), 'ilpermissiongui');
1244  if ($ilCtrl->getNextClass() == "ilpermissiongui")
1245  {
1246  $tabs_gui->activateTab("perm_settings");
1247  }
1248  }
1249 
1250  // show clipboard
1251  if (strtolower($_GET["baseClass"]) == "ilrepositorygui" && !empty($_SESSION["clipboard"]))
1252  {
1253  $tabs_gui->addTarget("clipboard",
1254  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
1255  }
1256 
1257  }
1258 
1259  //*****************
1260  // COMMON METHODS (may be overwritten in derived classes
1261  // if special handling is necessary)
1262  //*****************
1263 
1268  {
1269  $_SESSION["il_cont_admin_panel"] = true;
1270  $this->ctrl->redirect($this, "render");
1271  }
1272 
1277  {
1278  $_SESSION["il_cont_admin_panel"] = false;
1279  $this->ctrl->redirect($this, "render");
1280  }
1281 
1285  function editOrderObject()
1286  {
1287  global $ilTabs;
1288 
1289  $this->edit_order = true;
1290  $_SESSION["il_cont_admin_panel"] = false;
1291  $this->renderObject();
1292 
1293  $ilTabs->activateSubTab("ordering");
1294  }
1295 
1300  public function isActiveOrdering()
1301  {
1302  return $this->edit_order ? true : false;
1303  }
1304 
1309  public function isActiveItemOrdering()
1310  {
1311  if($this->isActiveOrdering())
1312  {
1313  return (ilContainerSortingSettings::_lookupSortMode($this->object->getId()) == ilContainer::SORT_MANUAL);
1314  }
1315  return false;
1316  }
1317 
1321  public function addToDeskObject()
1322  {
1323  global $ilSetting, $lng;
1324 
1325  if((int)$ilSetting->get('disable_my_offers'))
1326  {
1327  return $this->renderObject();
1328  }
1329 
1330  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1332  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
1333  $this->renderObject();
1334  }
1335 
1339  public function removeFromDeskObject()
1340  {
1341  global $ilSetting, $lng;
1342 
1343  if((int)$ilSetting->get('disable_my_offers'))
1344  {
1345  return $this->renderObject();
1346  }
1347 
1348  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1350  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
1351  $this->renderObject();
1352  }
1353 
1355  {
1356  $this->multi_download_enabled = true;
1357  $this->renderObject();
1358  }
1359 
1361  {
1363  }
1364 
1365  // BEGIN WebDAV: Lock/Unlock objects
1366  function lockObject()
1367  {
1368  global $tree, $ilUser, $rbacsystem;
1369 
1370  if (!$rbacsystem->checkAccess("write",$_GET['item_ref_id']))
1371  {
1372  $this->ilErr->raiseError($this->lng->txt('err_no_permission'),$this->ilErr->MESSAGE);
1373  }
1374 
1375 
1376  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1378  {
1379  require_once 'Services/WebDAV/classes/class.ilDAVLocks.php';
1380  $locks = new ilDAVLocks();
1381 
1382  $result = $locks->lockRef($_GET['item_ref_id'],
1383  $ilUser->getId(), $ilUser->getLogin(),
1384  'ref_'.$_GET['item_ref_id'].'_usr_'.$ilUser->getId(),
1385  time() + /*30*24*60**/60, 0, 'exclusive'
1386  );
1387 
1389  $this->lng->txt(
1390  ($result === true) ? 'object_locked' : $result
1391  ),
1392  true);
1393  }
1394  $this->renderObject();
1395  }
1396  // END WebDAV: Lock/Unlock objects
1397 
1404  function cutObject()
1405  {
1406  global $rbacsystem, $ilCtrl;
1407 
1408  if ($_GET["item_ref_id"] != "")
1409  {
1410  $_POST["id"] = array($_GET["item_ref_id"]);
1411  }
1412 
1413  //$this->ilias->raiseError("move operation does not work at the moment and is disabled",$this->ilias->error_obj->MESSAGE);
1414 
1415  if (!isset($_POST["id"]))
1416  {
1417  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1418  }
1419 
1420  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1421  foreach ($_POST["id"] as $ref_id)
1422  {
1423  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1424  $node_data = $this->tree->getNodeData($ref_id);
1425  $subtree_nodes = $this->tree->getSubTree($node_data);
1426 
1427  $all_node_data[] = $node_data;
1428  $all_subtree_nodes[] = $subtree_nodes;
1429 
1430  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1431  foreach ($subtree_nodes as $node)
1432  {
1433  if($node['type'] == 'rolf')
1434  {
1435  continue;
1436  }
1437 
1438  if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
1439  {
1440  $no_cut[] = $node["ref_id"];
1441  }
1442  }
1443  }
1444  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1445  if (count($no_cut))
1446  {
1447  $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
1448  $this->ilias->error_obj->MESSAGE);
1449  }
1450  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1451  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1452  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1453 
1454  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"),true);
1455 
1456  return $this->initAndDisplayMoveIntoObjectObject();
1457  } // END CUT
1458 
1466  function copyObject()
1467  {
1468  global $rbacsystem, $ilCtrl, $objDefinition;
1469 
1470  if ($_GET["item_ref_id"] != "")
1471  {
1472  $_POST["id"] = array($_GET["item_ref_id"]);
1473  }
1474 
1475  if (!isset($_POST["id"]))
1476  {
1477  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1478  }
1479 
1480  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1481  $containers = 0;
1482  foreach ($_POST["id"] as $ref_id)
1483  {
1484  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1485  $node_data = $this->tree->getNodeData($ref_id);
1486 
1487  // count containers
1488  if ($objDefinition->isContainer($node_data["type"]))
1489  {
1490  $containers++;
1491  }
1492 
1493  $subtree_nodes = $this->tree->getSubTree($node_data);
1494 
1495  $all_node_data[] = $node_data;
1496  $all_subtree_nodes[] = $subtree_nodes;
1497 
1498  // CHECK COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1499  foreach ($subtree_nodes as $node)
1500  {
1501  if($node['type'] == 'rolf')
1502  {
1503  continue;
1504  }
1505 
1506  if (!$rbacsystem->checkAccess('visible,read,copy',$node["ref_id"]))
1507  {
1508  $no_copy[] = $node["ref_id"];
1509  }
1510  }
1511  }
1512 
1513  if ($containers > 0 && count($_POST["id"]) > 1)
1514  {
1515  $this->ilias->raiseError($this->lng->txt("cntr_container_only_on_their_own"), $this->ilias->error_obj->MESSAGE);
1516  }
1517 
1518  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1519  if (count($no_copy))
1520  {
1521  $this->ilias->raiseError(
1522  $this->lng->txt("msg_no_perm_copy") . " " . implode(',',$this->getTitlesByRefId($no_copy)),
1523  $this->ilias->error_obj->MESSAGE);
1524  }
1525 
1526  // if we have a single container, set it as source id and redirect to ilObjectCopyGUI
1527  if (count($_POST["id"]) == 1)
1528  {
1529  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $_POST["id"][0]);
1530  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1531  }
1532  else
1533  {
1534  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($_POST["id"],"_"));
1535  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1536  }
1537 
1538  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1539  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1540  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1541 
1542  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"), true);
1543 
1545  } // END COPY
1546 
1547  function downloadObject()
1548  {
1549  global $rbacsystem, $ilCtrl;
1550 
1551  if ($_GET["item_ref_id"] != "")
1552  {
1553  $_POST["id"] = array($_GET["item_ref_id"]);
1554  }
1555 
1556  if (!isset($_POST["id"]))
1557  {
1558  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1559  }
1560 
1561  // FOR ALL OBJECTS THAT SHOULD BE DOWNLOADED
1562  foreach ($_POST["id"] as $ref_id)
1563  {
1564  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1565  $obj_type = $object->getType();
1566  if (!in_array($obj_type, array("fold", "file")))
1567  {
1568  $no_download[] = $object->getType();
1569  }
1570  else if (!$rbacsystem->checkAccess('read', $ref_id))
1571  {
1572  $no_perm[] = $ref_id;
1573  }
1574  }
1575 
1576  // IF THERE IS ANY OBJECT THAT CANNOT BE DOWNLOADED
1577  if (count($no_download))
1578  {
1579  $no_download = array_unique($no_download);
1580  foreach ($no_download as $type)
1581  {
1582  $txt_objs[] = $this->lng->txt("objs_".$type);
1583  }
1584  $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_download"),$this->ilias->error_obj->MESSAGE);
1585  }
1586 
1587  // NO ACCESS
1588  if (count($no_perm))
1589  {
1590  $this->ilias->raiseError(
1591  $this->lng->txt("msg_obj_perm_download")." ".implode(',',$no_perm),
1592  $this->ilias->error_obj->MESSAGE);
1593  }
1594 
1595  // download the objects
1596  $this->downloadMultipleObjects($_POST["id"]);
1597  }
1598 
1599  private function downloadMultipleObjects($a_ref_ids)
1600  {
1601  global $lng, $rbacsystem, $ilAccess;
1602 
1603  include_once "./Services/Utilities/classes/class.ilUtil.php";
1604  include_once 'Modules/Folder/classes/class.ilObjFolder.php';
1605  include_once 'Modules/File/classes/class.ilObjFile.php';
1606  include_once 'Modules/File/classes/class.ilFileException.php';
1607 
1608  // create temporary file to download
1609  $zip = PATH_TO_ZIP;
1610  $tmpdir = ilUtil::ilTempnam();
1611  ilUtil::makeDir($tmpdir);
1612 
1613  try
1614  {
1615  // copy each selected object
1616  foreach ($a_ref_ids as $ref_id)
1617  {
1618  if (!$ilAccess->checkAccess("read", "", $ref_id))
1619  continue;
1620 
1621  if (ilObject::_isInTrash($ref_id))
1622  continue;
1623 
1624  // get object
1625  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1626  $obj_type = $object->getType();
1627  if ($obj_type == "fold")
1628  {
1629  // copy folder to temp directory
1630  self::recurseFolder($ref_id, $object->getTitle(), $tmpdir);
1631  }
1632  else if ($obj_type == "file")
1633  {
1634  // copy file to temp directory
1635  self::copyFile($object->getId(), $object->getTitle(), $tmpdir);
1636  }
1637  }
1638 
1639  // compress the folder
1640  $deliverFilename = ilUtil::getAsciiFilename($this->object->getTitle()) . ".zip";
1641  $tmpzipfile = ilUtil::ilTempnam() . ".zip";
1642  ilUtil::zip($tmpdir, $tmpzipfile, true);
1643  ilUtil::delDir($tmpdir);
1644  ilUtil::deliverFile($tmpzipfile, $deliverFilename, '', false, true, true);
1645  }
1646  catch (ilFileException $e)
1647  {
1648  ilUtil::sendInfo($e->getMessage(), true);
1649  }
1650  }
1651 
1660  private static function recurseFolder($refid, $title, $tmpdir)
1661  {
1662  global $rbacsystem, $tree, $ilAccess;
1663 
1664  $tmpdir = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1665  ilUtil::makeDir($tmpdir);
1666 
1667  $subtree = $tree->getChildsByTypeFilter($refid, array("fold","file"));
1668 
1669  foreach ($subtree as $child)
1670  {
1671  if (!$ilAccess->checkAccess("read", "", $child["ref_id"]))
1672  continue;
1673 
1674  if (ilObject::_isInTrash($child["ref_id"]))
1675  continue;
1676 
1677  if ($child["type"] == "fold")
1678  self::recurseFolder($child["ref_id"], $child["title"], $tmpdir);
1679  else
1680  self::copyFile($child["obj_id"], $child["title"], $tmpdir);
1681  }
1682  }
1683 
1684  private static function copyFile($obj_id, $title, $tmpdir)
1685  {
1686  $newFilename = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1687 
1688  // copy to temporary directory
1689  $oldFilename = ilObjFile::_lookupAbsolutePath($obj_id);
1690  if (!copy($oldFilename, $newFilename))
1691  throw new ilFileException("Could not copy ".$oldFilename." to ".$newFilename);
1692 
1693  touch($newFilename, filectime($oldFilename));
1694  }
1695 
1702  function linkObject()
1703  {
1704  global $clipboard, $rbacsystem, $rbacadmin, $ilCtrl;
1705 
1706  if ($_GET["item_ref_id"] != "")
1707  {
1708  $_POST["id"] = array($_GET["item_ref_id"]);
1709  }
1710 
1711  if (!isset($_POST["id"]))
1712  {
1713  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1714  }
1715 
1716  // CHECK ACCESS
1717  foreach ($_POST["id"] as $ref_id)
1718  {
1719  if (!$rbacsystem->checkAccess('delete',$ref_id))
1720  {
1721  $no_cut[] = $ref_id;
1722  }
1723 
1724  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1725 
1726  if (!$this->objDefinition->allowLink($object->getType()))
1727  {
1728  $no_link[] = $object->getType();
1729  }
1730  }
1731 
1732  // NO ACCESS
1733  if (count($no_cut))
1734  {
1735  $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
1736  implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
1737  }
1738 
1739  if (count($no_link))
1740  {
1741  //#12203
1742  $this->ilias->raiseError($this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
1743 
1744  //$this->ilias->raiseError($this->lng->txt("msg_not_possible_link")." ".
1745  // implode(',',$no_link),$this->ilias->error_obj->MESSAGE);
1746  }
1747 
1748  // WRITE TO CLIPBOARD
1749  $clipboard["parent"] = $_GET["ref_id"];
1750  $clipboard["cmd"] = $ilCtrl->getCmd();
1751 
1752  foreach ($_POST["id"] as $ref_id)
1753  {
1754  $clipboard["ref_ids"][] = $ref_id;
1755  }
1756 
1757  $_SESSION["clipboard"] = $clipboard;
1758 
1759  $suffix = 'p';
1760  if(count($clipboard["ref_ids"]) == 1)
1761  {
1762  $suffix = 's';
1763  }
1764  ilUtil::sendInfo($this->lng->txt("msg_link_clipboard_" . $suffix),true);
1765 
1767 
1768  } // END LINK
1769 
1770 
1776  function clearObject()
1777  {
1778  unset($_SESSION["clipboard"]);
1779  unset($_SESSION["il_rep_clipboard"]);
1780 
1781  //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1782 
1783  // only redirect if clipboard was cleared
1784  if (isset($_POST["cmd"]["clear"]))
1785  {
1786  ilUtil::sendSuccess($this->lng->txt("msg_clear_clipboard"),true);
1787 
1788  //$this->ctrl->returnToParent($this);
1789  //ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1791  }
1792  }
1793 
1795  {
1796  global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree, $ilObjDataCache, $ilUser;
1797 
1798  $command = $_SESSION['clipboard']['cmd'];
1799  if(!in_array($command, array('cut', 'link', 'copy')))
1800  {
1801  $message = __METHOD__.": cmd was neither 'cut', 'link' nor 'copy'; may be a hack attempt!";
1802  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
1803  }
1804 
1805  if($command == 'cut')
1806  {
1807  if(isset($_POST['node']) && (int)$_POST['node'])
1808  $_POST['nodes'] = array($_POST['node']);
1809  }
1810 
1811  if(!is_array($_POST['nodes']) || !count($_POST['nodes']))
1812  {
1813  ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'));
1814  switch ($command)
1815  {
1816  case 'cut':
1817  $this->showPasteTreeObject();
1818  break;
1819  case 'copy':
1820  $this->showPasteTreeObject();
1821  break;
1822  case 'link':
1823  $this->showPasteTreeObject();
1824  break;
1825  }
1826  return;
1827  }
1828 
1829  // this loop does all checks
1830  $folder_objects_cache = array();
1831  foreach($_SESSION['clipboard']['ref_ids'] as $ref_id)
1832  {
1833  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
1834  $current_parent_id = $tree->getParentId($obj_data->getRefId());
1835 
1836  foreach($_POST['nodes'] as $folder_ref_id)
1837  {
1838  if(!array_key_exists($folder_ref_id, $folder_objects_cache))
1839  {
1840  $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id);
1841  }
1842 
1843  // CHECK ACCESS
1844  if(!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType()))
1845  {
1846  $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().']');
1847  }
1848 
1849  // CHECK IF REFERENCE ALREADY EXISTS
1850  if($folder_ref_id == $current_parent_id)
1851  {
1852  $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().']');
1853  }
1854 
1855  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1856  if ($tree->isGrandChild($ref_id, $folder_ref_id) ||
1857  $ref_id == $folder_ref_id)
1858  {
1859  $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle().' ['.$obj_data->getRefId().']');
1860  }
1861 
1862  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
1863  if(!in_array($obj_data->getType(), array_keys($this->objDefinition->getSubObjects($folder_objects_cache[$folder_ref_id]->getType()))))
1864  {
1865  $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().']',
1866  $GLOBALS['lng']->txt('obj_'.$obj_data->getType()));
1867  }
1868  }
1869  }
1870 
1872  // process checking results
1873  if(count($exists) && $command != "copy")
1874  {
1875  $error .= implode('<br />', $exists);
1876  }
1877 
1878  if(count($is_child))
1879  {
1880  $error .= $error != '' ? '<br />' : '';
1881  $error .= implode('<br />', $is_child);
1882  }
1883 
1884  if(count($not_allowed_subobject))
1885  {
1886  $error .= $error != '' ? '<br />' : '';
1887  $error .= implode('<br />', $not_allowed_subobject);
1888  }
1889 
1890  if(count($no_paste))
1891  {
1892  $error .= $error != '' ? '<br />' : '';
1893  $error .= implode('<br />', $no_paste);
1894  }
1895 
1896  if($error != '')
1897  {
1898  ilUtil::sendFailure($error);
1899  switch ($command)
1900  {
1901  case 'cut':
1902  $this->showPasteTreeObject();
1903  break;
1904  case 'copy':
1905  $this->showPasteTreeObject();
1906  break;
1907  case 'link':
1908  $this->showPasteTreeObject();
1909  break;
1910  }
1911  return;
1912  }
1913 
1914  // log pasteObject call
1915  $log->write(__METHOD__.", cmd: ".$command);
1916 
1918  // everything ok: now paste the objects to new location
1919 
1920  // to prevent multiple actions via back/reload button
1921  $ref_ids = $_SESSION['clipboard']['ref_ids'];
1922  unset($_SESSION['clipboard']['ref_ids']);
1923 
1924  // BEGIN ChangeEvent: Record paste event.
1925  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1926  // END ChangeEvent: Record paste event.
1927 
1928  // process COPY command
1929  if($command == 'copy')
1930  {
1931  foreach($_POST['nodes'] as $folder_ref_id)
1932  {
1933  foreach($ref_ids as $ref_id)
1934  {
1935  $revIdMapping = array();
1936 
1937  $oldNode_data = $tree->getNodeData($ref_id);
1938  if ($oldNode_data['parent'] == $folder_ref_id)
1939  {
1940  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
1941  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
1942  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, $newTitle);
1943  }
1944  else
1945  {
1946  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, null);
1947  }
1948 
1949  // BEGIN ChangeEvent: Record copy event.
1950  $old_parent_data = $tree->getParentNodeData($ref_id);
1951  $newNode_data = $tree->getNodeData($newRef);
1952  ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
1953  $oldNode_data['obj_id'], $ilUser->getId());
1954  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
1955  $ilObjDataCache->lookupObjId($folder_ref_id));
1956  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
1957  // END PATCH ChangeEvent: Record cut event.
1958  }
1959  }
1960 
1961  ilUtil::sendSuccess($this->lng->txt('msg_cloned'), true);
1962  } // END COPY
1963 
1964  // process CUT command
1965  if($command == 'cut')
1966  {
1967  foreach($_POST['nodes'] as $folder_ref_id)
1968  {
1969  foreach($ref_ids as $ref_id)
1970  {
1971  // Store old parent
1972  $old_parent = $tree->getParentId($ref_id);
1973  $tree->moveTree($ref_id, $folder_ref_id);
1974  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1975 
1976  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
1978 
1979  // BEGIN ChangeEvent: Record cut event.
1980  $node_data = $tree->getNodeData($ref_id);
1981  $old_parent_data = $tree->getNodeData($old_parent);
1982  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
1983  $old_parent_data['obj_id']);
1984  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
1985  $ilObjDataCache->lookupObjId($folder_ref_id));
1986  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
1987  // END PATCH ChangeEvent: Record cut event.
1988  }
1989 
1990  // prevent multiple iterations for cut cmommand
1991  break;
1992  }
1993 
1994  ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
1995  } // END CUT
1996 
1997  // process LINK command
1998  if($command == 'link')
1999  {
2000  $linked_to_folders = array();
2001 
2002  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
2003  $rbac_log_active = ilRbacLog::isActive();
2004 
2005  foreach($_POST['nodes'] as $folder_ref_id)
2006  {
2007  $linked_to_folders[$folder_ref_id] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id));
2008 
2009  foreach($ref_ids as $ref_id)
2010  {
2011  // get node data
2012  $top_node = $tree->getNodeData($ref_id);
2013 
2014  // get subnodes of top nodes
2015  $subnodes[$ref_id] = $tree->getSubtree($top_node);
2016  }
2017 
2018  // now move all subtrees to new location
2019  foreach($subnodes as $key => $subnode)
2020  {
2021  // first paste top_node....
2022  $obj_data = ilObjectFactory::getInstanceByRefId($key);
2023  $new_ref_id = $obj_data->createReference();
2024  $obj_data->putInTree($folder_ref_id);
2025  $obj_data->setPermissions($folder_ref_id);
2026 
2027  // rbac log
2028  if($rbac_log_active)
2029  {
2030  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
2031  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
2032  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, $key);
2033  }
2034 
2035  // BEGIN ChangeEvent: Record link event.
2036  $node_data = $tree->getNodeData($new_ref_id);
2037  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2038  $ilObjDataCache->lookupObjId($folder_ref_id));
2039  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2040  // END PATCH ChangeEvent: Record link event.
2041  }
2042 
2043  $log->write(__METHOD__.', link finished');
2044  }
2045 
2046  $linked_targets = array();
2047  if(count($linked_to_folders))
2048  {
2049  require_once 'Services/Link/classes/class.ilLink.php';
2050  foreach($linked_to_folders as $ref_id => $title)
2051  {
2052  $linked_targets[] = '<a href="' . ilLink::_getLink($ref_id) . '">' . $title . '</a>';
2053  }
2054  }
2055 
2056  $suffix = 'p';
2057  if(count($ref_ids) == 1)
2058  {
2059  $suffix = 's';
2060  }
2061  ilUtil::sendSuccess(sprintf($this->lng->txt('mgs_objects_linked_to_the_following_folders_' . $suffix), implode(', ', $linked_targets)), true);
2062  } // END LINK
2063 
2064  // clear clipboard
2065  $this->clearObject();
2066 
2067  $this->ctrl->returnToParent($this);
2068  }
2069 
2071  {
2072  global $tree;
2073 
2074  // empty session on init
2075  $_SESSION['paste_linked_repexpand'] = array();
2076 
2077  // copy opend nodes from repository explorer
2078  $_SESSION['paste_linked_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2079 
2080  // open current position
2081  $path = $tree->getPathId((int)$_GET['ref_id']);
2082  foreach((array)$path as $node_id)
2083  {
2084  if(!in_array($node_id, $_SESSION['paste_linked_repexpand']))
2085  $_SESSION['paste_linked_repexpand'][] = $node_id;
2086  }
2087 
2088  return $this->showPasteTreeObject();
2089  }
2090 
2094  public function showPasteTreeObject()
2095  {
2096  global $ilTabs, $ilToolbar;
2097 
2098  $ilTabs->setTabActive('view_content');
2099 
2100  if(!in_array($_SESSION['clipboard']['cmd'], array('link', 'copy', 'cut')))
2101  {
2102  $message = __METHOD__.": Unknown action.";
2103  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2104  }
2105  $cmd = $_SESSION['clipboard']['cmd'];
2106 
2107  //
2108  $exp = $this->getTreeSelectorGUI($cmd);
2109  if ($exp->handleCommand())
2110  {
2111  return;
2112  }
2113  $output = $exp->getHTML();
2114 
2115  $txt_var = ($cmd == "copy")
2116  ? "copy"
2117  : "paste";
2118 
2119  // toolbars
2120  $t = new ilToolbarGUI();
2121  $t->setFormAction($this->ctrl->getFormAction($this, "performPasteIntoMultipleObjects"));
2122  $t->addFormButton($this->lng->txt($txt_var), "performPasteIntoMultipleObjects");
2123  $t->addSeparator();
2124  $t->addFormButton($this->lng->txt("obj_insert_into_clipboard"), "keepObjectsInClipboard");
2125  $t->addFormButton($this->lng->txt("cancel"), "cancelMoveLink");
2126  $t->setCloseFormTag(false);
2127  $t->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), " ");
2128  $output = $t->getHTML().$output;
2129  $t->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), " ");
2130  $t->setCloseFormTag(true);
2131  $t->setOpenFormTag(false);
2132  $output.= "<br />".$t->getHTML();
2133 
2134  $this->tpl->setContent($output);
2135  }
2136 
2137 
2138 
2139 /* public function showLinkIntoMultipleObjectsTreeObject()
2140  {
2141  global $ilTabs, $ilToolbar;
2142 
2143  $ilTabs->setTabActive('view_content');
2144 
2145  if(!in_array($_SESSION['clipboard']['cmd'], array('link')))
2146  {
2147  $message = __METHOD__.": cmd was not 'link'; may be a hack attempt!";
2148  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2149  }
2150 
2151  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
2152  "Services/Object");
2153 
2154  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2155  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_CHECK,
2156  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_linked_repexpand');
2157  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showLinkIntoMultipleObjectsTree'));
2158  $exp->setTargetGet('ref_id');
2159  $exp->setPostVar('nodes[]');
2160  $exp->highlightNode($_GET['ref_id']);
2161  is_array($_POST['nodes']) ? $exp->setCheckedItems((array)$_POST['nodes']) : $exp->setCheckedItems(array());
2162 
2163  if($_GET['paste_linked_repexpand'] == '')
2164  {
2165  $expanded = $this->tree->readRootId();
2166  }
2167  else
2168  {
2169  $expanded = $_GET['paste_linked_repexpand'];
2170  }
2171 
2172  $this->tpl->setVariable('FORM_TARGET', '_top');
2173  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2174 
2175  $exp->setExpand($expanded);
2176  // build html-output
2177  $exp->setOutput(0);
2178  $output = $exp->getOutput();
2179 
2180  $this->tpl->setVariable('OBJECT_TREE', $output);
2181 
2182  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2183  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
2184 
2185  $ilToolbar->addButton($this->lng->txt('cancel'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2186  }*/
2187 
2192  public function cancelMoveLinkObject()
2193  {
2194  unset($_SESSION['clipboard']);
2195  $GLOBALS['ilCtrl']->returnToParent($this);
2196  }
2197 
2202  {
2203  ilUtil::sendSuccess($this->lng->txt("obj_inserted_clipboard"), true);
2204  $GLOBALS['ilCtrl']->returnToParent($this);
2205  }
2206 
2207 
2209  {
2210  global $tree;
2211 
2212  // empty session on init
2213  $_SESSION['paste_copy_repexpand'] = array();
2214 
2215  // copy opend nodes from repository explorer
2216  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2217 
2218  // open current position
2219  $path = $tree->getPathId((int)$_GET['ref_id']);
2220  foreach((array)$path as $node_id)
2221  {
2222  if(!in_array($node_id, $_SESSION['paste_copy_repexpand']))
2223  $_SESSION['paste_copy_repexpand'][] = $node_id;
2224  }
2225 
2226  return $this->showPasteTreeObject();
2227  }
2228 
2229  /*public function showCopyIntoMultipleObjectsTreeObject()
2230  {
2231  global $ilTabs, $ilToolbar;
2232 
2233  $ilTabs->setTabActive('view_content');
2234 
2235  if(!in_array($_SESSION['clipboard']['cmd'], array('copy')))
2236  {
2237  $message = __METHOD__.": cmd was not 'copy'; may be a hack attempt!";
2238  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2239  }
2240 
2241  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html', "Services/Object");
2242 
2243  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2244  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_CHECK,
2245  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_copy_repexpand');
2246  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showCopyIntoMultipleObjectsTree'));
2247  $exp->setTargetGet('ref_id');
2248  $exp->setPostVar('nodes[]');
2249  $exp->highlightNode($_GET['ref_id']);
2250  is_array($_POST['nodes']) ? $exp->setCheckedItems((array)$_POST['nodes']) : $exp->setCheckedItems(array());
2251 
2252  if($_GET['paste_copy_repexpand'] == '')
2253  {
2254  $expanded = $this->tree->readRootId();
2255  }
2256  else
2257  {
2258  $expanded = $_GET['paste_copy_repexpand'];
2259  }
2260 
2261  $this->tpl->setVariable('FORM_TARGET', '_top');
2262  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2263 
2264  $exp->setExpand($expanded);
2265  // build html-output
2266  $exp->setOutput(0);
2267  $output = $exp->getOutput();
2268 
2269  $this->tpl->setVariable('OBJECT_TREE', $output);
2270 
2271  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2272  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('copy'));
2273 
2274  $ilToolbar->addButton($this->lng->txt('cancel'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2275  }*/
2276 
2278  {
2279  global $tree;
2280 
2281  // empty session on init
2282  $_SESSION['paste_cut_repexpand'] = array();
2283 
2284  // copy opend nodes from repository explorer
2285  $_SESSION['paste_cut_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2286 
2287  // open current position
2288  $path = $tree->getPathId((int)$_GET['ref_id']);
2289  foreach((array)$path as $node_id)
2290  {
2291  if(!in_array($node_id, $_SESSION['paste_cut_repexpand']))
2292  $_SESSION['paste_cut_repexpand'][] = $node_id;
2293  }
2294 
2295  return $this->showPasteTreeObject();
2296  }
2297 
2298  /*public function showMoveIntoObjectTreeObject()
2299  {
2300  global $ilTabs, $ilToolbar;
2301 
2302  $ilTabs->setTabActive('view_content');
2303 
2304  if(!in_array($_SESSION['clipboard']['cmd'], array('cut')))
2305  {
2306  $message = __METHOD__.": cmd was not 'cut'; may be a hack attempt!";
2307  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
2308  }
2309 
2310  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
2311  "Services/Object");
2312 
2313  require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
2314  $exp = new ilPasteIntoMultipleItemsExplorer(ilPasteIntoMultipleItemsExplorer::SEL_TYPE_RADIO,
2315  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto', 'paste_cut_repexpand');
2316  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showMoveIntoObjectTree'));
2317  $exp->setTargetGet('ref_id');
2318  $exp->setPostVar('node');
2319  $exp->setCheckedItems(array((int)$_POST['node']));
2320  $exp->highlightNode($_GET['ref_id']);
2321 
2322  if($_GET['paste_cut_repexpand'] == '')
2323  {
2324  $expanded = $this->tree->readRootId();
2325  }
2326  else
2327  {
2328  $expanded = $_GET['paste_cut_repexpand'];
2329  }
2330 
2331  $this->tpl->setVariable('FORM_TARGET', '_top');
2332  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects'));
2333 
2334  $exp->setExpand($expanded);
2335  // build html-output
2336  $exp->setOutput(0);
2337  $output = $exp->getOutput();
2338 
2339  $this->tpl->setVariable('OBJECT_TREE', $output);
2340 
2341  $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
2342  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
2343 
2344  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this,'cancelMoveLink'));
2345  }*/
2346 
2353  function pasteObject()
2354  {
2355  global $rbacsystem, $rbacadmin, $rbacreview, $log,$tree;
2356  global $ilUser, $lng, $ilCtrl;
2357 
2358  // BEGIN ChangeEvent: Record paste event.
2359  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2360  // END ChangeEvent: Record paste event.
2361 
2362 //var_dump($_SESSION["clipboard"]);exit;
2363  if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
2364  {
2365  $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
2366  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
2367  }
2368 
2369  // this loop does all checks
2370  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2371  {
2372  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
2373 
2374  // CHECK ACCESS
2375  if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
2376  {
2377  $no_paste[] = $ref_id;
2378  $no_paste_titles[] = $obj_data->getTitle();
2379  }
2380 
2381  // CHECK IF REFERENCE ALREADY EXISTS
2382  if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
2383  {
2384  $exists[] = $ref_id;
2385  break;
2386  }
2387 
2388  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
2389  if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
2390  {
2391  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2392  }
2393 
2394  if ($ref_id == $this->object->getRefId())
2395  {
2396  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2397  }
2398 
2399  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
2400  $obj_type = $obj_data->getType();
2401 
2402  if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
2403  {
2404  $not_allowed_subobject[] = $obj_data->getType();
2405  }
2406  }
2407 
2409  // process checking results
2410  // BEGIN WebDAV: Copying an object into the same container is allowed
2411  if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy")
2412  // END WebDAV: Copying an object into the same container is allowed
2413  {
2414  $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
2415  }
2416 
2417  if (count($is_child))
2418  {
2419  $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
2420  $this->ilias->error_obj->MESSAGE);
2421  }
2422 
2423  if (count($not_allowed_subobject))
2424  {
2425  $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
2426  $this->ilias->error_obj->MESSAGE);
2427  }
2428 
2429  if (count($no_paste))
2430  {
2431  $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
2432  implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
2433  }
2434 
2435  // log pasteObject call
2436  $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
2437 
2439  // everything ok: now paste the objects to new location
2440 
2441  // to prevent multiple actions via back/reload button
2442  $ref_ids = $_SESSION["clipboard"]["ref_ids"];
2443  unset($_SESSION["clipboard"]["ref_ids"]);
2444 
2445  // BEGIN WebDAV: Support a copy command in the repository
2446  // process COPY command
2447  if ($_SESSION["clipboard"]["cmd"] == "copy")
2448  {
2449  unset($_SESSION["clipboard"]["cmd"]);
2450 
2451  // new implementation, redirects to ilObjectCopyGUI
2452  if (count($ref_ids) == 1)
2453  {
2454  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2455  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $ref_ids[0]);
2456  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2457  }
2458  else
2459  {
2460  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2461  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($ref_ids, "_"));
2462  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2463  }
2464 
2465 
2466 
2467  /* old implementation
2468 
2469  foreach($ref_ids as $ref_id)
2470  {
2471  $revIdMapping = array();
2472 
2473  $oldNode_data = $tree->getNodeData($ref_id);
2474  if ($oldNode_data['parent'] == $this->object->getRefId())
2475  {
2476  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2477  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
2478  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
2479  }
2480  else
2481  {
2482  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
2483  }
2484 
2485  // BEGIN ChangeEvent: Record copy event.
2486  $old_parent_data = $tree->getParentNodeData($ref_id);
2487  $newNode_data = $tree->getNodeData($newRef);
2488  ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
2489  $oldNode_data['obj_id'], $ilUser->getId());
2490  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
2491  $this->object->getId());
2492  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2493  // END ChangeEvent: Record copy event.
2494  }*/
2495 
2496  $log->write("ilObjectGUI::pasteObject(), copy finished");
2497  }
2498  // END WebDAV: Support a Copy command in the repository
2499 
2500  // process CUT command
2501  if ($_SESSION["clipboard"]["cmd"] == "cut")
2502  {
2503 
2504  foreach($ref_ids as $ref_id)
2505  {
2506  // Store old parent
2507  $old_parent = $tree->getParentId($ref_id);
2508  $this->tree->moveTree($ref_id,$this->object->getRefId());
2509  $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
2510 
2511  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
2513 
2514  // BEGIN ChangeEvent: Record cut event.
2515  $node_data = $tree->getNodeData($ref_id);
2516  $old_parent_data = $tree->getNodeData($old_parent);
2517  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
2518  $old_parent_data['obj_id']);
2519  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2520  $this->object->getId());
2521  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2522  // END PATCH ChangeEvent: Record cut event.
2523  }
2524  } // END CUT
2525 
2526  // process LINK command
2527  if ($_SESSION["clipboard"]["cmd"] == "link")
2528  {
2529  foreach ($ref_ids as $ref_id)
2530  {
2531  // get node data
2532  $top_node = $this->tree->getNodeData($ref_id);
2533 
2534  // get subnodes of top nodes
2535  $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
2536  }
2537 
2538  // now move all subtrees to new location
2539  foreach ($subnodes as $key => $subnode)
2540  {
2541  // first paste top_node....
2542  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
2543  $new_ref_id = $obj_data->createReference();
2544  $obj_data->putInTree($_GET["ref_id"]);
2545  $obj_data->setPermissions($_GET["ref_id"]);
2546 
2547  // BEGIN ChangeEvent: Record link event.
2548  $node_data = $tree->getNodeData($new_ref_id);
2549  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
2550  $this->object->getId());
2551  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2552  // END PATCH ChangeEvent: Record link event.
2553  }
2554 
2555  $log->write("ilObjectGUI::pasteObject(), link finished");
2556 
2557  // inform other objects in hierarchy about link operation
2558  //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
2559  } // END LINK
2560 
2561  // save cmd for correct message output after clearing the clipboard
2562  $last_cmd = $_SESSION["clipboard"]["cmd"];
2563 
2564 
2565  // clear clipboard
2566  $this->clearObject();
2567 
2568  if ($last_cmd == "cut")
2569  {
2570  ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"),true);
2571  }
2572  // BEGIN WebDAV: Support a copy command in repository
2573  else if ($last_cmd == "copy")
2574  {
2575  ilUtil::sendSuccess($this->lng->txt("msg_cloned"),true);
2576  }
2577  else if ($last_cmd == 'link')
2578  // END WebDAV: Support copy command in repository
2579  {
2580  ilUtil::sendSuccess($this->lng->txt("msg_linked"),true);
2581  }
2582 
2583  $this->ctrl->returnToParent($this);
2584 
2585  } // END PASTE
2586 
2587 
2588  // BEGIN WebDAV: Support a copy command in repository
2589 
2597  // stefan.born@phzh.ch (01.07.2013):
2598  // UNCOMMENTED DUE NEW copyObject FUNCTION AND BECAUSE IT SEEMS THIS FUNCTION IS NOT USED ANYWHERE
2599  /*function copyObject()
2600  {
2601  global $ilAccess,$ilObjDefinition;
2602 
2603  if(!$ilAccess->checkAccess('copy','',$_GET['item_ref_id']))
2604  {
2605  $title = ilObject::_lookupTitle(ilObject::_lookupObjId($_GET['item_ref_id']));
2606 
2607  ilUtil::sendFailure($this->lng->txt('msg_no_perm_copy').' '.$title,true);
2608  $this->ctrl->returnToParent($this);
2609  }
2610 
2611  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2612  $_SESSION["clipboard"]["cmd"] = 'copy';
2613 
2614  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2615 
2616  // THIS FUNCTION DOES NOT EXIST!
2617  return $this->initAndDisplayCopyIntoObjectObject();
2618 
2619 
2620 
2621 
2622 
2623 
2624  // FOR ALL OBJECTS THAT SHOULD BE COPIED
2625  foreach ($_POST["id"] as $ref_id)
2626  {
2627  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
2628  $node_data = $this->tree->getNodeData($ref_id);
2629  $subtree_nodes = $this->tree->getSubTree($node_data);
2630 
2631  $all_node_data[] = $node_data;
2632  $all_subtree_nodes[] = $subtree_nodes;
2633 
2634  // CHECK VIEW, READ AND COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
2635  foreach ($subtree_nodes as $node)
2636  {
2637  if($node['type'] == 'rolf')
2638  {
2639  continue;
2640  }
2641 
2642  if (!$rbacsystem->checkAccess('visible,read,copy',$node["ref_id"]))
2643  {
2644  $no_copy[] = $node["ref_id"];
2645  }
2646  }
2647  }
2648  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'view,read'
2649  if (count($no_copy))
2650  {
2651  $this->ilias->raiseError($this->lng->txt("msg_no_perm_copy")." ".implode(',',$this->getTitlesByRefId($no_copy)),
2652  $this->ilias->error_obj->MESSAGE);
2653  }
2654  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
2655  $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
2656  ? $_GET["cmd"]
2657  : key($_POST["cmd"]);
2658  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
2659 
2660  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
2661 
2662  $this->ctrl->returnToParent($this);
2663 
2664  } // END COPY
2665  */
2666  // BEGIN WebDAV: Support copy command in repository
2667 
2668 
2672  function clipboardObject()
2673  {
2674  global $ilErr, $ilLog, $ilTabs, $tpl, $ilToolbar, $ilCtrl, $lng;
2675 
2676  $ilTabs->activateTab("clipboard");
2677 
2678  // function should not be called if clipboard is empty
2679  if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
2680  {
2681  $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
2682  $ilLog->write($message,$ilLog->FATAL);
2683  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
2684  }
2685 
2686  $data = array();
2687  foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
2688  {
2689  if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
2690  {
2691  continue;
2692  }
2693 
2694  $data[] = array(
2695  "type" => $tmp_obj->getType(),
2696  "type_txt" => $this->lng->txt("obj_".$tmp_obj->getType()),
2697  "title" => $tmp_obj->getTitle(),
2698  "cmd" => ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]),
2699  "ref_id" => $ref_id,
2700  "obj_id" => $tmp_obj->getId()
2701  );
2702 
2703  unset($tmp_obj);
2704  }
2705 
2706  include_once("./Services/Object/classes/class.ilObjClipboardTableGUI.php");
2707  $tab = new ilObjClipboardTableGUI($this, "clipboard");
2708  $tab->setData($data);
2709  $tpl->setContent($tab->getHTML());
2710 
2711  if (count($data) > 0)
2712  {
2713  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
2714  $ilToolbar->addFormButton($lng->txt("insert_object_here"),
2715  "paste");
2716  $ilToolbar->addFormButton($lng->txt("clear_clipboard"),
2717  "clear");
2718  }
2719 
2720  return true;
2721  }
2722 
2723 
2728  function showCustomIconsEditing($a_input_colspan = 1, ilPropertyFormGUI $a_form = null, $a_as_section = true)
2729  {
2730  if ($this->ilias->getSetting("custom_icons"))
2731  {
2732  if(!$a_form)
2733  {
2734  /*
2735  $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
2736  "tpl.container_icon_settings.html", "Services/Container");
2737 
2738  if (($big_icon = $this->object->getBigIconPath()) != "")
2739  {
2740  $this->tpl->setCurrentBlock("big_icon");
2741  $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
2742  $this->tpl->parseCurrentBlock();
2743  }
2744  if ($this->object->getType() != "root")
2745  {
2746  if (($small_icon = $this->object->getSmallIconPath()) != "")
2747  {
2748  $this->tpl->setCurrentBlock("small_icon");
2749  $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
2750  $this->tpl->parseCurrentBlock();
2751  }
2752  $this->tpl->setCurrentBlock("small_icon_row");
2753  $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("standard_icon"));
2754  $this->tpl->setVariable("SMALL_SIZE", "(".
2755  $this->ilias->getSetting("custom_icon_small_width")."x".
2756  $this->ilias->getSetting("custom_icon_small_height").")");
2757  $this->tpl->setVariable("TXT_REMOVE_S", $this->lng->txt("remove"));
2758  $this->tpl->parseCurrentBlock();
2759  }
2760  if (($tiny_icon = $this->object->getTinyIconPath()) != "")
2761  {
2762  $this->tpl->setCurrentBlock("tiny_icon");
2763  $this->tpl->setVariable("SRC_TINY_ICON", $tiny_icon);
2764  $this->tpl->parseCurrentBlock();
2765  }
2766  $this->tpl->setCurrentBlock("container_icon_settings");
2767  $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
2768  $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
2769  $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
2770  $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
2771  $this->tpl->setVariable("TINY_ICON", $this->lng->txt("tiny_icon"));
2772  $this->tpl->setVariable("BIG_SIZE", "(".
2773  $this->ilias->getSetting("custom_icon_big_width")."x".
2774  $this->ilias->getSetting("custom_icon_big_height").")");
2775  $this->tpl->setVariable("TINY_SIZE", "(".
2776  $this->ilias->getSetting("custom_icon_tiny_width")."x".
2777  $this->ilias->getSetting("custom_icon_tiny_height").")");
2778  $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
2779  $this->tpl->parseCurrentBlock();
2780  */
2781  }
2782  else
2783  {
2784  //$big_icon = $this->object->getBigIconPath();
2785  $custom_icon = $this->object->getCustomIconPath();
2786  //$tiny_icon = $this->object->getTinyIconPath();
2787 
2788  if($a_as_section)
2789  {
2790  $title = new ilFormSectionHeaderGUI();
2791  $title->setTitle($this->lng->txt("icon_settings"));
2792  }
2793  else
2794  {
2795  $title = new ilCustomInputGUI($this->lng->txt("icon_settings"), "");
2796  }
2797  $a_form->addItem($title);
2798 
2799  // big
2800  /*
2801  $caption = $this->lng->txt("big_icon")." (".
2802  $this->ilias->getSetting("custom_icon_big_width")."x".
2803  $this->ilias->getSetting("custom_icon_big_height").")";
2804  $icon = new ilImageFileInputGUI($caption, "cont_big_icon");
2805  $icon->setImage($big_icon);
2806  if($a_as_section)
2807  {
2808  $a_form->addItem($icon);
2809  }
2810  else
2811  {
2812  $title->addSubItem($icon);
2813  }*/
2814 
2815  // small/standard
2816  //if ($this->object->getType() != "root")
2817  //{
2818  /*$caption = $this->lng->txt("standard_icon")." (".
2819  $this->ilias->getSetting("custom_icon_small_width")."x".
2820  $this->ilias->getSetting("custom_icon_small_height").")";*/
2821  $caption = $this->lng->txt("cont_custom_icon");
2822  $icon = new ilImageFileInputGUI($caption, "cont_icon");
2823  $icon->setSuffixes(array("svg"));
2824  $icon->setImage($custom_icon);
2825  if($a_as_section)
2826  {
2827  $a_form->addItem($icon);
2828  }
2829  else
2830  {
2831  $title->addSubItem($icon);
2832  }
2833  //}
2834 
2835  // tiny
2836  /*
2837  $caption = $this->lng->txt("tiny_icon")." (".
2838  $this->ilias->getSetting("custom_icon_tiny_width")."x".
2839  $this->ilias->getSetting("custom_icon_tiny_height").")";
2840  $icon = new ilImageFileInputGUI($caption, "cont_tiny_icon");
2841  $icon->setImage($tiny_icon);
2842  if($a_as_section)
2843  {
2844  $a_form->addItem($icon);
2845  }
2846  else
2847  {
2848  $title->addSubItem($icon);
2849  }
2850  */
2851  }
2852  }
2853  }
2854 
2856  {
2857  global $ilAccess;
2858 
2859  // #10081
2860  if($_SESSION["il_cont_admin_panel"] &&
2861  $this->object->getRefId() &&
2862  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
2863  {
2864  return false;
2865  }
2866 
2867  return $_SESSION["il_cont_admin_panel"];
2868  }
2869 
2873  function setColumnSettings($column_gui)
2874  {
2875  global $ilAccess;
2876  parent::setColumnSettings($column_gui);
2877 
2878  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
2879  $this->isActiveAdministrationPanel() &&
2880  $this->allowBlocksMoving())
2881  {
2882  $column_gui->setEnableMovement(true);
2883  }
2884 
2885  $column_gui->setRepositoryItems(
2886  $this->object->getSubItems($this->isActiveAdministrationPanel(), true));
2887 
2888  //if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
2889  // && $this->allowBlocksConfigure())
2890  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
2891  {
2892  $column_gui->setBlockProperty("news", "settings", true);
2893  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
2894  $column_gui->setBlockProperty("news", "default_visibility_option", true);
2895  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
2896  }
2897 
2898  if ($this->isActiveAdministrationPanel())
2899  {
2900  $column_gui->setAdminCommands(true);
2901  }
2902  }
2903 
2908  {
2909  true;
2910  }
2911 
2916  {
2917  true;
2918  }
2919 
2927  public function cloneWizardPageTreeObject()
2928  {
2929  $this->cloneWizardPageObject(true);
2930  }
2931 
2939  public function cloneWizardPageListObject()
2940  {
2941  $this->cloneWizardPageObject(false);
2942  }
2943 
2950  public function cloneWizardPageObject($a_tree_view = true)
2951  {
2952  include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
2953 
2954  global $ilObjDataCache,$tree;
2955 
2956  if(!$_REQUEST['clone_source'])
2957  {
2958  ilUtil::sendFailure($this->lng->txt('select_one'));
2959  if(isset($_SESSION['wizard_search_title']))
2960  {
2961  $this->searchCloneSourceObject();
2962  }
2963  else
2964  {
2965  $this->createObject();
2966  }
2967  return false;
2968  }
2969  $source_id = $_REQUEST['clone_source'];
2970  $new_type = $_REQUEST['new_type'];
2971  $this->ctrl->setParameter($this,'clone_source',(int) $_REQUEST['clone_source']);
2972  $this->ctrl->setParameter($this,'new_type',$new_type);
2973 
2974 
2975  // Generell JavaScript
2976  $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
2977  $this->tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
2978 
2979 
2980  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.container_wizard_page.html',
2981  "Services/Container");
2982  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
2983  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$new_type.'.svg'));
2984  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$new_type));
2985  $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt($new_type.'_wizard_page'));
2986  $this->tpl->setVariable('INFO_DUPLICATE',$this->lng->txt($new_type.'_copy_threads_info'));
2987  $this->tpl->setVariable('BTN_COPY',$this->lng->txt('obj_'.$new_type.'_duplicate'));
2988  $this->tpl->setVariable('BTN_BACK',$this->lng->txt('btn_back'));
2989  if(isset($_SESSION['wizard_search_title']))
2990  {
2991  $this->tpl->setVariable('CMD_BACK','searchCloneSource');
2992  }
2993  else
2994  {
2995  $this->tpl->setVariable('CMD_BACK','create');
2996  }
2997 
2998  $this->tpl->setVariable('BTN_TREE',$this->lng->txt('treeview'));
2999  $this->tpl->setVariable('BTN_LIST',$this->lng->txt('flatview'));
3000 
3001  // Fill item rows
3002  // tree view
3003  if($a_tree_view)
3004  {
3005  $first = true;
3006  $has_items = false;
3007  foreach($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id),true) as $node)
3008  {
3009  if($first == true)
3010  {
3011  $first = false;
3012  continue;
3013  }
3014 
3015  if($node['type'] == 'rolf')
3016  {
3017  continue;
3018  }
3019 
3020  $has_items = true;
3021 
3022  for($i = $source_node['depth'];$i < $node['depth']; $i++)
3023  {
3024  $this->tpl->touchBlock('padding');
3025  $this->tpl->touchBlock('end_padding');
3026  }
3027  // fill options
3028  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$node['type']);
3029  $copy_wizard_page->fillTreeSelection($node['ref_id'],$node['type'],$node['depth']);
3030 
3031  $this->tpl->setCurrentBlock('tree_row');
3032  $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'.svg'));
3033  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$node['type']));
3034  $this->tpl->setVariable('TREE_TITLE',$node['title']);
3035  $this->tpl->parseCurrentBlock();
3036  }
3037  if(!$has_items)
3038  {
3039  $this->tpl->setCurrentBlock('no_content');
3040  $this->tpl->setVariable('TXT_NO_CONTENT',$this->lng->txt('container_no_items'));
3041  $this->tpl->parseCurrentBlock();
3042  }
3043  else
3044  {
3045  $this->tpl->setCurrentBlock('tree_footer');
3046  $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
3047  $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
3048  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
3049  $this->tpl->parseCurrentBlock();
3050 
3051  }
3052  }
3053  else
3054  {
3055  foreach($tree->getSubTreeTypes($source_id,array('rolf','crs')) as $type)
3056  {
3057  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$type);
3058  if(strlen($html = $copy_wizard_page->getWizardPageBlockHTML()))
3059  {
3060  $this->tpl->setCurrentBlock('obj_row');
3061  $this->tpl->setVariable('ITEM_BLOCK',$html);
3062  $this->tpl->parseCurrentBlock();
3063  }
3064  }
3065  }
3066  }
3067 
3075  public function cloneAllObject()
3076  {
3077  global $ilLog, $ilCtrl;
3078 
3079  include_once('./Services/Link/classes/class.ilLink.php');
3080  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
3081 
3082  global $ilAccess,$ilErr,$rbacsystem,$tree,$ilUser;
3083 
3084  $new_type = $_REQUEST['new_type'];
3085  $ref_id = (int) $_GET['ref_id'];
3086  $clone_source = (int) $_REQUEST['clone_source'];
3087 
3088  if(!$rbacsystem->checkAccess('create', $ref_id,$new_type))
3089  {
3090  $ilErr->raiseError($this->lng->txt('permission_denied'));
3091  }
3092  if(!$clone_source)
3093  {
3094  ilUtil::sendFailure($this->lng->txt('select_one'));
3095  $this->createObject();
3096  return false;
3097  }
3098  if(!$ilAccess->checkAccess('write','', $clone_source,$new_type))
3099  {
3100  $ilErr->raiseError($this->lng->txt('permission_denied'));
3101  }
3102 
3103  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
3104  $orig = ilObjectFactory::getInstanceByRefId($clone_source);
3105  $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
3106 
3107  // Check if copy is in progress
3108  if ($result == $ref_id)
3109  {
3110  ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"),true);
3111  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
3112  $ilCtrl->redirectByClass("ilrepositorygui", "");
3113  }
3114  else
3115  {
3116  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
3117  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $result);
3118  $ilCtrl->redirectByClass("ilrepositorygui", "");
3119  }
3120  }
3121 
3122 
3130  public function saveSortingObject()
3131  {
3132  include_once('Services/Container/classes/class.ilContainerSorting.php');
3133  $sorting = ilContainerSorting::_getInstance($this->object->getId());
3134 
3135  // Allow comma
3136  $positions = str_replace(',','.',$_POST['position']);
3137 
3138  $sorting->savePost($positions);
3139  ilUtil::sendSuccess($this->lng->txt('cntr_saved_sorting'), true);
3140  $this->ctrl->redirect($this, "editOrder");
3141  }
3142 
3143  // BEGIN WebDAV: Support a copy command in the repository
3154  function cloneNodes($srcRef,$dstRef,&$mapping, $newName=null)
3155  {
3156  global $tree;
3157  global $ilias;
3158 
3159  // clone the source node
3160  $srcObj =& $ilias->obj_factory->getInstanceByRefId($srcRef);
3161  error_log(__METHOD__.' cloning srcRef='.$srcRef.' dstRef='.$dstRef.'...');
3162  $newRef = $srcObj->cloneObject($dstRef)->getRefId();
3163  error_log(__METHOD__.' ...cloning... newRef='.$newRef.'...');
3164 
3165  // We must immediately apply a new name to the object, to
3166  // prevent confusion of WebDAV clients about having two objects with identical
3167  // name in the repository.
3168  if (! is_null($newName))
3169  {
3170  $newObj =& $ilias->obj_factory->getInstanceByRefId($newRef);
3171  $newObj->setTitle($newName);
3172  $newObj->update();
3173  unset($newObj);
3174  }
3175  unset($srcObj);
3176  $mapping[$newRef] = $srcRef;
3177 
3178  // clone all children of the source node
3179  $children = $tree->getChilds($srcRef);
3180  foreach ($tree->getChilds($srcRef) as $child)
3181  {
3182  // Don't clone role folders, because it does not make sense to clone local roles
3183  // FIXME - Maybe it does make sense (?)
3184  if ($child["type"] != 'rolf')
3185  {
3186  $this->cloneNodes($child["ref_id"],$newRef,$mapping);
3187  }
3188  else
3189  {
3190  if (count($rolf = $tree->getChildsByType($newRef,"rolf")))
3191  {
3192  $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
3193  }
3194  }
3195  }
3196  error_log(__METHOD__.' ...cloned srcRef='.$srcRef.' dstRef='.$dstRef.' newRef='.$newRef);
3197  return $newRef;
3198  }
3199  // END PATCH WebDAV: Support a copy command in the repository
3200 
3204  function modifyItemGUI(&$a_item_list_gui, $a_item_data, $a_show_path)
3205  {
3206  global $lng;
3207 
3208  if($a_show_path)
3209  {
3210  $a_item_list_gui->addCustomProperty($lng->txt('path'),
3211  ilContainer::buildPath($a_item_data['ref_id'], $this->object->getRefId()),
3212  false, true);
3213  }
3214  }
3215 
3219  static function _buildPath($a_ref_id, $a_course_ref_id)
3220  {
3221  global $tree;
3222 
3223  $path_arr = $tree->getPathFull($a_ref_id, $a_course_ref_id);
3224  $counter = 0;
3225  foreach($path_arr as $data)
3226  {
3227  if($counter++)
3228  {
3229  $path .= " > ";
3230  }
3231  $path .= $data['title'];
3232  }
3233 
3234  return $path;
3235  }
3236 
3237  //
3238  // Style editing
3239  //
3240 
3245  {
3246  global $ilTabs, $tpl;
3247 
3248  $this->checkPermission("write");
3249 
3250  $this->initStylePropertiesForm();
3251  $tpl->setContent($this->form->getHTML());
3252 
3253  $ilTabs->activateTab("obj_sty");
3254  }
3255 
3260  {
3261  global $ilCtrl, $lng, $ilTabs, $ilSetting, $tpl;
3262 
3263  $tpl->setTreeFlatIcon("", "");
3264  $ilTabs->clearTargets();
3265  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
3266  "xhtml_page");
3267  if ($xpage_id > 0)
3268  {
3269  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
3270  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
3271  }
3272  else
3273  {
3274  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
3275  $this->object->getRefId(), "_top");
3276  }
3277 
3278  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
3279  $page_gui = new ilContainerPageGUI($this->object->getId());
3280  $style_id = $this->object->getStyleSheetId();
3281  if (ilObject::_lookupType($style_id) == "sty")
3282  {
3283  $page_gui->setStyleId($style_id);
3284  }
3285  else
3286  {
3287  $style_id = 0;
3288  }
3289  $page_gui->setTabHook($this, "addPageTabs");
3290  $ilCtrl->getHTML($page_gui);
3291  $ilTabs->setTabActive("obj_sty");
3292 
3293  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3294  $lng->loadLanguageModule("style");
3295 
3296  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3297  $this->form = new ilPropertyFormGUI();
3298 
3299  $fixed_style = $ilSetting->get("fixed_content_style_id");
3300 // $style_id = $this->object->getStyleSheetId();
3301 
3302  if ($fixed_style > 0)
3303  {
3304  $st = new ilNonEditableValueGUI($lng->txt("wiki_current_style"));
3305  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
3306  $this->lng->txt("global_fixed").")");
3307  $this->form->addItem($st);
3308  }
3309  else
3310  {
3311  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
3312  $_GET["ref_id"]);
3313 
3314  $st_styles[0] = $this->lng->txt("default");
3315  ksort($st_styles);
3316 
3317  if ($style_id > 0)
3318  {
3319  // individual style
3320  if (!ilObjStyleSheet::_lookupStandard($style_id))
3321  {
3322  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
3323  $st->setValue(ilObject::_lookupTitle($style_id));
3324  $this->form->addItem($st);
3325 
3326 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
3327 
3328  // delete command
3329  $this->form->addCommandButton("editStyle",
3330  $lng->txt("style_edit_style"));
3331  $this->form->addCommandButton("deleteStyle",
3332  $lng->txt("style_delete_style"));
3333 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
3334  }
3335  }
3336 
3337  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
3338  {
3339  $style_sel = ilUtil::formSelect ($style_id, "style_id",
3340  $st_styles, false, true);
3341  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
3342  $style_sel->setOptions($st_styles);
3343  $style_sel->setValue($style_id);
3344  $this->form->addItem($style_sel);
3345 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
3346  $this->form->addCommandButton("saveStyleSettings",
3347  $lng->txt("save"));
3348  $this->form->addCommandButton("createStyle",
3349  $lng->txt("sty_create_ind_style"));
3350  }
3351  }
3352  $this->form->setTitle($lng->txt("obj_sty"));
3353  $this->form->setFormAction($ilCtrl->getFormAction($this));
3354  }
3355 
3360  {
3361  global $ilCtrl;
3362 
3363  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
3364  }
3365 
3369  function editStyleObject()
3370  {
3371  global $ilCtrl;
3372 
3373  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
3374  }
3375 
3380  {
3381  global $ilCtrl;
3382 
3383  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
3384  }
3385 
3390  {
3391  global $ilSetting;
3392 
3393  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3394  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3395  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3396  || $this->object->getStyleSheetId() == 0))
3397  {
3398  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
3399  $this->object->update();
3400  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3401  }
3402  $this->ctrl->redirect($this, "editStyleProperties");
3403  }
3404 
3409  {
3410  global $ilCtrl;
3411 
3412  $ref_id = $_GET["cmdrefid"];
3414  $type = ilObject::_lookupType($obj_id);
3415 
3416  // this should be done via container-object->getSubItem in the future
3417  $data = array("child" => $ref_id, "ref_id" => $ref_id, "obj_id" => $obj_id,
3418  "type" => $type);
3419  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
3420  $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($type);
3421  $item_list_gui->setContainerObject($this);
3422 
3423  $item_list_gui->enableComments(true);
3424  $item_list_gui->enableNotes(true);
3425  $item_list_gui->enableTags(true);
3426 
3427  $this->modifyItemGUI($item_list_gui, $data, false);
3428  $html = $item_list_gui->getListItemHTML($ref_id,
3429  $obj_id, "", "", true, true);
3430 
3431  // include plugin slot for async item list
3432  global $ilPluginAdmin;
3433  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
3434  foreach ($pl_names as $pl)
3435  {
3436  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
3437  $gui_class = $ui_plugin->getUIClassInstance();
3438  $resp = $gui_class->getHTML("Services/Container", "async_item_list", array("html" => $html));
3439  if ($resp["mode"] != ilUIHookPluginGUI::KEEP)
3440  {
3441  $html = $gui_class->modifyHTML($html, $resp);
3442  }
3443  }
3444 
3445  echo $html;
3446  exit;
3447  }
3448 
3453  protected function showPasswordInstructionObject($a_init = true)
3454  {
3455  global $tpl,$ilToolbar;
3456 
3457  if($a_init)
3458  {
3459  ilUtil::sendInfo($this->lng->txt('webdav_pwd_instruction'));
3460  $this->initFormPasswordInstruction();
3461  }
3462 
3463  include_once ('Services/WebDAV/classes/class.ilDAVServer.php');
3464  $davServer = ilDAVServer::getInstance();
3465  $ilToolbar->addButton(
3466  $this->lng->txt('mount_webfolder'),
3467  $davServer->getMountURI($this->object->getRefId()),
3468  '_blank',
3469  '',
3470  $davServer->getFolderURI($this->object->getRefId())
3471  );
3472 
3473  $tpl->setContent($this->form->getHTML());
3474  }
3475 
3480  protected function initFormPasswordInstruction()
3481  {
3482  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3483  $this->form = new ilPropertyFormGUI();
3484  $this->form->setFormAction($this->ctrl->getFormAction($this));
3485 
3486  // new password
3487  $ipass = new ilPasswordInputGUI($this->lng->txt("desired_password"), "new_password");
3488  $ipass->setRequired(true);
3489 
3490  $this->form->addItem($ipass);
3491  $this->form->addCommandButton("savePassword", $this->lng->txt("save"));
3492  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
3493 
3494  $this->form->setTitle($this->lng->txt("chg_ilias_and_webfolder_password"));
3495  $this->form->setFormAction($this->ctrl->getFormAction($this));
3496 
3497  return $this->form;
3498  }
3499 
3504  protected function savePasswordObject()
3505  {
3506  global $ilUser;
3507 
3508  $form = $this->initFormPasswordInstruction();
3509  if($form->checkInput())
3510  {
3511  $ilUser->resetPassword($this->form->getInput('new_password'),$this->form->getInput('new_password'));
3512  ilUtil::sendSuccess($this->lng->txt('webdav_pwd_instruction_success'),true);
3513  $this->showPasswordInstructionObject(false);
3514  return true;
3515  }
3516  $form->setValuesByPost();
3518  }
3519 
3527  {
3528  global $tpl;
3529 
3530  $html = null;
3531 
3532  $item_data = $this->object->getSubItems(false, false, (int) $_GET["child_ref_id"]);
3533  $container_view = $this->getContentGUI();
3534 
3535  // list item is session material (not part of "_all"-items - see below)
3536  include_once './Modules/Session/classes/class.ilEventItems.php';
3537  $event_items = ilEventItems::_getItemsOfContainer($this->object->getRefId());
3538  if(in_array((int)$_GET["child_ref_id"], $event_items))
3539  {
3540  include_once('./Services/Object/classes/class.ilObjectActivation.php');
3541  foreach ($this->object->items["sess"] as $id)
3542  {
3543  $items = ilObjectActivation::getItemsByEvent($id['obj_id']);
3544  foreach($items as $event_item)
3545  {
3546  if ($event_item["child"] == (int)$_GET["child_ref_id"])
3547  {
3548  // sessions
3549  if((int)$_GET["parent_ref_id"])
3550  {
3551  $event_item["parent"] = (int)$_GET["parent_ref_id"];
3552  }
3553  $html = $container_view->renderItem($event_item);
3554  }
3555  }
3556  }
3557  }
3558 
3559  // "normal" list item
3560  if(!$html)
3561  {
3562  foreach ($this->object->items["_all"] as $id)
3563  {
3564  if ($id["child"] == (int) $_GET["child_ref_id"])
3565  {
3566  $html = $container_view->renderItem($id);
3567  }
3568  }
3569  }
3570 
3571  if($html)
3572  {
3573  echo $html;
3574 
3575  // we need to add onload code manually (rating, comments, etc.)
3576  echo $tpl->getOnLoadCodeForAsynch();
3577  }
3578 
3579  exit;
3580  }
3581 
3582  // begin-patch fm
3589  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
3590  {
3591  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
3592 
3593  // begin-patch fm
3594  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
3595  if(ilFMSettings::getInstance()->isEnabled())
3596  {
3597  if($lg instanceof ilObjectListGUI)
3598  {
3599  $lg->addCustomCommand($this->ctrl->getLinkTarget($this,'fileManagerLaunch'), 'fm_start','_blank');
3600  }
3601  }
3602  // end-patch fm
3603  return $lg;
3604  }
3605 
3609  protected function fileManagerLaunchObject()
3610  {
3611  global $ilUser;
3612 
3613  $tpl = new ilTemplate('tpl.fm_launch_ws.html',false,false,'Services/WebServices/FileManager');
3614  $tpl->setVariable('JNLP_URL',ILIAS_HTTP_PATH.'/Services/WebServices/FileManager/lib/dist/FileManager.jnlp');
3615  $tpl->setVariable('SESSION_ID', $_COOKIE['PHPSESSID'].'::'.CLIENT_ID);
3616  $tpl->setVariable('UID',$ilUser->getId());
3617  $tpl->setVariable('REF_ID', $this->object->getRefId());
3618  $tpl->setVariable('WSDL_URI', ILIAS_HTTP_PATH.'/webservice/soap/server.php?wsdl');
3619  $tpl->setVariable('LOCAL_FRAME', ilFMSettings::getInstance()->isLocalFSEnabled() ? 1 : 0);
3620  $tpl->setVariable('REST_URI',ILIAS_HTTP_PATH.'/Services/WebServices/Rest/server.php');
3621  $tpl->setVariable('FILE_LOCKS',0);
3622  $tpl->setVariable('UPLOAD_FILESIZE', ilFMSettings::getInstance()->getMaxFileSize());
3623 
3624  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
3625  $header_top_title = ilObjSystemFolder::_getHeaderTitle();
3626  $tpl->setVariable('HEADER_TITLE',$header_top_title ? $header_top_title : '');
3627  echo $tpl->get();
3628  exit;
3629  }
3630  // begin-patch fm
3631 
3638  function showRepTree($a_initial_call = false)
3639  {
3640  global $tpl, $ilUser, $ilSetting, $ilCtrl;
3641 
3642  // set current repository view mode
3643  if (!empty($_GET["set_mode"]))
3644  {
3645  $_SESSION["il_rep_mode"] = $_GET["set_mode"];
3646  if ($ilUser->getId() != ANONYMOUS_USER_ID)
3647  {
3648  $ilUser->writePref("il_rep_mode", $_GET["set_mode"]);
3649  }
3650  }
3651 
3652  // get user setting
3653  if ($_SESSION["il_rep_mode"] == "")
3654  {
3655  if ($ilUser->getId() != ANONYMOUS_USER_ID)
3656  {
3657  $_SESSION["il_rep_mode"] = $ilUser->getPref("il_rep_mode");
3658  }
3659  }
3660 
3661  // if nothing set, get default view
3662  if ($_SESSION["il_rep_mode"] == "")
3663  {
3664  $_SESSION["il_rep_mode"] = $ilSetting->get("default_repository_view");
3665  }
3666 
3667  $mode = ($_SESSION["il_rep_mode"] != "")
3668  ? $_SESSION["il_rep_mode"]
3669  : "flat";
3670 
3671  // check for administration context, see #0016312
3672  if ($mode == "tree" && (strtolower($_GET["baseClass"]) != "iladministrationgui"))
3673  {
3674  include_once("./Services/Repository/classes/class.ilRepositoryExplorerGUI.php");
3675  $exp = new ilRepositoryExplorerGUI($this, "showRepTree");
3676  if (!$exp->handleCommand())
3677  {
3678  $tpl->setLeftNavContent($exp->getHTML());
3679  }
3680  }
3681  }
3682 
3688  protected function initSortingForm(ilPropertyFormGUI $form, array $a_sorting_settings)
3689  {
3690  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
3691  include_once './Services/Container/classes/class.ilContainer.php';
3692 
3693  $settings = new ilContainerSortingSettings($this->object->getId());
3694  $sort = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'), "sorting");
3695 
3696  if(in_array(ilContainer::SORT_INHERIT, $a_sorting_settings))
3697  {
3698  $sort_inherit = new ilRadioOption();
3699  $sort_inherit->setTitle(
3700  $this->lng->txt('sort_inherit_prefix').
3701  ' ('.ilContainerSortingSettings::sortModeToString(
3703  $this->object->getId())).') '
3704  );
3705  $sort_inherit->setValue(ilContainer::SORT_INHERIT);
3706  $sort_inherit->setInfo($this->lng->txt('sorting_info_inherit'));
3707  $sort->addOption($sort_inherit);
3708  }
3709  if(in_array(ilContainer::SORT_TITLE,$a_sorting_settings))
3710  {
3711  $sort_title = new ilRadioOption(
3712  $this->lng->txt('sorting_title_header'),
3714  );
3715  $sort_title->setInfo($this->lng->txt('sorting_info_title'));
3716 
3717  $this->initSortingDirectionForm($settings,$sort_title,'title');
3718  $sort->addOption($sort_title);
3719  }
3720  if(in_array(ilContainer::SORT_CREATION, $a_sorting_settings))
3721  {
3722  $sort_activation = new ilRadioOption($this->lng->txt('sorting_creation_header'),ilContainer::SORT_CREATION);
3723  $sort_activation->setInfo($this->lng->txt('sorting_creation_info'));
3724  $this->initSortingDirectionForm($settings,$sort_activation,'creation');
3725  $sort->addOption($sort_activation);
3726  }
3727  if(in_array(ilContainer::SORT_ACTIVATION, $a_sorting_settings))
3728  {
3729  $sort_activation = new ilRadioOption($this->lng->txt('crs_sort_activation'),ilContainer::SORT_ACTIVATION);
3730  $sort_activation->setInfo($this->lng->txt('crs_sort_timing_info'));
3731  $this->initSortingDirectionForm($settings,$sort_activation,'activation');
3732  $sort->addOption($sort_activation);
3733  }
3734  if(in_array(ilContainer::SORT_MANUAL, $a_sorting_settings))
3735  {
3736  $sort_manual = new ilRadioOption(
3737  $this->lng->txt('sorting_manual_header'),
3739  );
3740  $sort_manual->setInfo($this->lng->txt('sorting_info_manual'));
3741  $this->initManualSortingOptionForm($settings, $sort_manual, "manual", $a_sorting_settings);
3742  $sort->addOption($sort_manual);
3743  }
3744 
3745  $sort->setValue($settings->getSortMode());
3746  $form->addItem($sort);
3747 
3748  return $form;
3749  }
3750 
3755  protected function initSortingDirectionForm(ilContainerSortingSettings $sorting_settings, $element, $a_prefix)
3756  {
3757  $direction = new ilRadioGroupInputGUI($this->lng->txt('sorting_direction'),$a_prefix.'_sorting_direction');
3758  $direction->setValue($sorting_settings->getSortDirection());
3759  $direction->setRequired(TRUE);
3760 
3761  // asc
3762  $asc = new ilRadioOption(
3763  $this->lng->txt('sorting_asc'),
3765  );
3766  $direction->addOption($asc);
3767 
3768  // desc
3769  $desc = new ilRadioOption(
3770  $this->lng->txt('sorting_desc'),
3772  );
3773  $direction->addOption($desc);
3774 
3775  $element->addSubItem($direction);
3776 
3777  return $element;
3778  }
3779 
3784  protected function initManualSortingOptionForm(ilContainerSortingSettings $settings, $element, $a_prefix,
3785  $a_sorting_settings)
3786  {
3787  $position = new ilRadioGroupInputGUI($this->lng->txt('sorting_new_items_position'),$a_prefix.'_new_items_position');
3788  $position->setValue($settings->getSortNewItemsPosition());
3789  $position->setRequired(TRUE);
3790 
3791  //new items insert on top
3792  $new_top = new ilRadioOption(
3793  $this->lng->txt('sorting_new_items_at_top'),
3795  );
3796 
3797  $position->addOption($new_top);
3798 
3799  //new items insert at bottom
3800  $new_bottom = new ilRadioOption(
3801  $this->lng->txt('sorting_new_items_at_bottom'),
3803  );
3804 
3805  $position->addOption($new_bottom);
3806 
3807  $element->addSubItem($position);
3808 
3809  $order = new ilRadioGroupInputGUI($this->lng->txt('sorting_new_items_order'),$a_prefix.'_new_items_order');
3810  $order->setValue($settings->getSortNewItemsOrder());
3811  $order->setRequired(TRUE);
3812 
3813  if(in_array(ilContainer::SORT_TITLE, $a_sorting_settings))
3814  {
3815  //new items sort in alphabetical order
3816  $new_title = new ilRadioOption(
3817  $this->lng->txt('sorting_title_header'),
3819  );
3820 
3821  $order->addOption($new_title);
3822  }
3823 
3824  if(in_array(ilContainer::SORT_CREATION, $a_sorting_settings))
3825  {
3826  //new items sort by creation date
3827  $new_creation = new ilRadioOption(
3828  $this->lng->txt('sorting_creation_header'),
3830  );
3831 
3832  $order->addOption($new_creation);
3833  }
3834 
3835 
3836  if(in_array(ilContainer::SORT_ACTIVATION, $a_sorting_settings))
3837  {
3838  //new items by activation
3839  $new_activation = new ilRadioOption(
3840  $this->lng->txt('crs_sort_activation'),
3842  );
3843 
3844  $order->addOption($new_activation);
3845  }
3846 
3847  $element->addSubItem($order);
3848 
3849  $this->initSortingDirectionForm($settings,$element,'manual');
3850 
3851  return $element;
3852  }
3853 
3858  protected function saveSortingSettings(ilPropertyFormGUI $form)
3859  {
3860  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
3861  $settings = new ilContainerSortingSettings($this->object->getId());
3862  $settings->setSortMode($form->getInput("sorting"));
3863 
3864  switch($form->getInput('sorting'))
3865  {
3867  $settings->setSortDirection($form->getInput('title_sorting_direction'));
3868  break;
3870  $settings->setSortDirection($form->getInput('activation_sorting_direction'));
3871  break;
3873  $settings->setSortDirection($form->getInput('creation_sorting_direction'));
3874  break;
3876  $settings->setSortNewItemsPosition($form->getInput('manual_new_items_position'));
3877  $settings->setSortNewItemsOrder($form->getInput('manual_new_items_order'));
3878  $settings->setSortDirection($form->getInput('manual_sorting_direction'));
3879  break;
3880  }
3881 
3882  $settings->update();
3883  }
3884 
3890  public function trashObject()
3891  {
3892  global $tpl;
3893 
3894  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3895  $ru = new ilRepUtilGUI($this);
3896  $ru->showTrashTable($_GET["ref_id"]);
3897  }
3898 
3904  public function removeFromSystemObject()
3905  {
3906  global $log, $ilAppEventHandler, $lng;
3907 
3908  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3909  $ru = new ilRepUtilGUI($this);
3910  $ru->removeObjectsFromSystem($_POST["trash_id"]);
3911  $this->ctrl->redirect($this, "trash");
3912  }
3913 
3917  public function undeleteObject()
3918  {
3919  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3920  $ru = new ilRepUtilGUI($this);
3921  $ru->restoreObjects($_GET["ref_id"], $_POST["trash_id"]);
3922  $this->ctrl->redirect($this, "trash");
3923  }
3924 
3929  {
3930  global $lng;
3931  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3932 
3933  if(!isset($_POST["trash_id"]))
3934  {
3935  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3936  $this->ctrl->redirect($this, "trash");
3937  }
3938 
3939  $ru = new ilRepUtilGUI($this);
3940  $ru->confirmRemoveFromSystemObject($_POST["trash_id"]);
3941  }
3942 
3947  protected function getTreeSelectorGUI($cmd)
3948  {
3949  include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
3950  $exp = new ilRepositorySelectorExplorerGUI($this, "showPasteTree");
3951  $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "fold"));
3952  if ($cmd == "link") {
3953  $exp->setSelectMode("nodes", true);
3954  return $exp;
3955  } else {
3956  $exp->setSelectMode("nodes[]", false);
3957  return $exp;
3958  }
3959  }
3960 }
3961 ?>