ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
37 require_once "./classes/class.ilObjectGUI.php";
38 require_once "./Services/Container/classes/class.ilContainer.php";
39 
41 {
46  function ilContainerGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
47  {
48  global $rbacsystem, $lng, $tree;
49 
50  $this->rbacsystem =& $rbacsystem;
51 
52  $lng->loadLanguageModule("cntr");
53 
54  //$this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
55 
56  // Activate tree cache when rendering the container to improve performance
57  //$tree->useCache(false);
58 
59  // prepare output things should generally be made in executeCommand
60  // method (maybe dependent on current class/command
61  $this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
62  }
63 
68  function &executeCommand()
69  {
70  global $tpl;
71 
72  $next_class = $this->ctrl->getNextClass();
73  $cmd = $this->ctrl->getCmd("render");
74 
75  switch($next_class)
76  {
77  // page editing
78  case "ilpageobjectgui":
79  $ret = $this->forwardToPageObject();
80  $tpl->setContent($ret);
81  break;
82 
83  default:
84  $this->prepareOutput();
85  $cmd .= "Object";
86  $this->$cmd();
87  break;
88  }
89  return true;
90  }
91 
95  function &forwardToPageObject()
96  {
97  global $lng, $ilTabs, $ilCtrl;
98 
99  $ilTabs->clearTargets();
100 
101  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
102  "xhtml_page");
103  if ($xpage_id > 0)
104  {
105  $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"),
106  $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
107  }
108  else
109  {
110  $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=".$this->object->getType()."_".
111  $this->object->getRefId(), "_top");
112  }
113 
114  // page object
115  include_once("./Services/COPage/classes/class.ilPageObject.php");
116  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
117 
118  $lng->loadLanguageModule("content");
119 
120  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
121  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
123 
124  if (!ilPageObject::_exists($this->object->getType(),
125  $this->object->getId()))
126  {
127  // doesn't exist -> create new one
128  $new_page_object = new ilPageObject($this->object->getType());
129  $new_page_object->setParentId($this->object->getId());
130  $new_page_object->setId($this->object->getId());
131  $new_page_object->createFromXML();
132  }
133 
134  // get page object
135 // $page_object = new ilPageObject($this->object->getType(),
136 // $this->object->getId(), 0, true);
137  $this->ctrl->setReturnByClass("ilpageobjectgui", "edit");
138  //$page_object =& $this->obj->getPageObject();
139 // $page_object->buildDom();
140  //$page_object->addUpdateListener($this, "updateHistory");
141 // $int_links = $page_object->getInternalLinks();
142  //$link_xml = $this->getLinkXML($int_links);
143  $page_gui =& new ilPageObjectGUI($this->object->getType(),
144  $this->object->getId());
145 
146  // $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
147  //$page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId(),
148  // $view_frame);
149 
150  $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
151  $page_gui->setTemplateTargetVar("ADM_CONTENT");
152  $page_gui->setLinkXML($link_xml);
153  //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
154  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
155  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
156  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
157  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
158  $page_gui->setPresentationTitle("");
159  $page_gui->setTemplateOutput(false);
160  //$page_gui->setLocator($contObjLocator);
161  $page_gui->setHeader("");
162  $page_gui->setEnabledRepositoryObjects(true);
163  $page_gui->setEnabledFileLists(false);
164  $page_gui->setEnabledMaps(true);
165  $page_gui->setEnabledPCTabs(true);
166 
167  // old editor information text
168  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
169  "xhtml_page");
170  if ($xpage_id > 0)
171  {
172  $wtpl = new ilTemplate("tpl.cntr_old_editor_message.html", true,
173  true, "Services/Container");
174  $wtpl->setVariable("ALT_WARNING", $lng->txt("warning"));
175  $wtpl->setVariable("IMG_WARNING",
176  ilUtil::getImagePath("icon_alert_s.gif"));
177  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
178  $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
179  $wtpl->setVariable("HREF_SWITCH_TO_NEW_EDITOR",
180  $ilCtrl->getLinkTarget($this, "useNewEditor"));
181  $wtpl->setVariable("TXT_MIGRATION_SWITCH",
182  $lng->txt("cntr_switch_to_new_editor_cmd"));
183  $page_gui->setPrependingHtml($wtpl->get());
184  }
185 
186  $ret =& $this->ctrl->forwardCommand($page_gui);
187 
188  //$ret =& $page_gui->executeCommand();
189  return $ret;
190  }
191 
196  {
197  global $ilSetting;
198 
199  if (!$ilSetting->get("enable_cat_page_edit"))
200  {
201  return;
202  }
203 
204  // old page editor content
205  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
206  "xhtml_page");
207 
208  if ($xpage_id > 0)
209  {
210  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
211  $xpage = new ilXHTMLPage($xpage_id);
212  return $xpage->getContent();
213  }
214 
215 
216  // page object
217  include_once("./Services/COPage/classes/class.ilPageObject.php");
218  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
219 
220  // if page does not exist, return nothing
221  if (!ilPageObject::_exists($this->object->getType(),
222  $this->object->getId()))
223  {
224  return "";
225  }
226 
227  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
228  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
230 
231  // get page object
232  $page_gui =& new ilPageObjectGUI($this->object->getType(),
233  $this->object->getId());
234 
235  $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
236  //$page_gui->setTemplateTargetVar("ADM_CONTENT");
237  $page_gui->setLinkXML($link_xml);
238  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
239  //$page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
240  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
241  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
242  $page_gui->setPresentationTitle("");
243  $page_gui->setTemplateOutput(false);
244  //$page_gui->setLocator($contObjLocator);
245  $page_gui->setHeader("");
246  $page_gui->setEnabledRepositoryObjects(true);
247  $page_gui->setEnabledFileLists(false);
248  $page_gui->setEnabledPCTabs(true);
249  $page_gui->setEnabledMaps(true);
250  $ret = $page_gui->showPage();
251 
252  //$ret =& $page_gui->executeCommand();
253  return $ret;
254  }
255 
259  function prepareOutput($a_show_subobjects = true)
260  {
261  if (parent::prepareOutput()) // return false in admin mode
262  {
263  if ($this->getCreationMode() != true && $a_show_subobjects)
264  {
265  // This method is called directly from ilContainerGUI::renderObject
266  #$this->showPossibleSubObjects();
267  $this->showTreeFlatIcon();
268  }
269  }
270  }
271 
272  function showTreeFlatIcon()
273  {
274  global $tpl;
275 
276  // dont show icon, if role (permission gui->rolegui) is edited
277  if ($_GET["obj_id"] != "")
278  {
279  return;
280  }
281 
282  $mode = ($_SESSION["il_rep_mode"] == "flat")
283  ? "tree"
284  : "flat";
285  $link = "repository.php?cmd=frameset&set_mode=".$mode."&ref_id=".$this->object->getRefId();
286  $tpl->setTreeFlatIcon($link, $mode);
287  }
288 
293  {
294  global $ilias;
295 
296  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
297  {
298  $this->tpl->setTitle($this->object->getTitle());
299  $this->tpl->setDescription($this->object->getLongDescription());
300 
301  // set tile icon
302  $icon = ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif");
303  if ($ilias->getSetting("custom_icons") &&
304  in_array($this->object->getType(), array("cat","grp","crs", "root")))
305  {
306  require_once("./Services/Container/classes/class.ilContainer.php");
307  if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
308  {
309  $icon = $path;
310  }
311  }
312  $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
313  }
314  }
315 
316 
321  {
322  global $ilAccess,$ilCtrl;
323 
324  $found = false;
325  $cmd = ($this->cmd != "")
326  ? $this->cmd
327  : $this->ctrl->getCmd();
328 
329  #if ($cmd != "" && $cmd != "showList" && $cmd != "render"
330  # && $cmd != "view")
331  #{
332  # return;
333  #}
334 
335  $type = $this->object->getType();
336 
337  $d = $this->objDefinition->getCreatableSubObjects($type);
338 
339  if (count($d) > 0)
340  {
341  foreach ($d as $row)
342  {
343  $count = 0;
344  if ($row["max"] > 0)
345  {
346  //how many elements are present?
347  //var_dump($this->data);
348  // this is broken
349  /*
350  for ($i=0; $i<count($this->data["ctrl"]); $i++)
351  {
352  if ($this->data["ctrl"][$i]["type"] == $row["name"])
353  {
354  $count++;
355  }
356  }*/
357  }
358 
359  if ($row["max"] == "" || $count < $row["max"])
360  {
361  //if (in_array($row["name"], array("sahs", "alm", "hlm", "lm", "grp", "frm", "mep","crs", "mcst", "wiki",
362  // "cat", "glo", "dbk","exc", "qpl", "tst", "svy", "spl", "chat",
363  // "htlm","fold","linkr","file","icrs","icla","crsg",'webr',"feed",'rcrs')))
364  //{
365  if (!in_array($row["name"], array("rolf")))
366  {
367  if ($this->rbacsystem->checkAccess("create", $this->object->getRefId(), $row["name"]))
368  {
369  $subobj[] = $row["name"];
370  }
371  }
372  }
373  }
374  }
375  if (is_array($subobj))
376  {
377  $formaction = "repository.php?ref_id=".$this->object->getRefId()."&cmd=post";
378  $formaction = $ilCtrl->appendRequestTokenParameterString($formaction);
379  $formaction = $this->ctrl->getFormAction($this);
380  $opts = ilUtil::formSelect("", "new_type", $subobj);
381  $this->tpl->setCreationSelector($formaction,
382  $opts, "create", $this->lng->txt("add"));
383  }
384  }
385 
389  function renderObject()
390  {
391  global $ilDB, $tpl;
392 
393  switch ($this->object->getViewMode())
394  {
395  // all items in one block
397  include_once("./Services/Container/classes/class.ilContainerSimpleContentGUI.php");
398  $container_view = new ilContainerSimpleContentGUI($this);
399  break;
400 
402  include_once('./Services/Container/classes/class.ilContainerObjectiveGUI.php');
403  $container_view = new ilContainerObjectiveGUI($this);
404  break;
405 
406  // all items in one block
408  case IL_CRS_VIEW_TIMING: // not nice this workaround
409  include_once("./Services/Container/classes/class.ilContainerSessionsContentGUI.php");
410  $container_view = new ilContainerSessionsContentGUI($this);
411  break;
412 
413  // ILinc courses
415  include_once 'Services/Container/classes/class.ilContainerILincContentGUI.php';
416  $container_view = new ilContainerILincContentGUI($this);
417  break;
418 
419  // all items in one block
421  default:
422  include_once("./Services/Container/classes/class.ilContainerByTypeContentGUI.php");
423  $container_view = new ilContainerByTypeContentGUI($this);
424  break;
425  }
426 
427  $container_view->setOutput();
428 
429  // 'add object'
430  //$this->showPossibleSubObjects();
431 
432 
433 /* Old implementation
434  // BEGIN ChangeEvent: record read event.
435  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
436  if (ilChangeEvent::_isActive())
437  {
438  if ($this->object != null)
439  {
440  global $ilUser;
441  ilChangeEvent::_recordReadEvent($this->object->getId(), $ilUser->getId());
442  }
443  }
444  // END ChangeEvent: record read event.
445 
446  $this->getCenterColumnHTML(true);
447  if ($this->type == 'cat' || $this->type == 'grp')
448  {
449  $this->tpl->setRightContent($this->getRightColumnHTML());
450  }
451 */
452  }
453 
459 /*
460  function getContent()
461  {
462  global $ilBench, $tree;
463 
464  // course content interface methods could probably
465  // move to this class
466  if($this->type != 'icrs' and $tree->checkForParentType($this->ref_id,'crs'))
467  {
468  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
469  $course_content_obj = new ilCourseContentGUI($this);
470 
471  $this->ctrl->setCmd('view');
472  $this->ctrl->setCmdClass(get_class($course_content_obj));
473  $this->ctrl->forwardCommand($course_content_obj);
474 
475  return;
476  }
477 
478  // 'add object'
479  $this->showPossibleSubObjects();
480 
481  $ilBench->start("ilContainerGUI", "0000__renderObject");
482 
483  $tpl = new ilTemplate ("tpl.container_page.html", true, true);
484 
485  // get all sub items
486  $ilBench->start("ilContainerGUI", "0100_getSubItems");
487  // BEGIN WebDAV Show hidden files when administration panel is on
488  $this->getSubItems($this->isActiveAdministrationPanel(), true);
489  // END WebDAV Show hidden files when administration panel is on
490  $ilBench->stop("ilContainerGUI", "0100_getSubItems");
491 
492  // Show introduction, if repository is empty
493  if (count($this->items) == 1 && is_array($this->items["adm"]) && $this->object->getRefId() == ROOT_FOLDER_ID)
494  {
495  $html = $this->getIntroduction();
496  $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
497  }
498  else // show item list otherwise
499  {
500  $ilBench->start("ilContainerGUI", "0200_renderItemList");
501  $html = $this->renderItemList();
502  $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
503  $ilBench->stop("ilContainerGUI", "0200_renderItemList");
504  }
505 
506  $this->showAdministrationPanel($tpl);
507  $this->showPermanentLink($tpl);
508 
509  $this->html = $tpl->get();
510 
511  $ilBench->stop("ilContainerGUI", "0000__renderObject");
512  }
513 */
514 
519  {
520  global $ilAccess, $ilSetting;
521  global $ilUser;
522 
523  if ($this->isActiveAdministrationPanel())
524  {
525  $GLOBALS["tpl"]->setAdminViewButton(
526  $this->ctrl->getLinkTarget($this, "disableAdministrationPanel"),
527  $this->lng->txt("basic_commands"));
528 
529  // administration panel
530  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
531  && $this->object->enablePageEditing())
532  {
533  $GLOBALS["tpl"]->setEditPageButton(
534  $this->ctrl->getLinkTarget($this, "editPageFrame"),
535  $this->lng->txt("edit_page"),
536  ilFrameTargetInfo::_getFrame("MainContent")
537  );
538  }
539 
540  if ($this->object->gotItems())
541  {
542  $GLOBALS["tpl"]->addAdminPanelCommand("delete",
543  $this->lng->txt("delete_selected_items"));
544  }
545 
546  if (!$_SESSION["clipboard"])
547  {
548  if ($this->object->gotItems())
549  {
550  $GLOBALS["tpl"]->addAdminPanelCommand("cut",
551  $this->lng->txt("move_selected_items"));
552  // BEGIN WebDAV: Support a copy command in the repository
553  // does currently not work
554  // $GLOBALS["tpl"]->addAdminPanelCommand("copy",
555  // $this->lng->txt("copy_selected_items"));
556  // END WebDAV: Support a copy command in the repository
557  $GLOBALS["tpl"]->addAdminPanelCommand("link",
558  $this->lng->txt("link_selected_items"));
559  }
560  }
561  else
562  {
563  $GLOBALS["tpl"]->addAdminPanelCommand("paste",
564  $this->lng->txt("paste_clipboard_items"));
565  $GLOBALS["tpl"]->addAdminPanelCommand("clear",
566  $this->lng->txt("clear_clipboard"));
567  }
568  if($this->object->gotItems() and $ilAccess->checkAccess("write", "", $this->object->getRefId()))
569  {
570  include_once('./Services/Container/classes/class.ilContainer.php');
571 
572  if ($this->object->getOrderType() == ilContainer::SORT_MANUAL)
573  {
574  $GLOBALS["tpl"]->addAdminPanelCommand("saveSorting",
575  $this->lng->txt('sorting_save'));
576  }
577  }
578 
579  $this->ctrl->setParameter($this, "type", "");
580  $this->ctrl->setParameter($this, "item_ref_id", "");
581  $GLOBALS["tpl"]->setPageFormAction($this->ctrl->getFormAction($this));
582  }
583  else if (
584  $ilUser->getId() != ANONYMOUS_USER_ID &&
585  ($this->adminCommands ||
586  (is_object($this->object) &&
587  ($ilAccess->checkAccess("write", "", $this->object->getRefId())))
588  ||
589  (is_object($this->object) &&
590  ($this->object->getHiddenFilesFound())) ||
591  $_SESSION["clipboard"]
592  )
593  )
594  {
595  $GLOBALS["tpl"]->setAdminViewButton(
596  $this->ctrl->getLinkTarget($this, "enableAdministrationPanel"),
597  $this->lng->txt("all_commands"));
598  }
599  }
600 
602  {
603  global $tree;
604 
605  if(!$tree->checkForParentType($this->object->getRefId(),'crs'))
606  {
607  return false;
608  }
609  $tpl->setCurrentBlock("custom_button");
610  $tpl->setVariable("ADMIN_MODE_LINK",$this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editTimings'));
611  $tpl->setVariable("TXT_ADMIN_MODE",$this->lng->txt('timings_edit'));
612  $tpl->parseCurrentBlock();
613  return true;
614  }
619  {
620  $GLOBALS["tpl"]->setPermanentLink($this->object->getType(),
621  $this->object->getRefId(), "", "_top");
622  }
623 
628  {
629  global $ilCtrl;
630 
631  $_SESSION["il_cntr_editor"] = "std";
632  $ilCtrl->redirect($this, "editPageFrame");
633  }
634 
639  {
640  global $ilCtrl;
641 
642  $_SESSION["il_cntr_editor"] = "old";
643  $ilCtrl->redirect($this, "editPageFrame");
644  }
645 
650  {
651  global $ilCtrl, $ilAccess, $lng, $ilCtrl;
652 
653  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
654  {
655  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
656 
657  /* keep old page content for now...
658  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
659  "xhtml_page");
660  if ($xpage_id)
661  {
662  $xpage = new ilXHTMLPage($xpage_id);
663  }
664  */
665 
666  ilContainer::_writeContainerSetting($this->object->getId(),
667  "xhtml_page", 0);
668 
669  ilUtil::sendInfo($lng->txt("cntr_switched_editor"), true);
670  }
671 
672  $ilCtrl->redirect($this, "editPageFrame");
673  }
674 
679  {
680  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
681  $fs_gui = new ilFramesetGUI();
682 
683  $fs_gui->setFramesetTitle($this->object->getTitle());
684  $fs_gui->setMainFrameName("content");
685  $fs_gui->setSideFrameName("link_list");
686 
687  // old tiny stuff
688  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
689  "xhtml_page");
690  if ($xpage_id > 0 && $_SESSION["il_cntr_editor"] != "std")
691  {
692  $fs_gui->setMainFrameSource(
693  $this->ctrl->getLinkTarget(
694  $this, "editPageContent"));
695  $fs_gui->setSideFrameSource(
696  $this->ctrl->getLinkTarget($this, "showLinkList"));
697  }
698  else
699  {
700  $fs_gui->setMainWidth("100%");
701  $fs_gui->setSideWidth("0");
702 
703  // to do: check this
704  $fs_gui->setSideFrameSource("");
705 
706  // page object stuff
707  $fs_gui->setMainFrameSource(
708  $this->ctrl->getLinkTargetByClass(
709  array("ilpageobjectgui"), "edit"));
710  }
711 
712  $fs_gui->show();
713  exit;
714  }
715 
722  {
723  global $rbacsystem, $tpl, $lng, $ilCtrl;
724 
725  if (!$rbacsystem->checkAccess("write", $this->ref_id))
726  {
727  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
728  }
729 
730  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
731  "xhtml_page");
732  if ($xpage_id > 0)
733  {
734  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
735  $xpage = new ilXHTMLPage($xpage_id);
736  $content = $xpage->getContent();
737  }
738 
739  // get template
740  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.container_edit_page_content.html",
741  "Services/Container");
742  $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
743  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
744  $tpl->setVariable("TXT_EDIT_PAGE_CONTENT",
745  $this->lng->txt("edit_page_content"));
746  $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
747  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
748  $tpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_old_editor_warning"));
749  $tpl->setVariable("TXT_MIGRATION_OPEN_STD_EDITOR", $lng->txt("cntr_old_editor_open_standard_editor"));
750  $tpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert_s.gif"));
751  $tpl->setVariable("HREF_OPEN_STD_EDITOR", $ilCtrl->getLinkTarget($this, "switchToStdEditor"));
752  $tpl->setVariable("ALT_WARNING", $lng->txt("warning"));
753 
754  include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
755  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
756  //$ta = new ilTextAreaInputGUI();
757  //$tags = $ta->getRteTagSet("extended_table_img");
758 
759  // add rte support
760  include_once "./Services/RTE/classes/class.ilRTE.php";
761  $rtestring = ilRTE::_getRTEClassname();
762  include_once "./Services/RTE/classes/class.$rtestring.php";
763  $rte = new $rtestring();
764  //$rte->addPlugin("latex");
765  include_once "./classes/class.ilObject.php";
767  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
768  $rte->addRTESupport($obj_id, $obj_type);
769  //$rte->setStyleSelect(true);
770  //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
771  }
772 
774  {
775  include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
776  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
777  $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
778  "xhtml_page");
779 
780  /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
781  include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
782  $ta = new ilTextAreaInputGUI();
783  $ta->setRteTagSet("extended_table_img");
784  $tags = $ta->getRteTagString();*/
785 
786  //$text = ilUtil::stripSlashes($_POST["page_content"],
787  // true,
788  // $tags);
789 
790  $text = ilUtil::stripSlashes($_POST["page_content"],
791  true,
793  if ($xpage_id > 0)
794  {
795  $xpage = new ilXHTMLPage($xpage_id);
796  $xpage->setContent($text);
797  $xpage->save();
798  }
799  else
800  {
801  $xpage = new ilXHTMLPage();
802  $xpage->setContent($text);
803  $xpage->save();
804  ilContainer::_writeContainerSetting($this->object->getId(),
805  "xhtml_page", $xpage->getId());
806  }
807 
808  include_once("Services/RTE/classes/class.ilRTE.php");
809  ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType().":html",
810  $this->object->getId());
811 
812  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
813  $this->ctrl->redirect($this, "");
814  }
815 
817  {
818  ilUtil::sendInfo($this->lng->txt("action_aborted"), true);
819  $this->ctrl->redirect($this, "");
820  }
821 
822  function renderItemList($a_type = "all")
823  {
825 
826  include_once("classes/class.ilObjectListGUIFactory.php");
827 
828  $output_html = "";
830 
831  $type_grps = $this->object->getGroupedObjTypes();
832 
833  switch ($a_type)
834  {
835  // render all items list
836  case "all":
837 
838  // new behaviour
839  $output_html.= $this->getContainerPageHTML();
840 
841  // all item types
842  /*
843  $type_ordering = array(
844  "cat", "fold", "crs","rcrs", "icrs", "icla", "grp", "chat", "frm", "lres",
845  "glo", "webr", "mcst", "wiki", "file", "exc",
846  "tst", "svy", "mep", "qpl", "spl");*/
847 
848  $cur_obj_type = "";
849  $overall_tpl =& $this->newBlockTemplate();
850  $this->type_template = array();
851  $first = true;
852 
853  // iterate all types
854  foreach ($type_grps as $type => $v)
855  {
856  // set template (overall or type specific)
857  if (is_int(strpos($output_html, "[list-".$type."]")))
858  {
859  $tpl =& $this->newBlockTemplate();
860  $overall = false; // individual
861  }
862  else
863  {
864  $tpl =& $overall_tpl;
865  $overall = true; // put to the rest
866  }
867 
868  if (is_array($this->items[$type]))
869  {
870 
871  $item_html = array();
872 
873  foreach($this->items[$type] as $key => $item)
874  {
875  // get list gui class for each object type
876  if ($cur_obj_type != $item["type"])
877  {
878  $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
879  $item_list_gui->setContainerObject($this);
880  }
881  // render item row
882  $ilBench->start("ilContainerGUI", "0210_getListHTML");
883 
884  // show administration command buttons (or not)
885  if (!$this->isActiveAdministrationPanel())
886  {
887  $item_list_gui->enableDelete(false);
888  $item_list_gui->enableLink(false);
889  $item_list_gui->enableCut(false);
890  }
891 
892  $html = $item_list_gui->getListItemHTML($item["ref_id"],
893  $item["obj_id"], $item["title"], $item["description"]);
894 
895  // check whether any admin command is allowed for
896  // the items
897  $this->determineAdminCommands($item["ref_id"],
898  $item_list_gui->adminCommandsIncluded());
899  $ilBench->stop("ilContainerGUI", "0210_getListHTML");
900  if ($html != "")
901  {
902  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
903  $item_html[] = array(
904  "html" => $html,
905  "item_ref_id" => $item["ref_id"],
906  "item_obj_id" => $item["obj_id"],
907  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
908  $item_list_gui->getIconImageType() :
909  $item['type']
910  );
911  // END WebDAV: Use $item_list_gui to determine icon image type
912  }
913  }
914 
915  // output block for resource type
916  if (count($item_html) > 0)
917  {
918  // separator row
919  if (!$first && $overall)
920  {
921  $this->addSeparatorRow($tpl);
922  }
923 
924  if ($overall)
925  {
926  $first = false;
927  }
928 
929  // add a header for each resource type
930  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
931  {
932  $this->addHeaderRow($tpl, $type, false);
933  }
934  else
935  {
936  $this->addHeaderRow($tpl, $type);
937  }
938  $this->resetRowType();
939 
940  // content row
941  $this->current_position = 1;
942  foreach($item_html as $item)
943  {
944  // BEGIN WebDAV: Use $item_list_gui to determine image type
945  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $item['item_icon_image_type']);
946  // END WebDAV: Use $item_list_gui to determine image type
947  }
948 
949  // store type specific templates in array
950  if (is_int(strpos($output_html, "[list-".$type."]")))
951  {
952  $this->type_template[$type] = $tpl;
953  }
954  }
955  else
956  {
957  // [list-...] tag available, but no item of type accessible
958  if (!$overall)
959  {
960  $this->addHeaderRow($tpl, $type);
961  $this->resetRowType();
962  $this->addMessageRow($tpl,
963  $this->lng->txt("msg_no_type_accessible"), $type);
964  $this->type_template[$type] = $tpl;
965  }
966  }
967  }
968  else
969  {
970  // [list-...] tag available, but no item of type exists
971  if (!$overall)
972  {
973  $this->addHeaderRow($tpl, $type);
974  $this->resetRowType();
975  $this->addMessageRow($tpl,
976  $this->lng->txt("msg_no_type_available"), $type);
977  $this->type_template[$type] = $tpl;
978  }
979  }
980 
981  }
982 
983 
984  // I don't know why but executing this
985  // line before the following foreach loop seems to be crucial
986  if ($output_html != "")
987  {
988  //$output_html.= "<br /><br />";
989  }
990  $output_html.= $overall_tpl->get();
991  //$output_html = str_replace("<br>++", "++", $output_html);
992  //$output_html = str_replace("<br>++", "++", $output_html);
993  //$output_html = str_replace("++<br>", "++", $output_html);
994  //$output_html = str_replace("++<br>", "++", $output_html);
995  foreach ($this->type_template as $type => $tpl)
996  {
997  $output_html = eregi_replace("\[list-".$type."\]",
998  "</p>".$tpl->get()."<p class=\"ilc_Standard\">",
999  $output_html);
1000  }
1001 
1002  //if (ilPageObject::_exists($this->object->getType(),
1003  // $this->object->getId()))
1004  if ($xpage_id > 0)
1005  {
1006  $page_block = new ilTemplate("tpl.container_page_block.html", false, false,
1007  "Services/Container");
1008  $page_block->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
1009  $output_html = $page_block->get();
1010  }
1011 
1012  break;
1013 
1014  default:
1015  // to do:
1016  break;
1017  }
1018  return $output_html;
1019  }
1020 
1022  {
1023  global $lng, $tree;
1024 
1025  $tpl = new ilTemplate("tpl.container_link_help.html", true, true);
1026 
1027  $type_ordering = array(
1028  "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
1029  "glo", "webr", "file", "exc",
1030  "tst", "svy", "mep", "qpl", "spl");
1031 
1032  $childs = $tree->getChilds($_GET["ref_id"]);
1033  foreach($childs as $child)
1034  {
1035  if (in_array($child["type"], array("lm", "dbk", "sahs", "htlm")))
1036  {
1037  $cnt["lres"]++;
1038  }
1039  else
1040  {
1041  $cnt[$child["type"]]++;
1042  }
1043  }
1044 
1045  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1046  $tpl->setVariable("TXT_HELP_HEADER", $lng->txt("help"));
1047  foreach($type_ordering as $type)
1048  {
1049  $tpl->setCurrentBlock("row");
1050  $tpl->setVariable("ROWCOL", "tblrow".((($i++)%2)+1));
1051  if ($type != "lres")
1052  {
1053  $tpl->setVariable("TYPE", $lng->txt("objs_".$type).
1054  " (".((int)$cnt[$type]).")");
1055  }
1056  else
1057  {
1058  $tpl->setVariable("TYPE", $lng->txt("learning_resources").
1059  " (".((int)$cnt["lres"]).")");
1060  }
1061  $tpl->setVariable("TXT_LINK", "[list-".$type."]");
1062  $tpl->parseCurrentBlock();
1063  }
1064  $tpl->show();
1065  exit;
1066 
1067  }
1068 
1073  {
1074  $this->adminCommands = false;
1075  }
1076 
1080 /* function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
1081  {
1082  if (!$this->adminCommands)
1083  {
1084  if (!$this->isActiveAdministrationPanel())
1085  {
1086  if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
1087  {
1088  $this->adminCommands = true;
1089  }
1090  }
1091  else
1092  {
1093  $this->adminCommands = $a_admin_com_included_in_list;
1094  }
1095  }
1096  }*/
1097 
1104  function &newBlockTemplate()
1105  {
1106  $tpl = new ilTemplate ("tpl.container_list_block.html", true, true,
1107  "Services/Container");
1108  $this->cur_row_type = "row_type_1";
1109  return $tpl;
1110  }
1111 
1119  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1120  {
1121  $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
1122  $title = $this->lng->txt("objs_".$a_type);
1123 
1124  if ($a_show_image)
1125  {
1126  $a_tpl->setCurrentBlock("container_header_row_image");
1127  $a_tpl->setVariable("HEADER_IMG", $icon);
1128  $a_tpl->setVariable("HEADER_ALT", $title);
1129  }
1130  else
1131  {
1132  $a_tpl->setCurrentBlock("container_header_row");
1133  }
1134 
1135  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1136  $a_tpl->parseCurrentBlock();
1137  $a_tpl->touchBlock("container_row");
1138  }
1139 
1147  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1148  $a_image_type = "")
1149  {
1150  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1151  ? "row_type_2"
1152  : "row_type_1";
1153 
1154  $a_tpl->touchBlock($this->cur_row_type);
1155 
1156  $nbsp = true;
1157  if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
1158  {
1159  $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
1160  $alt = $this->lng->txt("obj_".$a_image_type);
1161 
1162  // custom icon
1163  if ($this->ilias->getSetting("custom_icons") &&
1164  in_array($a_image_type, array("cat","grp","crs")))
1165  {
1166  require_once("./Services/Container/classes/class.ilContainer.php");
1167  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1168  {
1169  $icon = $path;
1170  }
1171  }
1172 
1173  $a_tpl->setCurrentBlock("block_row_image");
1174  $a_tpl->setVariable("ROW_IMG", $icon);
1175  $a_tpl->setVariable("ROW_ALT", $alt);
1176  $a_tpl->parseCurrentBlock();
1177  $nbsp = false;
1178  }
1179 
1180  if ($this->isActiveAdministrationPanel())
1181  {
1182  $a_tpl->setCurrentBlock("block_row_check");
1183  $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
1184  $a_tpl->parseCurrentBlock();
1185  $nbsp = false;
1186  }
1187  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1188  if($this->isActiveAdministrationPanel() &&
1190  {
1191  $a_tpl->setCurrentBlock('block_position');
1192  $a_tpl->setVariable('POS_TYPE',$a_image_type);
1193  $a_tpl->setVariable('POS_ID',$a_item_ref_id);
1194  $a_tpl->setVariable('POSITION',sprintf('%.1f',$this->current_position++));
1195  $a_tpl->parseCurrentBlock();
1196  }
1197  if ($nbsp)
1198  {
1199  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1200  }
1201  $a_tpl->setCurrentBlock("container_standard_row");
1202  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1203  $a_tpl->parseCurrentBlock();
1204  $a_tpl->touchBlock("container_row");
1205  }
1206 
1210  function addMessageRow(&$a_tpl, $a_message, $a_type)
1211  {
1212  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1213  ? "row_type_2"
1214  : "row_type_1";
1215 
1216  $a_tpl->touchBlock($this->cur_row_type);
1217 
1218  $type = $this->lng->txt("obj_".$a_type);
1219  $a_message = str_replace("[type]", $type, $a_message);
1220 
1221  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1222 
1223  $a_tpl->setCurrentBlock("container_standard_row");
1224  $a_tpl->setVariable("BLOCK_ROW_CONTENT",
1225  $a_message);
1226  $a_tpl->parseCurrentBlock();
1227  $a_tpl->touchBlock("container_row");
1228  }
1229 
1230  function resetRowType()
1231  {
1232  $this->cur_row_type = "";
1233  }
1234 
1235  function addSeparatorRow(&$a_tpl)
1236  {
1237  $a_tpl->touchBlock("separator_row");
1238  $a_tpl->touchBlock("container_row");
1239  }
1240 
1242  {
1243  global $lng;
1244 
1245  if (!$this->isActiveAdministrationPanel()
1246  || strtolower($this->ctrl->getCmdClass()) != "ilpageobjectgui")
1247  {
1248  return;
1249  }
1250 
1251  $lng->loadLanguageModule("content");
1252  //$tabs_gui = new ilTabsGUI();
1253  //$tabs_gui->setSubTabs();
1254 
1255  // back to upper context
1256  $this->tabs_gui->setBackTarget($this->lng->txt("obj_cat"),
1257  $this->ctrl->getLinkTarget($this, "frameset"),
1258  ilFrameTargetInfo::_getFrame("MainContent"));
1259 
1260  $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view")
1261  , array("", "view"), "ilpageobjectgui");
1262 
1263  //$this->tpl->setTabs($tabs_gui->getHTML());
1264  }
1265 
1266 
1271  function getTabs(&$tabs_gui)
1272  {
1273  global $rbacsystem;
1274 
1275  // edit permissions
1276  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
1277  {
1278  $tabs_gui->addTarget("perm_settings",
1279  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1280  }
1281 
1282  // show clipboard
1283  if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION["clipboard"]))
1284  {
1285  $tabs_gui->addTarget("clipboard",
1286  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
1287  }
1288 
1289  }
1290 
1291  //*****************
1292  // COMMON METHODS (may be overwritten in derived classes
1293  // if special handling is necessary)
1294  //*****************
1295 
1300  {
1301  $_SESSION["il_cont_admin_panel"] = true;
1302  $this->ctrl->redirect($this, "render");
1303  }
1304 
1309  {
1310  $_SESSION["il_cont_admin_panel"] = false;
1311  $this->ctrl->redirect($this, "render");
1312  }
1313 
1317  function addToDeskObject()
1318  {
1319  if ($_GET["item_ref_id"] and $_GET["type"])
1320  {
1321  $this->ilias->account->addDesktopItem($_GET["item_ref_id"], $_GET["type"]);
1322  }
1323  else
1324  {
1325  if ($_POST["items"])
1326  {
1327  foreach ($_POST["items"] as $item)
1328  {
1329  $type = ilObject::_lookupType($item, true);
1330  $this->ilias->account->addDesktopItem($item, $type);
1331  }
1332  }
1333  }
1334  $this->renderObject();
1335  }
1336  // BEGIN WebDAV: Lock/Unlock objects
1337  function lockObject()
1338  {
1339  global $tree, $ilUser, $rbacsystem;
1340 
1341  if (!$rbacsystem->checkAccess("write",$_GET['item_ref_id']))
1342  {
1343  $this->ilErr->raiseError($this->lng->txt('err_no_permission'),$this->ilErr->MESSAGE);
1344  }
1345 
1346 
1347  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1349  {
1350  require_once 'Services/WebDAV/classes/class.ilDAVLocks.php';
1351  $locks = new ilDAVLocks();
1352 
1353  $result = $locks->lockRef($_GET['item_ref_id'],
1354  $ilUser->getId(), $ilUser->getLogin(),
1355  'ref_'.$_GET['item_ref_id'].'_usr_'.$ilUser->getId(),
1356  time() + /*30*24*60**/60, 0, 'exclusive'
1357  );
1358 
1360  $this->lng->txt(
1361  ($result === true) ? 'object_locked' : $result
1362  ),
1363  true);
1364  }
1365  $this->renderObject();
1366  }
1367  // END WebDAV: Lock/Unlock objects
1368 
1372  function getActions()
1373  {
1374  // standard actions for container
1375  return array(
1376  "cut" => array("name" => "cut", "lng" => "cut"),
1377  "delete" => array("name" => "delete", "lng" => "delete"),
1378  "link" => array("name" => "link", "lng" => "link"),
1379  "paste" => array("name" => "paste", "lng" => "paste"),
1380  "clear" => array("name" => "clear", "lng" => "clear")
1381  );
1382  }
1383 
1384 
1389  {
1390  if ($_GET["item_ref_id"] and $_GET["type"])
1391  {
1392  $this->ilias->account->dropDesktopItem($_GET["item_ref_id"], $_GET["type"]);
1393  }
1394  else
1395  {
1396  if ($_POST["items"])
1397  {
1398  foreach ($_POST["items"] as $item)
1399  {
1400  $type = ilObject::_lookupType($item, true);
1401  $this->ilias->account->dropDesktopItem($item, $type);
1402  unset($tmp_obj);
1403  }
1404  }
1405  }
1406  $this->renderObject();
1407  }
1408 
1409 
1416  function cutObject()
1417  {
1418  global $rbacsystem;
1419 
1420  if ($_GET["item_ref_id"] != "")
1421  {
1422  $_POST["id"] = array($_GET["item_ref_id"]);
1423  }
1424 
1425  //$this->ilias->raiseError("move operation does not work at the moment and is disabled",$this->ilias->error_obj->MESSAGE);
1426 
1427 //echo "CUT";
1428 //echo $_SESSION["referer"];
1429  if (!isset($_POST["id"]))
1430  {
1431  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1432  }
1433 
1434  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1435  foreach ($_POST["id"] as $ref_id)
1436  {
1437  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1438  $node_data = $this->tree->getNodeData($ref_id);
1439  $subtree_nodes = $this->tree->getSubTree($node_data);
1440 
1441  $all_node_data[] = $node_data;
1442  $all_subtree_nodes[] = $subtree_nodes;
1443 
1444  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1445  foreach ($subtree_nodes as $node)
1446  {
1447  if($node['type'] == 'rolf')
1448  {
1449  continue;
1450  }
1451 
1452  if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
1453  {
1454  $no_cut[] = $node["ref_id"];
1455  }
1456  }
1457  }
1458  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1459  if (count($no_cut))
1460  {
1461  $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
1462  $this->ilias->error_obj->MESSAGE);
1463  }
1464  //echo "GET";var_dump($_GET);echo "POST";var_dump($_POST);
1465  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1466  $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
1467  ? $_GET["cmd"]
1468  : key($_POST["cmd"]);
1469 //echo "-".$clipboard["cmd"]."-";
1470  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1471 //echo "-".$_SESSION["clipboard"]["cmd"]."-";
1472 
1473  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"),true);
1474 
1475  $this->ctrl->returnToParent($this);
1476 
1477  } // END CUT
1478 
1479 
1486  function linkObject()
1487  {
1488  global $clipboard, $rbacsystem, $rbacadmin;
1489 
1490  if ($_GET["item_ref_id"] != "")
1491  {
1492  $_POST["id"] = array($_GET["item_ref_id"]);
1493  }
1494 
1495  if (!isset($_POST["id"]))
1496  {
1497  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1498  }
1499 
1500  // CHECK ACCESS
1501  foreach ($_POST["id"] as $ref_id)
1502  {
1503  if (!$rbacsystem->checkAccess('delete',$ref_id))
1504  {
1505  $no_cut[] = $ref_id;
1506  }
1507 
1508  $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1509 
1510  if (!$this->objDefinition->allowLink($object->getType()))
1511  {
1512  $no_link[] = $object->getType();
1513  }
1514  }
1515 
1516  // NO ACCESS
1517  if (count($no_cut))
1518  {
1519  $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
1520  implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
1521  }
1522 
1523  if (count($no_link))
1524  {
1525  $no_link = array_unique($no_link);
1526 
1527  foreach ($no_link as $type)
1528  {
1529  $txt_objs[] = $this->lng->txt("objs_".$type);
1530  }
1531 
1532  $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
1533 
1534  //$this->ilias->raiseError($this->lng->txt("msg_not_possible_link")." ".
1535  // implode(',',$no_link),$this->ilias->error_obj->MESSAGE);
1536  }
1537 
1538  // WRITE TO CLIPBOARD
1539  $clipboard["parent"] = $_GET["ref_id"];
1540  $clipboard["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
1541  ? $_GET["cmd"]
1542  : key($_POST["cmd"]);
1543 
1544  foreach ($_POST["id"] as $ref_id)
1545  {
1546  $clipboard["ref_ids"][] = $ref_id;
1547  }
1548 
1549  $_SESSION["clipboard"] = $clipboard;
1550 
1551  ilUtil::sendInfo($this->lng->txt("msg_link_clipboard"),true);
1552 
1553  $this->ctrl->returnToParent($this);
1554 
1555  } // END LINK
1556 
1557 
1563  function clearObject()
1564  {
1565  unset($_SESSION["clipboard"]);
1566  unset($_SESSION["il_rep_clipboard"]);
1567  //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1568 
1569  // only redirect if clipboard was cleared
1570  if (isset($_POST["cmd"]["clear"]))
1571  {
1572  ilUtil::sendInfo($this->lng->txt("msg_clear_clipboard"),true);
1573 
1574  $this->ctrl->returnToParent($this);
1575  //ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
1576  }
1577  }
1578 
1585  function pasteObject()
1586  {
1587  global $rbacsystem, $rbacadmin, $rbacreview, $log,$tree;
1588  global $ilUser, $lng;
1589 
1590  // BEGIN ChangeEvent: Record paste event.
1591  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1592  // END ChangeEvent: Record paste event.
1593 
1594 //var_dump($_SESSION["clipboard"]);exit;
1595  if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
1596  {
1597  $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
1598  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
1599  }
1600 
1601  // this loop does all checks
1602  foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
1603  {
1604  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
1605 
1606  // CHECK ACCESS
1607  if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
1608  {
1609  $no_paste[] = $ref_id;
1610  $no_paste_titles[] = $obj_data->getTitle();
1611  }
1612 
1613  // CHECK IF REFERENCE ALREADY EXISTS
1614  if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
1615  {
1616  $exists[] = $ref_id;
1617  break;
1618  }
1619 
1620  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1621  if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
1622  {
1623  $is_child[] = $ref_id;
1624  }
1625 
1626  // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
1627  $obj_type = $obj_data->getType();
1628 
1629  if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
1630  {
1631  $not_allowed_subobject[] = $obj_data->getType();
1632  }
1633  }
1634 
1636  // process checking results
1637  // BEGIN WebDAV: Copying an object into the same container is allowed
1638  if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy")
1639  // END WebDAV: Copying an object into the same container is allowed
1640  {
1641  $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
1642  }
1643 
1644  if (count($is_child))
1645  {
1646  $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
1647  $this->ilias->error_obj->MESSAGE);
1648  }
1649 
1650  if (count($not_allowed_subobject))
1651  {
1652  $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
1653  $this->ilias->error_obj->MESSAGE);
1654  }
1655 
1656  if (count($no_paste))
1657  {
1658  $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
1659  implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
1660  }
1661 
1662  // log pasteObject call
1663  $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
1664 
1666  // everything ok: now paste the objects to new location
1667 
1668  // to prevent multiple actions via back/reload button
1669  $ref_ids = $_SESSION["clipboard"]["ref_ids"];
1670  unset($_SESSION["clipboard"]["ref_ids"]);
1671 
1672  // BEGIN WebDAV: Support a copy command in the repository
1673  // process COPY command
1674  if ($_SESSION["clipboard"]["cmd"] == "copy")
1675  {
1676  foreach($ref_ids as $ref_id)
1677  {
1678  $revIdMapping = array();
1679 
1680  $oldNode_data = $tree->getNodeData($ref_id);
1681  if ($oldNode_data['parent'] == $this->object->getRefId())
1682  {
1683  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
1684  $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
1685  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
1686  }
1687  else
1688  {
1689  $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
1690  }
1691 
1692 
1693  // BEGIN ChangeEvent: Record copy event.
1694  if (ilChangeEvent::_isActive() )
1695  {
1696  $old_parent_data = $tree->getParentNodeData($ref_id);
1697  $newNode_data = $tree->getNodeData($newRef);
1698  ilChangeEvent::_recordReadEvent($oldNode_data['obj_id'], $ilUser->getId());
1699  ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add',
1700  $this->object->getId());
1701  ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
1702  }
1703  // END ChangeEvent: Record copy event.
1704  }
1705  $log->write("ilObjectGUI::pasteObject(), copy finished");
1706  }
1707  // END WebDAV: Support a Copy command in the repository
1708 
1709  // process CUT command
1710  if ($_SESSION["clipboard"]["cmd"] == "cut")
1711  {
1712 
1713  foreach($ref_ids as $ref_id)
1714  {
1715  // Store old parent
1716  $old_parent = $tree->getParentId($ref_id);
1717  $this->tree->moveTree($ref_id,$this->object->getRefId());
1718  $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
1719 
1720  include_once('classes/class.ilConditionHandler.php');
1722 
1723  // BEGIN ChangeEvent: Record cut event.
1724  if (ilChangeEvent::_isActive() )
1725  {
1726  $node_data = $tree->getNodeData($ref_id);
1727  $old_parent_data = $tree->getNodeData($old_parent);
1728  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove',
1729  $old_parent_data['obj_id']);
1730  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
1731  $this->object->getId());
1732  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
1733  }
1734  // END PATCH ChangeEvent: Record cut event.
1735  }
1736  } // END CUT
1737 
1738  // process LINK command
1739  if ($_SESSION["clipboard"]["cmd"] == "link")
1740  {
1741  foreach ($ref_ids as $ref_id)
1742  {
1743  // get node data
1744  $top_node = $this->tree->getNodeData($ref_id);
1745 
1746  // get subnodes of top nodes
1747  $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
1748  }
1749 
1750  // now move all subtrees to new location
1751  foreach ($subnodes as $key => $subnode)
1752  {
1753  // first paste top_node....
1754  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
1755  $new_ref_id = $obj_data->createReference();
1756  $obj_data->putInTree($_GET["ref_id"]);
1757  $obj_data->setPermissions($_GET["ref_id"]);
1758 
1759  // ... remove top_node from list ...
1760  array_shift($subnode);
1761 
1762  // ... store mapping of old ref_id => new_ref_id in hash array ...
1763  $mapping[$new_ref_id] = $key;
1764 
1765  // save old ref_id & create rolefolder if applicable
1766  $old_ref_id = $obj_data->getRefId();
1767  $obj_data->setRefId($new_ref_id);
1768  $obj_data->initDefaultRoles();
1769  $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
1770 
1771  if (isset($rolf_data["child"]))
1772  {
1773  // a role folder was created, so map it to old role folder
1774  $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
1775 
1776  // ... use mapping array to find out the correct new parent node where to put in the node...
1777  //$new_parent = array_search($node["parent"],$mapping);
1778  // ... append node to mapping for further possible subnodes ...
1779  $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
1780 
1781  // log creation of role folder
1782  $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
1783  ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
1784  ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
1785 
1786  }
1787  // BEGIN ChangeEvent: Record link event.
1788  if (ilChangeEvent::_isActive() )
1789  {
1790  $node_data = $tree->getNodeData($new_ref_id);
1791  ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add',
1792  $this->object->getId());
1793  ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
1794  }
1795  // END PATCH ChangeEvent: Record link event.
1796 
1797  // ... insert subtree of top_node if any subnodes exist ...
1798  if (count($subnode) > 0)
1799  {
1800  foreach ($subnode as $node)
1801  {
1802  if ($node["type"] != 'rolf')
1803  {
1804  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
1805  $new_ref_id = $obj_data->createReference();
1806 
1807  // ... use mapping array to find out the correct new parent node where to put in the node...
1808  $new_parent = array_search($node["parent"],$mapping);
1809  // ... append node to mapping for further possible subnodes ...
1810  $mapping[$new_ref_id] = (int) $node["child"];
1811 
1812  $obj_data->putInTree($new_parent);
1813  $obj_data->setPermissions($new_parent);
1814 
1815  // save old ref_id & create rolefolder if applicable
1816  $old_ref_id = $obj_data->getRefId();
1817  $obj_data->setRefId($new_ref_id);
1818  $obj_data->initDefaultRoles();
1819  $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
1820 
1821  if (isset($rolf_data["child"]))
1822  {
1823  // a role folder was created, so map it to old role folder
1824  $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
1825 
1826  // ... use mapping array to find out the correct new parent node where to put in the node...
1827  //$new_parent = array_search($node["parent"],$mapping);
1828  // ... append node to mapping for further possible subnodes ...
1829  $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
1830 
1831  // log creation of role folder
1832  $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
1833  ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
1834  ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
1835 
1836  }
1837  }
1838 
1839  // re-map $subnodes
1840  foreach ($subnodes as $old_ref => $subnode)
1841  {
1842  $new_ref = array_search($old_ref,$mapping);
1843 
1844  foreach ($subnode as $node)
1845  {
1846  $node["child"] = array_search($node["child"],$mapping);
1847  $node["parent"] = array_search($node["parent"],$mapping);
1848  $new_subnodes[$ref_id][] = $node;
1849  }
1850  }
1851 
1852  }
1853  }
1854  }
1855 
1856  $log->write("ilObjectGUI::pasteObject(), link finished");
1857 
1858  // inform other objects in hierarchy about link operation
1859  //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
1860  } // END LINK
1861 
1862  // save cmd for correct message output after clearing the clipboard
1863  $last_cmd = $_SESSION["clipboard"]["cmd"];
1864 
1865 
1866  // clear clipboard
1867  $this->clearObject();
1868 
1869  if ($last_cmd == "cut")
1870  {
1871  ilUtil::sendInfo($this->lng->txt("msg_cut_copied"),true);
1872  }
1873  // BEGIN WebDAV: Support a copy command in repository
1874  else if ($last_cmd == "copy")
1875  {
1876  ilUtil::sendInfo($this->lng->txt("msg_cloned"),true);
1877  }
1878  else if ($last_command == 'link')
1879  // END WebDAV: Support copy command in repository
1880  {
1881  ilUtil::sendInfo($this->lng->txt("msg_linked"),true);
1882  }
1883 
1884  $this->ctrl->returnToParent($this);
1885 
1886  } // END PASTE
1887 
1888  // BEGIN WebDAV: Support a copy command in repository
1895  function copyObject()
1896  {
1897  global $rbacsystem;
1898 
1899  if ($_GET["item_ref_id"] != "")
1900  {
1901  $_POST["id"] = array($_GET["item_ref_id"]);
1902  }
1903 
1904  if (!isset($_POST["id"]))
1905  {
1906  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1907  }
1908 
1909  // FOR ALL OBJECTS THAT SHOULD BE COPIED
1910  foreach ($_POST["id"] as $ref_id)
1911  {
1912  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1913  $node_data = $this->tree->getNodeData($ref_id);
1914  $subtree_nodes = $this->tree->getSubTree($node_data);
1915 
1916  $all_node_data[] = $node_data;
1917  $all_subtree_nodes[] = $subtree_nodes;
1918 
1919  // CHECK VIEW, READ AND COPY PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1920  foreach ($subtree_nodes as $node)
1921  {
1922  if($node['type'] == 'rolf')
1923  {
1924  continue;
1925  }
1926 
1927  if (!$rbacsystem->checkAccess('visible,read,copy',$node["ref_id"]))
1928  {
1929  $no_copy[] = $node["ref_id"];
1930  }
1931  }
1932  }
1933  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'view,read'
1934  if (count($no_copy))
1935  {
1936  $this->ilias->raiseError($this->lng->txt("msg_no_perm_copy")." ".implode(',',$this->getTitlesByRefId($no_copy)),
1937  $this->ilias->error_obj->MESSAGE);
1938  }
1939  $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
1940  $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
1941  ? $_GET["cmd"]
1942  : key($_POST["cmd"]);
1943  $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
1944 
1945  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"),true);
1946 
1947  $this->ctrl->returnToParent($this);
1948 
1949  } // END COPY
1950  // BEGIN WebDAV: Support copy command in repository
1951 
1952 
1956  function clipboardObject()
1957  {
1958  global $ilErr,$ilLog;
1959 
1960  // function should not be called if clipboard is empty
1961  if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
1962  {
1963  $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
1964  $ilLog->write($message,$ilLog->FATAL);
1965  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
1966  }
1967 
1968  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html");
1969 
1970  // FORMAT DATA
1971  $counter = 0;
1972  $f_result = array();
1973 
1974  foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
1975  {
1976  if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
1977  {
1978  continue;
1979  }
1980 
1981  //$f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
1982  $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
1983  $f_result[$counter][] = $tmp_obj->getTitle();
1984  //$f_result[$counter][] = $tmp_obj->getDescription();
1985  $f_result[$counter][] = ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]);
1986 
1987  unset($tmp_obj);
1988  ++$counter;
1989  }
1990 
1991  $this->__showClipboardTable($f_result, "clipboardObject");
1992 
1993  return true;
1994  }
1995 
1996 
2001  function showCustomIconsEditing($a_input_colspan = 1)
2002  {
2003  if ($this->ilias->getSetting("custom_icons"))
2004  {
2005  $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
2006  "tpl.container_icon_settings.html");
2007 
2008  if (($big_icon = $this->object->getBigIconPath()) != "")
2009  {
2010  $this->tpl->setCurrentBlock("big_icon");
2011  $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
2012  $this->tpl->parseCurrentBlock();
2013  }
2014  if (($small_icon = $this->object->getSmallIconPath()) != "")
2015  {
2016  $this->tpl->setCurrentBlock("small_icon");
2017  $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
2018  $this->tpl->parseCurrentBlock();
2019  }
2020  if (($tiny_icon = $this->object->getTinyIconPath()) != "")
2021  {
2022  $this->tpl->setCurrentBlock("tiny_icon");
2023  $this->tpl->setVariable("SRC_TINY_ICON", $tiny_icon);
2024  $this->tpl->parseCurrentBlock();
2025  }
2026  $this->tpl->setCurrentBlock("container_icon_settings");
2027  $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
2028  $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
2029  $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
2030  $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
2031  $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("standard_icon"));
2032  $this->tpl->setVariable("TINY_ICON", $this->lng->txt("tiny_icon"));
2033  $this->tpl->setVariable("BIG_SIZE", "(".
2034  $this->ilias->getSetting("custom_icon_big_width")."x".
2035  $this->ilias->getSetting("custom_icon_big_height").")");
2036  $this->tpl->setVariable("SMALL_SIZE", "(".
2037  $this->ilias->getSetting("custom_icon_small_width")."x".
2038  $this->ilias->getSetting("custom_icon_small_height").")");
2039  $this->tpl->setVariable("TINY_SIZE", "(".
2040  $this->ilias->getSetting("custom_icon_tiny_width")."x".
2041  $this->ilias->getSetting("custom_icon_tiny_height").")");
2042  $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
2043  $this->tpl->parseCurrentBlock();
2044  }
2045  }
2046 
2048  {
2049  return $_SESSION["il_cont_admin_panel"];
2050  }
2051 
2055  function setColumnSettings($column_gui)
2056  {
2057  global $ilAccess;
2058  parent::setColumnSettings($column_gui);
2059 
2060  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
2061  $this->isActiveAdministrationPanel() &&
2062  $this->allowBlocksMoving())
2063  {
2064  $column_gui->setEnableMovement(true);
2065  }
2066 
2067  $column_gui->setRepositoryItems(
2068  $this->object->getSubItems($this->isActiveAdministrationPanel(), true));
2069 
2070  //if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
2071  // && $this->allowBlocksConfigure())
2072  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
2073  {
2074  $column_gui->setBlockProperty("news", "settings", true);
2075  //$column_gui->setBlockProperty("news", "public_notifications_option", true);
2076  $column_gui->setBlockProperty("news", "default_visibility_option", true);
2077  $column_gui->setBlockProperty("news", "hide_news_block_option", true);
2078  }
2079 
2080  if ($this->isActiveAdministrationPanel())
2081  {
2082  $column_gui->setAdminCommands(true);
2083  }
2084  }
2085 
2090  {
2091  true;
2092  }
2093 
2098  {
2099  true;
2100  }
2101 
2109  public function cloneWizardPageTreeObject()
2110  {
2111  $this->cloneWizardPageObject(true);
2112  }
2113 
2121  public function cloneWizardPageListObject()
2122  {
2123  $this->cloneWizardPageObject(false);
2124  }
2125 
2132  public function cloneWizardPageObject($a_tree_view = true)
2133  {
2134  include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
2135 
2136  global $ilObjDataCache,$tree;
2137 
2138  if(!$_REQUEST['clone_source'])
2139  {
2140  ilUtil::sendInfo($this->lng->txt('select_one'));
2141  if(isset($_SESSION['wizard_search_title']))
2142  {
2143  $this->searchCloneSourceObject();
2144  }
2145  else
2146  {
2147  $this->createObject();
2148  }
2149  return false;
2150  }
2151  $source_id = $_REQUEST['clone_source'];
2152  $new_type = $_REQUEST['new_type'];
2153  $this->ctrl->setParameter($this,'clone_source',(int) $_REQUEST['clone_source']);
2154  $this->ctrl->setParameter($this,'new_type',$new_type);
2155 
2156 
2157  // Generell JavaScript
2158  $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
2159  $this->tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
2160 
2161 
2162  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.container_wizard_page.html');
2163  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
2164  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$new_type.'.gif'));
2165  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$new_type));
2166  $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt($new_type.'_wizard_page'));
2167  $this->tpl->setVariable('INFO_DUPLICATE',$this->lng->txt($new_type.'_copy_threads_info'));
2168  $this->tpl->setVariable('BTN_COPY',$this->lng->txt('obj_'.$new_type.'_duplicate'));
2169  $this->tpl->setVariable('BTN_BACK',$this->lng->txt('btn_back'));
2170  if(isset($_SESSION['wizard_search_title']))
2171  {
2172  $this->tpl->setVariable('CMD_BACK','searchCloneSource');
2173  }
2174  else
2175  {
2176  $this->tpl->setVariable('CMD_BACK','create');
2177  }
2178 
2179  $this->tpl->setVariable('BTN_TREE',$this->lng->txt('treeview'));
2180  $this->tpl->setVariable('BTN_LIST',$this->lng->txt('flatview'));
2181 
2182  // Fill item rows
2183  // tree view
2184  if($a_tree_view)
2185  {
2186  $first = true;
2187  $has_items = false;
2188  foreach($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id),true) as $node)
2189  {
2190  if($first == true)
2191  {
2192  $first = false;
2193  continue;
2194  }
2195 
2196  if($node['type'] == 'rolf')
2197  {
2198  continue;
2199  }
2200 
2201  $has_items = true;
2202 
2203  for($i = $source_node['depth'];$i < $node['depth']; $i++)
2204  {
2205  $this->tpl->touchBlock('padding');
2206  $this->tpl->touchBlock('end_padding');
2207  }
2208  // fill options
2209  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$node['type']);
2210  $copy_wizard_page->fillTreeSelection($node['ref_id'],$node['type'],$node['depth']);
2211 
2212  $this->tpl->setCurrentBlock('tree_row');
2213  $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'_s.gif'));
2214  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$node['type']));
2215  $this->tpl->setVariable('TREE_TITLE',$node['title']);
2216  $this->tpl->parseCurrentBlock();
2217  }
2218  if(!$has_items)
2219  {
2220  $this->tpl->setCurrentBlock('no_content');
2221  $this->tpl->setVariable('TXT_NO_CONTENT',$this->lng->txt('container_no_items'));
2222  $this->tpl->parseCurrentBlock();
2223  }
2224  else
2225  {
2226  $this->tpl->setCurrentBlock('tree_footer');
2227  $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
2228  $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
2229  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
2230  $this->tpl->parseCurrentBlock();
2231 
2232  }
2233  }
2234  else
2235  {
2236  foreach($tree->getSubTreeTypes($source_id,array('rolf','crs')) as $type)
2237  {
2238  $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$type);
2239  if(strlen($html = $copy_wizard_page->getWizardPageBlockHTML()))
2240  {
2241  $this->tpl->setCurrentBlock('obj_row');
2242  $this->tpl->setVariable('ITEM_BLOCK',$html);
2243  $this->tpl->parseCurrentBlock();
2244  }
2245  }
2246  }
2247  }
2248 
2256  public function cloneAllObject()
2257  {
2258  global $ilLog;
2259 
2260  include_once('classes/class.ilLink.php');
2261  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
2262 
2263  global $ilAccess,$ilErr,$rbacsystem,$tree,$ilUser;
2264 
2265  $new_type = $_REQUEST['new_type'];
2266  $ref_id = (int) $_GET['ref_id'];
2267  $clone_source = (int) $_REQUEST['clone_source'];
2268 
2269  if(!$rbacsystem->checkAccess('create', $ref_id,$new_type))
2270  {
2271  $ilErr->raiseError($this->lng->txt('permission_denied'));
2272  }
2273  if(!$clone_source)
2274  {
2275  ilUtil::sendInfo($this->lng->txt('select_one'));
2276  $this->createObject();
2277  return false;
2278  }
2279  if(!$ilAccess->checkAccess('write','', $clone_source,$new_type))
2280  {
2281  $ilErr->raiseError($this->lng->txt('permission_denied'));
2282  }
2283 
2284  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
2285  $orig = ilObjectFactory::getInstanceByRefId($clone_source);
2286  $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
2287 
2288  // Check if copy is in progress
2289  if ($result == $ref_id)
2290  {
2291  ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"),true);
2292  ilUtil::redirect('repository.php?ref_id='.$ref_id);
2293  }
2294  else
2295  {
2296  ilUtil::sendInfo($this->lng->txt("object_duplicated"),true);
2297  ilUtil::redirect('repository.php?ref_id='.$result);
2298  }
2299  }
2300 
2308  public function copyWizardHasOptions($a_mode)
2309  {
2310  switch($a_mode)
2311  {
2312  case self::COPY_WIZARD_NEEDS_PAGE:
2313  return true;
2314 
2315  default:
2316  return false;
2317  }
2318  }
2319 
2327  public function saveSortingObject()
2328  {
2329  include_once('Services/Container/classes/class.ilContainerSorting.php');
2330  $sorting = ilContainerSorting::_getInstance($this->object->getId());
2331  $sorting->savePost($_POST['position']);
2332  ilUtil::sendInfo($this->lng->txt('sorting_saved',true));
2333  $this->ctrl->returnToParent($this);
2334  }
2335 
2336  // BEGIN WebDAV: Support a copy command in the repository
2347  function cloneNodes($srcRef,$dstRef,&$mapping, $newName=null)
2348  {
2349  global $tree;
2350  global $ilias;
2351 
2352  // clone the source node
2353  $srcObj =& $ilias->obj_factory->getInstanceByRefId($srcRef);
2354  error_log(__METHOD__.' cloning srcRef='.$srcRef.' dstRef='.$dstRef.'...');
2355  $newRef = $srcObj->cloneObject($dstRef)->getRefId();
2356  error_log(__METHOD__.' ...cloning... newRef='.$newRef.'...');
2357 
2358  // We must immediately apply a new name to the object, to
2359  // prevent confusion of WebDAV clients about having two objects with identical
2360  // name in the repository.
2361  if (! is_null($newName))
2362  {
2363  $newObj =& $ilias->obj_factory->getInstanceByRefId($newRef);
2364  $newObj->setTitle($newName);
2365  $newObj->update();
2366  unset($newObj);
2367  }
2368  unset($srcObj);
2369  $mapping[$newRef] = $srcRef;
2370 
2371  // clone all children of the source node
2372  $children = $tree->getChilds($srcRef);
2373  foreach ($tree->getChilds($srcRef) as $child)
2374  {
2375  // Don't clone role folders, because it does not make sense to clone local roles
2376  // FIXME - Maybe it does make sense (?)
2377  if ($child["type"] != 'rolf')
2378  {
2379  $this->cloneNodes($child["ref_id"],$newRef,$mapping);
2380  }
2381  else
2382  {
2383  if (count($rolf = $tree->getChildsByType($newRef,"rolf")))
2384  {
2385  $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
2386  }
2387  }
2388  }
2389  error_log(__METHOD__.' ...cloned srcRef='.$srcRef.' dstRef='.$dstRef.' newRef='.$newRef);
2390  return $newRef;
2391  }
2392  // END PATCH WebDAV: Support a copy command in the repository
2393 
2397  function modifyItemGUI(&$a_item_list_gui, $a_item_data, $a_show_path)
2398  {
2399  global $lng;
2400 
2401  if($a_show_path)
2402  {
2403  $a_item_list_gui->addCustomProperty($lng->txt('path'),
2404  ilContainer_buildPath($a_item_data['ref_id'], $this->object->getRefId()),
2405  false, true);
2406  }
2407  }
2408 
2412  static function _buildPath($a_ref_id, $a_course_ref_id)
2413  {
2414  global $tree;
2415 
2416  $path_arr = $tree->getPathFull($a_ref_id, $a_course_ref_id);
2417  $counter = 0;
2418  foreach($path_arr as $data)
2419  {
2420  if($counter++)
2421  {
2422  $path .= " > ";
2423  }
2424  $path .= $data['title'];
2425  }
2426 
2427  return $path;
2428  }
2429 
2430 }
2431 ?>