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