ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFolderGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
20 require_once "./Services/Container/classes/class.ilContainerGUI.php";
21 
23 {
24  var $folder_tree; // folder tree
25 
30  function ilObjFolderGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = false)
31  {
32  $this->type = "fold";
33  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output, false);
34  }
35 
36 
40  function viewObject()
41  {
42  global $tree;
43 
44  $this->checkPermission('read');
45 
46  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
47  {
49  return true;
50  }
51  $this->renderObject();
52  $this->tabs_gui->setTabActive('view_content');
53  return true;
54  }
55 
59  function renderObject()
60  {
61  global $ilTabs;
62 
63  $this->checkPermission('read');
64 
65  $ilTabs->activateTab("view_content");
67  return $ret;
68  }
69 
70  function &executeCommand()
71  {
72  global $ilUser,$ilCtrl;
73 
74  $next_class = $this->ctrl->getNextClass($this);
75  $cmd = $this->ctrl->getCmd();
76 
77  // show repository tree
78  $this->showRepTree(true);
79 
80  switch ($next_class)
81  {
82  case 'ilpermissiongui':
83  $this->prepareOutput();
84  $this->tabs_gui->setTabActive('perm_settings');
85  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
86  $perm_gui =& new ilPermissionGUI($this);
87  $ret =& $this->ctrl->forwardCommand($perm_gui);
88  break;
89 
90  case 'ilcoursecontentgui':
91  $this->prepareOutput();
92  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
93  $course_content_obj = new ilCourseContentGUI($this);
94  $this->ctrl->forwardCommand($course_content_obj);
95  break;
96 
97  case "illearningprogressgui":
98  $this->prepareOutput();
99  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
100 
102  $this->object->getRefId(),
103  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
104  $this->ctrl->forwardCommand($new_gui);
105  $this->tabs_gui->setTabActive('learning_progress');
106  break;
107 
108  // container page editing
109  case "ilcontainerpagegui":
110  $this->prepareOutput(false);
111  $this->checkPermission("write");
112  $ret = $this->forwardToPageObject();
113  if ($ret != "")
114  {
115  $this->tpl->setContent($ret);
116  }
117  break;
118 
119  case 'ilinfoscreengui':
120  $this->prepareOutput();
121  $this->infoScreen();
122  break;
123 
124  case 'ilobjectcopygui':
125  $this->prepareOutput();
126 
127  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
128  $cp = new ilObjectCopyGUI($this);
129  $cp->setType('fold');
130  $this->ctrl->forwardCommand($cp);
131  break;
132 
133  case "ilobjstylesheetgui":
134  $this->forwardToStyleSheet();
135  break;
136 
137  case 'ilexportgui':
138  $this->prepareOutput();
139 
140  $this->tabs_gui->setTabActive('export');
141  include_once './Services/Export/classes/class.ilExportGUI.php';
142  $exp = new ilExportGUI($this);
143  $exp->addFormat('xml');
144  $this->ctrl->forwardCommand($exp);
145  break;
146 
147  case "ilcommonactiondispatchergui":
148  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
150  $this->ctrl->forwardCommand($gui);
151  break;
152 
153  case 'ildidactictemplategui':
154  $this->ctrl->setReturn($this,'edit');
155  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
156  $did = new ilDidacticTemplateGUI($this);
157  $this->ctrl->forwardCommand($did);
158  break;
159 
160  default:
161 
162  $this->prepareOutput();
163  // Dirty hack for course timings view
164  if($this->forwardToTimingsView())
165  {
166  break;
167  }
168 
169  if (empty($cmd))
170  {
171  $cmd = "view";
172  }
173  $cmd .= "Object";
174  $this->$cmd();
175  break;
176  }
177 
178  $this->addHeaderAction();
179  }
180 
184  function setFolderTree($a_tree)
185  {
186  $this->folder_tree =& $a_tree;
187  }
188 
193  public function importFileObject()
194  {
195  global $lng;
196 
197  if(parent::importFileObject())
198  {
199  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
200  $this->ctrl->returnToParent($this);
201  }
202  }
203 
204  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
205  {
206  // Show didactic template type
207  $this->initDidacticTemplate($a_form);
208 
209  // Sorting
210  $sog = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'),'sor');
211  $sog->setRequired(true);
212 
213  // implicit: there is always a group or course in the path
214  $sde = new ilRadioOption();
215  $sde->setValue(ilContainer::SORT_INHERIT);
216  $sde->setTitle($this->lng->txt('sort_inherit_prefix').' ('.
218  $sde->setInfo($this->lng->txt('sorting_info_inherit'));
219  $sog->addOption($sde);
220 
221  $sma = new ilRadioOption();
222  $sma->setValue(ilContainer::SORT_TITLE);
223  $sma->setTitle($this->lng->txt('sorting_title_header'));
224  $sma->setInfo($this->lng->txt('sorting_info_title'));
225  $sog->addOption($sma);
226 
227  $sti = new ilRadioOption();
228  $sti->setValue(ilContainer::SORT_MANUAL);
229  $sti->setTitle($this->lng->txt('sorting_manual_header'));
230  $sti->setInfo($this->lng->txt('sorting_info_manual'));
231  $sog->addOption($sti);
232 
233  $a_form->addItem($sog);
234  }
235 
236  protected function getEditFormCustomValues(array &$a_values)
237  {
238  // we cannot use $this->object->getOrderType()
239  // if set to inherit it will be translated to parent setting
240  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
241  $sort = new ilContainerSortingSettings($this->object->getId());
242  $a_values["sor"] = $sort->getSortMode();
243  }
244 
245  protected function updateCustom(ilPropertyFormGUI $a_form)
246  {
247  // Save sorting
248  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
249  $sort = new ilContainerSortingSettings($this->object->getId());
250  $sort->setSortMode($a_form->getInput('sor'));
251  $sort->update();
252  }
253 
254  // BEGIN ChangeEvent show info screen on folder object
260  function showSummaryObject()
261  {
262  $this->ctrl->setCmd("showSummary");
263  $this->ctrl->setCmdClass("ilinfoscreengui");
264  $this->infoScreen();
265  }
266 
267  protected function afterSave(ilObject $a_new_object)
268  {
269  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
270  $sort = new ilContainerSortingSettings($a_new_object->getId());
272  $sort->update();
273 
274  // always send a message
275  ilUtil::sendSuccess($this->lng->txt("fold_added"),true);
276  $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
277  $this->redirectToRefId($a_new_object->getRefId(), "");
278  }
279 
285  function infoScreenObject()
286  {
287  $this->ctrl->setCmd("showSummary");
288  $this->ctrl->setCmdClass("ilinfoscreengui");
289  $this->infoScreen();
290  }
291 
295  function infoScreen()
296  {
297  global $ilAccess;
298 
299  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
300  {
301  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
302  }
303 
304  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
305  $info = new ilInfoScreenGUI($this);
306 
307  $info->enablePrivateNotes();
308 
309  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
310  {
311  $info->enableNews();
312  }
313 
314  // no news editing for files, just notifications
315  $info->enableNewsEditing(false);
316  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
317  {
318  $news_set = new ilSetting("news");
319  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
320 
321  if ($enable_internal_rss)
322  {
323  $info->setBlockProperty("news", "settings", true);
324  $info->setBlockProperty("news", "public_notifications_option", true);
325  }
326  }
327 
328 
329  // standard meta data
330  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
331 
332  // forward the command
333  $this->ctrl->forwardCommand($info);
334  }
335  // END ChangeEvent show info screen on folder object
336 
340  function getTabs(&$tabs_gui)
341  {
342  global $rbacsystem, $ilUser, $lng, $ilCtrl,$ilAccess, $ilHelp;
343 
344  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
345 
346  $ilHelp->setScreenIdComponent("fold");
347 
348  $tabs_gui->setTabActive("");
349  if ($rbacsystem->checkAccess('read',$this->ref_id))
350  {
351  $tabs_gui->addTab("view_content", $lng->txt("content"),
352  $this->ctrl->getLinkTarget($this, ""));
353 
354  //BEGIN ChangeEvent add info tab to category object
355  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
356  || strtolower($_GET["cmdClass"]) == "ilnotegui")
357  ? true
358  : false;
359  $tabs_gui->addTarget("info_short",
360  $this->ctrl->getLinkTargetByClass(
361  array("ilobjfoldergui", "ilinfoscreengui"), "showSummary"),
362  array("showSummary","", "infoScreen"),
363  "", "", $force_active);
364  //END ChangeEvent add info tab to category object
365  }
366 
367  if ($rbacsystem->checkAccess('write',$this->ref_id))
368  {
369  $tabs_gui->addTarget("settings",
370  $this->ctrl->getLinkTarget($this, "edit"), "edit", "", "", ($ilCtrl->getCmd() == "edit"));
371  }
372 
373  // learning progress
374  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
375  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
376  {
377  $tabs_gui->addTarget('learning_progress',
378  $this->ctrl->getLinkTargetByClass(array('ilobjfoldergui','illearningprogressgui'),''),
379  '',
380  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
381  }
382 
383  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
384  {
385  $tabs_gui->addTarget(
386  'export',
387  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
388  'export',
389  'ilexportgui'
390  );
391  }
392 
393 
394  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
395  {
396  $tabs_gui->addTarget("perm_settings",
397  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
398  }
399 
400  // show clipboard in repository
401  if ($_GET["baseClass"] == "ilRepositoryGUI" and !empty($_SESSION['il_rep_clipboard']))
402  {
403  $tabs_gui->addTarget("clipboard",
404  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
405  }
406 
407  }
408 
412  function _goto($a_target)
413  {
414  global $ilAccess, $ilErr, $lng;
415 
416  if ($ilAccess->checkAccess("read", "", $a_target))
417  {
419  }
420  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
421  }
422 
423 
424  public function downloadFolderObject () {
425  global $ilAccess, $ilErr, $lng;
426 
427  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
428  {
429  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
430  }
431  $filename = $this->object->downloadFolder();
432  ilUtil::deliverFile($filename, ilUtil::getASCIIFilename($this->object->getTitle().".zip"));
433  }
434 
438  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
439  {
440  global $tree;
441 
442  // if folder is in a course, modify item list gui according to course requirements
443  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
444  {
445  include_once("./Modules/Course/classes/class.ilObjCourse.php");
446  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
447  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
448  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, 'ilcoursecontentgui', $a_item_data, $a_show_path,
449  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
450  $this->object->getRefId());
451  }
452  }
453 
454  protected function forwardToTimingsView()
455  {
456  global $tree;
457 
458  if(!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs'))
459  {
460  return false;
461  }
462  include_once './Modules/Course/classes/class.ilObjCourse.php';
463  if(!$this->ctrl->getCmd() and ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) == ilContainer::VIEW_TIMING)
464  {
465  if(!isset($_SESSION['crs_timings'])) {
466  $_SESSION['crs_timings'] = true;
467  }
468 
469  if($_SESSION['crs_timings'] == true) {
470  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
471  $course_content_obj = new ilCourseContentGUI($this);
472  $this->ctrl->setCmdClass(get_class($course_content_obj));
473  $this->ctrl->setCmd('editUserTimings');
474  $this->ctrl->forwardCommand($course_content_obj);
475  return true;
476  }
477  }
478  $_SESSION['crs_timings'] = false;
479  return false;
480  }
481 
488  function editObject()
489  {
490  $this->setSubTabs("settings");
492  }
493 
494 
498  function setSubTabs($a_tab)
499  {
500  global $ilTabs, $lng;
501 
502  $ilTabs->addSubTab("settings",
503  $lng->txt("fold_settings"),
504  $this->ctrl->getLinkTarget($this,'edit'));
505 
506  // custom icon
507  if ($this->ilias->getSetting("custom_icons"))
508  {
509  $ilTabs->addSubTab("icons",
510  $lng->txt("icon_settings"),
511  $this->ctrl->getLinkTarget($this,'editIcons'));
512  }
513 
514  $ilTabs->activateSubTab($a_tab);
515  $ilTabs->activateTab("settings");
516  }
517 
518 
522 
526  function editIconsObject($a_form = null)
527  {
528  global $tpl;
529 
530  $this->checkPermission('write');
531 
532  $this->tabs_gui->setTabActive('settings');
533 
534  if(!$a_form)
535  {
536  $a_form = $this->initIconsForm();
537  }
538 
539  $tpl->setContent($a_form->getHTML());
540  }
541 
542  function initIconsForm()
543  {
544  $this->setSubTabs("icons");
545 
546  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
547  $form = new ilPropertyFormGUI();
548  $form->setFormAction($this->ctrl->getFormAction($this));
549 
550  $this->showCustomIconsEditing(1, $form);
551 
552  // $form->setTitle($this->lng->txt('edit_grouping'));
553  $form->addCommandButton('updateIcons', $this->lng->txt('save'));
554 
555  return $form;
556  }
557 
561  function updateIconsObject()
562  {
563  $this->checkPermission('write');
564 
565  $form = $this->initIconsForm();
566  if($form->checkInput())
567  {
568  //save custom icons
569  if ($this->ilias->getSetting("custom_icons"))
570  {
571  if($_POST["cont_big_icon_delete"])
572  {
573  $this->object->removeBigIcon();
574  }
575  if($_POST["cont_small_icon_delete"])
576  {
577  $this->object->removeSmallIcon();
578  }
579  if($_POST["cont_tiny_icon_delete"])
580  {
581  $this->object->removeTinyIcon();
582  }
583  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
584  $_FILES["cont_small_icon"]['tmp_name'], $_FILES["cont_tiny_icon"]['tmp_name']);
585 
586  }
587  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
588  $this->ctrl->redirect($this,"editIcons");
589  }
590 
591  $form->setValuesByPost();
592  $this->editIconsObject($form);
593  }
594 
595 
596 
597 } // END class.ilObjFolderGUI
598 ?>