ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
106  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
107  {
108  global $DIC;
109 
110  $this->lng = $DIC->language();
111  $this->tpl = $DIC["tpl"];
112  $this->ctrl = $DIC->ctrl();
113  $this->tabs = $DIC->tabs();
114  $this->settings = $DIC->settings();
115  $this->user = $DIC->user();
116  $this->db = $DIC->database();
117  $this->access = $DIC->access();
118  $this->tree = $DIC->repositoryTree();
119  $this->error = $DIC["ilErr"];
120  $this->obj_definition = $DIC["objDefinition"];
121  $this->rbacadmin = $DIC->rbac()->admin();
122  $this->rbacreview = $DIC->rbac()->review();
123  $this->log = $DIC["ilLog"];
124  $this->obj_data_cache = $DIC["ilObjDataCache"];
125  $this->toolbar = $DIC->toolbar();
126  $this->plugin_admin = $DIC["ilPluginAdmin"];
127  $this->app_event_handler = $DIC["ilAppEventHandler"];
128  $rbacsystem = $DIC->rbac()->system();
129  $lng = $DIC->language();
130 
131  $this->rbacsystem = $rbacsystem;
132 
133  $lng->loadLanguageModule("cntr");
134  $lng->loadLanguageModule('cont');
135 
136  // prepare output things should generally be made in executeCommand
137  // method (maybe dependent on current class/command
138  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
139  }
140 
145  public function executeCommand()
146  {
147  $tpl = $this->tpl;
148 
149  $next_class = $this->ctrl->getNextClass();
150  $cmd = $this->ctrl->getCmd("render");
151 
152 
153  switch ($next_class) {
154  // page editing
155  case "ilcontainerpagegui":
156  if ($_GET["redirectSource"] != "ilinternallinkgui") {
157  $ret = $this->forwardToPageObject();
158  $tpl->setContent($ret);
159  } else {
160  return "";
161  }
162  break;
163 
164  case "ilobjstylesheetgui":
165  $this->forwardToStyleSheet();
166  break;
167 
168  default:
169  $this->prepareOutput();
170  $cmd .= "Object";
171  $this->$cmd();
172  break;
173  }
174  return true;
175  }
176 
182  protected function getEditFormValues()
183  {
184  $values = parent::getEditFormValues();
185 
186  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
187  $values['didactic_type'] =
188  'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
189 
190  return $values;
191  }
192 
196  protected function afterUpdate()
197  {
198  // check if template is changed
199  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
200  $current_tpl_id = (int) ilDidacticTemplateObjSettings::lookupTemplateId(
201  $this->object->getRefId()
202  );
203  $new_tpl_id = (int) $this->getDidacticTemplateVar('dtpl');
204 
205  if ($new_tpl_id != $current_tpl_id) {
206  $_REQUEST['tplid'] = $new_tpl_id;
207 
208  // redirect to didactic template confirmation
209  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
210  $this->ctrl->setReturn($this, 'edit');
211  $this->ctrl->setCmdClass('ildidactictemplategui');
212  $this->ctrl->setCmd('confirmTemplateSwitch');
213  $dtpl_gui = new ilDidacticTemplateGUI($this);
214  return $this->ctrl->forwardCommand($dtpl_gui);
215  }
216  parent::afterUpdate();
217  }
218 
219 
223  public function forwardToStyleSheet()
224  {
226  $ilTabs = $this->tabs;
227 
228  $ilTabs->clearTargets();
229 
230  $cmd = $ilCtrl->getCmd();
231  include_once("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
232  $this->ctrl->setReturn($this, "editStyleProperties");
233  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
234  $style_gui->omitLocator();
235  if ($cmd == "create" || $_GET["new_type"]=="sty") {
236  $style_gui->setCreationMode(true);
237  }
238 
239  if ($cmd == "confirmedDelete") {
240  $this->object->setStyleSheetId(0);
241  $this->object->update();
242  }
243 
244  $ret = $this->ctrl->forwardCommand($style_gui);
245 
246  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
247  $style_id = $ret;
248  $this->object->setStyleSheetId($style_id);
249  $this->object->update();
250  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
251  }
252  }
253 
254 
258  public function &forwardToPageObject()
259  {
260  $lng = $this->lng;
261  $ilTabs = $this->tabs;
263 
264  $cmd = $ilCtrl->getCmd();
265 
266  if (in_array($cmd, array("displayMediaFullscreen", "downloadFile", "displayMedia"))) {
267  $this->checkPermission("read");
268  } else {
269  $this->checkPermission("write");
270  }
271 
272  $ilTabs->clearTargets();
273 
274  if ($_GET["redirectSource"] == "ilinternallinkgui") {
275  exit;
276  }
277 
279  $this->object->getId(),
280  "xhtml_page"
281  );
282  if ($xpage_id > 0) {
283  $ilTabs->setBackTarget(
284  $lng->txt("cntr_back_to_old_editor"),
285  $ilCtrl->getLinkTarget($this, "switchToOldEditor"),
286  "_top"
287  );
288  } else {
289  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=" . $this->object->getType() . "_" .
290  $this->object->getRefId(), "_top");
291  }
292 
293  // page object
294  include_once("./Services/Container/classes/class.ilContainerPage.php");
295  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
296 
297  $lng->loadLanguageModule("content");
298 
299  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
300  $this->tpl->setVariable(
301  "LOCATION_CONTENT_STYLESHEET",
302  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
303  );
304  $this->tpl->setCurrentBlock("SyntaxStyle");
305  $this->tpl->setVariable(
306  "LOCATION_SYNTAX_STYLESHEET",
308  );
309  $this->tpl->parseCurrentBlock();
310 
312  "cont",
313  $this->object->getId()
314  )) {
315  // doesn't exist -> create new one
316  $new_page_object = new ilContainerPage();
317  $new_page_object->setParentId($this->object->getId());
318  $new_page_object->setId($this->object->getId());
319  $new_page_object->createFromXML();
320  }
321 
322  // get page object
323  $this->ctrl->setReturnByClass("ilcontainerpagegui", "edit");
324  $page_gui = new ilContainerPageGUI($this->object->getId());
325  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
326  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
327  $this->object->getStyleSheetId(),
328  $this->object->getType()
329  ));
330 
331  $page_gui->setTemplateTargetVar("ADM_CONTENT");
332  $page_gui->setFileDownloadLink("");
333  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
334  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
335  $page_gui->setPresentationTitle("");
336  $page_gui->setTemplateOutput(false);
337 
338  // old editor information text
340  $this->object->getId(),
341  "xhtml_page"
342  );
343  if ($xpage_id > 0) {
344  $wtpl = new ilTemplate(
345  "tpl.cntr_old_editor_message.html",
346  true,
347  true,
348  "Services/Container"
349  );
350  $wtpl->setVariable("ALT_WARNING", $lng->txt("warning"));
351  $wtpl->setVariable(
352  "IMG_WARNING",
353  ilUtil::getImagePath("icon_alert.svg")
354  );
355  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
356  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
357  $wtpl->setVariable(
358  "HREF_SWITCH_TO_NEW_EDITOR",
359  $ilCtrl->getLinkTarget($this, "useNewEditor")
360  );
361  $wtpl->setVariable(
362  "TXT_MIGRATION_SWITCH",
363  $lng->txt("cntr_switch_to_new_editor_cmd")
364  );
365  $page_gui->setPrependingHtml($wtpl->get());
366  }
367 
368  // style tab
369  $page_gui->setTabHook($this, "addPageTabs");
370 
371  $ret = $this->ctrl->forwardCommand($page_gui);
372 
373  //$ret =& $page_gui->executeCommand();
374  return $ret;
375  }
376 
380  public function addPageTabs()
381  {
382  $ilTabs = $this->tabs;
384 
385  $ilTabs->addTarget(
386  "obj_sty",
387  $ilCtrl->getLinkTarget($this, 'editStyleProperties'),
388  "editStyleProperties"
389  );
390  }
391 
395  public function getContainerPageHTML()
396  {
399 
400  if (!$ilSetting->get("enable_cat_page_edit")) {
401  return;
402  }
403 
404  // old page editor content
406  $this->object->getId(),
407  "xhtml_page"
408  );
409  if ($xpage_id > 0) {
410  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
411  $xpage = new ilXHTMLPage($xpage_id);
412  return $xpage->getContent();
413  }
414 
415 
416  // page object
417 
418 
419  // if page does not exist, return nothing
420  include_once("./Services/COPage/classes/class.ilPageUtil.php");
422  "cont",
423  $this->object->getId()
424  )) {
425  return "";
426  }
427  include_once("./Services/Container/classes/class.ilContainerPage.php");
428  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
429 
430  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
431  $this->tpl->setVariable(
432  "LOCATION_CONTENT_STYLESHEET",
433  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
434  );
435  $this->tpl->setCurrentBlock("SyntaxStyle");
436  $this->tpl->setVariable(
437  "LOCATION_SYNTAX_STYLESHEET",
439  );
440  $this->tpl->parseCurrentBlock();
441 
442  // get page object
443  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
444  $ot = ilObjectTranslation::getInstance($this->object->getId());
445  $lang = $ot->getEffectiveContentLang($ilUser->getCurrentLanguage(), "cont");
446  $page_gui = new ilContainerPageGUI($this->object->getId(), 0, $lang);
447  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
448  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
449  $this->object->getStyleSheetId(),
450  $this->object->getType()
451  ));
452 
453  $page_gui->setPresentationTitle("");
454  $page_gui->setTemplateOutput(false);
455  $page_gui->setHeader("");
456  $ret = $page_gui->showPage();
457 
458  //$ret = "<div style='background-color: white; padding:5px; margin-bottom: 30px;'>".$ret."</div>";
459 
460  //$ret =& $page_gui->executeCommand();
461  return $ret;
462  }
463 
467  public function prepareOutput($a_show_subobjects = true)
468  {
469  if (parent::prepareOutput($a_show_subobjects)) { // return false in admin mode
470  if ($this->getCreationMode() != true && $a_show_subobjects) {
471  // This method is called directly from ilContainerGUI::renderObject
472  #$this->showPossibleSubObjects();
473  $this->showTreeFlatIcon();
474 
475  // Member view
476  include_once './Services/Container/classes/class.ilMemberViewGUI.php';
477  ilMemberViewGUI::showMemberViewSwitch($this->object->getRefId());
478  }
479  }
480  }
481 
482  public function showTreeFlatIcon()
483  {
484  $tpl = $this->tpl;
485 
486  // dont show icon, if role (permission gui->rolegui) is edited
487  if ($_GET["obj_id"] != "") {
488  return;
489  }
490  // hide for member view
491  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
492  if (ilMemberViewSettings::getInstance()->isActive()) {
493  return;
494  }
495 
496  $mode = ($_SESSION["il_rep_mode"] == "flat")
497  ? "tree"
498  : "flat";
499  $link = "ilias.php?baseClass=ilRepositoryGUI&amp;cmd=frameset&amp;set_mode=" . $mode . "&amp;ref_id=" . $this->object->getRefId();
500  $tpl->setTreeFlatIcon($link, $mode);
501  }
502 
506  public function setTitleAndDescription()
507  {
508  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title")) {
509  $this->tpl->setTitle($this->object->getTitle());
510  $this->tpl->setDescription($this->object->getLongDescription());
511 
512  // set tile icon
513  $icon = ilObject::_getIcon($this->object->getId(), "big", $this->object->getType());
514  $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_" . $this->object->getType()));
515 
516  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
517  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
518  $lgui->initItem($this->object->getRefId(), $this->object->getId());
519  $this->tpl->setAlertProperties($lgui->getAlertProperties());
520  }
521  }
522 
526  public function showPossibleSubObjects()
527  {
528  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
529  $gui = new ilObjectAddNewItemGUI($this->object->getRefId());
530  $gui->render();
531  }
532 
539  public function getContentGUI()
540  {
541  $courseTimingView = -1;
542  if (defined('IL_CRS_VIEW_TIMING')) {
543  $courseTimingView = IL_CRS_VIEW_TIMING;
544  }
545 
546  switch ($this->object->getViewMode()) {
547  // all items in one block
549  include_once("./Services/Container/classes/class.ilContainerSimpleContentGUI.php");
550  $container_view = new ilContainerSimpleContentGUI($this);
551  break;
552 
554  include_once('./Services/Container/classes/class.ilContainerObjectiveGUI.php');
555  $container_view = new ilContainerObjectiveGUI($this);
556  break;
557 
558  // all items in one block
560  case $courseTimingView: // not nice this workaround
561  include_once("./Services/Container/classes/class.ilContainerSessionsContentGUI.php");
562  $container_view = new ilContainerSessionsContentGUI($this);
563  break;
564 
565  // all items in one block
567  default:
568  include_once("./Services/Container/classes/class.ilContainerByTypeContentGUI.php");
569  $container_view = new ilContainerByTypeContentGUI($this);
570  break;
571  }
572 
573  return $container_view;
574  }
575 
576 
577 
581  public function renderObject()
582  {
583  $ilDB = $this->db;
584  $tpl = $this->tpl;
585  $ilTabs = $this->tabs;
588 
589  $container_view = $this->getContentGUI();
590 
591  $this->setContentSubTabs();
592  if ($this->isActiveAdministrationPanel()) {
593  $ilTabs->activateSubTab("manage");
594  } else {
595  $ilTabs->activateSubTab("view_content");
596  }
597 
598  $container_view->setOutput();
599 
600  $this->adminCommands = $container_view->adminCommands;
601 
602  // it is important not to show the subobjects/admin panel here, since
603  // we will create nested forms in case, e.g. a news/calendar item is added
604  if ($ilCtrl->getNextClass() != "ilcolumngui") {
606  $this->showPossibleSubObjects();
607  }
608 
609  $this->showPermanentLink($tpl);
610 
611  // add tree updater javascript
612  if ((int) $_GET["ref_id"] > 1 && $ilSetting->get("rep_tree_synchronize")) {
613  $ilCtrl->setParameter($this, "active_node", (int) $_GET["ref_id"]);
614  /*$tpl->addOnloadCode("
615  if (parent && parent.tree && parent.tree.updater)
616  {
617  parent.tree.updater('tree_div', '".
618  $ilCtrl->getLinkTarget($this, "showTree", "", true, false)
619  ."');
620  }");*/
621  }
622  }
623 
627  public function setContentSubTabs()
628  {
630  }
631 
635  public function showAdministrationPanel(&$tpl)
636  {
637  $ilAccess = $this->access;
638  $lng = $this->lng;
639 
640  $lng->loadLanguageModule('cntr');
641 
642  if ($_SESSION["clipboard"]) {
643  // #11545
644  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
645 
646  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
647  $toolbar = new ilToolbarGUI();
648  $this->ctrl->setParameter($this, "type", "");
649  $this->ctrl->setParameter($this, "item_ref_id", "");
650 
651  $toolbar->addFormButton(
652  $this->lng->txt('paste_clipboard_items'),
653  'paste'
654  );
655 
656  $toolbar->addFormButton(
657  $this->lng->txt('clear_clipboard'),
658  'clear'
659  );
660 
661  $GLOBALS['tpl']->addAdminPanelToolbar($toolbar, true, false);
662  } elseif ($this->isActiveAdministrationPanel()) {
663  // #11545
664  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
665 
666  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
667  $toolbar = new ilToolbarGUI();
668  $this->ctrl->setParameter($this, "type", "");
669  $this->ctrl->setParameter($this, "item_ref_id", "");
670 
671  // if (!$_SESSION["clipboard"])
672  // {
673  if ($this->object->gotItems()) {
674  $toolbar->setLeadingImage(
675  ilUtil::getImagePath("arrow_upright.svg"),
676  $lng->txt("actions")
677  );
678  $toolbar->addFormButton(
679  $this->lng->txt('delete_selected_items'),
680  'delete'
681  );
682  $toolbar->addFormButton(
683  $this->lng->txt('move_selected_items'),
684  'cut'
685  );
686  $toolbar->addFormButton(
687  $this->lng->txt('copy_selected_items'),
688  'copy'
689  );
690  $toolbar->addFormButton(
691  $this->lng->txt('link_selected_items'),
692  'link'
693  );
694  // add download button if multi download enabled
695  $folder_set = new ilSetting("fold");
696  if ($folder_set->get("enable_multi_download") == true) {
697  $toolbar->addSeparator();
698 
699  if (!$folder_set->get("bgtask_download", 0)) {
700  $toolbar->addFormButton(
701  $this->lng->txt('download_selected_items'),
702  'download'
703  );
704  } else {
705  $url = $this->ctrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjfoldergui", "ilbackgroundtaskhub"), "", "", true, false);
706  $GLOBALS['tpl']->addJavaScript("Services/BackgroundTask/js/BgTask.js");
707  $GLOBALS['tpl']->addOnLoadCode("il.BgTask.initMultiForm('ilFolderDownloadBackgroundTaskHandler');");
708  $GLOBALS['tpl']->addOnLoadCode('il.BgTask.setAjax("' . $url . '");');
709 
710  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
711  $button = ilSubmitButton::getInstance();
712  $button->setCaption("download_selected_items");
713  $button->addCSSClass("ilbgtasksubmit");
714  $button->setCommand("download");
715  $toolbar->addButtonInstance($button);
716  }
717  }
718  }
719  if ($this->object->getType() == 'crs' or $this->object->getType() == 'grp') {
720  if ($this->object->gotItems()) {
721  $toolbar->addSeparator();
722  }
723 
724  $toolbar->addButton(
725  $this->lng->txt('cntr_adopt_content'),
726  $this->ctrl->getLinkTargetByClass(
727  'ilObjectCopyGUI',
728  'adoptContent'
729  )
730  );
731  }
732  // }
733  /*else
734  {
735 
736  if ($this->isMultiDownloadEnabled())
737  {
738  $toolbar->addSeparator();
739  $toolbar->addFormButton(
740  $this->lng->txt('download_selected_items'),
741  'download'
742  );
743  }
744  }*/
745 
746  $GLOBALS['tpl']->addAdminPanelToolbar(
747  $toolbar,
748  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false,
749  ($this->object->gotItems() && !$_SESSION["clipboard"]) ? true : false
750  );
751 
752  // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
753  if ($this->object->gotItems()) {
754  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
755  }
756  } else {
757  if ($this->edit_order) {
758  if ($this->object->gotItems() and $ilAccess->checkAccess("write", "", $this->object->getRefId())) {
759  include_once('./Services/Container/classes/class.ilContainer.php');
760 
761  if ($this->isActiveOrdering()) {
762  // #11843
763  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
764 
765  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
766  $toolbar = new ilToolbarGUI();
767  $this->ctrl->setParameter($this, "type", "");
768  $this->ctrl->setParameter($this, "item_ref_id", "");
769 
770  $toolbar->addFormButton(
771  $this->lng->txt('sorting_save'),
772  'saveSorting'
773  );
774 
775  $GLOBALS['tpl']->addAdminPanelToolbar($toolbar, true, false);
776 
777  /*
778  $GLOBALS["tpl"]->addAdminPanelCommand("saveSorting",
779  $this->lng->txt('sorting_save'));
780 
781  // button should appear at bottom, too
782  $GLOBALS["tpl"]->admin_panel_bottom = true;
783  */
784  }
785  }
786  }
787  // bugfix mantis 24559
788  // undoing an erroneous change inside mantis 23516 by adding "Download Multiple Objects"-functionality for non-admins
789  // as they don't have the possibility to use the multi-download-capability of the manage-tab
790  elseif ($this->isMultiDownloadEnabled()) {
791  // bugfix mantis 0021272
792  $ref_id = $_GET['ref_id'];
793  $num_files = $this->tree->getChildsByType($ref_id, "file");
794  $num_folders = $this->tree->getChildsByType($ref_id, "fold");
795  if (count($num_files) > 0 or count($num_folders) > 0) {
796  // #11843
797  $GLOBALS['tpl']->setPageFormAction($this->ctrl->getFormAction($this));
798 
799  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
800  $toolbar = new ilToolbarGUI();
801  $this->ctrl->setParameter($this, "type", "");
802  $this->ctrl->setParameter($this, "item_ref_id", "");
803 
804  $toolbar->addFormButton(
805  $this->lng->txt('download_selected_items'),
806  'download'
807  );
808 
809  $GLOBALS['tpl']->addAdminPanelToolbar(
810  $toolbar,
811  $this->object->gotItems() ? true : false,
812  $this->object->gotItems() ? true : false
813  );
814  } else {
815  ilUtil::sendInfo($this->lng->txt('msg_no_downloadable_objects'), true);
816  }
817  }
818  }
819  }
820 
821  public function __showTimingsButton(&$tpl)
822  {
823  $tree = $this->tree;
824 
825  if (!$tree->checkForParentType($this->object->getRefId(), 'crs')) {
826  return false;
827  }
828  $tpl->setCurrentBlock("custom_button");
829  $tpl->setVariable("ADMIN_MODE_LINK", $this->ctrl->getLinkTargetByClass('ilcoursecontentgui', 'editTimings'));
830  $tpl->setVariable("TXT_ADMIN_MODE", $this->lng->txt('timings_edit'));
831  $tpl->parseCurrentBlock();
832  return true;
833  }
837  public function showPermanentLink(&$tpl)
838  {
839  $GLOBALS["tpl"]->setPermanentLink(
840  $this->object->getType(),
841  $this->object->getRefId(),
842  "",
843  "_top"
844  );
845  }
846 
850  public function switchToStdEditorObject()
851  {
853 
854  $_SESSION["il_cntr_editor"] = "std";
855  $ilCtrl->redirect($this, "editPageFrame");
856  }
857 
861  public function switchToOldEditorObject()
862  {
864 
865  $_SESSION["il_cntr_editor"] = "old";
866  $ilCtrl->redirect($this, "editPageFrame");
867  }
868 
872  public function useNewEditorObject()
873  {
875  $ilAccess = $this->access;
876  $lng = $this->lng;
878 
879  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
880  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
881 
882  /* keep old page content for now...
883  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
884  "xhtml_page");
885  if ($xpage_id)
886  {
887  $xpage = new ilXHTMLPage($xpage_id);
888  }
889  */
890 
892  $this->object->getId(),
893  "xhtml_page",
894  0
895  );
896 
897  ilUtil::sendSuccess($lng->txt("cntr_switched_editor"), true);
898  }
899 
900  $ilCtrl->redirect($this, "editPageFrame");
901  }
902 
906  public function editPageFrameObject()
907  {
908  // old tiny stuff
910  $this->object->getId(),
911  "xhtml_page"
912  );
913  if ($xpage_id > 0 && $_SESSION["il_cntr_editor"] != "std") {
914  $this->ctrl->redirect($this, "editPageContent");
915  } else {
916  $this->ctrl->redirectByClass(array("ilcontainerpagegui"), "edit");
917  }
918  }
919 
925  public function editPageContentObject()
926  {
928  $tpl = $this->tpl;
929  $lng = $this->lng;
932 
933  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
934  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
935  }
936 
938  $this->object->getId(),
939  "xhtml_page"
940  );
941  if ($xpage_id > 0) {
942  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
943  $xpage = new ilXHTMLPage($xpage_id);
944  $content = $xpage->getContent();
945  }
946 
947  // get template
948  $tpl->addBlockFile(
949  "ADM_CONTENT",
950  "adm_content",
951  "tpl.container_edit_page_content.html",
952  "Services/Container"
953  );
954  $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
955  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
956  $tpl->setVariable(
957  "TXT_EDIT_PAGE_CONTENT",
958  $this->lng->txt("edit_page_content")
959  );
960  $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
961  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
962  $tpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_old_editor_warning"));
963  $tpl->setVariable("TXT_MIGRATION_OPEN_STD_EDITOR", $lng->txt("cntr_old_editor_open_standard_editor"));
964  $tpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert.svg"));
965  $tpl->setVariable("HREF_OPEN_STD_EDITOR", $ilCtrl->getLinkTarget($this, "switchToStdEditor"));
966  $tpl->setVariable("ALT_WARNING", $lng->txt("warning"));
967 
968  include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
969  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
970  //$ta = new ilTextAreaInputGUI();
971  //$tags = $ta->getRteTagSet("extended_table_img");
972 
973  // add rte support
974  include_once "./Services/RTE/classes/class.ilRTE.php";
975  $rtestring = ilRTE::_getRTEClassname();
976  include_once "./Services/RTE/classes/class.$rtestring.php";
977  $rte = new $rtestring();
978  //$rte->addPlugin("latex");
979  include_once "./Services/Object/classes/class.ilObject.php";
981  $obj_type = ilObject::_lookupType($_GET["ref_id"], true);
982  $rte->addRTESupport($obj_id, $obj_type);
983  //$rte->setStyleSelect(true);
984  //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
985  }
986 
987  public function savePageContentObject()
988  {
989  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
990  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
992  $this->object->getId(),
993  "xhtml_page"
994  );
995 
996  /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
997  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
998  $ta = new ilTextAreaInputGUI();
999  $ta->setRteTagSet("extended_table_img");
1000  $tags = $ta->getRteTagString();*/
1001 
1002  //$text = ilUtil::stripSlashes($_POST["page_content"],
1003  // true,
1004  // $tags);
1005 
1007  $_POST["page_content"],
1008  true,
1010  );
1011  if ($xpage_id > 0) {
1012  $xpage = new ilXHTMLPage($xpage_id);
1013  $xpage->setContent($text);
1014  $xpage->save();
1015  } else {
1016  $xpage = new ilXHTMLPage();
1017  $xpage->setContent($text);
1018  $xpage->save();
1020  $this->object->getId(),
1021  "xhtml_page",
1022  $xpage->getId()
1023  );
1024  }
1025 
1026  include_once("Services/RTE/classes/class.ilRTE.php");
1028  $text,
1029  $this->object->getType() . ":html",
1030  $this->object->getId()
1031  );
1032 
1033  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1034  $this->ctrl->redirect($this, "");
1035  }
1036 
1037  public function cancelPageContentObject()
1038  {
1039  $this->ctrl->redirect($this, "");
1040  }
1041 
1042  public function showLinkListObject()
1043  {
1044  $lng = $this->lng;
1045  $tree = $this->tree;
1046 
1047  $tpl = new ilTemplate(
1048  "tpl.container_link_help.html",
1049  true,
1050  true,
1051  "Services/Container"
1052  );
1053 
1054  $type_ordering = array(
1055  "cat", "fold", "crs", "grp", "chat", "frm", "lres",
1056  "glo", "webr", "file", "exc",
1057  "tst", "svy", "mep", "qpl", "spl");
1058 
1059  $childs = $tree->getChilds($_GET["ref_id"]);
1060  foreach ($childs as $child) {
1061  if (in_array($child["type"], array("lm", "sahs", "htlm"))) {
1062  $cnt["lres"]++;
1063  } else {
1064  $cnt[$child["type"]]++;
1065  }
1066  }
1067 
1068  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1069  $tpl->setVariable("TXT_HELP_HEADER", $lng->txt("help"));
1070  foreach ($type_ordering as $type) {
1071  $tpl->setCurrentBlock("row");
1072  $tpl->setVariable("ROWCOL", "tblrow" . ((($i++)%2)+1));
1073  if ($type != "lres") {
1074  $tpl->setVariable("TYPE", $lng->txt("objs_" . $type) .
1075  " (" . ((int) $cnt[$type]) . ")");
1076  } else {
1077  $tpl->setVariable("TYPE", $lng->txt("learning_resources") .
1078  " (" . ((int) $cnt["lres"]) . ")");
1079  }
1080  $tpl->setVariable("TXT_LINK", "[list-" . $type . "]");
1081  $tpl->parseCurrentBlock();
1082  }
1083  $tpl->show();
1084  exit;
1085  }
1086 
1091  {
1092  $this->adminCommands = false;
1093  }
1094 
1098  /* function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
1099  {
1100  if (!$this->adminCommands)
1101  {
1102  if (!$this->isActiveAdministrationPanel())
1103  {
1104  if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
1105  {
1106  $this->adminCommands = true;
1107  }
1108  }
1109  else
1110  {
1111  $this->adminCommands = $a_admin_com_included_in_list;
1112  }
1113  }
1114  }*/
1115 
1122  public function &newBlockTemplate()
1123  {
1124  $tpl = new ilTemplate(
1125  "tpl.container_list_block.html",
1126  true,
1127  true,
1128  "Services/Container"
1129  );
1130  $this->cur_row_type = "row_type_1";
1131  return $tpl;
1132  }
1133 
1141  public function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1142  {
1143  $icon = ilUtil::getImagePath("icon_" . $a_type . ".svg");
1144  $title = $this->lng->txt("objs_" . $a_type);
1145 
1146  if ($a_show_image) {
1147  $a_tpl->setCurrentBlock("container_header_row_image");
1148  $a_tpl->setVariable("HEADER_IMG", $icon);
1149  $a_tpl->setVariable("HEADER_ALT", $title);
1150  } else {
1151  $a_tpl->setCurrentBlock("container_header_row");
1152  }
1153 
1154  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1155  $a_tpl->parseCurrentBlock();
1156  //$a_tpl->touchBlock("container_row");
1157  }
1158 
1166  public function addStandardRow(
1167  &$a_tpl,
1168  $a_html,
1169  $a_item_ref_id = "",
1170  $a_item_obj_id = "",
1171  $a_image_type = ""
1172  ) {
1174 
1175  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1176  ? "row_type_2"
1177  : "row_type_1";
1178 
1179  $a_tpl->touchBlock($this->cur_row_type);
1180 
1181  $nbsp = true;
1182  if ($ilSetting->get("icon_position_in_lists") == "item_rows") {
1183  $icon = ilUtil::getImagePath("icon_" . $a_image_type . ".svg");
1184  $alt = $this->lng->txt("obj_" . $a_image_type);
1185 
1186  // custom icon
1187  if ($ilSetting->get("custom_icons") &&
1188  in_array($a_image_type, array("cat","grp","crs"))) {
1189  require_once("./Services/Container/classes/class.ilContainer.php");
1190  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "") {
1191  $icon = $path;
1192  }
1193  }
1194 
1195  $a_tpl->setCurrentBlock("block_row_image");
1196  $a_tpl->setVariable("ROW_IMG", $icon);
1197  $a_tpl->setVariable("ROW_ALT", $alt);
1198  $a_tpl->parseCurrentBlock();
1199  $nbsp = false;
1200  }
1201 
1202  if ($this->isActiveAdministrationPanel()) {
1203  $a_tpl->setCurrentBlock("block_row_check");
1204  $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
1205  $a_tpl->parseCurrentBlock();
1206  $nbsp = false;
1207  }
1208  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1209  if ($this->isActiveAdministrationPanel() &&
1211  $a_tpl->setCurrentBlock('block_position');
1212  $a_tpl->setVariable('POS_TYPE', $a_image_type);
1213  $a_tpl->setVariable('POS_ID', $a_item_ref_id);
1214  $a_tpl->setVariable('POSITION', sprintf('%.1f', $this->current_position++));
1215  $a_tpl->parseCurrentBlock();
1216  }
1217  if ($nbsp) {
1218  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1219  }
1220  $a_tpl->setCurrentBlock("container_standard_row");
1221  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1222  $a_tpl->parseCurrentBlock();
1223  $a_tpl->touchBlock("container_row");
1224  }
1225 
1229  public function addMessageRow(&$a_tpl, $a_message, $a_type)
1230  {
1231  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1232  ? "row_type_2"
1233  : "row_type_1";
1234 
1235  $a_tpl->touchBlock($this->cur_row_type);
1236 
1237  $type = $this->lng->txt("obj_" . $a_type);
1238  $a_message = str_replace("[type]", $type, $a_message);
1239 
1240  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1241 
1242  $a_tpl->setCurrentBlock("container_standard_row");
1243  $a_tpl->setVariable(
1244  "BLOCK_ROW_CONTENT",
1245  $a_message
1246  );
1247  $a_tpl->parseCurrentBlock();
1248  $a_tpl->touchBlock("container_row");
1249  }
1250 
1251  public function resetRowType()
1252  {
1253  $this->cur_row_type = "";
1254  }
1255 
1256 
1260  public function setPageEditorTabs()
1261  {
1262  $lng = $this->lng;
1263 
1264  if (!$this->isActiveAdministrationPanel()
1265  || strtolower($this->ctrl->getCmdClass()) != "ilcontainerpagegui") {
1266  return;
1267  }
1268 
1269  $lng->loadLanguageModule("content");
1270  //$tabs_gui = new ilTabsGUI();
1271  //$tabs_gui->setSubTabs();
1272 
1273  // back to upper context
1274  $this->tabs_gui->setBackTarget(
1275  $this->lng->txt("obj_cat"),
1276  $this->ctrl->getLinkTarget($this, "frameset"),
1277  ilFrameTargetInfo::_getFrame("MainContent")
1278  );
1279 
1280  $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilcontainerpagegui", "view"), array("", "view"), "ilcontainerpagegui");
1281 
1282  //$this->tpl->setTabs($tabs_gui->getHTML());
1283  }
1284 
1288  public function addStandardContainerSubTabs($a_include_view = true)
1289  {
1290  $ilTabs = $this->tabs;
1291  $ilAccess = $this->access;
1292  $lng = $this->lng;
1293  $ilCtrl = $this->ctrl;
1294  $ilUser = $this->user;
1296 
1297  if (!is_object($this->object)) {
1298  return;
1299  }
1300 
1301  if ($a_include_view && $ilAccess->checkAccess("read", "", $this->object->getRefId())) {
1302  if (!$this->isActiveAdministrationPanel()) {
1303  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "view"));
1304  } else {
1305  $ilTabs->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTarget($this, "disableAdministrationPanel"));
1306  }
1307  }
1308 
1309  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1310  (
1311  $this->adminCommands ||
1312  (is_object($this->object) &&
1313  ($ilAccess->checkAccess("write", "", $this->object->getRefId())))
1314  ||
1315  (is_object($this->object) &&
1316  ($this->object->getHiddenFilesFound())) ||
1317  $_SESSION["clipboard"]
1318  )
1319  ) {
1320  if ($this->isActiveAdministrationPanel()) {
1321  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, ""));
1322  } else {
1323  $ilTabs->addSubTab("manage", $lng->txt("cntr_manage"), $ilCtrl->getLinkTarget($this, "enableAdministrationPanel"));
1324  }
1325  }
1326  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1327  is_object($this->object) &&
1328  $ilAccess->checkAccess("write", "", $this->object->getRefId()) /* &&
1329  $this->object->getOrderType() == ilContainer::SORT_MANUAL */ // always on because of custom block order
1330  ) {
1331  $ilTabs->addSubTab("ordering", $lng->txt("cntr_ordering"), $ilCtrl->getLinkTarget($this, "editOrder"));
1332  }
1333  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1334  is_object($this->object) &&
1335  $ilAccess->checkAccess("write", "", $this->object->getRefId())
1336  ) {
1337  if ($ilSetting->get("enable_cat_page_edit")) {
1338  $ilTabs->addSubTab(
1339  "page_editor",
1340  $lng->txt("cntr_text_media_editor"),
1341  $ilCtrl->getLinkTarget($this, "editPageFrame"),
1342  ilFrameTargetInfo::_getFrame("MainContent")
1343  );
1344  }
1345  }
1346  }
1347 
1348 
1353  public function getTabs()
1354  {
1356  $ilCtrl = $this->ctrl;
1357 
1358  // edit permissions
1359  if ($rbacsystem->checkAccess('edit_permission', $this->ref_id)) {
1360  $this->tabs_gui->addTarget(
1361  "perm_settings",
1362  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1363  array("perm","info","owner"),
1364  'ilpermissiongui'
1365  );
1366  if ($ilCtrl->getNextClass() == "ilpermissiongui") {
1367  $this->tabs_gui->activateTab("perm_settings");
1368  }
1369  }
1370 
1371  // show clipboard
1372  if (strtolower($_GET["baseClass"]) == "ilrepositorygui" && !empty($_SESSION["clipboard"])) {
1373  $this->tabs_gui->addTarget(
1374  "clipboard",
1375  $this->ctrl->getLinkTarget($this, "clipboard"),
1376  "clipboard",
1377  get_class($this)
1378  );
1379  }
1380  }
1381 
1382  //*****************
1383  // COMMON METHODS (may be overwritten in derived classes
1384  // if special handling is necessary)
1385  //*****************
1386 
1391  {
1392  $_SESSION["il_cont_admin_panel"] = true;
1393  $this->ctrl->redirect($this, "render");
1394  }
1395 
1400  {
1401  $_SESSION["il_cont_admin_panel"] = false;
1402  $this->ctrl->redirect($this, "render");
1403  }
1404 
1408  public function editOrderObject()
1409  {
1410  $ilTabs = $this->tabs;
1411 
1412  $this->edit_order = true;
1413  $_SESSION["il_cont_admin_panel"] = false;
1414  $this->renderObject();
1415 
1416  $ilTabs->activateSubTab("ordering");
1417  }
1418 
1423  public function isActiveOrdering()
1424  {
1425  return $this->edit_order ? true : false;
1426  }
1427 
1432  public function isActiveItemOrdering()
1433  {
1434  if ($this->isActiveOrdering()) {
1436  }
1437  return false;
1438  }
1439 
1443  public function addToDeskObject()
1444  {
1446  $lng = $this->lng;
1447 
1448  if ((int) $ilSetting->get('disable_my_offers')) {
1449  return $this->renderObject();
1450  }
1451 
1452  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1454  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
1455  $this->renderObject();
1456  }
1457 
1461  public function removeFromDeskObject()
1462  {
1464  $lng = $this->lng;
1465 
1466  if ((int) $ilSetting->get('disable_my_offers')) {
1467  return $this->renderObject();
1468  }
1469 
1470  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
1472  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
1473  $this->renderObject();
1474  }
1475 
1476  // bugfix mantis 24559
1477  // undoing an erroneous change inside mantis 23516 by adding "Download Multiple Objects"-functionality for non-admins
1478  // as they don't have the possibility to use the multi-download-capability of the manage-tab
1479  public function enableMultiDownloadObject()
1480  {
1481  $this->multi_download_enabled = true;
1482  $this->renderObject();
1483  }
1484 
1485  public function isMultiDownloadEnabled()
1486  {
1488  }
1489 
1490  // BEGIN WebDAV: Lock/Unlock objects
1491  public function lockObject()
1492  {
1493  $tree = $this->tree;
1494  $ilUser = $this->user;
1496 
1497  if (!$rbacsystem->checkAccess("write", $_GET['item_ref_id'])) {
1498  $this->ilErr->raiseError($this->lng->txt('err_no_permission'), $this->ilErr->MESSAGE);
1499  }
1500 
1501 
1502  require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1504  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1506  require_once 'Services/WebDAV/classes/class.ilDAVLocks.php';
1507  $locks = new ilDAVLocks();
1508 
1509  $result = $locks->lockRef(
1510  $_GET['item_ref_id'],
1511  $ilUser->getId(),
1512  $ilUser->getLogin(),
1513  'ref_' . $_GET['item_ref_id'] . '_usr_' . $ilUser->getId(),
1514  time() + /*30*24*60**/60,
1515  0,
1516  'exclusive'
1517  );
1518 
1520  $this->lng->txt(
1521  ($result === true) ? 'object_locked' : $result
1522  ),
1523  true
1524  );
1525  }
1526  }
1527  $this->renderObject();
1528  }
1529  // END WebDAV: Lock/Unlock objects
1530 
1537  public function cutObject()
1538  {
1540  $ilCtrl = $this->ctrl;
1541  $ilErr = $this->error;
1542 
1543  if ($_GET["item_ref_id"] != "") {
1544  $_POST["id"] = array($_GET["item_ref_id"]);
1545  }
1546 
1547  $no_cut = [];
1548 
1549  if (!isset($_POST["id"])) {
1550  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1551  }
1552 
1553  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1554  foreach ($_POST["id"] as $ref_id) {
1555  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1556  $node_data = $this->tree->getNodeData($ref_id);
1557  $subtree_nodes = $this->tree->getSubTree($node_data);
1558 
1559  $all_node_data[] = $node_data;
1560  $all_subtree_nodes[] = $subtree_nodes;
1561 
1562  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1563  foreach ($subtree_nodes as $node) {
1564  if ($node['type'] == 'rolf') {
1565  continue;
1566  }
1567 
1568  if (!$rbacsystem->checkAccess('delete', $node["ref_id"])) {
1569  $no_cut[] = $node["ref_id"];
1570  }
1571  }
1572  }
1573  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1574  if (count($no_cut)) {
1575  $titles = array();
1576  foreach ((array) $no_cut as $cut_id) {
1577  $titles[] = ilObject::_lookupTitle(ilObject::_lookupObjId($cut_id));
1578  }
1579  $ilErr->raiseError(
1580  $this->lng->txt("msg_no_perm_cut") . " " . implode(',', (array) $titles),
1581  $ilErr->MESSAGE
1582  );
1583  }
1584  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1585  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1586  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1587 
1588  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
1589 
1590  return $this->initAndDisplayMoveIntoObjectObject();
1591  } // END CUT
1592 
1600  public function copyObject()
1601  {
1603  $ilCtrl = $this->ctrl;
1605  $ilErr = $this->error;
1606 
1607  $no_copy = [];
1608 
1609  if ($_GET["item_ref_id"] != "") {
1610  $_POST["id"] = array($_GET["item_ref_id"]);
1611  }
1612 
1613  if (!isset($_POST["id"])) {
1614  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1615  }
1616 
1617  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1618  $containers = 0;
1619  foreach ($_POST["id"] as $ref_id) {
1620  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1621  $node_data = $this->tree->getNodeData($ref_id);
1622 
1623  // count containers
1624  if ($objDefinition->isContainer($node_data["type"])) {
1625  $containers++;
1626  }
1627 
1628  $subtree_nodes = $this->tree->getSubTree($node_data);
1629 
1630  $all_node_data[] = $node_data;
1631  $all_subtree_nodes[] = $subtree_nodes;
1632 
1633  // CHECK COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1634  foreach ($subtree_nodes as $node) {
1635  if ($node['type'] == 'rolf') {
1636  continue;
1637  }
1638 
1639  if (!$rbacsystem->checkAccess('visible,read,copy', $node["ref_id"])) {
1640  $no_copy[] = $node["ref_id"];
1641  }
1642  }
1643  }
1644 
1645  if ($containers > 0 && count($_POST["id"]) > 1) {
1646  $ilErr->raiseError($this->lng->txt("cntr_container_only_on_their_own"), $ilErr->MESSAGE);
1647  }
1648 
1649  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1650  if (is_array($no_copy) && count($no_copy)) {
1651  $titles = array();
1652  foreach ((array) $no_copy as $copy_id) {
1653  $titles[] = ilObject::_lookupTitle(ilObject::_lookupObjId($copy_id));
1654  }
1655  $ilErr->raiseError(
1656  $this->lng->txt("msg_no_perm_copy") . " " . implode(',', $titles),
1657  $ilErr->MESSAGE
1658  );
1659  }
1660 
1661  // if we have a single container, set it as source id and redirect to ilObjectCopyGUI
1662  if (count($_POST["id"]) == 1) {
1663  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $_POST["id"][0]);
1664  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1665  } else {
1666  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($_POST["id"], "_"));
1667  $ilCtrl->redirectByClass("ilobjectcopygui", "initTargetSelection");
1668  }
1669 
1670  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1671  $_SESSION["clipboard"]["cmd"] = $ilCtrl->getCmd();
1672  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1673 
1674  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"), true);
1675 
1677  } // END COPY
1678 
1679  public function downloadObject()
1680  {
1682  $ilErr = $this->error;
1683 
1684  $no_download = [];
1685  $no_perm = [];
1686 
1687  if ($_GET["item_ref_id"] != "") {
1688  $_POST["id"] = array($_GET["item_ref_id"]);
1689  }
1690 
1691  if (!isset($_POST["id"])) {
1692  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1693  }
1694 
1695  // FOR ALL OBJECTS THAT SHOULD BE DOWNLOADED
1696  foreach ($_POST["id"] as $ref_id) {
1698  $obj_type = $object->getType();
1699  if (!in_array($obj_type, array("fold", "file"))) {
1700  $no_download[] = $object->getType();
1701  } elseif (!$rbacsystem->checkAccess('read', $ref_id)) {
1702  $no_perm[] = $ref_id;
1703  }
1704  }
1705 
1706  // IF THERE IS ANY OBJECT THAT CANNOT BE DOWNLOADED
1707  if (count($no_download)) {
1708  $no_download = array_unique($no_download);
1709  foreach ($no_download as $type) {
1710  $txt_objs[] = $this->lng->txt("objs_" . $type);
1711  }
1712  $ilErr->raiseError(implode(', ', $txt_objs) . " " . $this->lng->txt("msg_obj_no_download"), $ilErr->MESSAGE);
1713  }
1714 
1715  // NO ACCESS
1716  if (count($no_perm)) {
1717  $ilErr->raiseError(
1718  $this->lng->txt("msg_obj_perm_download") . " " . implode(',', $no_perm),
1719  $ilErr->MESSAGE
1720  );
1721  }
1722 
1723  // download the objects
1724  $this->downloadMultipleObjects($_POST["id"]);
1725  }
1726 
1727  private function downloadMultipleObjects($a_ref_ids)
1728  {
1729  $lng = $this->lng;
1731  $ilAccess = $this->access;
1732 
1733  include_once 'Modules/Folder/classes/class.ilObjFolder.php';
1734  include_once 'Modules/File/classes/class.ilObjFile.php';
1735  include_once 'Modules/File/classes/class.ilFileException.php';
1736 
1737  // create temporary file to download
1738  $zip = PATH_TO_ZIP;
1739  $tmpdir = ilUtil::ilTempnam();
1740  ilUtil::makeDir($tmpdir);
1741 
1742  try {
1743  // copy each selected object
1744  foreach ($a_ref_ids as $ref_id) {
1745  if (!$ilAccess->checkAccess("read", "", $ref_id)) {
1746  continue;
1747  }
1748 
1749  if (ilObject::_isInTrash($ref_id)) {
1750  continue;
1751  }
1752 
1753  // get object
1755  $obj_type = $object->getType();
1756  if ($obj_type == "fold") {
1757  // copy folder to temp directory
1758  self::recurseFolder($ref_id, $object->getTitle(), $tmpdir);
1759  } elseif ($obj_type == "file") {
1760  // copy file to temp directory
1761  self::copyFile($object->getId(), $object->getTitle(), $tmpdir);
1762  }
1763  }
1764 
1765  // compress the folder
1766  $deliverFilename = ilUtil::getAsciiFilename($this->object->getTitle()) . ".zip";
1767  $tmpzipfile = ilUtil::ilTempnam() . ".zip";
1768  ilUtil::zip($tmpdir, $tmpzipfile, true);
1769  ilUtil::delDir($tmpdir);
1770  ilUtil::deliverFile($tmpzipfile, $deliverFilename, '', false, true, true);
1771  } catch (ilFileException $e) {
1772  ilUtil::sendInfo($e->getMessage(), true);
1773  }
1774  }
1775 
1784  private static function recurseFolder($refid, $title, $tmpdir)
1785  {
1786  global $DIC;
1787 
1788  $rbacsystem = $DIC->rbac()->system();
1789  $tree = $DIC->repositoryTree();
1790  $ilAccess = $DIC->access();
1791 
1792  $tmpdir = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1793  ilUtil::makeDir($tmpdir);
1794 
1795  $subtree = $tree->getChildsByTypeFilter($refid, array("fold","file"));
1796 
1797  foreach ($subtree as $child) {
1798  if (!$ilAccess->checkAccess("read", "", $child["ref_id"])) {
1799  continue;
1800  }
1801 
1802  if (ilObject::_isInTrash($child["ref_id"])) {
1803  continue;
1804  }
1805 
1806  if ($child["type"] == "fold") {
1807  self::recurseFolder($child["ref_id"], $child["title"], $tmpdir);
1808  } else {
1809  self::copyFile($child["obj_id"], $child["title"], $tmpdir);
1810  }
1811  }
1812  }
1813 
1814  private static function copyFile($obj_id, $title, $tmpdir)
1815  {
1816  $newFilename = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
1817 
1818  // copy to temporary directory
1819  $oldFilename = ilObjFile::_lookupAbsolutePath($obj_id);
1820 
1821  if (!copy($oldFilename, $newFilename)) {
1822  throw new ilFileException("Could not copy " . $oldFilename . " to " . $newFilename);
1823  }
1824 
1825  touch($newFilename, filectime($oldFilename));
1826  }
1827 
1834  public function linkObject()
1835  {
1837  $ilCtrl = $this->ctrl;
1838  $ilErr = $this->error;
1839 
1840  $no_cut = [];
1841  $no_link = [];
1842 
1843  if ($_GET["item_ref_id"] != "") {
1844  $_POST["id"] = array($_GET["item_ref_id"]);
1845  }
1846 
1847  if (!isset($_POST["id"])) {
1848  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1849  }
1850 
1851  // CHECK ACCESS
1852  foreach ($_POST["id"] as $ref_id) {
1853  if (!$rbacsystem->checkAccess('delete', $ref_id)) {
1854  $no_cut[] = $ref_id;
1855  }
1856 
1858 
1859  if (!$this->objDefinition->allowLink($object->getType())) {
1860  $no_link[] = $object->getType();
1861  }
1862  }
1863 
1864  // NO ACCESS
1865  if (count($no_cut)) {
1866  $ilErr->raiseError($this->lng->txt("msg_no_perm_link") . " " .
1867  implode(',', $no_cut), $ilErr->MESSAGE);
1868  }
1869 
1870  if (count($no_link)) {
1871  //#12203
1872  $ilErr->raiseError($this->lng->txt("msg_obj_no_link"), $ilErr->MESSAGE);
1873  }
1874 
1875  // WRITE TO CLIPBOARD
1876  $clipboard["parent"] = $_GET["ref_id"];
1877  $clipboard["cmd"] = $ilCtrl->getCmd();
1878 
1879  foreach ($_POST["id"] as $ref_id) {
1880  $clipboard["ref_ids"][] = $ref_id;
1881  }
1882 
1883  $_SESSION["clipboard"] = $clipboard;
1884 
1885  $suffix = 'p';
1886  if (count($clipboard["ref_ids"]) == 1) {
1887  $suffix = 's';
1888  }
1889  ilUtil::sendInfo($this->lng->txt("msg_link_clipboard_" . $suffix), true);
1890 
1892  } // END LINK
1893 
1894 
1900  public function clearObject()
1901  {
1902  unset($_SESSION["clipboard"]);
1903  unset($_SESSION["il_rep_clipboard"]);
1904 
1905  //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1906 
1907  // only redirect if clipboard was cleared
1908  if (isset($_POST["cmd"]["clear"])) {
1909  ilUtil::sendSuccess($this->lng->txt("msg_clear_clipboard"), true);
1910  // fixed mantis 0018474: Clear Clipboard redirects to Subtab View, instead of Subtab "Edit Multiple"
1911  $this->ctrl->redirect($this, 'render');
1912  }
1913  }
1914 
1916  {
1920  $ilLog = $this->log;
1921  $tree = $this->tree;
1922  $ilObjDataCache = $this->obj_data_cache;
1923  $ilUser = $this->user;
1924  $ilErr = $this->error;
1925 
1926  $exists = [];
1927  $is_child = [];
1928  $not_allowed_subobject = [];
1929  $no_paste = [];
1930 
1931  $command = $_SESSION['clipboard']['cmd'];
1932  if (!in_array($command, array('cut', 'link', 'copy'))) {
1933  $message = __METHOD__ . ": cmd was neither 'cut', 'link' nor 'copy'; may be a hack attempt!";
1934  $ilErr->raiseError($message, $ilErr->WARNING);
1935  }
1936 
1937  if ($command == 'cut') {
1938  if (isset($_POST['node']) && (int) $_POST['node']) {
1939  $_POST['nodes'] = array($_POST['node']);
1940  }
1941  }
1942 
1943  if (!is_array($_POST['nodes']) || !count($_POST['nodes'])) {
1944  ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'));
1945  switch ($command) {
1946  case 'cut':
1947  $this->showPasteTreeObject();
1948  break;
1949  case 'copy':
1950  $this->showPasteTreeObject();
1951  break;
1952  case 'link':
1953  $this->showPasteTreeObject();
1954  break;
1955  }
1956  return;
1957  }
1958 
1959  // this loop does all checks
1960  $folder_objects_cache = array();
1961  foreach ($_SESSION['clipboard']['ref_ids'] as $ref_id) {
1962  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
1963  $current_parent_id = $tree->getParentId($obj_data->getRefId());
1964 
1965  foreach ($_POST['nodes'] as $folder_ref_id) {
1966  if (!array_key_exists($folder_ref_id, $folder_objects_cache)) {
1967  $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id);
1968  }
1969 
1970  // CHECK ACCESS
1971  if (!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType())) {
1972  $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() . ']');
1973  }
1974 
1975  // CHECK IF REFERENCE ALREADY EXISTS
1976  if ($folder_ref_id == $current_parent_id) {
1977  $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() . ']');
1978  }
1979 
1980  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1981  if ($tree->isGrandChild($ref_id, $folder_ref_id) ||
1982  $ref_id == $folder_ref_id) {
1983  $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']');
1984  }
1985 
1986  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
1987  if (!in_array($obj_data->getType(), array_keys($folder_objects_cache[$folder_ref_id]->getPossibleSubObjects()))) {
1988  $not_allowed_subobject[] = sprintf(
1989  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
1990  $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']',
1991  $GLOBALS['lng']->txt('obj_' . $obj_data->getType())
1992  );
1993  }
1994  }
1995  }
1996 
1998  // process checking results
1999  if (count($exists) && $command != "copy") {
2000  $error .= implode('<br />', $exists);
2001  }
2002 
2003  if (count($is_child)) {
2004  $error .= $error != '' ? '<br />' : '';
2005  $error .= implode('<br />', $is_child);
2006  }
2007 
2008  if (count($not_allowed_subobject)) {
2009  $error .= $error != '' ? '<br />' : '';
2010  $error .= implode('<br />', $not_allowed_subobject);
2011  }
2012 
2013  if (count($no_paste)) {
2014  $error .= $error != '' ? '<br />' : '';
2015  $error .= implode('<br />', $no_paste);
2016  }
2017 
2018  if ($error != '') {
2020  switch ($command) {
2021  case 'cut':
2022  $this->showPasteTreeObject();
2023  break;
2024  case 'copy':
2025  $this->showPasteTreeObject();
2026  break;
2027  case 'link':
2028  $this->showPasteTreeObject();
2029  break;
2030  }
2031  return;
2032  }
2033 
2034  // log pasteObject call
2035  $ilLog->write(__METHOD__ . ", cmd: " . $command);
2036 
2038  // everything ok: now paste the objects to new location
2039 
2040  // to prevent multiple actions via back/reload button
2041  $ref_ids = $_SESSION['clipboard']['ref_ids'];
2042  unset($_SESSION['clipboard']['ref_ids']);
2043 
2044  // BEGIN ChangeEvent: Record paste event.
2045  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2046  // END ChangeEvent: Record paste event.
2047 
2048  // process COPY command
2049  if ($command == 'copy') {
2050  foreach ($_POST['nodes'] as $folder_ref_id) {
2051  foreach ($ref_ids as $ref_id) {
2052  $revIdMapping = array();
2053 
2054  $oldNode_data = $tree->getNodeData($ref_id);
2055  if ($oldNode_data['parent'] == $folder_ref_id) {
2056  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2057  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'], null);
2058  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, $newTitle);
2059  } else {
2060  $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, null);
2061  }
2062 
2063  // BEGIN ChangeEvent: Record copy event.
2064  $old_parent_data = $tree->getParentNodeData($ref_id);
2065  $newNode_data = $tree->getNodeData($newRef);
2067  $oldNode_data['type'],
2068  $ref_id,
2069  $oldNode_data['obj_id'],
2070  $ilUser->getId()
2071  );
2073  $newNode_data['obj_id'],
2074  $ilUser->getId(),
2075  'add',
2076  $ilObjDataCache->lookupObjId($folder_ref_id)
2077  );
2078  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2079  // END PATCH ChangeEvent: Record cut event.
2080  }
2081  }
2082 
2083  ilUtil::sendSuccess($this->lng->txt('msg_cloned'), true);
2084  } // END COPY
2085 
2086  // process CUT command
2087  if ($command == 'cut') {
2088  foreach ($_POST['nodes'] as $folder_ref_id) {
2089  foreach ($ref_ids as $ref_id) {
2090  // Store old parent
2091  $old_parent = $tree->getParentId($ref_id);
2092  $tree->moveTree($ref_id, $folder_ref_id);
2093  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
2094 
2095  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
2097 
2098  // BEGIN ChangeEvent: Record cut event.
2099  $node_data = $tree->getNodeData($ref_id);
2100  $old_parent_data = $tree->getNodeData($old_parent);
2102  $node_data['obj_id'],
2103  $ilUser->getId(),
2104  'remove',
2105  $old_parent_data['obj_id']
2106  );
2108  $node_data['obj_id'],
2109  $ilUser->getId(),
2110  'add',
2111  $ilObjDataCache->lookupObjId($folder_ref_id)
2112  );
2113  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2114  // END PATCH ChangeEvent: Record cut event.
2115  }
2116 
2117  // prevent multiple iterations for cut cmommand
2118  break;
2119  }
2120 
2121  ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
2122  } // END CUT
2123 
2124  // process LINK command
2125  if ($command == 'link') {
2126  $linked_to_folders = array();
2127 
2128  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
2129  $rbac_log_active = ilRbacLog::isActive();
2130 
2131  foreach ($_POST['nodes'] as $folder_ref_id) {
2132  $linked_to_folders[$folder_ref_id] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id));
2133 
2134  foreach ($ref_ids as $ref_id) {
2135  // get node data
2136  $top_node = $tree->getNodeData($ref_id);
2137 
2138  // get subnodes of top nodes
2139  $subnodes[$ref_id] = $tree->getSubtree($top_node);
2140  }
2141 
2142  // now move all subtrees to new location
2143  foreach ($subnodes as $key => $subnode) {
2144  // first paste top_node....
2146  $new_ref_id = $obj_data->createReference();
2147  $obj_data->putInTree($folder_ref_id);
2148  $obj_data->setPermissions($folder_ref_id);
2149 
2150  // rbac log
2151  if ($rbac_log_active) {
2152  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
2153  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
2154  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, $key);
2155  }
2156 
2157  // BEGIN ChangeEvent: Record link event.
2158  $node_data = $tree->getNodeData($new_ref_id);
2160  $node_data['obj_id'],
2161  $ilUser->getId(),
2162  'add',
2163  $ilObjDataCache->lookupObjId($folder_ref_id)
2164  );
2165  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2166  // END PATCH ChangeEvent: Record link event.
2167  }
2168 
2169  $ilLog->write(__METHOD__ . ', link finished');
2170  }
2171 
2172  $linked_targets = array();
2173  if (count($linked_to_folders)) {
2174  require_once 'Services/Link/classes/class.ilLink.php';
2175  foreach ($linked_to_folders as $ref_id => $title) {
2176  $linked_targets[] = '<a href="' . ilLink::_getLink($ref_id) . '">' . $title . '</a>';
2177  }
2178  }
2179 
2180  $suffix = 'p';
2181  if (count($ref_ids) == 1) {
2182  $suffix = 's';
2183  }
2184  ilUtil::sendSuccess(sprintf($this->lng->txt('mgs_objects_linked_to_the_following_folders_' . $suffix), implode(', ', $linked_targets)), true);
2185  } // END LINK
2186 
2187  // clear clipboard
2188  $this->clearObject();
2189 
2190  $this->ctrl->returnToParent($this);
2191  }
2192 
2194  {
2195  $tree = $this->tree;
2196 
2197  // empty session on init
2198  $_SESSION['paste_linked_repexpand'] = array();
2199 
2200  // copy opend nodes from repository explorer
2201  $_SESSION['paste_linked_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2202 
2203  // open current position
2204  $path = $tree->getPathId((int) $_GET['ref_id']);
2205  foreach ((array) $path as $node_id) {
2206  if (!in_array($node_id, $_SESSION['paste_linked_repexpand'])) {
2207  $_SESSION['paste_linked_repexpand'][] = $node_id;
2208  }
2209  }
2210 
2211  return $this->showPasteTreeObject();
2212  }
2213 
2217  public function showPasteTreeObject()
2218  {
2219  $ilTabs = $this->tabs;
2220  $ilToolbar = $this->toolbar;
2221  $ilErr = $this->error;
2222 
2223  $ilTabs->setTabActive('view_content');
2224 
2225  if (!in_array($_SESSION['clipboard']['cmd'], array('link', 'copy', 'cut'))) {
2226  $message = __METHOD__ . ": Unknown action.";
2227  $ilErr->raiseError($message, $ilErr->WARNING);
2228  }
2229  $cmd = $_SESSION['clipboard']['cmd'];
2230 
2231  //
2232  $exp = $this->getTreeSelectorGUI($cmd);
2233  if ($exp->handleCommand()) {
2234  return;
2235  }
2236  $output = $exp->getHTML();
2237 
2238  $txt_var = ($cmd == "copy")
2239  ? "copy"
2240  : "paste";
2241 
2242  // toolbars
2243  $t = new ilToolbarGUI();
2244  $t->setFormAction($this->ctrl->getFormAction($this, "performPasteIntoMultipleObjects"));
2245 
2246  include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
2248  $b->setCaption($txt_var);
2249  $b->setCommand("performPasteIntoMultipleObjects");
2250 
2251  //$t->addFormButton($this->lng->txt($txt_var), "performPasteIntoMultipleObjects");
2252  $t->addStickyItem($b);
2253 
2254  $t->addSeparator();
2255  $this->lng->loadLanguageModule('obj');
2256  $t->addFormButton($this->lng->txt("obj_insert_into_clipboard"), "keepObjectsInClipboard");
2257 
2258  $t->addFormButton($this->lng->txt("cancel"), "cancelMoveLink");
2259  $t->setCloseFormTag(false);
2260  $t->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), " ");
2261  $output = $t->getHTML() . $output;
2262  $t->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), " ");
2263  $t->setCloseFormTag(true);
2264  $t->setOpenFormTag(false);
2265  $output.= "<br />" . $t->getHTML();
2266 
2267  $this->tpl->setContent($output);
2268  }
2269 
2270 
2275  public function cancelMoveLinkObject()
2276  {
2277  unset($_SESSION['clipboard']);
2278  $GLOBALS['ilCtrl']->returnToParent($this);
2279  }
2280 
2285  {
2286  ilUtil::sendSuccess($this->lng->txt("obj_inserted_clipboard"), true);
2287  $GLOBALS['ilCtrl']->returnToParent($this);
2288  }
2289 
2290 
2292  {
2293  $tree = $this->tree;
2294 
2295  // empty session on init
2296  $_SESSION['paste_copy_repexpand'] = array();
2297 
2298  // copy opend nodes from repository explorer
2299  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2300 
2301  // open current position
2302  $path = $tree->getPathId((int) $_GET['ref_id']);
2303  foreach ((array) $path as $node_id) {
2304  if (!in_array($node_id, $_SESSION['paste_copy_repexpand'])) {
2305  $_SESSION['paste_copy_repexpand'][] = $node_id;
2306  }
2307  }
2308 
2309  return $this->showPasteTreeObject();
2310  }
2311 
2312 
2314  {
2315  $tree = $this->tree;
2316 
2317  // empty session on init
2318  $_SESSION['paste_cut_repexpand'] = array();
2319 
2320  // copy opend nodes from repository explorer
2321  $_SESSION['paste_cut_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
2322 
2323  // open current position
2324  $path = $tree->getPathId((int) $_GET['ref_id']);
2325  foreach ((array) $path as $node_id) {
2326  if (!in_array($node_id, $_SESSION['paste_cut_repexpand'])) {
2327  $_SESSION['paste_cut_repexpand'][] = $node_id;
2328  }
2329  }
2330 
2331  return $this->showPasteTreeObject();
2332  }
2333 
2334 
2341  public function pasteObject()
2342  {
2345  $ilLog = $this->log;
2346  $tree = $this->tree;
2347  $ilUser = $this->user;
2348  $ilCtrl = $this->ctrl;
2349  $ilErr = $this->error;
2350 
2351  // BEGIN ChangeEvent: Record paste event.
2352  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
2353  // END ChangeEvent: Record paste event.
2354 
2355  //var_dump($_SESSION["clipboard"]);exit;
2356  if (!in_array($_SESSION["clipboard"]["cmd"], array("cut","link","copy"))) {
2357  $message = get_class($this) . "::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
2358  $ilErr->raiseError($message, $ilErr->WARNING);
2359  }
2360 
2361  // this loop does all checks
2362  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id) {
2363  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
2364 
2365  // CHECK ACCESS
2366  if (!$rbacsystem->checkAccess('create', $this->object->getRefId(), $obj_data->getType())) {
2367  $no_paste[] = $ref_id;
2368  $no_paste_titles[] = $obj_data->getTitle();
2369  }
2370 
2371  // CHECK IF REFERENCE ALREADY EXISTS
2372  if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId())) {
2373  $exists[] = $ref_id;
2374  break;
2375  }
2376 
2377  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
2378  if ($this->tree->isGrandChild($ref_id, $this->object->getRefId())) {
2379  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2380  }
2381 
2382  if ($ref_id == $this->object->getRefId()) {
2383  $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
2384  }
2385 
2386  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
2387  $obj_type = $obj_data->getType();
2388 
2389  if (!in_array($obj_type, array_keys($this->object->getPossibleSubObjects()))) {
2390  $not_allowed_subobject[] = $obj_data->getType();
2391  }
2392  }
2393 
2395  // process checking results
2396  // BEGIN WebDAV: Copying an object into the same container is allowed
2397  if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy") {
2398  // END WebDAV: Copying an object into the same container is allowed
2399  $ilErr->raiseError($this->lng->txt("msg_obj_exists"), $ilErr->MESSAGE);
2400  }
2401 
2402  if (count($is_child)) {
2403  $ilErr->raiseError(
2404  $this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child),
2405  $ilErr->MESSAGE
2406  );
2407  }
2408 
2409  if (count($not_allowed_subobject)) {
2410  $ilErr->raiseError(
2411  $this->lng->txt("msg_may_not_contain") . " " . implode(',', $not_allowed_subobject),
2412  $ilErr->MESSAGE
2413  );
2414  }
2415 
2416  if (count($no_paste)) {
2417  $ilErr->raiseError($this->lng->txt("msg_no_perm_paste") . " " .
2418  implode(',', $no_paste), $ilErr->MESSAGE);
2419  }
2420 
2421  // log pasteObject call
2422  $ilLog->write("ilObjectGUI::pasteObject(), cmd: " . $_SESSION["clipboard"]["cmd"]);
2423 
2425  // everything ok: now paste the objects to new location
2426 
2427  // to prevent multiple actions via back/reload button
2428  $ref_ids = $_SESSION["clipboard"]["ref_ids"];
2429  unset($_SESSION["clipboard"]["ref_ids"]);
2430 
2431  // BEGIN WebDAV: Support a copy command in the repository
2432  // process COPY command
2433  if ($_SESSION["clipboard"]["cmd"] == "copy") {
2434  unset($_SESSION["clipboard"]["cmd"]);
2435 
2436  // new implementation, redirects to ilObjectCopyGUI
2437  if (count($ref_ids) == 1) {
2438  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2439  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $ref_ids[0]);
2440  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2441  } else {
2442  $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
2443  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($ref_ids, "_"));
2444  $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
2445  }
2446 
2447 
2448 
2449  /* old implementation
2450 
2451  foreach($ref_ids as $ref_id)
2452  {
2453  $revIdMapping = array();
2454 
2455  $oldNode_data = $tree->getNodeData($ref_id);
2456  if ($oldNode_data['parent'] == $this->object->getRefId())
2457  {
2458  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
2459  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
2460  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
2461  }
2462  else
2463  {
2464  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
2465  }
2466 
2467  // BEGIN ChangeEvent: Record copy event.
2468  $old_parent_data = $tree->getParentNodeData($ref_id);
2469  $newNode_data = $tree->getNodeData($newRef);
2470  ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
2471  $oldNode_data['obj_id'], $ilUser->getId());
2472  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
2473  $this->object->getId());
2474  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
2475  // END ChangeEvent: Record copy event.
2476  }*/
2477 
2478  $ilLog->write("ilObjectGUI::pasteObject(), copy finished");
2479  }
2480  // END WebDAV: Support a Copy command in the repository
2481 
2482  // process CUT command
2483  if ($_SESSION["clipboard"]["cmd"] == "cut") {
2484  foreach ($ref_ids as $ref_id) {
2485  // Store old parent
2486  $old_parent = $tree->getParentId($ref_id);
2487  $this->tree->moveTree($ref_id, $this->object->getRefId());
2488  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
2489 
2490  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
2492 
2493  // BEGIN ChangeEvent: Record cut event.
2494  $node_data = $tree->getNodeData($ref_id);
2495  $old_parent_data = $tree->getNodeData($old_parent);
2497  $node_data['obj_id'],
2498  $ilUser->getId(),
2499  'remove',
2500  $old_parent_data['obj_id']
2501  );
2503  $node_data['obj_id'],
2504  $ilUser->getId(),
2505  'add',
2506  $this->object->getId()
2507  );
2508  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2509  // END PATCH ChangeEvent: Record cut event.
2510  }
2511  } // END CUT
2512 
2513  // process LINK command
2514  if ($_SESSION["clipboard"]["cmd"] == "link") {
2515  foreach ($ref_ids as $ref_id) {
2516  // get node data
2517  $top_node = $this->tree->getNodeData($ref_id);
2518 
2519  // get subnodes of top nodes
2520  $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
2521  }
2522 
2523  // now move all subtrees to new location
2524  foreach ($subnodes as $key => $subnode) {
2525  // first paste top_node....
2526  $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
2527  $new_ref_id = $obj_data->createReference();
2528  $obj_data->putInTree($_GET["ref_id"]);
2529  $obj_data->setPermissions($_GET["ref_id"]);
2530 
2531  // BEGIN ChangeEvent: Record link event.
2532  $node_data = $tree->getNodeData($new_ref_id);
2534  $node_data['obj_id'],
2535  $ilUser->getId(),
2536  'add',
2537  $this->object->getId()
2538  );
2539  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
2540  // END PATCH ChangeEvent: Record link event.
2541  }
2542 
2543  $ilLog->write("ilObjectGUI::pasteObject(), link finished");
2544  } // END LINK
2545 
2546  // save cmd for correct message output after clearing the clipboard
2547  $last_cmd = $_SESSION["clipboard"]["cmd"];
2548 
2549 
2550  // clear clipboard
2551  $this->clearObject();
2552 
2553  if ($last_cmd == "cut") {
2554  ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"), true);
2555  }
2556  // BEGIN WebDAV: Support a copy command in repository
2557  elseif ($last_cmd == "copy") {
2558  ilUtil::sendSuccess($this->lng->txt("msg_cloned"), true);
2559  } elseif ($last_cmd == 'link') {
2560  // END WebDAV: Support copy command in repository
2561  ilUtil::sendSuccess($this->lng->txt("msg_linked"), true);
2562  }
2563 
2564  $this->ctrl->returnToParent($this);
2565  } // END PASTE
2566 
2567 
2571  public function clipboardObject()
2572  {
2573  $ilErr = $this->error;
2574  $ilLog = $this->log;
2575  $ilTabs = $this->tabs;
2576  $tpl = $this->tpl;
2577  $ilToolbar = $this->toolbar;
2578  $ilCtrl = $this->ctrl;
2579  $lng = $this->lng;
2580 
2581  $ilTabs->activateTab("clipboard");
2582 
2583  // function should not be called if clipboard is empty
2584  if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard'])) {
2585  $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
2586  $ilLog->write($message, $ilLog->FATAL);
2587  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->WARNING);
2588  }
2589 
2590  $data = array();
2591  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id) {
2592  if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
2593  continue;
2594  }
2595 
2596  $data[] = array(
2597  "type" => $tmp_obj->getType(),
2598  "type_txt" => $this->lng->txt("obj_" . $tmp_obj->getType()),
2599  "title" => $tmp_obj->getTitle(),
2600  "cmd" => ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]),
2601  "ref_id" => $ref_id,
2602  "obj_id" => $tmp_obj->getId()
2603  );
2604 
2605  unset($tmp_obj);
2606  }
2607 
2608  include_once("./Services/Object/classes/class.ilObjClipboardTableGUI.php");
2609  $tab = new ilObjClipboardTableGUI($this, "clipboard");
2610  $tab->setData($data);
2611  $tpl->setContent($tab->getHTML());
2612 
2613  if (count($data) > 0) {
2614  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
2615  $ilToolbar->addFormButton(
2616  $lng->txt("insert_object_here"),
2617  "paste"
2618  );
2619  $ilToolbar->addFormButton(
2620  $lng->txt("clear_clipboard"),
2621  "clear"
2622  );
2623  }
2624 
2625  return true;
2626  }
2627 
2628 
2633  public function showCustomIconsEditing($a_input_colspan = 1, ilPropertyFormGUI $a_form = null, $a_as_section = true)
2634  {
2636  if ($ilSetting->get("custom_icons")) {
2637  if ($a_form) {
2638  $custom_icon = $this->object->getCustomIconPath();
2639 
2640  if ($a_as_section) {
2642  $title->setTitle($this->lng->txt("icon_settings"));
2643  } else {
2644  $title = new ilCustomInputGUI($this->lng->txt("icon_settings"), "");
2645  }
2646  $a_form->addItem($title);
2647 
2648  $caption = $this->lng->txt("cont_custom_icon");
2649  $icon = new ilImageFileInputGUI($caption, "cont_icon");
2650  $icon->setSuffixes(array("svg"));
2651  $icon->setUseCache(false);
2652  $icon->setImage($custom_icon);
2653  if ($a_as_section) {
2654  $a_form->addItem($icon);
2655  } else {
2656  $title->addSubItem($icon);
2657  }
2658  }
2659  }
2660  }
2661 
2663  {
2664  $ilAccess = $this->access;
2665 
2666  // #10081
2667  if ($_SESSION["il_cont_admin_panel"] &&
2668  $this->object->getRefId() &&
2669  !$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
2670  return false;
2671  }
2672 
2673  return $_SESSION["il_cont_admin_panel"];
2674  }
2675 
2679  public function setColumnSettings(ilColumnGUI $column_gui)
2680  {
2681  $ilAccess = $this->access;
2682  parent::setColumnSettings($column_gui);
2683 
2684  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
2685  $this->isActiveAdministrationPanel() &&
2686  $this->allowBlocksMoving()) {
2687  $column_gui->setEnableMovement(true);
2688  }
2689 
2690  $column_gui->setRepositoryItems(
2691  $this->object->getSubItems($this->isActiveAdministrationPanel(), true)
2692  );
2693 
2694  //if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
2695  // && $this->allowBlocksConfigure())
2696  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
2697  $column_gui->setBlockProperty("news", "settings", true);
2698  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
2699  $column_gui->setBlockProperty("news", "default_visibility_option", true);
2700  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
2701  }
2702 
2703  if ($this->isActiveAdministrationPanel()) {
2704  $column_gui->setAdminCommands(true);
2705  }
2706  }
2707 
2711  public function allowBlocksMoving()
2712  {
2713  return true;
2714  }
2715 
2719  public function allowBlocksConfigure()
2720  {
2721  return true;
2722  }
2723 
2731  public function cloneWizardPageTreeObject()
2732  {
2733  $this->cloneWizardPageObject(true);
2734  }
2735 
2743  public function cloneWizardPageListObject()
2744  {
2745  $this->cloneWizardPageObject(false);
2746  }
2747 
2754  public function cloneWizardPageObject($a_tree_view = true)
2755  {
2756  include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
2757 
2758  $ilObjDataCache = $this->obj_data_cache;
2759  $tree = $this->tree;
2760 
2761  if (!$_REQUEST['clone_source']) {
2762  ilUtil::sendFailure($this->lng->txt('select_one'));
2763  if (isset($_SESSION['wizard_search_title'])) {
2764  $this->searchCloneSourceObject();
2765  } else {
2766  $this->createObject();
2767  }
2768  return false;
2769  }
2770  $source_id = $_REQUEST['clone_source'];
2771  $new_type = $_REQUEST['new_type'];
2772  $this->ctrl->setParameter($this, 'clone_source', (int) $_REQUEST['clone_source']);
2773  $this->ctrl->setParameter($this, 'new_type', $new_type);
2774 
2775 
2776  // Generell JavaScript
2777  $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
2778  $this->tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
2779 
2780 
2781  $this->tpl->addBlockFile(
2782  'ADM_CONTENT',
2783  'adm_content',
2784  'tpl.container_wizard_page.html',
2785  "Services/Container"
2786  );
2787  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
2788  $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_' . $new_type . '.svg'));
2789  $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_' . $new_type));
2790  $this->tpl->setVariable('TXT_DUPLICATE', $this->lng->txt($new_type . '_wizard_page'));
2791  $this->tpl->setVariable('INFO_DUPLICATE', $this->lng->txt($new_type . '_copy_threads_info'));
2792  $this->tpl->setVariable('BTN_COPY', $this->lng->txt('obj_' . $new_type . '_duplicate'));
2793  $this->tpl->setVariable('BTN_BACK', $this->lng->txt('btn_back'));
2794  if (isset($_SESSION['wizard_search_title'])) {
2795  $this->tpl->setVariable('CMD_BACK', 'searchCloneSource');
2796  } else {
2797  $this->tpl->setVariable('CMD_BACK', 'create');
2798  }
2799 
2800  $this->tpl->setVariable('BTN_TREE', $this->lng->txt('treeview'));
2801  $this->tpl->setVariable('BTN_LIST', $this->lng->txt('flatview'));
2802 
2803  // Fill item rows
2804  // tree view
2805  if ($a_tree_view) {
2806  $first = true;
2807  $has_items = false;
2808  foreach ($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id), true) as $node) {
2809  if ($first == true) {
2810  $first = false;
2811  continue;
2812  }
2813 
2814  if ($node['type'] == 'rolf') {
2815  continue;
2816  }
2817 
2818  $has_items = true;
2819 
2820  for ($i = $source_node['depth'];$i < $node['depth']; $i++) {
2821  $this->tpl->touchBlock('padding');
2822  $this->tpl->touchBlock('end_padding');
2823  }
2824  // fill options
2825  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id, $node['type']);
2826  $copy_wizard_page->fillTreeSelection($node['ref_id'], $node['type'], $node['depth']);
2827 
2828  $this->tpl->setCurrentBlock('tree_row');
2829  $this->tpl->setVariable('TREE_IMG', ilUtil::getImagePath('icon_' . $node['type'] . '.svg'));
2830  $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $node['type']));
2831  $this->tpl->setVariable('TREE_TITLE', $node['title']);
2832  $this->tpl->parseCurrentBlock();
2833  }
2834  if (!$has_items) {
2835  $this->tpl->setCurrentBlock('no_content');
2836  $this->tpl->setVariable('TXT_NO_CONTENT', $this->lng->txt('container_no_items'));
2837  $this->tpl->parseCurrentBlock();
2838  } else {
2839  $this->tpl->setCurrentBlock('tree_footer');
2840  $this->tpl->setVariable('TXT_COPY_ALL', $this->lng->txt('copy_all'));
2841  $this->tpl->setVariable('TXT_LINK_ALL', $this->lng->txt('link_all'));
2842  $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('omit_all'));
2843  $this->tpl->parseCurrentBlock();
2844  }
2845  } else {
2846  foreach ($tree->getSubTreeTypes($source_id, array('rolf','crs')) as $type) {
2847  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id, $type);
2848  if (strlen($html = $copy_wizard_page->getWizardPageBlockHTML())) {
2849  $this->tpl->setCurrentBlock('obj_row');
2850  $this->tpl->setVariable('ITEM_BLOCK', $html);
2851  $this->tpl->parseCurrentBlock();
2852  }
2853  }
2854  }
2855  }
2856 
2864  public function cloneAllObject()
2865  {
2866  $ilLog = $this->log;
2867  $ilCtrl = $this->ctrl;
2868 
2869  include_once('./Services/Link/classes/class.ilLink.php');
2870  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
2871 
2872  $ilAccess = $this->access;
2873  $ilErr = $this->error;
2875  $tree = $this->tree;
2876  $ilUser = $this->user;
2877 
2878  $new_type = $_REQUEST['new_type'];
2879  $ref_id = (int) $_GET['ref_id'];
2880  $clone_source = (int) $_REQUEST['clone_source'];
2881 
2882  if (!$rbacsystem->checkAccess('create', $ref_id, $new_type)) {
2883  $ilErr->raiseError($this->lng->txt('permission_denied'));
2884  }
2885  if (!$clone_source) {
2886  ilUtil::sendFailure($this->lng->txt('select_one'));
2887  $this->createObject();
2888  return false;
2889  }
2890  if (!$ilAccess->checkAccess('write', '', $clone_source, $new_type)) {
2891  $ilErr->raiseError($this->lng->txt('permission_denied'));
2892  }
2893 
2894  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
2895  $orig = ilObjectFactory::getInstanceByRefId($clone_source);
2896  $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
2897 
2898  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
2899  if (ilCopyWizardOptions::_isFinished($result['copy_id'])) {
2900  ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
2901  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $result['ref_id']);
2902  $ilCtrl->redirectByClass("ilrepositorygui", "");
2903  } else {
2904  ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"), true);
2905  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
2906  $ilCtrl->redirectByClass("ilrepositorygui", "");
2907  }
2908  }
2909 
2910 
2918  public function saveSortingObject()
2919  {
2920  include_once('Services/Container/classes/class.ilContainerSorting.php');
2921  $sorting = ilContainerSorting::_getInstance($this->object->getId());
2922 
2923  // Allow comma
2924  $positions = str_replace(',', '.', $_POST['position']);
2925 
2926  $sorting->savePost($positions);
2927  ilUtil::sendSuccess($this->lng->txt('cntr_saved_sorting'), true);
2928  $this->ctrl->redirect($this, "editOrder");
2929  }
2930 
2931  // BEGIN WebDAV: Support a copy command in the repository
2942  public function cloneNodes($srcRef, $dstRef, &$mapping, $newName=null)
2943  {
2944  $tree = $this->tree;
2945 
2946  // clone the source node
2947  $srcObj = ilObjectFactory::getInstanceByRefId($srcRef);
2948  error_log(__METHOD__ . ' cloning srcRef=' . $srcRef . ' dstRef=' . $dstRef . '...');
2949  $newRef = $srcObj->cloneObject($dstRef)->getRefId();
2950  error_log(__METHOD__ . ' ...cloning... newRef=' . $newRef . '...');
2951 
2952  // We must immediately apply a new name to the object, to
2953  // prevent confusion of WebDAV clients about having two objects with identical
2954  // name in the repository.
2955  if (!is_null($newName)) {
2956  $newObj = ilObjectFactory::getInstanceByRefId($newRef);
2957  $newObj->setTitle($newName);
2958  $newObj->update();
2959  unset($newObj);
2960  }
2961  unset($srcObj);
2962  $mapping[$newRef] = $srcRef;
2963 
2964  // clone all children of the source node
2965  $children = $tree->getChilds($srcRef);
2966  foreach ($tree->getChilds($srcRef) as $child) {
2967  // Don't clone role folders, because it does not make sense to clone local roles
2968  // FIXME - Maybe it does make sense (?)
2969  if ($child["type"] != 'rolf') {
2970  $this->cloneNodes($child["ref_id"], $newRef, $mapping);
2971  } else {
2972  if (count($rolf = $tree->getChildsByType($newRef, "rolf"))) {
2973  $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
2974  }
2975  }
2976  }
2977  error_log(__METHOD__ . ' ...cloned srcRef=' . $srcRef . ' dstRef=' . $dstRef . ' newRef=' . $newRef);
2978  return $newRef;
2979  }
2980  // END PATCH WebDAV: Support a copy command in the repository
2981 
2989  public function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
2990  {
2991  $lng = $this->lng;
2992 
2993  if ($a_show_path) {
2994  $a_item_list_gui->addCustomProperty(
2995  $lng->txt('path'),
2996  ilContainer::buildPath($a_item_data['ref_id'], $this->object->getRefId()),
2997  false,
2998  true
2999  );
3000  }
3001  }
3002 
3006  public static function _buildPath($a_ref_id, $a_course_ref_id)
3007  {
3008  global $DIC;
3009 
3010  $tree = $DIC->repositoryTree();
3011 
3012  $path_arr = $tree->getPathFull($a_ref_id, $a_course_ref_id);
3013  $counter = 0;
3014  foreach ($path_arr as $data) {
3015  if ($counter++) {
3016  $path .= " > ";
3017  }
3018  $path .= $data['title'];
3019  }
3020 
3021  return $path;
3022  }
3023 
3024  //
3025  // Style editing
3026  //
3027 
3031  public function editStylePropertiesObject()
3032  {
3033  $ilTabs = $this->tabs;
3034  $tpl = $this->tpl;
3035 
3036  $this->checkPermission("write");
3037 
3038  $this->initStylePropertiesForm();
3039  $tpl->setContent($this->form->getHTML());
3040 
3041  $ilTabs->activateTab("obj_sty");
3042  }
3043 
3047  public function initStylePropertiesForm()
3048  {
3049  $ilCtrl = $this->ctrl;
3050  $lng = $this->lng;
3051  $ilTabs = $this->tabs;
3053  $tpl = $this->tpl;
3054 
3055  $tpl->setTreeFlatIcon("", "");
3056  $ilTabs->clearTargets();
3058  $this->object->getId(),
3059  "xhtml_page"
3060  );
3061  if ($xpage_id > 0) {
3062  $ilTabs->setBackTarget(
3063  $lng->txt("cntr_back_to_old_editor"),
3064  $ilCtrl->getLinkTarget($this, "switchToOldEditor"),
3065  "_top"
3066  );
3067  } else {
3068  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=" . $this->object->getType() . "_" .
3069  $this->object->getRefId(), "_top");
3070  }
3071 
3072  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
3073  $page_gui = new ilContainerPageGUI($this->object->getId());
3074  $style_id = $this->object->getStyleSheetId();
3075  if (ilObject::_lookupType($style_id) == "sty") {
3076  $page_gui->setStyleId($style_id);
3077  } else {
3078  $style_id = 0;
3079  }
3080  $page_gui->setTabHook($this, "addPageTabs");
3081  $ilCtrl->getHTML($page_gui);
3082  $ilTabs->setTabActive("obj_sty");
3083 
3084  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3085  $lng->loadLanguageModule("style");
3086 
3087  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3088  $this->form = new ilPropertyFormGUI();
3089 
3090  $fixed_style = $ilSetting->get("fixed_content_style_id");
3091  // $style_id = $this->object->getStyleSheetId();
3092 
3093  if ($fixed_style > 0) {
3094  $st = new ilNonEditableValueGUI($lng->txt("wiki_current_style"));
3095  $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
3096  $this->lng->txt("global_fixed") . ")");
3097  $this->form->addItem($st);
3098  } else {
3100  true,
3101  false,
3102  $_GET["ref_id"]
3103  );
3104 
3105  $st_styles[0] = $this->lng->txt("default");
3106  ksort($st_styles);
3107 
3108  if ($style_id > 0) {
3109  // individual style
3110  if (!ilObjStyleSheet::_lookupStandard($style_id)) {
3111  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
3112  $st->setValue(ilObject::_lookupTitle($style_id));
3113  $this->form->addItem($st);
3114 
3115  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
3116 
3117  // delete command
3118  $this->form->addCommandButton(
3119  "editStyle",
3120  $lng->txt("style_edit_style")
3121  );
3122  $this->form->addCommandButton(
3123  "deleteStyle",
3124  $lng->txt("style_delete_style")
3125  );
3126  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
3127  }
3128  }
3129 
3130  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
3131  $style_sel = ilUtil::formSelect(
3132  $style_id,
3133  "style_id",
3134  $st_styles,
3135  false,
3136  true
3137  );
3138  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
3139  $style_sel->setOptions($st_styles);
3140  $style_sel->setValue($style_id);
3141  $this->form->addItem($style_sel);
3142  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
3143  $this->form->addCommandButton(
3144  "saveStyleSettings",
3145  $lng->txt("save")
3146  );
3147  $this->form->addCommandButton(
3148  "createStyle",
3149  $lng->txt("sty_create_ind_style")
3150  );
3151  }
3152  }
3153  $this->form->setTitle($lng->txt("obj_sty"));
3154  $this->form->setFormAction($ilCtrl->getFormAction($this));
3155  }
3156 
3160  public function createStyleObject()
3161  {
3162  $ilCtrl = $this->ctrl;
3163 
3164  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
3165  }
3166 
3170  public function editStyleObject()
3171  {
3172  $ilCtrl = $this->ctrl;
3173 
3174  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
3175  }
3176 
3180  public function deleteStyleObject()
3181  {
3182  $ilCtrl = $this->ctrl;
3183 
3184  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
3185  }
3186 
3190  public function saveStyleSettingsObject()
3191  {
3193 
3194  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3195  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3196  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3197  || $this->object->getStyleSheetId() == 0)) {
3198  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
3199  $this->object->update();
3200  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3201  }
3202  $this->ctrl->redirect($this, "editStyleProperties");
3203  }
3204 
3208  public function getAsynchItemListObject()
3209  {
3210  $ilCtrl = $this->ctrl;
3211 
3212  $ref_id = $_GET["cmdrefid"];
3215 
3216  // this should be done via container-object->getSubItem in the future
3217  $data = array("child" => $ref_id, "ref_id" => $ref_id, "obj_id" => $obj_id,
3218  "type" => $type);
3219  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
3221  $item_list_gui->setContainerObject($this);
3222 
3223  $item_list_gui->enableComments(true);
3224  $item_list_gui->enableNotes(true);
3225  $item_list_gui->enableTags(true);
3226 
3227  $this->modifyItemGUI($item_list_gui, $data, false);
3228  $html = $item_list_gui->getListItemHTML(
3229  $ref_id,
3230  $obj_id,
3231  "",
3232  "",
3233  true,
3234  true
3235  );
3236 
3237  // include plugin slot for async item list
3238  $ilPluginAdmin = $this->plugin_admin;
3239  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
3240  foreach ($pl_names as $pl) {
3241  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
3242  $gui_class = $ui_plugin->getUIClassInstance();
3243  $resp = $gui_class->getHTML("Services/Container", "async_item_list", array("html" => $html));
3244  if ($resp["mode"] != ilUIHookPluginGUI::KEEP) {
3245  $html = $gui_class->modifyHTML($html, $resp);
3246  }
3247  }
3248 
3249  echo $html;
3250  exit;
3251  }
3252 
3257  protected function showPasswordInstructionObject($a_init = true)
3258  {
3259  $tpl = $this->tpl;
3260  $ilToolbar = $this->toolbar;
3261 
3262  if ($a_init) {
3263  ilUtil::sendInfo($this->lng->txt('webdav_pwd_instruction'));
3264  $this->initFormPasswordInstruction();
3265  }
3266 
3267  include_once('Services/WebDAV/classes/class.ilDAVServer.php');
3268  $davServer = ilDAVServer::getInstance();
3269  $ilToolbar->addButton(
3270  $this->lng->txt('mount_webfolder'),
3271  $davServer->getMountURI($this->object->getRefId()),
3272  '_blank',
3273  '',
3274  $davServer->getFolderURI($this->object->getRefId())
3275  );
3276 
3277  $tpl->setContent($this->form->getHTML());
3278  }
3279 
3284  protected function initFormPasswordInstruction()
3285  {
3286  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3287  $this->form = new ilPropertyFormGUI();
3288  $this->form->setFormAction($this->ctrl->getFormAction($this));
3289 
3290  // new password
3291  $ipass = new ilPasswordInputGUI($this->lng->txt("desired_password"), "new_password");
3292  $ipass->setRequired(true);
3293 
3294  $this->form->addItem($ipass);
3295  $this->form->addCommandButton("savePassword", $this->lng->txt("save"));
3296  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
3297 
3298  $this->form->setTitle($this->lng->txt("chg_ilias_and_webfolder_password"));
3299  $this->form->setFormAction($this->ctrl->getFormAction($this));
3300 
3301  return $this->form;
3302  }
3303 
3308  protected function savePasswordObject()
3309  {
3310  $ilUser = $this->user;
3311 
3313  if ($form->checkInput()) {
3314  $ilUser->resetPassword($this->form->getInput('new_password'), $this->form->getInput('new_password'));
3315  ilUtil::sendSuccess($this->lng->txt('webdav_pwd_instruction_success'), true);
3316  $this->showPasswordInstructionObject(false);
3317  return true;
3318  }
3319  $form->setValuesByPost();
3321  }
3322 
3329  public function redrawListItemObject()
3330  {
3331  $tpl = $this->tpl;
3332 
3333  $html = null;
3334 
3335  $item_data = $this->object->getSubItems(false, false, (int) $_GET["child_ref_id"]);
3336  $container_view = $this->getContentGUI();
3337 
3338  // list item is session material (not part of "_all"-items - see below)
3339  include_once './Modules/Session/classes/class.ilEventItems.php';
3340  $event_items = ilEventItems::_getItemsOfContainer($this->object->getRefId());
3341  if (in_array((int) $_GET["child_ref_id"], $event_items)) {
3342  include_once('./Services/Object/classes/class.ilObjectActivation.php');
3343  foreach ($this->object->items["sess"] as $id) {
3344  $items = ilObjectActivation::getItemsByEvent($id['obj_id']);
3345  foreach ($items as $event_item) {
3346  if ($event_item["child"] == (int) $_GET["child_ref_id"]) {
3347  // sessions
3348  if ((int) $_GET["parent_ref_id"]) {
3349  $event_item["parent"] = (int) $_GET["parent_ref_id"];
3350  }
3351  $html = $container_view->renderItem($event_item);
3352  }
3353  }
3354  }
3355  }
3356 
3357  // "normal" list item
3358  if (!$html) {
3359  foreach ($this->object->items["_all"] as $id) {
3360  if ($id["child"] == (int) $_GET["child_ref_id"]) {
3361  $html = $container_view->renderItem($id);
3362  }
3363  }
3364  }
3365 
3366  if ($html) {
3367  echo $html;
3368 
3369  // we need to add onload code manually (rating, comments, etc.)
3370  echo $tpl->getOnLoadCodeForAsynch();
3371  }
3372 
3373  exit;
3374  }
3375 
3376  // begin-patch fm
3383  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
3384  {
3385  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
3386 
3387  // begin-patch fm
3388  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
3389  if (ilFMSettings::getInstance()->isEnabled()) {
3390  if ($lg instanceof ilObjectListGUI) {
3391  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'fileManagerLaunch'), 'fm_start', '_blank');
3392  }
3393  }
3394  // end-patch fm
3395  return $lg;
3396  }
3397 
3401  protected function fileManagerLaunchObject()
3402  {
3403  $ilUser = $this->user;
3404 
3405  $tpl = new ilTemplate('tpl.fm_launch_ws.html', false, false, 'Services/WebServices/FileManager');
3406  $tpl->setVariable('JNLP_URL', ILIAS_HTTP_PATH . '/Services/WebServices/FileManager/lib/dist/FileManager.jnlp');
3407  $tpl->setVariable('SESSION_ID', $_COOKIE['PHPSESSID'] . '::' . CLIENT_ID);
3408  $tpl->setVariable('UID', $ilUser->getId());
3409  $tpl->setVariable('REF_ID', $this->object->getRefId());
3410  $tpl->setVariable('WSDL_URI', ILIAS_HTTP_PATH . '/webservice/soap/server.php?wsdl');
3411  $tpl->setVariable('LOCAL_FRAME', ilFMSettings::getInstance()->isLocalFSEnabled() ? 1 : 0);
3412  $tpl->setVariable('REST_URI', ILIAS_HTTP_PATH . '/Services/WebServices/Rest/server.php');
3413  $tpl->setVariable('FILE_LOCKS', 0);
3414  $tpl->setVariable('UPLOAD_FILESIZE', ilFMSettings::getInstance()->getMaxFileSize());
3415 
3416  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
3417  $header_top_title = ilObjSystemFolder::_getHeaderTitle();
3418  $tpl->setVariable('HEADER_TITLE', $header_top_title ? $header_top_title : '');
3419  echo $tpl->get();
3420  exit;
3421  }
3422  // begin-patch fm
3423 
3427  public function showRepTree()
3428  {
3429  $tpl = $this->tpl;
3430  $ilUser = $this->user;
3432  $ilCtrl = $this->ctrl;
3433 
3434  // set current repository view mode
3435  if (!empty($_GET["set_mode"])) {
3436  $_SESSION["il_rep_mode"] = $_GET["set_mode"];
3437  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
3438  $ilUser->writePref("il_rep_mode", $_GET["set_mode"]);
3439  }
3440  }
3441 
3442  // get user setting
3443  if ($_SESSION["il_rep_mode"] == "") {
3444  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
3445  $_SESSION["il_rep_mode"] = $ilUser->getPref("il_rep_mode");
3446  }
3447  }
3448 
3449  // if nothing set, get default view
3450  if ($_SESSION["il_rep_mode"] == "") {
3451  $_SESSION["il_rep_mode"] = $ilSetting->get("default_repository_view");
3452  }
3453 
3454  $mode = ($_SESSION["il_rep_mode"] != "")
3455  ? $_SESSION["il_rep_mode"]
3456  : "flat";
3457 
3458  // check for administration context, see #0016312
3459  if ($mode == "tree" && (strtolower($_GET["baseClass"]) != "iladministrationgui")) {
3460  include_once("./Services/Repository/classes/class.ilRepositoryExplorerGUI.php");
3461  $exp = new ilRepositoryExplorerGUI($this, "showRepTree");
3462  if (!$exp->handleCommand()) {
3463  $tpl->setLeftNavContent($exp->getHTML());
3464  }
3465  }
3466  }
3467 
3473  protected function initSortingForm(ilPropertyFormGUI $form, array $a_sorting_settings)
3474  {
3475  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
3476  include_once './Services/Container/classes/class.ilContainer.php';
3477 
3478  $settings = new ilContainerSortingSettings($this->object->getId());
3479  $sort = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'), "sorting");
3480 
3481  if (in_array(ilContainer::SORT_INHERIT, $a_sorting_settings)) {
3482  $sort_inherit = new ilRadioOption();
3483  $sort_inherit->setTitle(
3484  $this->lng->txt('sort_inherit_prefix') .
3487  $this->object->getId()
3488  )
3489  ) . ') '
3490  );
3491  $sort_inherit->setValue(ilContainer::SORT_INHERIT);
3492  $sort_inherit->setInfo($this->lng->txt('sorting_info_inherit'));
3493  $sort->addOption($sort_inherit);
3494  }
3495  if (in_array(ilContainer::SORT_TITLE, $a_sorting_settings)) {
3496  $sort_title = new ilRadioOption(
3497  $this->lng->txt('sorting_title_header'),
3499  );
3500  $sort_title->setInfo($this->lng->txt('sorting_info_title'));
3501 
3502  $this->initSortingDirectionForm($settings, $sort_title, 'title');
3503  $sort->addOption($sort_title);
3504  }
3505  if (in_array(ilContainer::SORT_CREATION, $a_sorting_settings)) {
3506  $sort_activation = new ilRadioOption($this->lng->txt('sorting_creation_header'), ilContainer::SORT_CREATION);
3507  $sort_activation->setInfo($this->lng->txt('sorting_creation_info'));
3508  $this->initSortingDirectionForm($settings, $sort_activation, 'creation');
3509  $sort->addOption($sort_activation);
3510  }
3511  if (in_array(ilContainer::SORT_ACTIVATION, $a_sorting_settings)) {
3512  $sort_activation = new ilRadioOption($this->lng->txt('crs_sort_activation'), ilContainer::SORT_ACTIVATION);
3513  $sort_activation->setInfo($this->lng->txt('crs_sort_timing_info'));
3514  $this->initSortingDirectionForm($settings, $sort_activation, 'activation');
3515  $sort->addOption($sort_activation);
3516  }
3517  if (in_array(ilContainer::SORT_MANUAL, $a_sorting_settings)) {
3518  $sort_manual = new ilRadioOption(
3519  $this->lng->txt('sorting_manual_header'),
3521  );
3522  $sort_manual->setInfo($this->lng->txt('sorting_info_manual'));
3523  $this->initManualSortingOptionForm($settings, $sort_manual, "manual", $a_sorting_settings);
3524  $sort->addOption($sort_manual);
3525  }
3526 
3527  // Handle moved containers and there possibly invalid values
3528  if (in_array($settings->getSortMode(), $a_sorting_settings)) {
3529  $sort->setValue($settings->getSortMode());
3530  } else {
3531  $sort->setValue(ilContainer::SORT_TITLE);
3532  }
3533  $form->addItem($sort);
3534 
3535  return $form;
3536  }
3537 
3542  protected function initSortingDirectionForm(ilContainerSortingSettings $sorting_settings, $element, $a_prefix)
3543  {
3544  if ($a_prefix == 'manual') {
3545  $txt = $this->lng->txt('sorting_new_items_direction');
3546  } else {
3547  $txt = $this->lng->txt('sorting_direction');
3548  }
3549 
3550  $direction = new ilRadioGroupInputGUI($txt, $a_prefix . '_sorting_direction');
3551  $direction->setValue($sorting_settings->getSortDirection());
3552  $direction->setRequired(true);
3553 
3554  // asc
3555  $asc = new ilRadioOption(
3556  $this->lng->txt('sorting_asc'),
3558  );
3559  $direction->addOption($asc);
3560 
3561  // desc
3562  $desc = new ilRadioOption(
3563  $this->lng->txt('sorting_desc'),
3565  );
3566  $direction->addOption($desc);
3567 
3568  $element->addSubItem($direction);
3569 
3570  return $element;
3571  }
3572 
3577  protected function initManualSortingOptionForm(
3579  $element,
3580  $a_prefix,
3581  $a_sorting_settings
3582  ) {
3583  $position = new ilRadioGroupInputGUI($this->lng->txt('sorting_new_items_position'), $a_prefix . '_new_items_position');
3584  $position->setValue($settings->getSortNewItemsPosition());
3585  $position->setRequired(true);
3586 
3587  //new items insert on top
3588  $new_top = new ilRadioOption(
3589  $this->lng->txt('sorting_new_items_at_top'),
3591  );
3592 
3593  $position->addOption($new_top);
3594 
3595  //new items insert at bottom
3596  $new_bottom = new ilRadioOption(
3597  $this->lng->txt('sorting_new_items_at_bottom'),
3599  );
3600 
3601  $position->addOption($new_bottom);
3602 
3603  $element->addSubItem($position);
3604 
3605  $order = new ilRadioGroupInputGUI($this->lng->txt('sorting_new_items_order'), $a_prefix . '_new_items_order');
3606  $order->setValue($settings->getSortNewItemsOrder());
3607  $order->setRequired(true);
3608 
3609  if (in_array(ilContainer::SORT_TITLE, $a_sorting_settings)) {
3610  //new items sort in alphabetical order
3611  $new_title = new ilRadioOption(
3612  $this->lng->txt('sorting_title_header'),
3614  );
3615 
3616  $order->addOption($new_title);
3617  }
3618 
3619  if (in_array(ilContainer::SORT_CREATION, $a_sorting_settings)) {
3620  //new items sort by creation date
3621  $new_creation = new ilRadioOption(
3622  $this->lng->txt('sorting_creation_header'),
3624  );
3625 
3626  $order->addOption($new_creation);
3627  }
3628 
3629 
3630  if (in_array(ilContainer::SORT_ACTIVATION, $a_sorting_settings)) {
3631  //new items by activation
3632  $new_activation = new ilRadioOption(
3633  $this->lng->txt('crs_sort_activation'),
3635  );
3636 
3637  $order->addOption($new_activation);
3638  }
3639 
3640  $element->addSubItem($order);
3641 
3642  $this->initSortingDirectionForm($settings, $element, 'manual');
3643 
3644  return $element;
3645  }
3646 
3652  {
3653  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
3654  $settings = new ilContainerSortingSettings($this->object->getId());
3655  $settings->setSortMode($form->getInput("sorting"));
3656 
3657  switch ($form->getInput('sorting')) {
3659  $settings->setSortDirection($form->getInput('title_sorting_direction'));
3660  break;
3662  $settings->setSortDirection($form->getInput('activation_sorting_direction'));
3663  break;
3665  $settings->setSortDirection($form->getInput('creation_sorting_direction'));
3666  break;
3668  $settings->setSortNewItemsPosition($form->getInput('manual_new_items_position'));
3669  $settings->setSortNewItemsOrder($form->getInput('manual_new_items_order'));
3670  $settings->setSortDirection($form->getInput('manual_sorting_direction'));
3671  break;
3672  }
3673 
3674  $settings->update();
3675  }
3676 
3682  public function trashObject()
3683  {
3684  $tpl = $this->tpl;
3685 
3686  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3687  $ru = new ilRepUtilGUI($this);
3688  $ru->showTrashTable($_GET["ref_id"]);
3689  }
3690 
3696  public function removeFromSystemObject()
3697  {
3698  $ilLog = $this->log;
3699  $ilAppEventHandler = $this->app_event_handler;
3700  $lng = $this->lng;
3701 
3702  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3703  $ru = new ilRepUtilGUI($this);
3704  $ru->removeObjectsFromSystem($_POST["trash_id"]);
3705  $this->ctrl->redirect($this, "trash");
3706  }
3707 
3711  public function undeleteObject()
3712  {
3713  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3714  $ru = new ilRepUtilGUI($this);
3715  $ru->restoreObjects($_GET["ref_id"], $_POST["trash_id"]);
3716  $this->ctrl->redirect($this, "trash");
3717  }
3718 
3723  {
3724  $lng = $this->lng;
3725  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
3726 
3727  if (!isset($_POST["trash_id"])) {
3728  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3729  $this->ctrl->redirect($this, "trash");
3730  }
3731 
3732  $ru = new ilRepUtilGUI($this);
3733  $ru->confirmRemoveFromSystemObject($_POST["trash_id"]);
3734  }
3735 
3740  protected function getTreeSelectorGUI($cmd)
3741  {
3742  include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
3743  $exp = new ilRepositorySelectorExplorerGUI($this, "showPasteTree");
3744  // TODO: The study programme 'prg' is not included here, as the
3745  // ilRepositorySelectorExplorerGUI only handles static rules for
3746  // parent-child-relations and not the dynamic relationsships
3747  // required for the SP (see #16909).
3748  $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "fold"));
3749  if ($cmd == "link") {
3750  $exp->setSelectMode("nodes", true);
3751  return $exp;
3752  } else {
3753  $exp->setSelectMode("nodes[]", false);
3754  return $exp;
3755  }
3756  }
3757 
3761  public function setSideColumnReturn()
3762  {
3763  $this->ctrl->setReturn($this, "");
3764  }
3765 }
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
static _getRTEClassname()
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _isActionsVisible()
Static getter.
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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
$_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
addStandardRow(&$a_tpl, $a_html, $a_item_ref_id="", $a_item_obj_id="", $a_image_type="")
adds a standard row to a block template
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...
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
This class represents a property form user interface.
$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
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
This class represents a section header in a property form.
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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
static _isActive()
Static getter.
isActiveOrdering()
Check if ordering is enabled.
const IL_CRS_VIEW_TIMING
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.
static _lookupIconPath($a_id, $a_size="big")
lookup icon path
global $ilCtrl
Definition: ilias.php:18
initFormPasswordInstruction()
Init password form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$counter
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...
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
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.
GUI class for didactic template settings inside repository objects.
showPermanentLink(&$tpl)
show permanent link
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.
showCustomIconsEditing($a_input_colspan=1, ilPropertyFormGUI $a_form=null, $a_as_section=true)
show edit section of custom icons for container
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)
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.
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
static getInstance()
Get singelton instance.
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 type $lng.
copyObject()
Copy object(s) out from a container and write the information to clipboard It is not possible to copy...
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
disableAdministrationPanelObject()
enable administration panel
XHTML Page class.
static sortModeToString($a_sort_mode)
get String representation of sort mode
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)
Create a temporary file in an ILIAS writable directory.
setContentSubTabs()
Set content sub tabs.
This class represents an image file property in a property form.
static removeFromDesktop()
Remove item from personal desktop public.
This class represents a custom property in a property form.
downloadMultipleObjects($a_ref_ids)
static getInstance()
Get singleton instance.
setStyleId($a_styleid)
Set Style Id.
settings()
Definition: settings.php:2
getSortNewItemsPosition()
GET new item position.
static _getFrame($a_class, $a_type='')
Get content frame name.
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.
Create new PHPExcel object
obj_idprivate
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.
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
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
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static _getInstance($a_obj_id)
get instance by obj_id
showAdministrationPanel(&$tpl)
show administration panel
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
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
clipboardObject()
show clipboard
setRequired($a_required)
Set Required.
const IL_COMP_SERVICE
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.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20