ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFolderGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23 */
24 
25 
41 require_once "./Services/Container/classes/class.ilContainerGUI.php";
42 
44 {
45  var $folder_tree; // folder tree
46 
51  function ilObjFolderGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = false)
52  {
53  $this->type = "fold";
54  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output, false);
55  }
56 
57 
61  function viewObject()
62  {
63  global $tree;
64 
65  $this->checkPermission('read');
66 
67  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
68  {
70  return true;
71  }
72  $this->renderObject();
73  $this->tabs_gui->setTabActive('view_content');
74  return true;
75  }
76 
80  function renderObject()
81  {
82  global $ilTabs;
83 
84  $this->checkPermission('read');
85 
86  $ilTabs->activateTab("view_content");
88  return $ret;
89  }
90 
91  function &executeCommand()
92  {
93  global $ilUser,$ilCtrl;
94 
95  $next_class = $this->ctrl->getNextClass($this);
96  $cmd = $this->ctrl->getCmd();
97 
98  switch ($next_class)
99  {
100  case 'ilpermissiongui':
101  $this->prepareOutput();
102  $this->tabs_gui->setTabActive('perm_settings');
103  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
104  $perm_gui =& new ilPermissionGUI($this);
105  $ret =& $this->ctrl->forwardCommand($perm_gui);
106  break;
107 
108  case 'ilcoursecontentgui':
109  $this->prepareOutput();
110  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
111  $course_content_obj = new ilCourseContentGUI($this);
112  $this->ctrl->forwardCommand($course_content_obj);
113  break;
114 
115  case "illearningprogressgui":
116  $this->prepareOutput();
117  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
118 
120  $this->object->getRefId(),
121  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
122  $this->ctrl->forwardCommand($new_gui);
123  $this->tabs_gui->setTabActive('learning_progress');
124  break;
125 
126  // container page editing
127  case "ilpageobjectgui":
128  $this->prepareOutput(false);
129  $this->checkPermission("write");
130  $ret = $this->forwardToPageObject();
131  if ($ret != "")
132  {
133  $this->tpl->setContent($ret);
134  }
135  break;
136 
137  case 'ilinfoscreengui':
138  $this->prepareOutput();
139  $this->infoScreen();
140  break;
141 
142  case 'ilobjectcopygui':
143  $this->prepareOutput();
144 
145  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
146  $cp = new ilObjectCopyGUI($this);
147  $cp->setType('fold');
148  $this->ctrl->forwardCommand($cp);
149  break;
150 
151  case "ilobjstylesheetgui":
152  $this->forwardToStyleSheet();
153  break;
154 
155  case 'ilexportgui':
156  $this->prepareOutput();
157 
158  $this->tabs_gui->setTabActive('export');
159  include_once './Services/Export/classes/class.ilExportGUI.php';
160  $exp = new ilExportGUI($this);
161  $exp->addFormat('xml');
162  $this->ctrl->forwardCommand($exp);
163  break;
164 
165  case "ilcommonactiondispatchergui":
166  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
168  $this->ctrl->forwardCommand($gui);
169  break;
170 
171  case 'ildidactictemplategui':
172  $this->ctrl->setReturn($this,'edit');
173  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
174  $did = new ilDidacticTemplateGUI($this);
175  $this->ctrl->forwardCommand($did);
176  break;
177 
178  default:
179 
180  $this->prepareOutput();
181  // Dirty hack for course timings view
182  if($this->forwardToTimingsView())
183  {
184  break;
185  }
186 
187  if (empty($cmd))
188  {
189  $cmd = "view";
190  }
191  $cmd .= "Object";
192  $this->$cmd();
193  break;
194  }
195 
196  $this->addHeaderAction();
197  }
198 
202  function setFolderTree($a_tree)
203  {
204  $this->folder_tree =& $a_tree;
205  }
206 
211  public function importFileObject()
212  {
213  global $lng;
214 
215  if(parent::importFileObject())
216  {
217  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
218  $this->ctrl->returnToParent($this);
219  }
220  }
221 
222  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
223  {
224  // Show didactic template type
225  $this->initDidacticTemplate($a_form);
226 
227  // Sorting
228  $sog = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'),'sor');
229  $sog->setRequired(true);
230 
231  // implicit: there is always a group or course in the path
232  $sde = new ilRadioOption();
233  $sde->setValue(ilContainer::SORT_INHERIT);
234  $sde->setTitle($this->lng->txt('sort_inherit_prefix').' ('.
236  $sde->setInfo($this->lng->txt('sorting_info_inherit'));
237  $sog->addOption($sde);
238 
239  $sma = new ilRadioOption();
240  $sma->setValue(ilContainer::SORT_TITLE);
241  $sma->setTitle($this->lng->txt('sorting_title_header'));
242  $sma->setInfo($this->lng->txt('sorting_info_title'));
243  $sog->addOption($sma);
244 
245  $sti = new ilRadioOption();
246  $sti->setValue(ilContainer::SORT_MANUAL);
247  $sti->setTitle($this->lng->txt('sorting_manual_header'));
248  $sti->setInfo($this->lng->txt('sorting_info_manual'));
249  $sog->addOption($sti);
250 
251  $a_form->addItem($sog);
252  }
253 
254  protected function getEditFormCustomValues(array &$a_values)
255  {
256  // we cannot use $this->object->getOrderType()
257  // if set to inherit it will be translated to parent setting
258  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
259  $sort = new ilContainerSortingSettings($this->object->getId());
260  $a_values["sor"] = $sort->getSortMode();
261  }
262 
263  protected function updateCustom(ilPropertyFormGUI $a_form)
264  {
265  // Save sorting
266  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
267  $sort = new ilContainerSortingSettings($this->object->getId());
268  $sort->setSortMode($a_form->getInput('sor'));
269  $sort->update();
270  }
271 
272  // BEGIN ChangeEvent show info screen on folder object
278  function showSummaryObject()
279  {
280  $this->ctrl->setCmd("showSummary");
281  $this->ctrl->setCmdClass("ilinfoscreengui");
282  $this->infoScreen();
283  }
284 
285  protected function afterSave(ilObject $a_new_object)
286  {
287  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
288  $sort = new ilContainerSortingSettings($a_new_object->getId());
290  $sort->update();
291 
292  // always send a message
293  ilUtil::sendSuccess($this->lng->txt("fold_added"),true);
294  $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
295  $this->redirectToRefId($a_new_object->getRefId(), "");
296  }
297 
303  function infoScreenObject()
304  {
305  $this->ctrl->setCmd("showSummary");
306  $this->ctrl->setCmdClass("ilinfoscreengui");
307  $this->infoScreen();
308  }
309 
313  function infoScreen()
314  {
315  global $ilAccess;
316 
317  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
318  {
319  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
320  }
321 
322  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
323  $info = new ilInfoScreenGUI($this);
324 
325  $info->enablePrivateNotes();
326 
327  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
328  {
329  $info->enableNews();
330  }
331 
332  // no news editing for files, just notifications
333  $info->enableNewsEditing(false);
334  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
335  {
336  $news_set = new ilSetting("news");
337  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
338 
339  if ($enable_internal_rss)
340  {
341  $info->setBlockProperty("news", "settings", true);
342  $info->setBlockProperty("news", "public_notifications_option", true);
343  }
344  }
345 
346 
347  // standard meta data
348  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
349 
350  // forward the command
351  $this->ctrl->forwardCommand($info);
352  }
353  // END ChangeEvent show info screen on folder object
354 
358  function getTabs(&$tabs_gui)
359  {
360  global $rbacsystem, $ilUser, $lng, $ilCtrl,$ilAccess, $ilHelp;
361 
362  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
363 
364  $ilHelp->setScreenIdComponent("fold");
365 
366  $tabs_gui->setTabActive("");
367  if ($rbacsystem->checkAccess('read',$this->ref_id))
368  {
369  $tabs_gui->addTab("view_content", $lng->txt("content"),
370  $this->ctrl->getLinkTarget($this, ""));
371 
372  //BEGIN ChangeEvent add info tab to category object
373  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
374  || strtolower($_GET["cmdClass"]) == "ilnotegui")
375  ? true
376  : false;
377  $tabs_gui->addTarget("info_short",
378  $this->ctrl->getLinkTargetByClass(
379  array("ilobjfoldergui", "ilinfoscreengui"), "showSummary"),
380  array("showSummary","", "infoScreen"),
381  "", "", $force_active);
382  //END ChangeEvent add info tab to category object
383  }
384 
385  if ($rbacsystem->checkAccess('write',$this->ref_id))
386  {
387  $tabs_gui->addTarget("settings",
388  $this->ctrl->getLinkTarget($this, "edit"), "edit", "", "", ($ilCtrl->getCmd() == "edit"));
389  }
390 
391  // learning progress
392  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
393  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
394  {
395  $tabs_gui->addTarget('learning_progress',
396  $this->ctrl->getLinkTargetByClass(array('ilobjfoldergui','illearningprogressgui'),''),
397  '',
398  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
399  }
400 
401  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
402  {
403  $tabs_gui->addTarget(
404  'export',
405  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
406  'export',
407  'ilexportgui'
408  );
409  }
410 
411 
412  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
413  {
414  $tabs_gui->addTarget("perm_settings",
415  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
416  }
417 
418  // show clipboard in repository
419  if ($_GET["baseClass"] == "ilRepositoryGUI" and !empty($_SESSION['il_rep_clipboard']))
420  {
421  $tabs_gui->addTarget("clipboard",
422  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
423  }
424 
425  }
426 
430  function _goto($a_target)
431  {
432  global $ilAccess, $ilErr, $lng;
433 
434  if ($ilAccess->checkAccess("read", "", $a_target))
435  {
437  }
438  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
439  }
440 
441 
442  public function downloadFolderObject () {
443  global $ilAccess, $ilErr, $lng;
444 
445  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
446  {
447  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
448  }
449  $filename = $this->object->downloadFolder();
450  ilUtil::deliverFile($filename, ilUtil::getASCIIFilename($this->object->getTitle().".zip"));
451  }
452 
456  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
457  {
458  global $tree;
459 
460  // if folder is in a course, modify item list gui according to course requirements
461  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
462  {
463  include_once("./Modules/Course/classes/class.ilObjCourse.php");
464  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
465  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
466  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, 'ilcoursecontentgui', $a_item_data, $a_show_path,
467  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
468  $this->object->getRefId());
469  }
470  }
471 
472  protected function forwardToTimingsView()
473  {
474  global $tree;
475 
476  if(!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs'))
477  {
478  return false;
479  }
480  include_once './Modules/Course/classes/class.ilObjCourse.php';
481  if(!$this->ctrl->getCmd() and ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) == ilContainer::VIEW_TIMING)
482  {
483  if(!isset($_SESSION['crs_timings'])) {
484  $_SESSION['crs_timings'] = true;
485  }
486 
487  if($_SESSION['crs_timings'] == true) {
488  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
489  $course_content_obj = new ilCourseContentGUI($this);
490  $this->ctrl->setCmdClass(get_class($course_content_obj));
491  $this->ctrl->setCmd('editUserTimings');
492  $this->ctrl->forwardCommand($course_content_obj);
493  return true;
494  }
495  }
496  $_SESSION['crs_timings'] = false;
497  return false;
498  }
499 
500 
501 } // END class.ilObjFolderGUI
502 ?>