ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
5 
6 require_once "./Services/Object/classes/class.ilObjectGUI.php";
7 require_once "./Services/Container/classes/class.ilContainer.php";
8 include_once './Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
9 
23 {
27  protected $rbacsystem;
28 
32  protected $tabs;
33 
37  protected $settings;
38 
42  protected $user;
43 
47  protected $db;
48 
52  protected $access;
53 
57  protected $error;
58 
62  protected $obj_definition;
63 
67  protected $rbacadmin;
68 
72  protected $rbacreview;
73 
77  protected $log;
78 
82  protected $obj_data_cache;
83 
87  protected $toolbar;
88 
92  protected $plugin_admin;
93 
97  protected $app_event_handler;
98 
99  public $bl_cnt = 1; // block counter
100  public $multi_download_enabled = false;
101 
105  protected $ui;
106 
111  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
112  {
113  global $DIC;
114 
115  $this->lng = $DIC->language();
116  $this->tpl = $DIC["tpl"];
117  $this->ctrl = $DIC->ctrl();
118  $this->tabs = $DIC->tabs();
119  $this->settings = $DIC->settings();
120  $this->user = $DIC->user();
121  $this->db = $DIC->database();
122  $this->access = $DIC->access();
123  $this->tree = $DIC->repositoryTree();
124  $this->error = $DIC["ilErr"];
125  $this->obj_definition = $DIC["objDefinition"];
126  $this->rbacadmin = $DIC->rbac()->admin();
127  $this->rbacreview = $DIC->rbac()->review();
128  $this->log = $DIC["ilLog"];
129  $this->obj_data_cache = $DIC["ilObjDataCache"];
130  $this->toolbar = $DIC->toolbar();
131  $this->plugin_admin = $DIC["ilPluginAdmin"];
132  $this->app_event_handler = $DIC["ilAppEventHandler"];
133  $this->ui = $DIC->ui();
134  $rbacsystem = $DIC->rbac()->system();
135  $lng = $DIC->language();
136 
137  $this->rbacsystem = $rbacsystem;
138 
139  $lng->loadLanguageModule("cntr");
140  $lng->loadLanguageModule('cont');
141 
142  // prepare output things should generally be made in executeCommand
143  // method (maybe dependent on current class/command
144  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
145  }
146 
151  public function executeCommand()
152  {
153  $tpl = $this->tpl;
154 
155  $next_class = $this->ctrl->getNextClass();
156  $cmd = $this->ctrl->getCmd("render");
157 
158 
159  switch ($next_class) {
160  // page editing
161  case "ilcontainerpagegui":
162  if ($_GET["redirectSource"] != "ilinternallinkgui") {
163  $ret = $this->forwardToPageObject();
164  $tpl->setContent($ret);
165  } else {
166  return "";
167  }
168  break;
169 
170  case "ilobjstylesheetgui":
171  $this->forwardToStyleSheet();
172  break;
173 
174  default:
175  $this->prepareOutput();
176  $cmd .= "Object";
177  $this->$cmd();
178  break;
179  }
180  return true;
181  }
182 
188  protected function getEditFormValues()
189  {
190  $values = parent::getEditFormValues();
191 
192  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
193  $values['didactic_type'] =
194  'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
195 
196  return $values;
197  }
198 
202  protected function afterUpdate()
203  {
204  // check if template is changed
205  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
206  $current_tpl_id = (int) ilDidacticTemplateObjSettings::lookupTemplateId(
207  $this->object->getRefId()
208  );
209  $new_tpl_id = (int) $this->getDidacticTemplateVar('dtpl');
210 
211  if ($new_tpl_id != $current_tpl_id) {
212  $_REQUEST['tplid'] = $new_tpl_id;
213 
214  // redirect to didactic template confirmation
215  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
216  $this->ctrl->setReturn($this, 'edit');
217  $this->ctrl->setCmdClass('ildidactictemplategui');
218  $this->ctrl->setCmd('confirmTemplateSwitch');
219  $dtpl_gui = new ilDidacticTemplateGUI($this);
220  return $this->ctrl->forwardCommand($dtpl_gui);
221  }
222  parent::afterUpdate();
223  }
224 
225 
229  public function forwardToStyleSheet()
230  {
232  $ilTabs = $this->tabs;
233 
234  $ilTabs->clearTargets();
235 
236  $cmd = $ilCtrl->getCmd();
237  include_once("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
238  $this->ctrl->setReturn($this, "editStyleProperties");
239  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
240  $style_gui->omitLocator();
241  if ($cmd == "create" || $_GET["new_type"] == "sty") {
242  $style_gui->setCreationMode(true);
243  }
244 
245  if ($cmd == "confirmedDelete") {
246  $this->object->setStyleSheetId(0);
247  $this->object->update();
248  }
249 
250  $ret = $this->ctrl->forwardCommand($style_gui);
251 
252  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
253  $style_id = $ret;
254  $this->object->setStyleSheetId($style_id);
255  $this->object->update();
256  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
257  }
258  }
259 
260 
264  public function &forwardToPageObject()
265  {
266  $lng = $this->lng;
267  $ilTabs = $this->tabs;
269 
270  $cmd = $ilCtrl->getCmd();
271 
272  if (in_array($cmd, array("displayMediaFullscreen", "downloadFile", "displayMedia"))) {
273  $this->checkPermission("read");
274  } else {
275  $this->checkPermission("write");
276  }
277 
278  $ilTabs->clearTargets();
279 
280  if ($_GET["redirectSource"] == "ilinternallinkgui") {
281  exit;
282  }
283 
285  $this->object->getId(),
286  "xhtml_page"
287  );
288  if ($xpage_id > 0) {
289  $ilTabs->setBackTarget(
290  $lng->txt("cntr_back_to_old_editor"),
291  $ilCtrl->getLinkTarget($this, "switchToOldEditor"),
292  "_top"
293  );
294  } else {
295  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=" . $this->object->getType() . "_" .
296  $this->object->getRefId(), "_top");
297  }
298 
299  // page object
300  include_once("./Services/Container/classes/class.ilContainerPage.php");
301  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
302 
303  $lng->loadLanguageModule("content");
304 
305  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
306  $this->tpl->setVariable(
307  "LOCATION_CONTENT_STYLESHEET",
308  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
309  );
310  $this->tpl->setCurrentBlock("SyntaxStyle");
311  $this->tpl->setVariable(
312  "LOCATION_SYNTAX_STYLESHEET",
314  );
315  $this->tpl->parseCurrentBlock();
316 
318  "cont",
319  $this->object->getId()
320  )) {
321  // doesn't exist -> create new one
322  $new_page_object = new ilContainerPage();
323  $new_page_object->setParentId($this->object->getId());
324  $new_page_object->setId($this->object->getId());
325  $new_page_object->createFromXML();
326  }
327 
328  // get page object
329  $this->ctrl->setReturnByClass("ilcontainerpagegui", "edit");
330  $page_gui = new ilContainerPageGUI($this->object->getId());
331  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
332  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
333  $this->object->getStyleSheetId(),
334  $this->object->getType()
335  ));
336 
337  $page_gui->setTemplateTargetVar("ADM_CONTENT");
338  $page_gui->setFileDownloadLink("");
339  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
340  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
341  $page_gui->setPresentationTitle("");
342  $page_gui->setTemplateOutput(false);
343 
344  // old editor information text
346  $this->object->getId(),
347  "xhtml_page"
348  );
349  if ($xpage_id > 0) {
350  $wtpl = new ilTemplate(
351  "tpl.cntr_old_editor_message.html",
352  true,
353  true,
354  "Services/Container"
355  );
356  $wtpl->setVariable("ALT_WARNING", $lng->txt("warning"));
357  $wtpl->setVariable(
358  "IMG_WARNING",
359  ilUtil::getImagePath("icon_alert.svg")
360  );
361  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
362  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
363  $wtpl->setVariable(
364  "HREF_SWITCH_TO_NEW_EDITOR",
365  $ilCtrl->getLinkTarget($this, "useNewEditor")
366  );
367  $wtpl->setVariable(
368  "TXT_MIGRATION_SWITCH",
369  $lng->txt("cntr_switch_to_new_editor_cmd")
370  );
371  $page_gui->setPrependingHtml($wtpl->get());
372  }
373 
374  // style tab
375  $page_gui->setTabHook($this, "addPageTabs");
376 
377  $ret = $this->ctrl->forwardCommand($page_gui);
378 
379  //$ret =& $page_gui->executeCommand();
380  return $ret;
381  }
382 
386  public function addPageTabs()
387  {
388  $ilTabs = $this->tabs;
390 
391  $ilTabs->addTarget(
392  "obj_sty",
393  $ilCtrl->getLinkTarget($this, 'editStyleProperties'),
394  "editStyleProperties"
395  );
396  }
397 
401  public function getContainerPageHTML()
402  {
405 
406  if (!$ilSetting->get("enable_cat_page_edit")) {
407  return;
408  }
409 
410  // old page editor content
412  $this->object->getId(),
413  "xhtml_page"
414  );
415  if ($xpage_id > 0) {
416  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
417  $xpage = new ilXHTMLPage($xpage_id);
418  return $xpage->getContent();
419  }
420 
421 
422  // page object
423 
424 
425  // if page does not exist, return nothing
426  include_once("./Services/COPage/classes/class.ilPageUtil.php");
428  "cont",
429  $this->object->getId()
430  )) {
431  return "";
432  }
433  include_once("./Services/Container/classes/class.ilContainerPage.php");
434  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
435 
436  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
437  $this->tpl->setVariable(
438  "LOCATION_CONTENT_STYLESHEET",
439  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
440  );
441  $this->tpl->setCurrentBlock("SyntaxStyle");
442  $this->tpl->setVariable(
443  "LOCATION_SYNTAX_STYLESHEET",
445  );
446  $this->tpl->parseCurrentBlock();
447 
448  // get page object
449  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
450  $ot = ilObjectTranslation::getInstance($this->object->getId());
451  $lang = $ot->getEffectiveContentLang($ilUser->getCurrentLanguage(), "cont");
452  $page_gui = new ilContainerPageGUI($this->object->getId(), 0, $lang);
453  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
454  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
455  $this->object->getStyleSheetId(),
456  $this->object->getType()
457  ));
458 
459  $page_gui->setPresentationTitle("");
460  $page_gui->setTemplateOutput(false);
461  $page_gui->setHeader("");
462  $ret = $page_gui->showPage();
463 
464  //$ret = "<div style='background-color: white; padding:5px; margin-bottom: 30px;'>".$ret."</div>";
465 
466  //$ret =& $page_gui->executeCommand();
467  return $ret;
468  }
469 
473  public function prepareOutput($a_show_subobjects = true)
474  {
475  if (parent::prepareOutput($a_show_subobjects)) { // return false in admin mode
476  if ($this->getCreationMode() != true && $a_show_subobjects) {
477  // This method is called directly from ilContainerGUI::renderObject
478  #$this->showPossibleSubObjects();
479  $this->showTreeFlatIcon();
480 
481  // Member view
482  include_once './Services/Container/classes/class.ilMemberViewGUI.php';
483  ilMemberViewGUI::showMemberViewSwitch($this->object->getRefId());
484  }
485  }
486  }
487 
488  public function showTreeFlatIcon()
489  {
490  $tpl = $this->tpl;
491 
492  // dont show icon, if role (permission gui->rolegui) is edited
493  if ($_GET["obj_id"] != "") {
494  return;
495  }
496  // hide for member view
497  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
498  if (ilMemberViewSettings::getInstance()->isActive()) {
499  return;
500  }
501 
502  $mode = ($_SESSION["il_rep_mode"] == "flat")
503  ? "tree"
504  : "flat";
505  $link = "ilias.php?baseClass=ilRepositoryGUI&amp;cmd=frameset&amp;set_mode=" . $mode . "&amp;ref_id=" . $this->object->getRefId();
506  $tpl->setTreeFlatIcon($link, $mode);
507  }
508 
512  public function setTitleAndDescription()
513  {
514  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title")) {
515  $this->tpl->setTitle($this->object->getTitle());
516  $this->tpl->setDescription($this->object->getLongDescription());
517 
518  // set tile icon
519  $icon = ilObject::_getIcon($this->object->getId(), "big", $this->object->getType());
520  $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_" . $this->object->getType()));
521 
522  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
523  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
524  $lgui->initItem($this->object->getRefId(), $this->object->getId());
525  $this->tpl->setAlertProperties($lgui->getAlertProperties());
526  }
527  }
528 
532  public function showPossibleSubObjects()
533  {
534  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
535  $gui = new ilObjectAddNewItemGUI($this->object->getRefId());
536  $gui->render();
537  }
538 
545  public function getContentGUI()
546  {
547  switch ($this->object->getViewMode()) {
548  // all items in one block
550  include_once("./Services/Container/classes/class.ilContainerSimpleContentGUI.php");
551  $container_view = new ilContainerSimpleContentGUI($this);
552  break;
553 
555  include_once('./Services/Container/classes/class.ilContainerObjectiveGUI.php');
556  $container_view = new ilContainerObjectiveGUI($this);
557  break;
558 
559  // all items in one block
561  case ilCourseConstants::IL_CRS_VIEW_TIMING: // not nice this workaround
562  include_once("./Services/Container/classes/class.ilContainerSessionsContentGUI.php");
563  $container_view = new ilContainerSessionsContentGUI($this);
564  break;
565 
566  // all items in one block
568  default:
569  include_once("./Services/Container/classes/class.ilContainerByTypeContentGUI.php");
570  $container_view = new ilContainerByTypeContentGUI($this);
571  break;
572  }
573 
574  return $container_view;
575  }
576 
577 
578 
582  public function renderObject()
583  {
584  $ilDB = $this->db;
585  $tpl = $this->tpl;
586  $ilTabs = $this->tabs;
589 
590  $container_view = $this->getContentGUI();
591 
592  $this->setContentSubTabs();
593  if ($this->isActiveAdministrationPanel()) {
594  $ilTabs->activateSubTab("manage");
595  } else {
596  $ilTabs->activateSubTab("view_content");
597  }
598 
599  $container_view->setOutput();
600 
601  $this->adminCommands = $container_view->adminCommands;
602 
603  // it is important not to show the subobjects/admin panel here, since
604  // we will create nested forms in case, e.g. a news/calendar item is added
605  if ($ilCtrl->getNextClass() != "ilcolumngui") {
606  $this->showAdministrationPanel();
607  $this->showPossibleSubObjects();
608  }
609 
610  $this->showPermanentLink();
611 
612  // add tree updater javascript
613  if ((int) $_GET["ref_id"] > 1 && $ilSetting->get("rep_tree_synchronize")) {
614  $ilCtrl->setParameter($this, "active_node", (int) $_GET["ref_id"]);
615  }
616  }
617 
621  public function renderBlockAsynchObject()
622  {
623  $container_view = $this->getContentGUI();
624  echo $container_view->getSingleTypeBlockAsynch($_GET["type"]);
625  exit;
626  }
627 
628 
632  public function setContentSubTabs()
633  {
635  }
636 
640  public function showAdministrationPanel()
641  {
642  global $DIC;
643 
644  $ilAccess = $this->access;
645  $lng = $this->lng;
646 
647  $main_tpl = $DIC->ui()->mainTemplate();
648 
649  $lng->loadLanguageModule('cntr');
650 
651  if ($_SESSION["clipboard"]) {
652  // #11545
653  $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
654 
655  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
656  $toolbar = new ilToolbarGUI();
657  $this->ctrl->setParameter($this, "type", "");
658  $this->ctrl->setParameter($this, "item_ref_id", "");
659 
660  $toolbar->addFormButton(
661  $this->lng->txt('paste_clipboard_items'),
662  'paste'
663  );
664 
665  $toolbar->addFormButton(
666  $this->lng->txt('clear_clipboard'),
667  'clear'
668  );
669 
670  $main_tpl->addAdminPanelToolbar($toolbar, true, false);
671  } elseif ($this->isActiveAdministrationPanel()) {
672  // #11545
673  $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
674 
675  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
676  $toolbar = new ilToolbarGUI();
677  $this->ctrl->setParameter($this, "type", "");
678  $this->ctrl->setParameter($this, "item_ref_id", "");
679 
680  // if (!$_SESSION["clipboard"])
681  // {
682  if ($this->object->gotItems()) {
683  $toolbar->setLeadingImage(
684  ilUtil::getImagePath("arrow_upright.svg"),
685  $lng->txt("actions")
686  );
687  $toolbar->addFormButton(
688  $this->lng->txt('delete_selected_items'),
689  'delete'
690  );
691  $toolbar->addFormButton(
692  $this->lng->txt('move_selected_items'),
693  'cut'
694  );
695  $toolbar->addFormButton(
696  $this->lng->txt('copy_selected_items'),
697  'copy'
698  );
699  $toolbar->addFormButton(
700  $this->lng->txt('link_selected_items'),
701  'link'
702  );
703  // add download button if multi download enabled
704  $folder_set = new ilSetting("fold");
705  if ($folder_set->get("enable_multi_download") == true) {
706  $toolbar->addSeparator();
707  $this->addDownloadButton($main_tpl, $toolbar);
708  }
709  }
710  if ($this->object->getType() == 'crs' or $this->object->getType() == 'grp') {
711  if ($this->object->gotItems()) {
712  $toolbar->addSeparator();
713  }
714 
715  $toolbar->addButton(
716  $this->lng->txt('cntr_adopt_content'),
717  $this->ctrl->getLinkTargetByClass(
718  'ilObjectCopyGUI',
719  'adoptContent'
720  )
721  );
722  }
723  // }
724  /*else
725  {
726 
727  if ($this->isMultiDownloadEnabled())
728  {
729  $toolbar->addSeparator();
730  $toolbar->addFormButton(
731  $this->lng->txt('download_selected_items'),
732  'download'
733  );
734  }
735  }*/
736 
737  $main_tpl->addAdminPanelToolbar(
738  $toolbar,
739  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false,
740  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false
741  );
742 
743  // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
744  if ($this->object->gotItems()) {
745  $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
746  }
747  } else {
748  if ($this->edit_order) {
749  if ($this->object->gotItems() and $ilAccess->checkAccess("write", "", $this->object->getRefId())) {
750  include_once('./Services/Container/classes/class.ilContainer.php');
751 
752  if ($this->isActiveOrdering()) {
753  // #11843
754  $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
755 
756  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
757  $toolbar = new ilToolbarGUI();
758  $this->ctrl->setParameter($this, "type", "");
759  $this->ctrl->setParameter($this, "item_ref_id", "");
760 
761  $toolbar->addFormButton(
762  $this->lng->txt('sorting_save'),
763  'saveSorting'
764  );
765 
766  $main_tpl->addAdminPanelToolbar($toolbar, true, false);
767  }
768  }
769  }
770  // bugfix mantis 24559
771  // undoing an erroneous change inside mantis 23516 by adding "Download Multiple Objects"-functionality for non-admins
772  // as they don't have the possibility to use the multi-download-capability of the manage-tab
773  elseif ($this->isMultiDownloadEnabled()) {
774  // bugfix mantis 0021272
775  $ref_id = $_GET['ref_id'];
776  $num_files = $this->tree->getChildsByType($ref_id, "file");
777  $num_folders = $this->tree->getChildsByType($ref_id, "fold");
778  if (count($num_files) > 0 or count($num_folders) > 0) {
779  // #11843
780  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
781 
782  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
783  $toolbar = new ilToolbarGUI();
784  $this->ctrl->setParameter($this, "type", "");
785  $this->ctrl->setParameter($this, "item_ref_id", "");
786 
787  $this->addDownloadButton($main_tpl, $toolbar);
788 
789  $GLOBALS['tpl']->addAdminPanelToolbar(
790  $toolbar,
791  $this->object->gotItems() ? true : false,
792  $this->object->gotItems() ? true : false
793  );
794  } else {
795  ilUtil::sendInfo($this->lng->txt('msg_no_downloadable_objects'), true);
796  }
797  }
798  }
799  }
800 
801  private function addDownloadButton(&$tpl, &$toolbar) {
802  $folder_set = new ilSetting("fold");
803  if (!$folder_set->get("bgtask_download", 0)) {
804  $toolbar->addFormButton(
805  $this->lng->txt('download_selected_items'),
806  'download'
807  );
808  } else {
809  $url = $this->ctrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjfoldergui", "ilbackgroundtaskhub"), "", "", true, false);
810  $tpl->addJavaScript("Services/BackgroundTask/js/BgTask.js");
811  $tpl->addOnLoadCode("il.BgTask.initMultiForm('ilFolderDownloadBackgroundTaskHandler');");
812  $tpl->addOnLoadCode('il.BgTask.setAjax("' . $url . '");');
813 
814  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
815  $button = ilSubmitButton::getInstance();
816  $button->setCaption("download_selected_items");
817  $button->addCSSClass("ilbgtasksubmit");
818  $button->setCommand("download");
819  $toolbar->addButtonInstance($button);
820  }
821  }
822 
823  public function __showTimingsButton(&$tpl)
824  {
825  $tree = $this->tree;
826 
827  if (!$tree->checkForParentType($this->object->getRefId(), 'crs')) {
828  return false;
829  }
830  $tpl->setCurrentBlock("custom_button");
831  $tpl->setVariable("ADMIN_MODE_LINK", $this->ctrl->getLinkTargetByClass('ilcoursecontentgui', 'editTimings'));
832  $tpl->setVariable("TXT_ADMIN_MODE", $this->lng->txt('timings_edit'));
833  $tpl->parseCurrentBlock();
834  return true;
835  }
839  public function showPermanentLink()
840  {
841  global $DIC;
842 
843  $tpl = $DIC->ui()->mainTemplate();
844 
845  $tpl->setPermanentLink(
846  $this->object->getType(),
847  $this->object->getRefId(),
848  "",
849  "_top"
850  );
851  }
852 
856  public function switchToStdEditorObject()
857  {
859 
860  $_SESSION["il_cntr_editor"] = "std";
861  $ilCtrl->redirect($this, "editPageFrame");
862  }
863 
867  public function switchToOldEditorObject()
868  {
870 
871  $_SESSION["il_cntr_editor"] = "old";
872  $ilCtrl->redirect($this, "editPageFrame");
873  }
874 
878  public function useNewEditorObject()
879  {
881  $ilAccess = $this->access;
882  $lng = $this->lng;
884 
885  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
886  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
887 
888  /* keep old page content for now...
889  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
890  "xhtml_page");
891  if ($xpage_id)
892  {
893  $xpage = new ilXHTMLPage($xpage_id);
894  }
895  */
896 
898  $this->object->getId(),
899  "xhtml_page",
900  0
901  );
902 
903  ilUtil::sendSuccess($lng->txt("cntr_switched_editor"), true);
904  }
905 
906  $ilCtrl->redirect($this, "editPageFrame");
907  }
908 
912  public function editPageFrameObject()
913  {
914  // old tiny stuff
916  $this->object->getId(),
917  "xhtml_page"
918  );
919  if ($xpage_id > 0 && $_SESSION["il_cntr_editor"] != "std") {
920  $this->ctrl->redirect($this, "editPageContent");
921  } else {
922  $this->ctrl->redirectByClass(array("ilcontainerpagegui"), "edit");
923  }
924  }
925 
931  public function editPageContentObject()
932  {
934  $tpl = $this->tpl;
935  $lng = $this->lng;
938 
939  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
940  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
941  }
942 
944  $this->object->getId(),
945  "xhtml_page"
946  );
947  if ($xpage_id > 0) {
948  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
949  $xpage = new ilXHTMLPage($xpage_id);
950  $content = $xpage->getContent();
951  }
952 
953  // get template
954  $tpl->addBlockFile(
955  "ADM_CONTENT",
956  "adm_content",
957  "tpl.container_edit_page_content.html",
958  "Services/Container"
959  );
960  $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
961  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
962  $tpl->setVariable(
963  "TXT_EDIT_PAGE_CONTENT",
964  $this->lng->txt("edit_page_content")
965  );
966  $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
967  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
968  $tpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_old_editor_warning"));
969  $tpl->setVariable("TXT_MIGRATION_OPEN_STD_EDITOR", $lng->txt("cntr_old_editor_open_standard_editor"));
970  $tpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert.svg"));
971  $tpl->setVariable("HREF_OPEN_STD_EDITOR", $ilCtrl->getLinkTarget($this, "switchToStdEditor"));
972  $tpl->setVariable("ALT_WARNING", $lng->txt("warning"));
973 
974  include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
975  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
976  //$ta = new ilTextAreaInputGUI();
977  //$tags = $ta->getRteTagSet("extended_table_img");
978 
979  // add rte support
980  include_once "./Services/RTE/classes/class.ilRTE.php";
981  $rtestring = ilRTE::_getRTEClassname();
982  include_once "./Services/RTE/classes/class.$rtestring.php";
983  $rte = new $rtestring();
984  //$rte->addPlugin("latex");
985  include_once "./Services/Object/classes/class.ilObject.php";
987  $obj_type = ilObject::_lookupType($_GET["ref_id"], true);
988  $rte->addRTESupport($obj_id, $obj_type);
989  //$rte->setStyleSelect(true);
990  //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
991  }
992 
993  public function savePageContentObject()
994  {
995  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
996  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
998  $this->object->getId(),
999  "xhtml_page"
1000  );
1001 
1002  /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
1003  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
1004  $ta = new ilTextAreaInputGUI();
1005  $ta->setRteTagSet("extended_table_img");
1006  $tags = $ta->getRteTagString();*/
1007 
1008  //$text = ilUtil::stripSlashes($_POST["page_content"],
1009  // true,
1010  // $tags);
1011 
1013  $_POST["page_content"],
1014  true,
1016  );
1017  if ($xpage_id > 0) {
1018  $xpage = new ilXHTMLPage($xpage_id);
1019  $xpage->setContent($text);
1020  $xpage->save();
1021  } else {
1022  $xpage = new ilXHTMLPage();
1023  $xpage->setContent($text);
1024  $xpage->save();
1026  $this->object->getId(),
1027  "xhtml_page",
1028  $xpage->getId()
1029  );
1030  }
1031 
1032  include_once("Services/RTE/classes/class.ilRTE.php");
1034  $text,
1035  $this->object->getType() . ":html",
1036  $this->object->getId()
1037  );
1038 
1039  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1040  $this->ctrl->redirect($this, "");
1041  }
1042 
1043  public function cancelPageContentObject()
1044  {
1045  $this->ctrl->redirect($this, "");
1046  }
1047 
1048  public function showLinkListObject()
1049  {
1050  $lng = $this->lng;
1051  $tree = $this->tree;
1052 
1053  $tpl = new ilTemplate(
1054  "tpl.container_link_help.html",
1055  true,
1056  true,
1057  "Services/Container"
1058  );
1059 
1060  $type_ordering = array(
1061  "cat", "fold", "crs", "grp", "chat", "frm", "lres",
1062  "glo", "webr", "file", "exc",
1063  "tst", "svy", "mep", "qpl", "spl");
1064 
1065  $childs = $tree->getChilds($_GET["ref_id"]);
1066  foreach ($childs as $child) {
1067  if (in_array($child["type"], array("lm", "sahs", "htlm"))) {
1068  $cnt["lres"]++;
1069  } else {
1070  $cnt[$child["type"]]++;
1071  }
1072  }
1073 
1074  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1075  $tpl->setVariable("TXT_HELP_HEADER", $lng->txt("help"));
1076  foreach ($type_ordering as $type) {
1077  $tpl->setCurrentBlock("row");
1078  $tpl->setVariable("ROWCOL", "tblrow" . ((($i++) % 2) + 1));
1079  if ($type != "lres") {
1080  $tpl->setVariable("TYPE", $lng->txt("objs_" . $type) .
1081  " (" . ((int) $cnt[$type]) . ")");
1082  } else {
1083  $tpl->setVariable("TYPE", $lng->txt("obj_lrss") .
1084  " (" . ((int) $cnt["lres"]) . ")");
1085  }
1086  $tpl->setVariable("TXT_LINK", "[list-" . $type . "]");
1087  $tpl->parseCurrentBlock();
1088  }
1089  $tpl->show();
1090  exit;
1091  }
1092 
1097  {
1098  $this->adminCommands = false;
1099  }
1100 
1104  /* function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
1105  {
1106  if (!$this->adminCommands)
1107  {
1108  if (!$this->isActiveAdministrationPanel())
1109  {
1110  if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
1111  {
1112  $this->adminCommands = true;
1113  }
1114  }
1115  else
1116  {
1117  $this->adminCommands = $a_admin_com_included_in_list;
1118  }
1119  }
1120  }*/
1121 
1128  public function &newBlockTemplate()
1129  {
1130  $tpl = new ilTemplate(
1131  "tpl.container_list_block.html",
1132  true,
1133  true,
1134  "Services/Container"
1135  );
1136  $this->cur_row_type = "row_type_1";
1137  return $tpl;
1138  }
1139 
1147  public function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1148  {
1149  $icon = ilUtil::getImagePath("icon_" . $a_type . ".svg");
1150  $title = $this->lng->txt("objs_" . $a_type);
1151 
1152  if ($a_show_image) {
1153  $a_tpl->setCurrentBlock("container_header_row_image");
1154  $a_tpl->setVariable("HEADER_IMG", $icon);
1155  $a_tpl->setVariable("HEADER_ALT", $title);
1156  } else {
1157  $a_tpl->setCurrentBlock("container_header_row");
1158  }
1159 
1160  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1161  $a_tpl->parseCurrentBlock();
1162  //$a_tpl->touchBlock("container_row");
1163  }
1164 
1172  public function addStandardRow(
1173  &$a_tpl,
1174  $a_html,
1175  $a_item_ref_id = "",
1176  $a_item_obj_id = "",
1177  $a_image_type = ""
1178  ) {
1180 
1181  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1182  ? "row_type_2"
1183  : "row_type_1";
1184 
1185  $a_tpl->touchBlock($this->cur_row_type);
1186 
1187  $nbsp = true;
1188  if ($ilSetting->get("icon_position_in_lists") == "item_rows") {
1189  $icon = ilUtil::getImagePath("icon_" . $a_image_type . ".svg");
1190  $alt = $this->lng->txt("obj_" . $a_image_type);
1191 
1192  if ($ilSetting->get('custom_icons')) {
1193  global $DIC;
1195  $customIconFactory = $DIC['object.customicons.factory'];
1196  $customIcon = $customIconFactory->getPresenterByObjId($a_item_obj_id, $a_image_type);
1197 
1198  if ($customIcon->exists()) {
1199  $icon = $customIcon->getFullPath();
1200  }
1201  }
1202 
1203  $a_tpl->setCurrentBlock("block_row_image");
1204  $a_tpl->setVariable("ROW_IMG", $icon);
1205  $a_tpl->setVariable("ROW_ALT", $alt);
1206  $a_tpl->parseCurrentBlock();
1207  $nbsp = false;
1208  }
1209 
1210  if ($this->isActiveAdministrationPanel()) {
1211  $a_tpl->setCurrentBlock("block_row_check");
1212  $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
1213  $a_tpl->parseCurrentBlock();
1214  $nbsp = false;
1215  }
1216  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1217  if ($this->isActiveAdministrationPanel() &&
1219  $a_tpl->setCurrentBlock('block_position');
1220  $a_tpl->setVariable('POS_TYPE', $a_image_type);
1221  $a_tpl->setVariable('POS_ID', $a_item_ref_id);
1222  $a_tpl->setVariable('POSITION', sprintf('%.1f', $this->current_position++));
1223  $a_tpl->parseCurrentBlock();
1224  }
1225  if ($nbsp) {
1226  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1227  }
1228  $a_tpl->setCurrentBlock("container_standard_row");
1229  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1230  $a_tpl->parseCurrentBlock();
1231  $a_tpl->touchBlock("container_row");
1232  }
1233 
1237  public function addMessageRow(&$a_tpl, $a_message, $a_type)
1238  {
1239  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1240  ? "row_type_2"
1241  : "row_type_1";
1242 
1243  $a_tpl->touchBlock($this->cur_row_type);
1244 
1245  $type = $this->lng->txt("obj_" . $a_type);
1246  $a_message = str_replace("[type]", $type, $a_message);
1247 
1248  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1249 
1250  $a_tpl->setCurrentBlock("container_standard_row");
1251  $a_tpl->setVariable(
1252  "BLOCK_ROW_CONTENT",
1253  $a_message
1254  );
1255  $a_tpl->parseCurrentBlock();
1256  $a_tpl->touchBlock("container_row");
1257  }
1258 
1259  public function resetRowType()
1260  {
1261  $this->cur_row_type = "";
1262  }
1263 
1264 
1268  public function setPageEditorTabs()
1269  {
1270  $lng = $this->lng;
1271 
1272  if (!$this->isActiveAdministrationPanel()
1273  || strtolower($this->ctrl->getCmdClass()) != "ilcontainerpagegui") {
1274  return;
1275  }
1276 
1277  $lng->loadLanguageModule("content");
1278  //$tabs_gui = new ilTabsGUI();
1279  //$tabs_gui->setSubTabs();
1280 
1281  // back to upper context
1282  $this->tabs_gui->setBackTarget(
1283  $this->lng->txt("obj_cat"),
1284  $this->ctrl->getLinkTarget($this, "frameset"),
1285  ilFrameTargetInfo::_getFrame("MainContent")
1286  );
1287 
1288  $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilcontainerpagegui", "view"), array("", "view"), "ilcontainerpagegui");
1289 
1290  //$this->tpl->setTabs($tabs_gui->getHTML());
1291  }
1292 
1296  public function addStandardContainerSubTabs($a_include_view = true)
1297  {
1298  $ilTabs = $this->tabs;
1299  $ilAccess = $this->access;
1300  $lng = $this->lng;
1301  $ilCtrl = $this->ctrl;
1302  $ilUser = $this->user;
1304 
1305  if (!is_object($this->object)) {
1306  return;
1307  }
1308 
1309  if ($a_include_view && $ilAccess->checkAccess("read", "", $this->object->getRefId())) {
1310  if (!$this->isActiveAdministrationPanel()) {
1311  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "view"));
1312  } else {
1313  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "disableAdministrationPanel"));
1314  }
1315  }
1316 
1317  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1318  (
1319  $this->adminCommands ||
1320  (is_object($this->object) &&
1321  ($ilAccess->checkAccess("write", "", $this->object->getRefId())))
1322  ||
1323  (is_object($this->object) &&
1324  ($this->object->getHiddenFilesFound())) ||
1325  $_SESSION["clipboard"]
1326  )
1327  ) {
1328  if ($this->isActiveAdministrationPanel()) {
1329  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, ""));
1330  } else {
1331  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, "enableAdministrationPanel"));
1332  }
1333  }
1334  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1335  is_object($this->object) &&
1336  $ilAccess->checkAccess("write", "", $this->object->getRefId()) /* &&
1337  $this->object->getOrderType() == ilContainer::SORT_MANUAL */ // always on because of custom block order
1338  ) {
1339  $ilTabs->addSubTab("ordering", $lng->txt("cntr_ordering"), $ilCtrl->getLinkTarget($this, "editOrder"));
1340  }
1341  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1342  is_object($this->object) &&
1343  $ilAccess->checkAccess("write", "", $this->object->getRefId())
1344  ) {
1345  if ($ilSetting->get("enable_cat_page_edit")) {
1346  $ilTabs->addSubTab(
1347  "page_editor",
1348  $lng->txt("cntr_text_media_editor"),
1349  $ilCtrl->getLinkTarget($this, "editPageFrame"),
1350  ilFrameTargetInfo::_getFrame("MainContent")
1351  );
1352  }
1353  }
1354  }
1355 
1356 
1361  public function getTabs()
1362  {
1364  $ilCtrl = $this->ctrl;
1365 
1366  // edit permissions
1367  if ($rbacsystem->checkAccess('edit_permission', $this->ref_id)) {
1368  $this->tabs_gui->addTarget(
1369  "perm_settings",
1370  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1371  array("perm","info","owner"),
1372  'ilpermissiongui'
1373  );
1374  if ($ilCtrl->getNextClass() == "ilpermissiongui") {
1375  $this->tabs_gui->activateTab("perm_settings");
1376  }
1377  }
1378 
1379  // show clipboard
1380  if (strtolower($_GET["baseClass"]) == "ilrepositorygui" && !empty($_SESSION["clipboard"])) {
1381  $this->tabs_gui->addTarget(
1382  "clipboard",
1383  $this->ctrl->getLinkTarget($this, "clipboard"),
1384  "clipboard",
1385  get_class($this)
1386  );
1387  }
1388  }
1389 
1390  //*****************
1391  // COMMON METHODS (may be overwritten in derived classes
1392  // if special handling is necessary)
1393  //*****************
1394 
1399  {
1400  $_SESSION["il_cont_admin_panel"] = true;
1401  $this->ctrl->redirect($this, "render");
1402  }
1403 
1408  {
1409  $_SESSION["il_cont_admin_panel"] = false;
1410  $this->ctrl->redirect($this, "render");
1411  }
1412 
1416  public function editOrderObject()
1417  {
1418  $ilTabs = $this->tabs;
1419 
1420  $this->edit_order = true;
1421  $_SESSION["il_cont_admin_panel"] = false;
1422  $this->renderObject();
1423 
1424  $ilTabs->activateSubTab("ordering");
1425  }
1426 
1431  public function isActiveOrdering()
1432  {
1433  return $this->edit_order ? true : false;
1434  }
1435 
1440  public function isActiveItemOrdering()
1441  {
1442  if ($this->isActiveOrdering()) {
1443  return (ilContainerSortingSettings::_lookupSortMode($this->object->getId()) == ilContainer::SORT_MANUAL);
1444  }
1445  return false;
1446  }
1447 
1451  public function addToDeskObject()
1452  {
1454  $lng = $this->lng;
1455 
1456  if ((int) $ilSetting->get('disable_my_offers')) {
1457  return $this->renderObject();
1458  }
1459 
1460  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1462  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
1463  $this->renderObject();
1464  }
1465 
1469  public function removeFromDeskObject()
1470  {
1472  $lng = $this->lng;
1473 
1474  if ((int) $ilSetting->get('disable_my_offers')) {
1475  return $this->renderObject();
1476  }
1477 
1478  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1480  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
1481  $this->renderObject();
1482  }
1483 
1484  // bugfix mantis 24559
1485  // undoing an erroneous change inside mantis 23516 by adding "Download Multiple Objects"-functionality for non-admins
1486  // as they don't have the possibility to use the multi-download-capability of the manage-tab
1487  public function enableMultiDownloadObject()
1488  {
1489  $this->multi_download_enabled = true;
1490  $this->renderObject();
1491  }
1492 
1493  public function isMultiDownloadEnabled()
1494  {
1496  }
1497 
1504  public function cutObject()
1505  {
1507  $ilCtrl = $this->ctrl;
1508  $ilErr = $this->error;
1509 
1510  if ($_GET["item_ref_id"] != "") {
1511  $_POST["id"] = array($_GET["item_ref_id"]);
1512  }
1513 
1514  $no_cut = [];
1515 
1516  if (!isset($_POST["id"])) {
1517  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1518  }
1519 
1520  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1521  foreach ($_POST["id"] as $ref_id) {
1522  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1523  $node_data = $this->tree->getNodeData($ref_id);
1524  $subtree_nodes = $this->tree->getSubTree($node_data);
1525 
1526  $all_node_data[] = $node_data;
1527  $all_subtree_nodes[] = $subtree_nodes;
1528 
1529  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1530  foreach ($subtree_nodes as $node) {
1531  if ($node['type'] == 'rolf') {
1532  continue;
1533  }
1534 
1535  if (!$rbacsystem->checkAccess('delete', $node["ref_id"])) {
1536  $no_cut[] = $node["ref_id"];
1537  }
1538  }
1539  }
1540  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1541  if (count($no_cut)) {
1542  $titles = array();
1543  foreach ((array) $no_cut as $cut_id) {
1544  $titles[] = ilObject::_lookupTitle(ilObject::_lookupObjId($cut_id));
1545  }
1546  $ilErr->raiseError(
1547  $this->lng->txt("msg_no_perm_cut") . " " . implode(',', (array) $titles),
1548  $ilErr->MESSAGE
1549  );
1550  }
1551  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1552  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1553  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1554 
1555  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
1556 
1557  return $this->initAndDisplayMoveIntoObjectObject();
1558  } // END CUT
1559 
1567  public function copyObject()
1568  {
1570  $ilCtrl = $this->ctrl;
1572  $ilErr = $this->error;
1573 
1574  $no_copy = [];
1575 
1576  if ($_GET["item_ref_id"] != "") {
1577  $_POST["id"] = array($_GET["item_ref_id"]);
1578  }
1579 
1580  if (!isset($_POST["id"])) {
1581  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1582  }
1583 
1584  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1585  $containers = 0;
1586  foreach ($_POST["id"] as $ref_id) {
1587  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1588  $node_data = $this->tree->getNodeData($ref_id);
1589 
1590  // count containers
1591  if ($objDefinition->isContainer($node_data["type"])) {
1592  $containers++;
1593  }
1594 
1595  $subtree_nodes = $this->tree->getSubTree($node_data);
1596 
1597  $all_node_data[] = $node_data;
1598  $all_subtree_nodes[] = $subtree_nodes;
1599 
1600  // CHECK COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1601  foreach ($subtree_nodes as $node) {
1602  if ($node['type'] == 'rolf') {
1603  continue;
1604  }
1605 
1606  if (!$rbacsystem->checkAccess('visible,read,copy', $node["ref_id"])) {
1607  $no_copy[] = $node["ref_id"];
1608  }
1609  }
1610  }
1611 
1612  if ($containers > 0 && count($_POST["id"]) > 1) {
1613  $ilErr->raiseError($this->lng->txt("cntr_container_only_on_their_own"), $ilErr->MESSAGE);
1614  }
1615 
1616  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1617  if (is_array($no_copy) && count($no_copy)) {
1618  $titles = array();
1619  foreach ((array) $no_copy as $copy_id) {
1620  $titles[] = ilObject::_lookupTitle(ilObject::_lookupObjId($copy_id));
1621  }
1622  $ilErr->raiseError(
1623  $this->lng->txt("msg_no_perm_copy") . " " . implode(',', $titles),
1624  $ilErr->MESSAGE
1625  );
1626  }
1627 
1628  // if we have a single container, set it as source id and redirect to ilObjectCopyGUI
1629  if (count($_POST["id"]) == 1) {
1630  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $_POST["id"][0]);
1631  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1632  } else {
1633  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode("_", $_POST["id"]));
1634  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1635  }
1636 
1637  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1638  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1639  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1640 
1641  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"), true);
1642 
1644  } // END COPY
1645 
1646  public function downloadObject()
1647  {
1649  $ilErr = $this->error;
1650 
1651  $no_download = [];
1652  $no_perm = [];
1653 
1654  if ($_GET["item_ref_id"] != "") {
1655  $_POST["id"] = array($_GET["item_ref_id"]);
1656  }
1657 
1658  if (!isset($_POST["id"])) {
1659  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1660  }
1661 
1662  // FOR ALL OBJECTS THAT SHOULD BE DOWNLOADED
1663  foreach ($_POST["id"] as $ref_id) {
1665  $obj_type = $object->getType();
1666  if (!in_array($obj_type, array("fold", "file"))) {
1667  $no_download[] = $object->getType();
1668  } elseif (!$rbacsystem->checkAccess('read', $ref_id)) {
1669  $no_perm[] = $ref_id;
1670  }
1671  }
1672 
1673  // IF THERE IS ANY OBJECT THAT CANNOT BE DOWNLOADED
1674  if (count($no_download)) {
1675  $no_download = array_unique($no_download);
1676  foreach ($no_download as $type) {
1677  $txt_objs[] = $this->lng->txt("objs_" . $type);
1678  }
1679  $ilErr->raiseError(implode(', ', $txt_objs) . " " . $this->lng->txt("msg_obj_no_download"), $ilErr->MESSAGE);
1680  }
1681 
1682  // NO ACCESS
1683  if (count($no_perm)) {
1684  $ilErr->raiseError(
1685  $this->lng->txt("msg_obj_perm_download") . " " . implode(',', $no_perm),
1686  $ilErr->MESSAGE
1687  );
1688  }
1689 
1690  // download the objects
1691  $this->downloadMultipleObjects($_POST["id"]);
1692  }
1693 
1694  private function downloadMultipleObjects($a_ref_ids)
1695  {
1696  $lng = $this->lng;
1698  $ilAccess = $this->access;
1699 
1700  include_once 'Modules/Folder/classes/class.ilObjFolder.php';
1701  include_once 'Modules/File/classes/class.ilObjFile.php';
1702  include_once 'Modules/File/classes/class.ilFileException.php';
1703 
1704  // create temporary file to download
1705  $zip = PATH_TO_ZIP;
1706  $tmpdir = ilUtil::ilTempnam();
1707  ilUtil::makeDir($tmpdir);
1708 
1709  try {
1710  // copy each selected object
1711  foreach ($a_ref_ids as $ref_id) {
1712  if (!$ilAccess->checkAccess("read", "", $ref_id)) {
1713  continue;
1714  }
1715 
1716  if (ilObject::_isInTrash($ref_id)) {
1717  continue;
1718  }
1719 
1720  // get object
1722  $obj_type = $object->getType();
1723  if ($obj_type == "fold") {
1724  // copy folder to temp directory
1725  self::recurseFolder($ref_id, $object->getTitle(), $tmpdir);
1726  } elseif ($obj_type == "file") {
1727  // copy file to temp directory
1728  self::copyFile($object->getId(), $object->getTitle(), $tmpdir);
1729  }
1730  }
1731 
1732  // compress the folder
1733  $deliverFilename = ilUtil::getAsciiFilename($this->object->getTitle()) . ".zip";
1734  $tmpzipfile = ilUtil::ilTempnam() . ".zip";
1735  ilUtil::zip($tmpdir, $tmpzipfile, true);
1736  ilUtil::delDir($tmpdir);
1737  ilUtil::deliverFile($tmpzipfile, $deliverFilename, '', false, true, true);
1738  } catch (ilFileException $e) {
1739  ilUtil::sendInfo($e->getMessage(), true);
1740  }
1741  }
1742 
1751  private static function recurseFolder($refid, $title, $tmpdir)
1752  {
1753  global $DIC;
1754 
1755  $rbacsystem = $DIC->rbac()->system();
1756  $tree = $DIC->repositoryTree();
1757  $ilAccess = $DIC->access();
1758 
1759  $tmpdir = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1760  ilUtil::makeDir($tmpdir);
1761 
1762  $subtree = $tree->getChildsByTypeFilter($refid, array("fold","file"));
1763 
1764  foreach ($subtree as $child) {
1765  if (!$ilAccess->checkAccess("read", "", $child["ref_id"])) {
1766  continue;
1767  }
1768 
1769  if (ilObject::_isInTrash($child["ref_id"])) {
1770  continue;
1771  }
1772 
1773  if ($child["type"] == "fold") {
1774  self::recurseFolder($child["ref_id"], $child["title"], $tmpdir);
1775  } else {
1776  self::copyFile($child["obj_id"], $child["title"], $tmpdir);
1777  }
1778  }
1779  }
1780 
1781  private static function copyFile($obj_id, $title, $tmpdir)
1782  {
1783  $newFilename = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1784 
1785  // copy to temporary directory
1786  $oldFilename = ilObjFile::_lookupAbsolutePath($obj_id);
1787 
1788  if (!copy($oldFilename, $newFilename)) {
1789  throw new ilFileException("Could not copy " . $oldFilename . " to " . $newFilename);
1790  }
1791 
1792  touch($newFilename, filectime($oldFilename));
1793  }
1794 
1801  public function linkObject()
1802  {
1804  $ilCtrl = $this->ctrl;
1805  $ilErr = $this->error;
1806 
1807  $no_cut = [];
1808  $no_link = [];
1809 
1810  if ($_GET["item_ref_id"] != "") {
1811  $_POST["id"] = array($_GET["item_ref_id"]);
1812  }
1813 
1814  if (!isset($_POST["id"])) {
1815  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1816  }
1817 
1818  // CHECK ACCESS
1819  foreach ($_POST["id"] as $ref_id) {
1820  if (!$rbacsystem->checkAccess('delete', $ref_id)) {
1821  $no_cut[] = $ref_id;
1822  }
1823 
1825 
1826  if (!$this->objDefinition->allowLink($object->getType())) {
1827  $no_link[] = $object->getType();
1828  }
1829  }
1830 
1831  // NO ACCESS
1832  if (count($no_cut)) {
1833  $ilErr->raiseError($this->lng->txt("msg_no_perm_link") . " " .
1834  implode(',', $no_cut), $ilErr->MESSAGE);
1835  }
1836 
1837  if (count($no_link)) {
1838  //#12203
1839  $ilErr->raiseError($this->lng->txt("msg_obj_no_link"), $ilErr->MESSAGE);
1840  }
1841 
1842  // WRITE TO CLIPBOARD
1843  $clipboard["parent"] = $_GET["ref_id"];
1844  $clipboard["cmd"] = $ilCtrl->getCmd();
1845 
1846  foreach ($_POST["id"] as $ref_id) {
1847  $clipboard["ref_ids"][] = $ref_id;
1848  }
1849 
1850  $_SESSION["clipboard"] = $clipboard;
1851 
1852  $suffix = 'p';
1853  if (count($clipboard["ref_ids"]) == 1) {
1854  $suffix = 's';
1855  }
1856  ilUtil::sendInfo($this->lng->txt("msg_link_clipboard_" . $suffix), true);
1857 
1859  } // END LINK
1860 
1861 
1867  public function clearObject()
1868  {
1869  unset($_SESSION["clipboard"]);
1870  unset($_SESSION["il_rep_clipboard"]);
1871 
1872  //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1873 
1874  // only redirect if clipboard was cleared
1875  if (isset($_POST["cmd"]["clear"])) {
1876  ilUtil::sendSuccess($this->lng->txt("msg_clear_clipboard"), true);
1877  // fixed mantis 0018474: Clear Clipboard redirects to Subtab View, instead of Subtab "Edit Multiple"
1878  $this->ctrl->redirect($this, 'render');
1879  }
1880  }
1881 
1883  {
1887  $ilLog = $this->log;
1888  $tree = $this->tree;
1889  $ilObjDataCache = $this->obj_data_cache;
1890  $ilUser = $this->user;
1891  $ilErr = $this->error;
1892  $lng = $this->lng;
1893  $ctrl = $this->ctrl;
1894  $ui = $this->ui;
1895 
1896  $exists = [];
1897  $is_child = [];
1898  $not_allowed_subobject = [];
1899  $no_paste = [];
1900 
1901  $command = $_SESSION['clipboard']['cmd'];
1902  if (!in_array($command, array('cut', 'link', 'copy'))) {
1903  $message = __METHOD__ . ": cmd was neither 'cut', 'link' nor 'copy'; may be a hack attempt!";
1904  $ilErr->raiseError($message, $ilErr->WARNING);
1905  }
1906 
1907  if ($command == 'cut') {
1908  if (isset($_POST['node']) && (int) $_POST['node']) {
1909  $_POST['nodes'] = array($_POST['node']);
1910  }
1911  }
1912 
1913  if (!is_array($_POST['nodes']) || !count($_POST['nodes'])) {
1914  ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'));
1915  switch ($command) {
1916  case 'cut':
1917  $this->showPasteTreeObject();
1918  break;
1919  case 'copy':
1920  $this->showPasteTreeObject();
1921  break;
1922  case 'link':
1923  $this->showPasteTreeObject();
1924  break;
1925  }
1926  return;
1927  }
1928 
1929  // this loop does all checks
1930  $folder_objects_cache = array();
1931  foreach ($_SESSION['clipboard']['ref_ids'] as $ref_id) {
1932  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
1933  $current_parent_id = $tree->getParentId($obj_data->getRefId());
1934 
1935  foreach ($_POST['nodes'] as $folder_ref_id) {
1936  if (!array_key_exists($folder_ref_id, $folder_objects_cache)) {
1937  $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id);
1938  }
1939 
1940  // CHECK ACCESS
1941  if (!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType())) {
1942  $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() . ']');
1943  }
1944 
1945  // CHECK IF REFERENCE ALREADY EXISTS
1946  if ($folder_ref_id == $current_parent_id) {
1947  $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() . ']');
1948  }
1949 
1950  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1951  if ($tree->isGrandChild($ref_id, $folder_ref_id) ||
1952  $ref_id == $folder_ref_id) {
1953  $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']');
1954  }
1955 
1956  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
1957  if (!in_array($obj_data->getType(), array_keys($folder_objects_cache[$folder_ref_id]->getPossibleSubObjects()))) {
1958  $not_allowed_subobject[] = sprintf(
1959  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
1960  $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']',
1961  $lng->txt('obj_' . $obj_data->getType())
1962  );
1963  }
1964  }
1965  }
1966 
1968  // process checking results
1969  if (count($exists) && $command != "copy") {
1970  $error .= implode('<br />', $exists);
1971  }
1972 
1973  if (count($is_child)) {
1974  $error .= $error != '' ? '<br />' : '';
1975  $error .= implode('<br />', $is_child);
1976  }
1977 
1978  if (count($not_allowed_subobject)) {
1979  $error .= $error != '' ? '<br />' : '';
1980  $error .= implode('<br />', $not_allowed_subobject);
1981  }
1982 
1983  if (count($no_paste)) {
1984  $error .= $error != '' ? '<br />' : '';
1985  $error .= implode('<br />', $no_paste);
1986  }
1987 
1988  if ($error != '') {
1990  switch ($command) {
1991  case 'cut':
1992  $this->showPasteTreeObject();
1993  break;
1994  case 'copy':
1995  $this->showPasteTreeObject();
1996  break;
1997  case 'link':
1998  $this->showPasteTreeObject();
1999  break;
2000  }
2001  return;
2002  }
2003 
2004  // log pasteObject call
2005  $ilLog->write(__METHOD__ . ", cmd: " . $command);
2006 
2008  // everything ok: now paste the objects to new location
2009 
2010  // to prevent multiple actions via back/reload button
2011  $ref_ids = $_SESSION['clipboard']['ref_ids'];
2012  unset($_SESSION['clipboard']['ref_ids']);
2013 
2014  // BEGIN ChangeEvent: Record paste event.
2015  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2016  // END ChangeEvent: Record paste event.
2017 
2018  // process COPY command
2019  if ($command == 'copy') {
2020  foreach ($_POST['nodes'] as $folder_ref_id) {
2021  foreach ($ref_ids as $ref_id) {
2022  $revIdMapping = array();
2023 
2024  $oldNode_data = $tree->getNodeData($ref_id);
2025  if ($oldNode_data['parent'] == $folder_ref_id) {
2026  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2027  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'], null);
2028  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, $newTitle);
2029  } else {
2030  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, null);
2031  }
2032 
2033  // BEGIN ChangeEvent: Record copy event.
2034  $old_parent_data = $tree->getParentNodeData($ref_id);
2035  $newNode_data = $tree->getNodeData($newRef);
2037  $oldNode_data['type'],
2038  $ref_id,
2039  $oldNode_data['obj_id'],
2040  $ilUser->getId()
2041  );
2043  $newNode_data['obj_id'],
2044  $ilUser->getId(),
2045  'add',
2046  $ilObjDataCache->lookupObjId($folder_ref_id)
2047  );
2048  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2049  // END PATCH ChangeEvent: Record cut event.
2050  }
2051  }
2052 
2053  ilUtil::sendSuccess($this->lng->txt('msg_cloned'), true);
2054  } // END COPY
2055 
2056  // process CUT command
2057  if ($command == 'cut') {
2058  foreach ($_POST['nodes'] as $folder_ref_id) {
2059  foreach ($ref_ids as $ref_id) {
2060  // Store old parent
2061  $old_parent = $tree->getParentId($ref_id);
2062  $tree->moveTree($ref_id, $folder_ref_id);
2063  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
2064 
2065  include_once('./Services/Conditions/classes/class.ilConditionHandler.php');
2067 
2068  // BEGIN ChangeEvent: Record cut event.
2069  $node_data = $tree->getNodeData($ref_id);
2070  $old_parent_data = $tree->getNodeData($old_parent);
2072  $node_data['obj_id'],
2073  $ilUser->getId(),
2074  'remove',
2075  $old_parent_data['obj_id']
2076  );
2078  $node_data['obj_id'],
2079  $ilUser->getId(),
2080  'add',
2081  $ilObjDataCache->lookupObjId($folder_ref_id)
2082  );
2083  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2084  // END PATCH ChangeEvent: Record cut event.
2085  }
2086 
2087  // prevent multiple iterations for cut cmommand
2088  break;
2089  }
2090 
2091  ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
2092  } // END CUT
2093 
2094  // process LINK command
2095  if ($command == 'link') {
2096  $linked_to_folders = array();
2097 
2098  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
2099  $rbac_log_active = ilRbacLog::isActive();
2100 
2101  foreach ($_POST['nodes'] as $folder_ref_id) {
2102  $linked_to_folders[$folder_ref_id] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id));
2103 
2104  foreach ($ref_ids as $ref_id) {
2105  // get node data
2106  $top_node = $tree->getNodeData($ref_id);
2107 
2108  // get subnodes of top nodes
2109  $subnodes[$ref_id] = $tree->getSubtree($top_node);
2110  }
2111 
2112  // now move all subtrees to new location
2113  foreach ($subnodes as $key => $subnode) {
2114  // first paste top_node....
2116  $new_ref_id = $obj_data->createReference();
2117  $obj_data->putInTree($folder_ref_id);
2118  $obj_data->setPermissions($folder_ref_id);
2119 
2120  // rbac log
2121  if ($rbac_log_active) {
2122  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
2123  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
2124  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, $key);
2125  }
2126 
2127  // BEGIN ChangeEvent: Record link event.
2128  $node_data = $tree->getNodeData($new_ref_id);
2130  $node_data['obj_id'],
2131  $ilUser->getId(),
2132  'add',
2133  $ilObjDataCache->lookupObjId($folder_ref_id)
2134  );
2135  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2136  // END PATCH ChangeEvent: Record link event.
2137  }
2138 
2139  $ilLog->write(__METHOD__ . ', link finished');
2140  }
2141 
2142  $linked_targets = array();
2143  $links = [];
2144  if (count($linked_to_folders)) {
2145  require_once 'Services/Link/classes/class.ilLink.php';
2146  foreach ($linked_to_folders as $ref_id => $title) {
2147  $linked_targets[] = '<a href="' . ilLink::_getLink($ref_id) . '">' . $title . '</a>';
2148  $links[] = $ui->factory()->link()->standard($title, ilLink::_getLink($ref_id));
2149  }
2150  }
2151 
2152  $suffix = 'p';
2153  if (count($ref_ids) == 1) {
2154  $suffix = 's';
2155  }
2156 
2157  $mbox = $ui->factory()->messageBox()->success($this->lng->txt('mgs_objects_linked_to_the_following_folders_' . $suffix))
2158  ->withLinks($links);
2159 
2160  ilUtil::sendSuccess($ui->renderer()->render($mbox), true);
2161  } // END LINK
2162 
2163  // clear clipboard
2164  $this->clearObject();
2165 
2166  $this->ctrl->returnToParent($this);
2167  }
2168 
2170  {
2171  $tree = $this->tree;
2172 
2173  // empty session on init
2174  $_SESSION['paste_linked_repexpand'] = array();
2175 
2176  // copy opend nodes from repository explorer
2177  $_SESSION['paste_linked_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2178 
2179  // open current position
2180  $path = $tree->getPathId((int) $_GET['ref_id']);
2181  foreach ((array) $path as $node_id) {
2182  if (!in_array($node_id, $_SESSION['paste_linked_repexpand'])) {
2183  $_SESSION['paste_linked_repexpand'][] = $node_id;
2184  }
2185  }
2186 
2187  return $this->showPasteTreeObject();
2188  }
2189 
2193  public function showPasteTreeObject()
2194  {
2195  $ilTabs = $this->tabs;
2196  $ilToolbar = $this->toolbar;
2197  $ilErr = $this->error;
2198 
2199  $ilTabs->setTabActive('view_content');
2200 
2201  if (!in_array($_SESSION['clipboard']['cmd'], array('link', 'copy', 'cut'))) {
2202  $message = __METHOD__ . ": Unknown action.";
2203  $ilErr->raiseError($message, $ilErr->WARNING);
2204  }
2205  $cmd = $_SESSION['clipboard']['cmd'];
2206 
2207  //
2208  $exp = $this->getTreeSelectorGUI($cmd);
2209  if ($exp->handleCommand()) {
2210  return;
2211  }
2212  $output = $exp->getHTML();
2213 
2214  $txt_var = ($cmd == "copy")
2215  ? "copy"
2216  : "paste";
2217 
2218  // toolbars
2219  $t = new ilToolbarGUI();
2220  $t->setFormAction($this->ctrl->getFormAction($this, "performPasteIntoMultipleObjects"));
2221 
2222  include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
2224  $b->setCaption($txt_var);
2225  $b->setCommand("performPasteIntoMultipleObjects");
2226 
2227  //$t->addFormButton($this->lng->txt($txt_var), "performPasteIntoMultipleObjects");
2228  $t->addStickyItem($b);
2229 
2230  $t->addSeparator();
2231  $this->lng->loadLanguageModule('obj');
2232  $t->addFormButton($this->lng->txt("obj_insert_into_clipboard"), "keepObjectsInClipboard");
2233 
2234  $t->addFormButton($this->lng->txt("cancel"), "cancelMoveLink");
2235  $t->setCloseFormTag(false);
2236  $t->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), " ");
2237  $output = $t->getHTML() . $output;
2238  $t->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), " ");
2239  $t->setCloseFormTag(true);
2240  $t->setOpenFormTag(false);
2241  $output .= "<br />" . $t->getHTML();
2242 
2243  $this->tpl->setContent($output);
2244  }
2245 
2246 
2251  public function cancelMoveLinkObject()
2252  {
2253  $ilCtrl = $this->ctrl;
2254 
2255  unset($_SESSION['clipboard']);
2256  $ilCtrl->returnToParent($this);
2257  }
2258 
2263  {
2264  $ilCtrl = $this->ctrl;
2265 
2266  ilUtil::sendSuccess($this->lng->txt("obj_inserted_clipboard"), true);
2267  $ilCtrl->returnToParent($this);
2268  }
2269 
2270 
2272  {
2273  $tree = $this->tree;
2274 
2275  // empty session on init
2276  $_SESSION['paste_copy_repexpand'] = array();
2277 
2278  // copy opend nodes from repository explorer
2279  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2280 
2281  // open current position
2282  $path = $tree->getPathId((int) $_GET['ref_id']);
2283  foreach ((array) $path as $node_id) {
2284  if (!in_array($node_id, $_SESSION['paste_copy_repexpand'])) {
2285  $_SESSION['paste_copy_repexpand'][] = $node_id;
2286  }
2287  }
2288 
2289  return $this->showPasteTreeObject();
2290  }
2291 
2292 
2294  {
2295  $tree = $this->tree;
2296 
2297  // empty session on init
2298  $_SESSION['paste_cut_repexpand'] = array();
2299 
2300  // copy opend nodes from repository explorer
2301  $_SESSION['paste_cut_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2302 
2303  // open current position
2304  $path = $tree->getPathId((int) $_GET['ref_id']);
2305  foreach ((array) $path as $node_id) {
2306  if (!in_array($node_id, $_SESSION['paste_cut_repexpand'])) {
2307  $_SESSION['paste_cut_repexpand'][] = $node_id;
2308  }
2309  }
2310 
2311  return $this->showPasteTreeObject();
2312  }
2313 
2314 
2321  public function pasteObject()
2322  {
2325  $ilLog = $this->log;
2326  $tree = $this->tree;
2327  $ilUser = $this->user;
2328  $ilCtrl = $this->ctrl;
2329  $ilErr = $this->error;
2330 
2331  $exists = [];
2332  $no_paste = [];
2333  $is_child = [];
2334  $not_allowed_subobject = [];
2335 
2336  // BEGIN ChangeEvent: Record paste event.
2337  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2338  // END ChangeEvent: Record paste event.
2339 
2340  //var_dump($_SESSION["clipboard"]);exit;
2341  if (!in_array($_SESSION["clipboard"]["cmd"], array("cut","link","copy"))) {
2342  $message = get_class($this) . "::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
2343  $ilErr->raiseError($message, $ilErr->WARNING);
2344  }
2345 
2346  // this loop does all checks
2347  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id) {
2348  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
2349 
2350  // CHECK ACCESS
2351  if (!$rbacsystem->checkAccess('create', $this->object->getRefId(), $obj_data->getType())) {
2352  $no_paste[] = $ref_id;
2353  $no_paste_titles[] = $obj_data->getTitle();
2354  }
2355 
2356  // CHECK IF REFERENCE ALREADY EXISTS
2357  if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId())) {
2358  $exists[] = $ref_id;
2359  break;
2360  }
2361 
2362  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
2363  if ($this->tree->isGrandChild($ref_id, $this->object->getRefId())) {
2364  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2365  }
2366 
2367  if ($ref_id == $this->object->getRefId()) {
2368  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2369  }
2370 
2371  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
2372  $obj_type = $obj_data->getType();
2373 
2374  if (!in_array($obj_type, array_keys($this->object->getPossibleSubObjects()))) {
2375  $not_allowed_subobject[] = $obj_data->getType();
2376  }
2377  }
2378 
2380  // process checking results
2381  // BEGIN WebDAV: Copying an object into the same container is allowed
2382  if (count($exists) > 0 && $_SESSION["clipboard"]["cmd"] != "copy") {
2383  // END WebDAV: Copying an object into the same container is allowed
2384  $ilErr->raiseError($this->lng->txt("msg_obj_exists"), $ilErr->MESSAGE);
2385  }
2386 
2387  if (count($is_child) > 0) {
2388  $ilErr->raiseError(
2389  $this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child),
2390  $ilErr->MESSAGE
2391  );
2392  }
2393 
2394  if (count($not_allowed_subobject) > 0) {
2395  $ilErr->raiseError(
2396  $this->lng->txt("msg_may_not_contain") . " " . implode(',', $not_allowed_subobject),
2397  $ilErr->MESSAGE
2398  );
2399  }
2400 
2401  if (count($no_paste) > 0) {
2402  $ilErr->raiseError($this->lng->txt("msg_no_perm_paste") . " " .
2403  implode(',', $no_paste), $ilErr->MESSAGE);
2404  }
2405 
2406  // log pasteObject call
2407  $ilLog->write("ilObjectGUI::pasteObject(), cmd: " . $_SESSION["clipboard"]["cmd"]);
2408 
2410  // everything ok: now paste the objects to new location
2411 
2412  // to prevent multiple actions via back/reload button
2413  $ref_ids = $_SESSION["clipboard"]["ref_ids"];
2414  unset($_SESSION["clipboard"]["ref_ids"]);
2415 
2416  // BEGIN WebDAV: Support a copy command in the repository
2417  // process COPY command
2418  if ($_SESSION["clipboard"]["cmd"] == "copy") {
2419  unset($_SESSION["clipboard"]["cmd"]);
2420 
2421  // new implementation, redirects to ilObjectCopyGUI
2422  if (count($ref_ids) == 1) {
2423  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2424  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $ref_ids[0]);
2425  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2426  } else {
2427  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2428  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode("_", $ref_ids));
2429  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2430  }
2431 
2432 
2433 
2434  /* old implementation
2435 
2436  foreach($ref_ids as $ref_id)
2437  {
2438  $revIdMapping = array();
2439 
2440  $oldNode_data = $tree->getNodeData($ref_id);
2441  if ($oldNode_data['parent'] == $this->object->getRefId())
2442  {
2443  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2444  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
2445  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
2446  }
2447  else
2448  {
2449  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
2450  }
2451 
2452  // BEGIN ChangeEvent: Record copy event.
2453  $old_parent_data = $tree->getParentNodeData($ref_id);
2454  $newNode_data = $tree->getNodeData($newRef);
2455  ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
2456  $oldNode_data['obj_id'], $ilUser->getId());
2457  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
2458  $this->object->getId());
2459  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2460  // END ChangeEvent: Record copy event.
2461  }*/
2462 
2463  $ilLog->write("ilObjectGUI::pasteObject(), copy finished");
2464  }
2465  // END WebDAV: Support a Copy command in the repository
2466 
2467  // process CUT command
2468  if ($_SESSION["clipboard"]["cmd"] == "cut") {
2469  foreach ($ref_ids as $ref_id) {
2470  // Store old parent
2471  $old_parent = $tree->getParentId($ref_id);
2472  $this->tree->moveTree($ref_id, $this->object->getRefId());
2473  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
2474 
2475  include_once('./Services/Conditions/classes/class.ilConditionHandler.php');
2477 
2478  // BEGIN ChangeEvent: Record cut event.
2479  $node_data = $tree->getNodeData($ref_id);
2480  $old_parent_data = $tree->getNodeData($old_parent);
2482  $node_data['obj_id'],
2483  $ilUser->getId(),
2484  'remove',
2485  $old_parent_data['obj_id']
2486  );
2488  $node_data['obj_id'],
2489  $ilUser->getId(),
2490  'add',
2491  $this->object->getId()
2492  );
2493  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2494  // END PATCH ChangeEvent: Record cut event.
2495  }
2496  } // END CUT
2497 
2498  // process LINK command
2499  if ($_SESSION["clipboard"]["cmd"] == "link") {
2500  foreach ($ref_ids as $ref_id) {
2501  // get node data
2502  $top_node = $this->tree->getNodeData($ref_id);
2503 
2504  // get subnodes of top nodes
2505  $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
2506  }
2507 
2508  // now move all subtrees to new location
2509  foreach ($subnodes as $key => $subnode) {
2510  // first paste top_node....
2511  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
2512  $new_ref_id = $obj_data->createReference();
2513  $obj_data->putInTree($_GET["ref_id"]);
2514  $obj_data->setPermissions($_GET["ref_id"]);
2515 
2516  // BEGIN ChangeEvent: Record link event.
2517  $node_data = $tree->getNodeData($new_ref_id);
2519  $node_data['obj_id'],
2520  $ilUser->getId(),
2521  'add',
2522  $this->object->getId()
2523  );
2524  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2525  // END PATCH ChangeEvent: Record link event.
2526  }
2527 
2528  $ilLog->write("ilObjectGUI::pasteObject(), link finished");
2529  } // END LINK
2530 
2531  // save cmd for correct message output after clearing the clipboard
2532  $last_cmd = $_SESSION["clipboard"]["cmd"];
2533 
2534 
2535  // clear clipboard
2536  $this->clearObject();
2537 
2538  if ($last_cmd == "cut") {
2539  ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"), true);
2540  }
2541  // BEGIN WebDAV: Support a copy command in repository
2542  elseif ($last_cmd == "copy") {
2543  ilUtil::sendSuccess($this->lng->txt("msg_cloned"), true);
2544  } elseif ($last_cmd == 'link') {
2545  // END WebDAV: Support copy command in repository
2546  ilUtil::sendSuccess($this->lng->txt("msg_linked"), true);
2547  }
2548 
2549  $this->ctrl->returnToParent($this);
2550  } // END PASTE
2551 
2552 
2556  public function clipboardObject()
2557  {
2558  $ilErr = $this->error;
2559  $ilLog = $this->log;
2560  $ilTabs = $this->tabs;
2561  $tpl = $this->tpl;
2562  $ilToolbar = $this->toolbar;
2563  $ilCtrl = $this->ctrl;
2564  $lng = $this->lng;
2565 
2566  $ilTabs->activateTab("clipboard");
2567 
2568  // function should not be called if clipboard is empty
2569  if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard'])) {
2570  $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
2571  $ilLog->write($message, $ilLog->FATAL);
2572  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->WARNING);
2573  }
2574 
2575  $data = array();
2576  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id) {
2577  if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
2578  continue;
2579  }
2580 
2581  $data[] = array(
2582  "type" => $tmp_obj->getType(),
2583  "type_txt" => $this->lng->txt("obj_" . $tmp_obj->getType()),
2584  "title" => $tmp_obj->getTitle(),
2585  "cmd" => ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]),
2586  "ref_id" => $ref_id,
2587  "obj_id" => $tmp_obj->getId()
2588  );
2589 
2590  unset($tmp_obj);
2591  }
2592 
2593  include_once("./Services/Object/classes/class.ilObjClipboardTableGUI.php");
2594  $tab = new ilObjClipboardTableGUI($this, "clipboard");
2595  $tab->setData($data);
2596  $tpl->setContent($tab->getHTML());
2597 
2598  if (count($data) > 0) {
2599  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
2600  $ilToolbar->addFormButton(
2601  $lng->txt("insert_object_here"),
2602  "paste"
2603  );
2604  $ilToolbar->addFormButton(
2605  $lng->txt("clear_clipboard"),
2606  "clear"
2607  );
2608  }
2609 
2610  return true;
2611  }
2612 
2614  {
2615  $ilAccess = $this->access;
2616 
2617  // #10081
2618  if ($_SESSION["il_cont_admin_panel"] &&
2619  $this->object->getRefId() &&
2620  !$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
2621  return false;
2622  }
2623 
2624  return $_SESSION["il_cont_admin_panel"];
2625  }
2626 
2630  public function setColumnSettings(ilColumnGUI $column_gui)
2631  {
2632  $ilAccess = $this->access;
2633  parent::setColumnSettings($column_gui);
2634 
2635  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
2636  $this->isActiveAdministrationPanel() &&
2637  $this->allowBlocksMoving()) {
2638  $column_gui->setEnableMovement(true);
2639  }
2640 
2641  $column_gui->setRepositoryItems(
2642  $this->object->getSubItems($this->isActiveAdministrationPanel(), true)
2643  );
2644 
2645  //if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
2646  // && $this->allowBlocksConfigure())
2647  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
2648  $column_gui->setBlockProperty("news", "settings", true);
2649  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
2650  $column_gui->setBlockProperty("news", "default_visibility_option", true);
2651  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
2652  }
2653 
2654  if ($this->isActiveAdministrationPanel()) {
2655  $column_gui->setAdminCommands(true);
2656  }
2657  }
2658 
2662  public function allowBlocksMoving()
2663  {
2664  return true;
2665  }
2666 
2670  public function allowBlocksConfigure()
2671  {
2672  return true;
2673  }
2674 
2682  public function cloneWizardPageTreeObject()
2683  {
2684  $this->cloneWizardPageObject(true);
2685  }
2686 
2694  public function cloneWizardPageListObject()
2695  {
2696  $this->cloneWizardPageObject(false);
2697  }
2698 
2705  public function cloneWizardPageObject($a_tree_view = true)
2706  {
2707  include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
2708 
2709  $ilObjDataCache = $this->obj_data_cache;
2710  $tree = $this->tree;
2711 
2712  if (!$_REQUEST['clone_source']) {
2713  ilUtil::sendFailure($this->lng->txt('select_one'));
2714  if (isset($_SESSION['wizard_search_title'])) {
2715  $this->searchCloneSourceObject();
2716  } else {
2717  $this->createObject();
2718  }
2719  return false;
2720  }
2721  $source_id = $_REQUEST['clone_source'];
2722  $new_type = $_REQUEST['new_type'];
2723  $this->ctrl->setParameter($this, 'clone_source', (int) $_REQUEST['clone_source']);
2724  $this->ctrl->setParameter($this, 'new_type', $new_type);
2725 
2726 
2727  // Generell JavaScript
2728  $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
2729  $this->tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
2730 
2731 
2732  $this->tpl->addBlockFile(
2733  'ADM_CONTENT',
2734  'adm_content',
2735  'tpl.container_wizard_page.html',
2736  "Services/Container"
2737  );
2738  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
2739  $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_' . $new_type . '.svg'));
2740  $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_' . $new_type));
2741  $this->tpl->setVariable('TXT_DUPLICATE', $this->lng->txt($new_type . '_wizard_page'));
2742  $this->tpl->setVariable('INFO_DUPLICATE', $this->lng->txt($new_type . '_copy_threads_info'));
2743  $this->tpl->setVariable('BTN_COPY', $this->lng->txt('obj_' . $new_type . '_duplicate'));
2744  $this->tpl->setVariable('BTN_BACK', $this->lng->txt('btn_back'));
2745  if (isset($_SESSION['wizard_search_title'])) {
2746  $this->tpl->setVariable('CMD_BACK', 'searchCloneSource');
2747  } else {
2748  $this->tpl->setVariable('CMD_BACK', 'create');
2749  }
2750 
2751  $this->tpl->setVariable('BTN_TREE', $this->lng->txt('treeview'));
2752  $this->tpl->setVariable('BTN_LIST', $this->lng->txt('flatview'));
2753 
2754  // Fill item rows
2755  // tree view
2756  if ($a_tree_view) {
2757  $first = true;
2758  $has_items = false;
2759  foreach ($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id), true) as $node) {
2760  if ($first == true) {
2761  $first = false;
2762  continue;
2763  }
2764 
2765  if ($node['type'] == 'rolf') {
2766  continue;
2767  }
2768 
2769  $has_items = true;
2770 
2771  for ($i = $source_node['depth'];$i < $node['depth']; $i++) {
2772  $this->tpl->touchBlock('padding');
2773  $this->tpl->touchBlock('end_padding');
2774  }
2775  // fill options
2776  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id, $node['type']);
2777  $copy_wizard_page->fillTreeSelection($node['ref_id'], $node['type'], $node['depth']);
2778 
2779  $this->tpl->setCurrentBlock('tree_row');
2780  $this->tpl->setVariable('TREE_IMG', ilUtil::getImagePath('icon_' . $node['type'] . '.svg'));
2781  $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $node['type']));
2782  $this->tpl->setVariable('TREE_TITLE', $node['title']);
2783  $this->tpl->parseCurrentBlock();
2784  }
2785  if (!$has_items) {
2786  $this->tpl->setCurrentBlock('no_content');
2787  $this->tpl->setVariable('TXT_NO_CONTENT', $this->lng->txt('container_no_items'));
2788  $this->tpl->parseCurrentBlock();
2789  } else {
2790  $this->tpl->setCurrentBlock('tree_footer');
2791  $this->tpl->setVariable('TXT_COPY_ALL', $this->lng->txt('copy_all'));
2792  $this->tpl->setVariable('TXT_LINK_ALL', $this->lng->txt('link_all'));
2793  $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('omit_all'));
2794  $this->tpl->parseCurrentBlock();
2795  }
2796  } else {
2797  foreach ($tree->getSubTreeTypes($source_id, array('rolf','crs')) as $type) {
2798  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id, $type);
2799  if (strlen($html = $copy_wizard_page->getWizardPageBlockHTML())) {
2800  $this->tpl->setCurrentBlock('obj_row');
2801  $this->tpl->setVariable('ITEM_BLOCK', $html);
2802  $this->tpl->parseCurrentBlock();
2803  }
2804  }
2805  }
2806  }
2807 
2815  public function cloneAllObject()
2816  {
2817  $ilLog = $this->log;
2818  $ilCtrl = $this->ctrl;
2819 
2820  include_once('./Services/Link/classes/class.ilLink.php');
2821  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
2822 
2823  $ilAccess = $this->access;
2824  $ilErr = $this->error;
2826  $tree = $this->tree;
2827  $ilUser = $this->user;
2828 
2829  $new_type = $_REQUEST['new_type'];
2830  $ref_id = (int) $_GET['ref_id'];
2831  $clone_source = (int) $_REQUEST['clone_source'];
2832 
2833  if (!$rbacsystem->checkAccess('create', $ref_id, $new_type)) {
2834  $ilErr->raiseError($this->lng->txt('permission_denied'));
2835  }
2836  if (!$clone_source) {
2837  ilUtil::sendFailure($this->lng->txt('select_one'));
2838  $this->createObject();
2839  return false;
2840  }
2841  if (!$ilAccess->checkAccess('write', '', $clone_source, $new_type)) {
2842  $ilErr->raiseError($this->lng->txt('permission_denied'));
2843  }
2844 
2845  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
2846  $orig = ilObjectFactory::getInstanceByRefId($clone_source);
2847  $result = $orig->cloneAllObject($_COOKIE[session_name()], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
2848 
2849  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
2850  if (ilCopyWizardOptions::_isFinished($result['copy_id'])) {
2851  ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
2852  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $result['ref_id']);
2853  $ilCtrl->redirectByClass("ilrepositorygui", "");
2854  } else {
2855  ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"), true);
2856  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
2857  $ilCtrl->redirectByClass("ilrepositorygui", "");
2858  }
2859  }
2860 
2861 
2869  public function saveSortingObject()
2870  {
2871  include_once('Services/Container/classes/class.ilContainerSorting.php');
2872  $sorting = ilContainerSorting::_getInstance($this->object->getId());
2873 
2874  // Allow comma
2875  $positions = str_replace(',', '.', $_POST['position']);
2876 
2877  $sorting->savePost($positions);
2878  ilUtil::sendSuccess($this->lng->txt('cntr_saved_sorting'), true);
2879  $this->ctrl->redirect($this, "editOrder");
2880  }
2881 
2882  // BEGIN WebDAV: Support a copy command in the repository
2893  public function cloneNodes($srcRef, $dstRef, &$mapping, $newName = null)
2894  {
2895  $tree = $this->tree;
2896 
2897  // clone the source node
2898  $srcObj = ilObjectFactory::getInstanceByRefId($srcRef);
2899  error_log(__METHOD__ . ' cloning srcRef=' . $srcRef . ' dstRef=' . $dstRef . '...');
2900  $newRef = $srcObj->cloneObject($dstRef)->getRefId();
2901  error_log(__METHOD__ . ' ...cloning... newRef=' . $newRef . '...');
2902 
2903  // We must immediately apply a new name to the object, to
2904  // prevent confusion of WebDAV clients about having two objects with identical
2905  // name in the repository.
2906  if (!is_null($newName)) {
2907  $newObj = ilObjectFactory::getInstanceByRefId($newRef);
2908  $newObj->setTitle($newName);
2909  $newObj->update();
2910  unset($newObj);
2911  }
2912  unset($srcObj);
2913  $mapping[$newRef] = $srcRef;
2914 
2915  // clone all children of the source node
2916  $children = $tree->getChilds($srcRef);
2917  foreach ($tree->getChilds($srcRef) as $child) {
2918  // Don't clone role folders, because it does not make sense to clone local roles
2919  // FIXME - Maybe it does make sense (?)
2920  if ($child["type"] != 'rolf') {
2921  $this->cloneNodes($child["ref_id"], $newRef, $mapping);
2922  } else {
2923  if (count($rolf = $tree->getChildsByType($newRef, "rolf"))) {
2924  $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
2925  }
2926  }
2927  }
2928  error_log(__METHOD__ . ' ...cloned srcRef=' . $srcRef . ' dstRef=' . $dstRef . ' newRef=' . $newRef);
2929  return $newRef;
2930  }
2931  // END PATCH WebDAV: Support a copy command in the repository
2932 
2939  public function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
2940  {
2941  $lng = $this->lng;
2942 
2943  if ($a_show_path) {
2944  $a_item_list_gui->addCustomProperty(
2945  $lng->txt('path'),
2946  ilContainer::buildPath($a_item_data['ref_id'], $this->object->getRefId()),
2947  false,
2948  true
2949  );
2950  }
2951  }
2952 
2956  public static function _buildPath($a_ref_id, $a_course_ref_id)
2957  {
2958  global $DIC;
2959 
2960  $tree = $DIC->repositoryTree();
2961 
2962  $path_arr = $tree->getPathFull($a_ref_id, $a_course_ref_id);
2963  $counter = 0;
2964  foreach ($path_arr as $data) {
2965  if ($counter++) {
2966  $path .= " > ";
2967  }
2968  $path .= $data['title'];
2969  }
2970 
2971  return $path;
2972  }
2973 
2974  //
2975  // Style editing
2976  //
2977 
2981  public function editStylePropertiesObject()
2982  {
2983  $ilTabs = $this->tabs;
2984  $tpl = $this->tpl;
2985 
2986  $this->checkPermission("write");
2987 
2988  $this->initStylePropertiesForm();
2989  $tpl->setContent($this->form->getHTML());
2990 
2991  $ilTabs->activateTab("obj_sty");
2992  }
2993 
2997  public function initStylePropertiesForm()
2998  {
2999  $ilCtrl = $this->ctrl;
3000  $lng = $this->lng;
3001  $ilTabs = $this->tabs;
3003  $tpl = $this->tpl;
3004 
3005  $tpl->setTreeFlatIcon("", "");
3006  $ilTabs->clearTargets();
3008  $this->object->getId(),
3009  "xhtml_page"
3010  );
3011  if ($xpage_id > 0) {
3012  $ilTabs->setBackTarget(
3013  $lng->txt("cntr_back_to_old_editor"),
3014  $ilCtrl->getLinkTarget($this, "switchToOldEditor"),
3015  "_top"
3016  );
3017  } else {
3018  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=" . $this->object->getType() . "_" .
3019  $this->object->getRefId(), "_top");
3020  }
3021 
3022  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
3023  $page_gui = new ilContainerPageGUI($this->object->getId());
3024  $style_id = $this->object->getStyleSheetId();
3025  if (ilObject::_lookupType($style_id) == "sty") {
3026  $page_gui->setStyleId($style_id);
3027  } else {
3028  $style_id = 0;
3029  }
3030  $page_gui->setTabHook($this, "addPageTabs");
3031  $ilCtrl->getHTML($page_gui);
3032  $ilTabs->setTabActive("obj_sty");
3033 
3034  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3035  $lng->loadLanguageModule("style");
3036 
3037  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3038  $this->form = new ilPropertyFormGUI();
3039 
3040  $fixed_style = $ilSetting->get("fixed_content_style_id");
3041  // $style_id = $this->object->getStyleSheetId();
3042 
3043  if ($fixed_style > 0) {
3044  $st = new ilNonEditableValueGUI($lng->txt("wiki_current_style"));
3045  $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
3046  $this->lng->txt("global_fixed") . ")");
3047  $this->form->addItem($st);
3048  } else {
3050  true,
3051  false,
3052  $_GET["ref_id"]
3053  );
3054 
3055  $st_styles[0] = $this->lng->txt("default");
3056  ksort($st_styles);
3057 
3058  if ($style_id > 0) {
3059  // individual style
3060  if (!ilObjStyleSheet::_lookupStandard($style_id)) {
3061  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
3062  $st->setValue(ilObject::_lookupTitle($style_id));
3063  $this->form->addItem($st);
3064 
3065  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
3066 
3067  // delete command
3068  $this->form->addCommandButton(
3069  "editStyle",
3070  $lng->txt("style_edit_style")
3071  );
3072  $this->form->addCommandButton(
3073  "deleteStyle",
3074  $lng->txt("style_delete_style")
3075  );
3076  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
3077  }
3078  }
3079 
3080  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
3081  $style_sel = ilUtil::formSelect(
3082  $style_id,
3083  "style_id",
3084  $st_styles,
3085  false,
3086  true
3087  );
3088  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
3089  $style_sel->setOptions($st_styles);
3090  $style_sel->setValue($style_id);
3091  $this->form->addItem($style_sel);
3092  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
3093  $this->form->addCommandButton(
3094  "saveStyleSettings",
3095  $lng->txt("save")
3096  );
3097  $this->form->addCommandButton(
3098  "createStyle",
3099  $lng->txt("sty_create_ind_style")
3100  );
3101  }
3102  }
3103  $this->form->setTitle($lng->txt("obj_sty"));
3104  $this->form->setFormAction($ilCtrl->getFormAction($this));
3105  }
3106 
3110  public function createStyleObject()
3111  {
3112  $ilCtrl = $this->ctrl;
3113 
3114  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
3115  }
3116 
3120  public function editStyleObject()
3121  {
3122  $ilCtrl = $this->ctrl;
3123 
3124  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
3125  }
3126 
3130  public function deleteStyleObject()
3131  {
3132  $ilCtrl = $this->ctrl;
3133 
3134  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
3135  }
3136 
3140  public function saveStyleSettingsObject()
3141  {
3143 
3144  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3145  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3146  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3147  || $this->object->getStyleSheetId() == 0)) {
3148  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
3149  $this->object->update();
3150  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3151  }
3152  $this->ctrl->redirect($this, "editStyleProperties");
3153  }
3154 
3158  public function getAsynchItemListObject()
3159  {
3160  $ilCtrl = $this->ctrl;
3161 
3162  $ref_id = $_GET["cmdrefid"];
3165 
3166  // this should be done via container-object->getSubItem in the future
3167  $data = array("child" => $ref_id, "ref_id" => $ref_id, "obj_id" => $obj_id,
3168  "type" => $type);
3169  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
3171  $item_list_gui->setContainerObject($this);
3172 
3173  $item_list_gui->enableComments(true);
3174  $item_list_gui->enableNotes(true);
3175  $item_list_gui->enableTags(true);
3176 
3177  $this->modifyItemGUI($item_list_gui, $data, false);
3178  $html = $item_list_gui->getListItemHTML(
3179  $ref_id,
3180  $obj_id,
3181  "",
3182  "",
3183  true,
3184  true
3185  );
3186 
3187  // include plugin slot for async item list
3188  $ilPluginAdmin = $this->plugin_admin;
3189  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
3190  foreach ($pl_names as $pl) {
3191  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
3192  $gui_class = $ui_plugin->getUIClassInstance();
3193  $resp = $gui_class->getHTML("Services/Container", "async_item_list", array("html" => $html));
3194  if ($resp["mode"] != ilUIHookPluginGUI::KEEP) {
3195  $html = $gui_class->modifyHTML($html, $resp);
3196  }
3197  }
3198 
3199  echo $html;
3200  exit;
3201  }
3202 
3207  protected function showPasswordInstructionObject($a_init = true)
3208  {
3209  $tpl = $this->tpl;
3210  $ilToolbar = $this->toolbar;
3211 
3212  if ($a_init) {
3213  ilUtil::sendInfo($this->lng->txt('webdav_pwd_instruction'));
3214  $this->initFormPasswordInstruction();
3215  }
3216 
3217  include_once('Services/WebDAV/classes/class.ilWebDAVUtil.php');
3218  $dav_util = ilWebDAVUtil::getInstance();
3219  $ilToolbar->addButton(
3220  $this->lng->txt('mount_webfolder'),
3221  $dav_util->getMountURI($this->object->getRefId()),
3222  '_blank',
3223  '',
3224  $dav_util->getFolderURI($this->object->getRefId())
3225  );
3226 
3227 
3228  $tpl->setContent($this->form->getHTML());
3229  }
3230 
3235  protected function initFormPasswordInstruction()
3236  {
3237  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3238  $this->form = new ilPropertyFormGUI();
3239  $this->form->setFormAction($this->ctrl->getFormAction($this));
3240 
3241  // new password
3242  $ipass = new ilPasswordInputGUI($this->lng->txt("desired_password"), "new_password");
3243  $ipass->setRequired(true);
3244 
3245  $this->form->addItem($ipass);
3246  $this->form->addCommandButton("savePassword", $this->lng->txt("save"));
3247  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
3248 
3249  $this->form->setTitle($this->lng->txt("chg_ilias_and_webfolder_password"));
3250  $this->form->setFormAction($this->ctrl->getFormAction($this));
3251 
3252  return $this->form;
3253  }
3254 
3259  protected function savePasswordObject()
3260  {
3261  $ilUser = $this->user;
3262 
3264  if ($form->checkInput()) {
3265  $ilUser->resetPassword($this->form->getInput('new_password'), $this->form->getInput('new_password'));
3266  ilUtil::sendSuccess($this->lng->txt('webdav_pwd_instruction_success'), true);
3267  $this->showPasswordInstructionObject(false);
3268  return true;
3269  }
3270  $form->setValuesByPost();
3272  }
3273 
3280  public function redrawListItemObject()
3281  {
3282  $tpl = $this->tpl;
3283 
3284  $html = null;
3285 
3286  $item_data = $this->object->getSubItems(false, false, (int) $_GET["child_ref_id"]);
3287  $container_view = $this->getContentGUI();
3288 
3289  // list item is session material (not part of "_all"-items - see below)
3290  include_once './Modules/Session/classes/class.ilEventItems.php';
3291  $event_items = ilEventItems::_getItemsOfContainer($this->object->getRefId());
3292  if (in_array((int) $_GET["child_ref_id"], $event_items)) {
3293  include_once('./Services/Object/classes/class.ilObjectActivation.php');
3294  foreach ($this->object->items["sess"] as $id) {
3295  $items = ilObjectActivation::getItemsByEvent($id['obj_id']);
3296  foreach ($items as $event_item) {
3297  if ($event_item["child"] == (int) $_GET["child_ref_id"]) {
3298  // sessions
3299  if ((int) $_GET["parent_ref_id"]) {
3300  $event_item["parent"] = (int) $_GET["parent_ref_id"];
3301  }
3302  $html = $container_view->renderItem($event_item);
3303  }
3304  }
3305  }
3306  }
3307 
3308  // "normal" list item
3309  if (!$html) {
3310  foreach ($this->object->items["_all"] as $id) {
3311  if ($id["child"] == (int) $_GET["child_ref_id"]) {
3312  $html = $container_view->renderItem($id);
3313  }
3314  }
3315  }
3316 
3317  if ($html) {
3318  echo $html;
3319 
3320  // we need to add onload code manually (rating, comments, etc.)
3321  echo $tpl->getOnLoadCodeForAsynch();
3322  }
3323 
3324  exit;
3325  }
3326 
3327  // begin-patch fm
3334  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
3335  {
3336  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
3337 
3338  // begin-patch fm
3339  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
3340  if (ilFMSettings::getInstance()->isEnabled()) {
3341  if ($lg instanceof ilObjectListGUI) {
3342  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'fileManagerLaunch'), 'fm_start', '_blank');
3343  }
3344  }
3345  // end-patch fm
3346  return $lg;
3347  }
3348 
3352  protected function fileManagerLaunchObject()
3353  {
3354  $ilUser = $this->user;
3355 
3356  $tpl = new ilTemplate('tpl.fm_launch_ws.html', false, false, 'Services/WebServices/FileManager');
3357  $tpl->setVariable('JNLP_URL', ILIAS_HTTP_PATH . '/Services/WebServices/FileManager/lib/dist/FileManager.jnlp');
3358  $tpl->setVariable('SESSION_ID', $_COOKIE[session_name()] . '::' . CLIENT_ID);
3359  $tpl->setVariable('UID', $ilUser->getId());
3360  $tpl->setVariable('REF_ID', $this->object->getRefId());
3361  $tpl->setVariable('WSDL_URI', ILIAS_HTTP_PATH . '/webservice/soap/server.php?wsdl');
3362  $tpl->setVariable('LOCAL_FRAME', ilFMSettings::getInstance()->isLocalFSEnabled() ? 1 : 0);
3363  $tpl->setVariable('REST_URI', ILIAS_HTTP_PATH . '/Services/WebServices/Rest/server.php');
3364  $tpl->setVariable('FILE_LOCKS', 0);
3365  $tpl->setVariable('UPLOAD_FILESIZE', ilFMSettings::getInstance()->getMaxFileSize());
3366 
3367  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
3368  $header_top_title = ilObjSystemFolder::_getHeaderTitle();
3369  $tpl->setVariable('HEADER_TITLE', $header_top_title ? $header_top_title : '');
3370  echo $tpl->get();
3371  exit;
3372  }
3373  // begin-patch fm
3374 
3378  public function showRepTree()
3379  {
3380  $tpl = $this->tpl;
3381  $ilUser = $this->user;
3383  $ilCtrl = $this->ctrl;
3384 
3385  // set current repository view mode
3386  if (!empty($_GET["set_mode"])) {
3387  $_SESSION["il_rep_mode"] = $_GET["set_mode"];
3388  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
3389  $ilUser->writePref("il_rep_mode", $_GET["set_mode"]);
3390  }
3391  }
3392 
3393  // get user setting
3394  if ($_SESSION["il_rep_mode"] == "") {
3395  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
3396  $_SESSION["il_rep_mode"] = $ilUser->getPref("il_rep_mode");
3397  }
3398  }
3399 
3400  // if nothing set, get default view
3401  if ($_SESSION["il_rep_mode"] == "") {
3402  $_SESSION["il_rep_mode"] = $ilSetting->get("default_repository_view");
3403  }
3404 
3405  $mode = ($_SESSION["il_rep_mode"] != "")
3406  ? $_SESSION["il_rep_mode"]
3407  : "flat";
3408 
3409  if (isset($_REQUEST['new_type'])) {
3410  $ilCtrl->setParameter($this, 'new_type', \ilUtil::stripSlashes($_REQUEST['new_type']));
3411  }
3412 
3413  // check for administration context, see #0016312
3414  if ($mode == "tree" && (strtolower($_GET["baseClass"]) != "iladministrationgui")) {
3415  include_once("./Services/Repository/classes/class.ilRepositoryExplorerGUI.php");
3416  $exp = new ilRepositoryExplorerGUI($this, "showRepTree");
3417  if (method_exists($this, 'getAdditionalWhitelistTypes')) {
3418  $whitelist = array_merge(
3419  $exp->getTypeWhiteList(),
3420  $this->getAdditionalWhitelistTypes()
3421  );
3422  $exp->setTypeWhiteList($whitelist);
3423  }
3424 
3425  if (!$exp->handleCommand()) {
3426  $tpl->setLeftNavContent($exp->getHTML());
3427  }
3428  }
3429  }
3430 
3436  protected function initEditForm()
3437  {
3438  $lng = $this->lng;
3439  $ilCtrl = $this->ctrl;
3440 
3441  $lng->loadLanguageModule($this->object->getType());
3442 
3443  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3444  $form = new ilPropertyFormGUI();
3445  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
3446  $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
3447 
3448  $this->initFormTitleDescription($form);
3449 
3450  $this->initEditCustomForm($form);
3451 
3452  $form->addCommandButton("update", $this->lng->txt("save"));
3453  //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
3454 
3455  return $form;
3456  }
3457 
3462  public function initFormTitleDescription(ilPropertyFormGUI $form)
3463  {
3465  if (is_object($this->object)) { // note: this form can also be used for new groups (create group via awareness tool)
3466  $trans = $this->object->getObjectTranslation();
3467  }
3468 
3469  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
3470  $title->setRequired(true);
3471  $title->setSize(min(40, ilObject::TITLE_LENGTH));
3472  $title->setMaxLength(ilObject::TITLE_LENGTH);
3473  if (is_object($trans)) {
3474  $title->setValue($trans->getDefaultTitle());
3475  }
3476  $form->addItem($title);
3477 
3478  if (is_object($trans) && sizeof($trans->getLanguages()) > 1) {
3479  include_once('Services/MetaData/classes/class.ilMDLanguageItem.php');
3481  $title->setInfo($this->lng->txt("language") . ": " . $languages[$trans->getDefaultLanguage()] .
3482  ' <a href="' . $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "") .
3483  '">&raquo; ' . $this->lng->txt("obj_more_translations") . '</a>');
3484 
3485  unset($languages);
3486  }
3487 
3488  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
3489  $desc->setRows(2);
3490  $desc->setCols(40);
3491  if (is_object($trans)) {
3492  $desc->setValue($trans->getDefaultDescription());
3493  }
3494  $form->addItem($desc);
3495  }
3496 
3497 
3503  protected function initSortingForm(ilPropertyFormGUI $form, array $a_sorting_settings)
3504  {
3505  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
3506  include_once './Services/Container/classes/class.ilContainer.php';
3507 
3508  $settings = new ilContainerSortingSettings($this->object->getId());
3509  $sort = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'), "sorting");
3510 
3511  if (in_array(ilContainer::SORT_INHERIT, $a_sorting_settings)) {
3512  $sort_inherit = new ilRadioOption();
3513  $sort_inherit->setTitle(
3514  $this->lng->txt('sort_inherit_prefix') .
3517  $this->object->getId()
3518  )
3519  ) . ') '
3520  );
3521  $sort_inherit->setValue(ilContainer::SORT_INHERIT);
3522  $sort_inherit->setInfo($this->lng->txt('sorting_info_inherit'));
3523  $sort->addOption($sort_inherit);
3524  }
3525  if (in_array(ilContainer::SORT_TITLE, $a_sorting_settings)) {
3526  $sort_title = new ilRadioOption(
3527  $this->lng->txt('sorting_title_header'),
3529  );
3530  $sort_title->setInfo($this->lng->txt('sorting_info_title'));
3531 
3532  $this->initSortingDirectionForm($settings, $sort_title, 'title');
3533  $sort->addOption($sort_title);
3534  }
3535  if (in_array(ilContainer::SORT_CREATION, $a_sorting_settings)) {
3536  $sort_activation = new ilRadioOption($this->lng->txt('sorting_creation_header'), ilContainer::SORT_CREATION);
3537  $sort_activation->setInfo($this->lng->txt('sorting_creation_info'));
3538  $this->initSortingDirectionForm($settings, $sort_activation, 'creation');
3539  $sort->addOption($sort_activation);
3540  }
3541  if (in_array(ilContainer::SORT_ACTIVATION, $a_sorting_settings)) {
3542  $sort_activation = new ilRadioOption($this->lng->txt('crs_sort_activation'), ilContainer::SORT_ACTIVATION);
3543  $sort_activation->setInfo($this->lng->txt('crs_sort_timing_info'));
3544  $this->initSortingDirectionForm($settings, $sort_activation, 'activation');
3545  $sort->addOption($sort_activation);
3546  }
3547  if (in_array(ilContainer::SORT_MANUAL, $a_sorting_settings)) {
3548  $sort_manual = new ilRadioOption(
3549  $this->lng->txt('sorting_manual_header'),
3551  );
3552  $sort_manual->setInfo($this->lng->txt('sorting_info_manual'));
3553  $this->initManualSortingOptionForm($settings, $sort_manual, "manual", $a_sorting_settings);
3554  $sort->addOption($sort_manual);
3555  }
3556 
3557  // Handle moved containers and there possibly invalid values
3558  if (in_array($settings->getSortMode(), $a_sorting_settings)) {
3559  $sort->setValue($settings->getSortMode());
3560  } else {
3561  $sort->setValue(ilContainer::SORT_TITLE);
3562  }
3563  $form->addItem($sort);
3564 
3565  return $form;
3566  }
3567 
3574  {
3575  $lpres = new ilRadioGroupInputGUI($this->lng->txt('cont_list_presentation'), "list_presentation");
3576 
3577  $item_list = new ilRadioOption($this->lng->txt('cont_item_list'), "");
3578  //$item_list->setInfo($this->lng->txt('cont_item_list_info'));
3579  $lpres->addOption($item_list);
3580 
3581  $tile_view = new ilRadioOption($this->lng->txt('cont_tile_view'), "tile");
3582  //$tile_view->setInfo($this->lng->txt('cont_tile_view_info'));
3583  $lpres->addOption($tile_view);
3584 
3585  $lpres->setValue(
3586  ilContainer::_lookupContainerSetting($this->object->getId(), "list_presentation")
3587  );
3588 
3589  $form->addItem($lpres);
3590 
3591  return $form;
3592  }
3593 
3598  protected function saveListPresentation(ilPropertyFormGUI $form)
3599  {
3600  $val = ($form->getInput('list_presentation') == "tile")
3601  ? "tile"
3602  : "";
3603  ilContainer::_writeContainerSetting($this->object->getId(), "list_presentation", $val);
3604  }
3605 
3606 
3611  protected function initSortingDirectionForm(ilContainerSortingSettings $sorting_settings, $element, $a_prefix)
3612  {
3613  if ($a_prefix == 'manual') {
3614  $txt = $this->lng->txt('sorting_new_items_direction');
3615  } else {
3616  $txt = $this->lng->txt('sorting_direction');
3617  }
3618 
3619  $direction = new ilRadioGroupInputGUI($txt, $a_prefix . '_sorting_direction');
3620  $direction->setValue($sorting_settings->getSortDirection());
3621  $direction->setRequired(true);
3622 
3623  // asc
3624  $asc = new ilRadioOption(
3625  $this->lng->txt('sorting_asc'),
3627  );
3628  $direction->addOption($asc);
3629 
3630  // desc
3631  $desc = new ilRadioOption(
3632  $this->lng->txt('sorting_desc'),
3634  );
3635  $direction->addOption($desc);
3636 
3637  $element->addSubItem($direction);
3638 
3639  return $element;
3640  }
3641 
3646  protected function initManualSortingOptionForm(
3648  $element,
3649  $a_prefix,
3650  $a_sorting_settings
3651  ) {
3652  $position = new ilRadioGroupInputGUI($this->lng->txt('sorting_new_items_position'), $a_prefix . '_new_items_position');
3653  $position->setValue($settings->getSortNewItemsPosition());
3654  $position->setRequired(true);
3655 
3656  //new items insert on top
3657  $new_top = new ilRadioOption(
3658  $this->lng->txt('sorting_new_items_at_top'),
3660  );
3661 
3662  $position->addOption($new_top);
3663 
3664  //new items insert at bottom
3665  $new_bottom = new ilRadioOption(
3666  $this->lng->txt('sorting_new_items_at_bottom'),
3668  );
3669 
3670  $position->addOption($new_bottom);
3671 
3672  $element->addSubItem($position);
3673 
3674  $order = new ilRadioGroupInputGUI($this->lng->txt('sorting_new_items_order'), $a_prefix . '_new_items_order');
3675  $order->setValue($settings->getSortNewItemsOrder());
3676  $order->setRequired(true);
3677 
3678  if (in_array(ilContainer::SORT_TITLE, $a_sorting_settings)) {
3679  //new items sort in alphabetical order
3680  $new_title = new ilRadioOption(
3681  $this->lng->txt('sorting_title_header'),
3683  );
3684 
3685  $order->addOption($new_title);
3686  }
3687 
3688  if (in_array(ilContainer::SORT_CREATION, $a_sorting_settings)) {
3689  //new items sort by creation date
3690  $new_creation = new ilRadioOption(
3691  $this->lng->txt('sorting_creation_header'),
3693  );
3694 
3695  $order->addOption($new_creation);
3696  }
3697 
3698 
3699  if (in_array(ilContainer::SORT_ACTIVATION, $a_sorting_settings)) {
3700  //new items by activation
3701  $new_activation = new ilRadioOption(
3702  $this->lng->txt('crs_sort_activation'),
3704  );
3705 
3706  $order->addOption($new_activation);
3707  }
3708 
3709  $element->addSubItem($order);
3710 
3711  $this->initSortingDirectionForm($settings, $element, 'manual');
3712 
3713  return $element;
3714  }
3715 
3720  protected function saveSortingSettings(ilPropertyFormGUI $form)
3721  {
3722  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
3723  $settings = new ilContainerSortingSettings($this->object->getId());
3724  $settings->setSortMode($form->getInput("sorting"));
3725 
3726  switch ($form->getInput('sorting')) {
3728  $settings->setSortDirection($form->getInput('title_sorting_direction'));
3729  break;
3731  $settings->setSortDirection($form->getInput('activation_sorting_direction'));
3732  break;
3734  $settings->setSortDirection($form->getInput('creation_sorting_direction'));
3735  break;
3737  $settings->setSortNewItemsPosition($form->getInput('manual_new_items_position'));
3738  $settings->setSortNewItemsOrder($form->getInput('manual_new_items_order'));
3739  $settings->setSortDirection($form->getInput('manual_sorting_direction'));
3740  break;
3741  }
3742 
3743  $settings->update();
3744  }
3745 
3751  public function trashObject()
3752  {
3753  $tpl = $this->tpl;
3754 
3755  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3756  $ru = new ilRepUtilGUI($this);
3757  $ru->showTrashTable($_GET["ref_id"]);
3758  }
3759 
3765  public function removeFromSystemObject()
3766  {
3767  $ilLog = $this->log;
3768  $ilAppEventHandler = $this->app_event_handler;
3769  $lng = $this->lng;
3770 
3771  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3772  $ru = new ilRepUtilGUI($this);
3773  $ru->removeObjectsFromSystem($_POST["trash_id"]);
3774  $this->ctrl->redirect($this, "trash");
3775  }
3776 
3780  public function undeleteObject()
3781  {
3782  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3783  $ru = new ilRepUtilGUI($this);
3784  $ru->restoreObjects($_GET["ref_id"], $_POST["trash_id"]);
3785  $this->ctrl->redirect($this, "trash");
3786  }
3787 
3792  {
3793  $lng = $this->lng;
3794  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3795 
3796  if (!isset($_POST["trash_id"])) {
3797  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3798  $this->ctrl->redirect($this, "trash");
3799  }
3800 
3801  $ru = new ilRepUtilGUI($this);
3802  $ru->confirmRemoveFromSystemObject($_POST["trash_id"]);
3803  }
3804 
3809  protected function getTreeSelectorGUI($cmd)
3810  {
3811  include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
3812  $exp = new ilRepositorySelectorExplorerGUI($this, "showPasteTree");
3813  // TODO: The study programme 'prg' is not included here, as the
3814  // ilRepositorySelectorExplorerGUI only handles static rules for
3815  // parent-child-relations and not the dynamic relationsships
3816  // required for the SP (see #16909).
3817  $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "fold"));
3818 
3819  // Not all types are allowed in the LearningSequence
3820  // Extend whitelist, if all selected types are possible subojects of LSO
3821  if (in_array($_SESSION["clipboard"]["cmd"], ["link", "cut"])) {
3822  $lso_types = array_keys($this->obj_definition->getSubObjects('lso'));
3823  $refs = $_SESSION["clipboard"]["ref_ids"];
3824  $allow_lso = true;
3825  foreach ($refs as $item_ref_id) {
3826  $type = ilObject::_lookupType($item_ref_id, true);
3827  if (!in_array($type, $lso_types)) {
3828  $allow_lso = false;
3829  }
3830  }
3831  if ($allow_lso) {
3832  $whitelist = $exp->getTypeWhiteList();
3833  $whitelist[] = 'lso';
3834  $exp->setTypeWhiteList($whitelist);
3835  }
3836  }
3837 
3838  if ($cmd == "link") {
3839  $exp->setSelectMode("nodes", true);
3840  return $exp;
3841  } else {
3842  $exp->setSelectMode("nodes[]", false);
3843  return $exp;
3844  }
3845  }
3846 
3850  public function setSideColumnReturn()
3851  {
3852  $this->ctrl->setReturn($this, "");
3853  }
3854 }
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
static _getRTEClassname()
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
initManualSortingOptionForm(ilContainerSortingSettings $settings, $element, $a_prefix, $a_sorting_settings)
Add manual sorting options.
getContentGUI()
Get content gui object.
getAsynchItemListObject()
Get item list command drop down asynchronously.
static _getInstanceByType($a_source_id, $a_item_type)
Get instance by type.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
saveSortingObject()
Save Sorting.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
This class represents an option in a radio group.
deleteStyleObject()
Delete Style.
$lg
Definition: example_018.php:62
$path
Definition: aliased.php:25
$_COOKIE['client_id']
Definition: server.php:9
addMessageRow(&$a_tpl, $a_message, $a_type)
add message row
redrawListItemObject()
Redraw a list item (ajax)
initHeaderAction($a_sub_type=null, $a_sub_id=null)
Add file manager link.
enableAdministrationPanelObject()
enable administration panel
removeFromSystemObject()
remove objects from trash bin and all entries therefore every object needs a specific deleteObject() ...
clearObject()
clear clipboard and go back to last object
settings()
Definition: settings.php:2
setBlockProperty($a_block_type, $a_property, $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
initEditForm()
Init object edit form.
showPasswordInstructionObject($a_init=true)
Show webdav password instruction.
const SORT_NEW_ITEMS_POSITION_TOP
static getItemsByEvent($a_event_id)
Get session material / event items.
Shows all items grouped by type.
cloneWizardPageTreeObject()
public
saveSortingSettings(ilPropertyFormGUI $form)
Save sorting settings.
$_SESSION["AccountId"]
Explorer for selecting repository items.
fileManagerLaunchObject()
Launch jnlp.
& newBlockTemplate()
determin admin commands
This class represents a selection list property in a property form.
$result
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
renderObject()
render the object
addDownloadButton(&$tpl, &$toolbar)
This class represents a property form user interface.
renderBlockAsynchObject()
render the object
$type
static _appendNumberOfCopyToFilename($a_file_name, $nth_copy=null, $a_handle_extension=false)
Appends the text " - Copy" to a filename in the language of the current user.
global $DIC
Definition: saml.php:7
const TITLE_LENGTH
max length of object title
Container page GUI class.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
static copyFile($obj_id, $title, $tmpdir)
getEditFormValues()
Get values for edit form.
createStyleObject()
Create Style.
setTitleAndDescription()
called by prepare output
static _getItemsOfContainer($a_ref_id)
cloneAllObject()
Clone all object Overwritten method for copying container objects.
allowBlocksMoving()
Standard is to allow blocks moving.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
trashObject()
Show trash content of object.
if(!array_key_exists('StateId', $_REQUEST)) $id
editPageContentObject()
edit page content (for repository root node and categories)
static _isInTrash($a_ref_id)
checks wether object is in trash
executeCommand()
execute command note: this method is overwritten in all container objects
editOrderObject()
Edit order.
switchToStdEditorObject()
Switch to standard page editor.
prepareOutput($a_show_subobjects=true)
prepare output
static _lookupTitle($a_id)
lookup object title
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
confirmRemoveFromSystemObject()
confirmation screen remove from system
addItem($a_item)
Add Item (Property, SectionHeader).
static isActive()
createObject()
create new object form
isActiveOrdering()
Check if ordering is enabled.
static addToDesktop()
Add desktop item public.
setInfo($a_info)
Set Info.
setPageEditorTabs()
Add page editor tabs.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
user()
Definition: user.php:4
initSortingDirectionForm(ilContainerSortingSettings $sorting_settings, $element, $a_prefix)
Add sorting direction.
static _catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupStandard($a_id)
Lookup standard flag.
global $ilCtrl
Definition: ilias.php:18
initFormPasswordInstruction()
Init password form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static _isFinished($a_copy_id)
check if copy is finished
addHeaderRow(&$a_tpl, $a_type, $a_show_image=true)
adds a header row to a block template
$a_type
Definition: workflow.php:92
setRepositoryItems($a_repositoryitems)
Set Repository Items.
pasteObject()
paste object from clipboard to current place Depending on the chosen command the object(s) are linked...
editStyleObject()
Edit Style.
useNewEditorObject()
Use new editor (-> delete xhtml content page)
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Constructor public.
editStylePropertiesObject()
Edit style properties.
static showMemberViewSwitch($a_ref_id)
Show member view switch.
catch(Exception $e) $message
const SORT_NEW_ITEMS_POSITION_BOTTOM
This class represents a property in a property form.
setValue($a_value)
Set Value.
GUI class for didactic template settings inside repository objects.
savePasswordObject()
Save password.
undeleteObject()
Get objects back from trash.
if(isset($_POST['submit'])) $form
static _existsAndNotEmpty($a_parent_type, $a_id, $a_lang="-")
checks whether page exists and is not empty (may return true on some empty pages) ...
static _buildPath($a_ref_id, $a_course_ref_id)
build path
Container page object.
addSubItem($a_item)
Add Subitem.
linkObject()
create an new reference of an object in tree it&#39;s like a hard link of unix
Column user interface class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$values
clearAdminCommandsDetermination()
cleaer administration commands determination
setColumnSettings(ilColumnGUI $column_gui)
May be overwritten in subclasses.
const SORT_NEW_ITEMS_ORDER_CREATION
allowBlocksConfigure()
Standard is to allow blocks configuration.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
Repository explorer GUI class.
special template class to simplify handling of ITX/PEAR
omitLocator($a_omit=true)
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
Class ilObjectListGUI.
$text
Definition: errorreport.php:18
Repository GUI Utilities.
This class represents a text property in a property form.
static lookupSortModeFromParentContainer($a_obj_id)
Lookup sort mode from parent container.
showPasteTreeObject()
Show paste tree.
saveStyleSettingsObject()
Save style settings.
addPageTabs()
Add page tabs.
forwardToStyleSheet()
Forward to style object.
This class represents a password property in a property form.
& forwardToPageObject()
forward command to page object
$ilUser
Definition: imgupload.php:18
Class to report exception.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
const LINK_OBJECT
cancelMoveLinkObject()
Cancel move|link empty clipboard and return to parent.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getSyntaxStylePath()
get syntax style path
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static getContentStylePath($a_style_id, $add_random=true)
get content style path
setOptions($a_options)
Set Options.
showPossibleSubObjects()
show possible sub objects selection list
$txt
Definition: error.php:11
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
Modify list gui for presentation in container.
copyObject()
Copy object(s) out from a container and write the information to clipboard It is not possible to copy...
static _lookupType($a_id, $a_reference=false)
lookup object type
disableAdministrationPanelObject()
enable administration panel
XHTML Page class.
showPermanentLink()
show permanent link
static sortModeToString($a_sort_mode)
get String representation of sort mode
saveListPresentation(ilPropertyFormGUI $form)
Save list presentation setting.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
cloneWizardPageListObject()
public
const SORT_NEW_ITEMS_ORDER_ACTIVATION
getTabs()
common tabs for all container objects (should be called at the end of child getTabs() method ...
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
setContentSubTabs()
Set content sub tabs.
exit
Definition: backend.php:16
static removeFromDesktop()
Remove item from personal desktop public.
downloadMultipleObjects($a_ref_ids)
static getInstance()
Get singleton instance.
setStyleId($a_styleid)
Set Style Id.
initListPresentationForm(ilPropertyFormGUI $form)
Add list presentation settings to form.
getSortNewItemsPosition()
GET new item position.
static _getFrame($a_class, $a_type='')
Get content frame name.
static getInstance()
Get singleton instance.
static _getListGUIByType($a_type, $a_context=ilObjectListGUI::CONTEXT_REPOSITORY)
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
This class represents a non editable value in a property form.
initSortingForm(ilPropertyFormGUI $form, array $a_sorting_settings)
Append sorting settings to property form.
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
Render add new item selector.
Class ilObjStyleSheetGUI.
global $ilSetting
Definition: privfeed.php:17
static _adjustMovedObjectConditions($a_ref_id)
In the moment it is not allowed to create preconditions on objects that are located outside of a cour...
static getInstance()
Get instance.
This class represents a text area property in a property form.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static getInstance($a_obj_id)
Get instance.
global $ilDB
setTabHook($a_object, $a_function)
Set tab hook.
static _lookupAbsolutePath($obj_id, $a_version=null)
$ret
Definition: parser.php:6
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
getCreationMode()
get creation mode
$i
Definition: disco.tpl.php:19
cutObject()
cut object(s) out from a container and write the information to clipboard
Class ilContainerGUI.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _writeContainerSetting($a_id, $a_keyword, $a_value)
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
static _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
Synchronises appearances of media objects in $a_text with media object usage table.
initStylePropertiesForm()
Init style properties form.
$url
render()
Add new item selection to current page incl.
static _lookupSortMode($a_obj_id)
lookup sort mode
static _getInstance($a_obj_id)
get instance by obj_id
$links
showAdministrationPanel()
show administration panel
$languages
Definition: cssgen2.php:34
setAdminCommands($a_admincommands)
Set Administration Commmands.
isActiveItemOrdering()
Check if item ordering is enabled.
static recurseFolder($refid, $title, $tmpdir)
private functions which iterates through all folders and files and create an according file structure...
editPageFrameObject()
show page editor frameset
getContainerPageHTML()
Get container page HTML.
const SORT_NEW_ITEMS_ORDER_TITLE
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
cloneNodes($srcRef, $dstRef, &$mapping, $newName=null)
Recursively clones all nodes of the RBAC tree.
cloneWizardPageObject($a_tree_view=true)
Show clone wizard page for container objects.
$key
Definition: croninfo.php:18
$_POST["username"]
keepObjectsInClipboardObject()
Keep objects in the clipboard.
$html
Definition: example_001.php:87
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
clipboardObject()
show clipboard
setRequired($a_required)
Set Required.
const IL_COMP_SERVICE
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
setSideColumnReturn()
Set return point for side column actions.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
setEnableMovement($a_enablemovement)
Set Enable Movement.
GUI class for course objective view.
switchToOldEditorObject()
Switch to old page editor.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
addStandardContainerSubTabs($a_include_view=true)
Add standar container subtabs for view, manage, oderdering and text/media editor link.