ILIAS  Release_4_2_x_branch Revision 61807
 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  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
66  {
68  return true;
69  }
70  $this->renderObject();
71  $this->tabs_gui->setTabActive('view_content');
72  return true;
73  }
74 
78  function renderObject()
79  {
80  global $ilTabs;
81 
82  $ilTabs->activateTab("view_content");
84  return $ret;
85  }
86 
87  function &executeCommand()
88  {
89  global $ilUser,$ilCtrl;
90 
91  $next_class = $this->ctrl->getNextClass($this);
92  $cmd = $this->ctrl->getCmd();
93 
94  switch ($next_class)
95  {
96  case "ilconditionhandlerinterface":
97  $this->prepareOutput();
98  include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
99 
100  if($_GET['item_id'])
101  {
102  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
103  $this->__setSubTabs('activation');
104  $this->tabs_gui->setTabActive('view_content');
105 
106  $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
107  $this->ctrl->forwardCommand($new_gui);
108  }
109  else
110  {
111  $new_gui =& new ilConditionHandlerInterface($this);
112  $this->ctrl->forwardCommand($new_gui);
113  }
114  break;
115 
116  case 'ilpermissiongui':
117  $this->prepareOutput();
118  $this->tabs_gui->setTabActive('perm_settings');
119  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
120  $perm_gui =& new ilPermissionGUI($this);
121  $ret =& $this->ctrl->forwardCommand($perm_gui);
122  break;
123 
124  case 'ilcoursecontentgui':
125  $this->prepareOutput();
126  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
127  $course_content_obj = new ilCourseContentGUI($this);
128  $this->ctrl->forwardCommand($course_content_obj);
129  break;
130 
131  case 'ilcourseitemadministrationgui':
132  $this->prepareOutput();
133  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
134  $this->tabs_gui->clearSubTabs();
135  $this->ctrl->setReturn($this,'view');
136  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_REQUEST['item_id']);
137  $this->ctrl->forwardCommand($item_adm_gui);
138  break;
139 
140  case "illearningprogressgui":
141  $this->prepareOutput();
142  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
143 
145  $this->object->getRefId(),
146  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
147  $this->ctrl->forwardCommand($new_gui);
148  $this->tabs_gui->setTabActive('learning_progress');
149  break;
150 
151  // container page editing
152  case "ilpageobjectgui":
153  $this->prepareOutput(false);
154  $this->checkPermission("write");
155  $ret = $this->forwardToPageObject();
156  if ($ret != "")
157  {
158  $this->tpl->setContent($ret);
159  }
160  break;
161 
162  case 'ilinfoscreengui':
163  $this->prepareOutput();
164  $this->infoScreen();
165  break;
166 
167  case 'ilobjectcopygui':
168  $this->prepareOutput();
169 
170  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
171  $cp = new ilObjectCopyGUI($this);
172  $cp->setType('fold');
173  $this->ctrl->forwardCommand($cp);
174  break;
175 
176  case "ilobjstylesheetgui":
177  $this->forwardToStyleSheet();
178  break;
179 
180  case 'ilexportgui':
181  $this->prepareOutput();
182 
183  $this->tabs_gui->setTabActive('export');
184  include_once './Services/Export/classes/class.ilExportGUI.php';
185  $exp = new ilExportGUI($this);
186  $exp->addFormat('xml');
187  $this->ctrl->forwardCommand($exp);
188  break;
189 
190  case "ilcommonactiondispatchergui":
191  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
193  $this->ctrl->forwardCommand($gui);
194  break;
195 
196  case 'ildidactictemplategui':
197  $this->ctrl->setReturn($this,'edit');
198  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
199  $did = new ilDidacticTemplateGUI($this);
200  $this->ctrl->forwardCommand($did);
201  break;
202 
203  default:
204 
205  $this->prepareOutput();
206  // Dirty hack for course timings view
207  if($this->forwardToTimingsView())
208  {
209  break;
210  }
211 
212  if (empty($cmd))
213  {
214  $cmd = "view";
215  }
216  $cmd .= "Object";
217  $this->$cmd();
218  break;
219  }
220 
221  $this->addHeaderAction();
222  }
223 
227  function setFolderTree($a_tree)
228  {
229  $this->folder_tree =& $a_tree;
230  }
231 
236  public function importFileObject()
237  {
238  global $lng;
239 
240  if(parent::importFileObject())
241  {
242  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
243  $this->ctrl->returnToParent($this);
244  }
245  }
246 
247  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
248  {
249  // Show didactic template type
250  $this->initDidacticTemplate($a_form);
251 
252  // Sorting
253  $sog = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'),'sor');
254  $sog->setRequired(true);
255 
256  // implicit: there is always a group or course in the path
257  $sde = new ilRadioOption();
258  $sde->setValue(ilContainer::SORT_INHERIT);
259  $sde->setTitle($this->lng->txt('sort_inherit_prefix').' ('.
261  $sde->setInfo($this->lng->txt('sorting_info_inherit'));
262  $sog->addOption($sde);
263 
264  $sma = new ilRadioOption();
265  $sma->setValue(ilContainer::SORT_TITLE);
266  $sma->setTitle($this->lng->txt('sorting_title_header'));
267  $sma->setInfo($this->lng->txt('sorting_info_title'));
268  $sog->addOption($sma);
269 
270  $sti = new ilRadioOption();
271  $sti->setValue(ilContainer::SORT_MANUAL);
272  $sti->setTitle($this->lng->txt('sorting_manual_header'));
273  $sti->setInfo($this->lng->txt('sorting_info_manual'));
274  $sog->addOption($sti);
275 
276  $a_form->addItem($sog);
277  }
278 
279  protected function getEditFormCustomValues(array &$a_values)
280  {
281  // we cannot use $this->object->getOrderType()
282  // if set to inherit it will be translated to parent setting
283  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
284  $sort = new ilContainerSortingSettings($this->object->getId());
285  $a_values["sor"] = $sort->getSortMode();
286  }
287 
288  protected function updateCustom(ilPropertyFormGUI $a_form)
289  {
290  // Save sorting
291  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
292  $sort = new ilContainerSortingSettings($this->object->getId());
293  $sort->setSortMode($a_form->getInput('sor'));
294  $sort->update();
295  }
296 
297  // BEGIN ChangeEvent show info screen on folder object
303  function showSummaryObject()
304  {
305  $this->ctrl->setCmd("showSummary");
306  $this->ctrl->setCmdClass("ilinfoscreengui");
307  $this->infoScreen();
308  }
309 
315  function infoScreenObject()
316  {
317  $this->ctrl->setCmd("showSummary");
318  $this->ctrl->setCmdClass("ilinfoscreengui");
319  $this->infoScreen();
320  }
321 
325  function infoScreen()
326  {
327  global $ilAccess;
328 
329  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
330  {
331  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
332  }
333 
334  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
335  $info = new ilInfoScreenGUI($this);
336 
337  $info->enablePrivateNotes();
338 
339  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
340  {
341  $info->enableNews();
342  }
343 
344  // no news editing for files, just notifications
345  $info->enableNewsEditing(false);
346  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
347  {
348  $news_set = new ilSetting("news");
349  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
350 
351  if ($enable_internal_rss)
352  {
353  $info->setBlockProperty("news", "settings", true);
354  $info->setBlockProperty("news", "public_notifications_option", true);
355  }
356  }
357 
358 
359  // standard meta data
360  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
361 
362  // forward the command
363  $this->ctrl->forwardCommand($info);
364  }
365  // END ChangeEvent show info screen on folder object
366 
370  function getTabs(&$tabs_gui)
371  {
372  global $rbacsystem, $ilUser, $lng, $ilCtrl,$ilAccess;
373 
374  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
375 
376  $tabs_gui->setTabActive("");
377  if ($rbacsystem->checkAccess('read',$this->ref_id))
378  {
379  $tabs_gui->addTab("view_content", $lng->txt("content"),
380  $this->ctrl->getLinkTarget($this, ""));
381 
382  //BEGIN ChangeEvent add info tab to category object
383  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
384  || strtolower($_GET["cmdClass"]) == "ilnotegui")
385  ? true
386  : false;
387  $tabs_gui->addTarget("info_short",
388  $this->ctrl->getLinkTargetByClass(
389  array("ilobjfoldergui", "ilinfoscreengui"), "showSummary"),
390  array("showSummary","", "infoScreen"),
391  "", "", $force_active);
392  //END ChangeEvent add info tab to category object
393  }
394 
395  if ($rbacsystem->checkAccess('write',$this->ref_id))
396  {
397  $tabs_gui->addTarget("settings",
398  $this->ctrl->getLinkTarget($this, "edit"), "edit", "", "", ($ilCtrl->getCmd() == "edit"));
399  }
400 
401  // learning progress
402  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
403  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
404  {
405  $tabs_gui->addTarget('learning_progress',
406  $this->ctrl->getLinkTargetByClass(array('ilobjfoldergui','illearningprogressgui'),''),
407  '',
408  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
409  }
410 
411  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
412  {
413  $tabs_gui->addTarget(
414  'export',
415  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
416  'export',
417  'ilexportgui'
418  );
419  }
420 
421 
422  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
423  {
424  $tabs_gui->addTarget("perm_settings",
425  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
426  }
427 
428  // show clipboard in repository
429  if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION['il_rep_clipboard']))
430  {
431  $tabs_gui->addTarget("clipboard",
432  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
433  }
434 
435  }
436 
437  // Methods for ConditionHandlerInterface
438  function initConditionHandlerGUI($item_id)
439  {
440  include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
441 
442  if(!is_object($this->chi_obj))
443  {
444  if($_GET['item_id'])
445  {
446  $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
447  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
448  }
449  else
450  {
451  $this->chi_obj =& new ilConditionHandlerInterface($this);
452  }
453  }
454  return true;
455  }
456 
460  function __setSubTabs($a_tab)
461  {
462  global $rbacsystem,$ilUser;
463 
464  switch ($a_tab)
465  {
466 
467  case "activation":
468 
469  $this->tabs_gui->addSubTabTarget("activation",
470  $this->ctrl->getLinkTargetByClass('ilCourseItemAdministrationGUI','edit'),
471  "edit", get_class($this));
472  $this->ctrl->setParameterByClass('ilconditionhandlerinterface','item_id',(int) $_GET['item_id']);
473  $this->tabs_gui->addSubTabTarget("preconditions",
474  $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
475  "", "ilConditionHandlerInterface");
476  break;
477  }
478  }
479 
483  function _goto($a_target)
484  {
485  global $ilAccess, $ilErr, $lng;
486 
487  if ($ilAccess->checkAccess("read", "", $a_target))
488  {
489  $_GET["cmd"] = "frameset";
490  $_GET["ref_id"] = $a_target;
491  include("repository.php");
492  exit;
493  }
494  /*
495  else
496  {
497  // to do: force flat view
498 
499  // no info screen for folders
500  if ($ilAccess->checkAccess("visible", "", $a_target))
501  {
502  $_GET["cmd"] = "infoScreen";
503  $_GET["ref_id"] = $a_target;
504  include("repository.php");
505  exit;
506  }
507  else
508  {
509  // This part will never be reached
510  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
511  {
512  $_GET["cmd"] = "frameset";
513  $_GET["target"] = "";
514  $_GET["ref_id"] = ROOT_FOLDER_ID;
515  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
516  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
517  include("repository.php");
518  exit;
519  }
520  }
521  }
522  */
523  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
524  }
525 
526 
527  public function downloadFolderObject () {
528  global $ilAccess, $ilErr, $lng;
529 
530  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
531  {
532  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
533  }
534  $filename = $this->object->downloadFolder();
535  ilUtil::deliverFile($filename, ilUtil::getASCIIFilename($this->object->getTitle().".zip"));
536  }
537 
541  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
542  {
543  global $tree;
544 
545  // if folder is in a course, modify item list gui according to course requirements
546  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
547  {
548  include_once("./Modules/Course/classes/class.ilObjCourse.php");
549  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
550  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
551  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, 'ilcoursecontentgui', $a_item_data, $a_show_path,
552  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
553  $this->object->getRefId());
554  }
555  }
556 
557  protected function forwardToTimingsView()
558  {
559  global $tree;
560 
561  if(!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs'))
562  {
563  return false;
564  }
565  include_once './Modules/Course/classes/class.ilObjCourse.php';
566  if(!$this->ctrl->getCmd() and ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) == ilContainer::VIEW_TIMING)
567  {
568  if(!isset($_SESSION['crs_timings'])) {
569  $_SESSION['crs_timings'] = true;
570  }
571 
572  if($_SESSION['crs_timings'] == true) {
573  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
574  $course_content_obj = new ilCourseContentGUI($this);
575  $this->ctrl->setCmdClass(get_class($course_content_obj));
576  $this->ctrl->setCmd('editUserTimings');
577  $this->ctrl->forwardCommand($course_content_obj);
578  return true;
579  }
580  }
581  $_SESSION['crs_timings'] = false;
582  return false;
583  }
584 
585 
586 } // END class.ilObjFolderGUI
587 ?>