ILIAS  eassessment Revision 61809
 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 './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  default:
191 
192  $this->prepareOutput();
193  // Dirty hack for course timings view
194  if($this->forwardToTimingsView())
195  {
196  break;
197  }
198 
199  if (empty($cmd))
200  {
201  $cmd = "view";
202  }
203  $cmd .= "Object";
204  $this->$cmd();
205  break;
206  }
207  }
208 
212  function setFolderTree($a_tree)
213  {
214  $this->folder_tree =& $a_tree;
215  }
216 
221  public function createObject()
222  {
223  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.fold_create.html','Modules/Folder');
224  $this->ctrl->setParameter($this,'new_type',$this->type);
225 
226  $this->initFormCreate();
227 
228  $this->tpl->setVariable('NEW_FOLDER',$this->form->getHTML());
229  $this->fillCloneTemplate('DUPLICATE', 'fold');
230 
231  $this->initImportForm("fold");
232  $this->tpl->setVariable("IMPORT_FORM", $this->form->getHTML());
233 
234  }
235 
241  public function initImportForm($a_new_type = "")
242  {
243  global $lng, $ilCtrl;
244 
245  $lng->loadLanguageModule("fold");
246 
247  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
248  $this->form = new ilPropertyFormGUI();
249  $this->form->setTableWidth('600px');
250  $this->form->setTarget("_top");
251 
252  // Import file
253  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
254  $fi = new ilFileInputGUI($lng->txt("import_file"), "importfile");
255  $fi->setSuffixes(array("zip"));
256  $fi->setRequired(true);
257  $this->form->addItem($fi);
258 
259  $this->form->addCommandButton("importFile", $lng->txt("import"));
260  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
261  $this->form->setTitle($lng->txt($a_new_type."_import"));
262 
263  $this->form->setFormAction($ilCtrl->getFormAction($this));
264  }
265 
270  protected function initFormCreate()
271  {
272  if($this->form instanceof ilPropertyFormGUI)
273  {
274  return true;
275  }
276  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
277  $this->form = new ilPropertyFormGUI();
278  $this->form->setFormAction($this->ctrl->getFormAction($this,'save'));
279  $this->form->setTableWidth('600px');
280  $this->form->setTitle($this->lng->txt($this->type.'_new'));
281 
282  // Title
283  $tit = new ilTextInputGUI($this->lng->txt('title'),'tit');
284  $tit->setRequired(true);
285  $tit->setMaxLength(128);
286  $this->form->addItem($tit);
287 
288  // Description
289  $des = new ilTextAreaInputGUI($this->lng->txt('description'),'des');
290  $this->form->addItem($des);
291 
292  $this->form->addCommandButton('save', $this->lng->txt('save'));
293  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
294  }
295 
300  public function importFileObject()
301  {
302  global $lng;
303 
304  if(parent::importFileObject())
305  {
306  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
307  $this->ctrl->returnToParent($this);
308  }
309  }
310 
315  public function saveObject()
316  {
317  global $ilUser;
318 
319  $this->initFormCreate();
320 
321  if($this->form->checkInput())
322  {
323  $fold = parent::saveObject();
324  $fold->setTitle($this->form->getInput('tit'));
325  $fold->setDescription($this->form->getInput('des'));
326 
327  $fold->update();
328 
329  include_once 'Services/Tracking/classes/class.ilChangeEvent.php';
331  {
332  ilChangeEvent::_recordWriteEvent($fold->getId(), $ilUser->getId(), 'create');
333  }
334 
335  include_once './classes/class.ilLink.php';
336  ilUtil::sendSuccess($this->lng->txt($this->type."_added"),true);
337  ilUtil::redirect('repository.php?ref_id='.$fold->getRefId());
338  }
339  $this->form->setValuesByPost();
340  $this->createObject();
341  }
342 
343 
348  public function editObject()
349  {
350  $this->tabs_gui->setTabActive('settings');
351  $this->initFormEdit();
352 
353  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
354  $this->form->getItemByPostVar('tit')->setValue($this->object->getTitle());
355  $this->form->getItemByPostVar('des')->setValue($this->object->getDescription());
356  $this->form->getItemByPostVar('sor')->setValue($this->object->getOrderType());
357 # ilContainerSortingSettings::_readSortMode($this->object->getId())
358 # );
359 
360  $this->tpl->setContent($this->form->getHTML());
361  return true;
362  }
363 
364 
365  public function updateObject()
366  {
367  global $ilUser;
368 
369  $this->initFormEdit();
370  if($this->form->checkInput())
371  {
372  $this->object->setTitle($this->form->getInput('tit'));
373  $this->object->setDescription($this->form->getInput('des'));
374  $this->object->update();
375 
376  // Save sorting
377  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
378  $sort = new ilContainerSortingSettings($this->object->getId());
379  $sort->setSortMode($this->form->getInput('sor'));
380  $sort->update();
381 
382  include_once 'Services/Tracking/classes/class.ilChangeEvent.php';
384  {
385  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
386  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
387  }
388 
389  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
390  $this->ctrl->redirect($this,'edit');
391  }
392  $this->form->setValuesByPost();
393  $this->tabs_gui->setTabActive('settings');
394  $this->tpl->setContent($this->form->getHTML());
395  return true;
396  }
397 
402  protected function initFormEdit()
403  {
404  global $tree;
405 
406  if($this->form instanceof ilPropertyFormGUI)
407  {
408  return true;
409  }
410  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
411  $this->form = new ilPropertyFormGUI();
412  $this->form->setFormAction($this->ctrl->getFormAction($this,'update'));
413  $this->form->setTitle($this->lng->txt($this->type.'_edit'));
414 
415  // Title
416  $tit = new ilTextInputGUI($this->lng->txt('title'),'tit');
417  $tit->setRequired(true);
418  $tit->setMaxLength(128);
419  $this->form->addItem($tit);
420 
421  // Description
422  $des = new ilTextAreaInputGUI($this->lng->txt('description'),'des');
423  $this->form->addItem($des);
424 
425  // Sorting
426  $sog = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'),'sor');
427  $sog->setRequired(true);
428 
429  // implicit: there is always a group or course in the path
430  $sde = new ilRadioOption();
431  $sde->setValue(ilContainer::SORT_INHERIT);
432 
433  $title = $this->lng->txt('sort_inherit_prefix');
434  $title .= ' ('.ilContainerSortingSettings::sortModeToString(ilContainerSortingSettings::lookupSortModeFromParentContainer($this->object->getId())).') ';
435  $sde->setTitle($title);
436  $sde->setInfo($this->lng->txt('sorting_info_inherit'));
437  $sog->addOption($sde);
438 
439  $sma = new ilRadioOption();
440  $sma->setValue(ilContainer::SORT_TITLE);
441  $sma->setTitle($this->lng->txt('sorting_title_header'));
442  $sma->setInfo($this->lng->txt('sorting_info_title'));
443  $sog->addOption($sma);
444 
445  $sti = new ilRadioOption();
446  $sti->setValue(ilContainer::SORT_MANUAL);
447  $sti->setTitle($this->lng->txt('sorting_manual_header'));
448  $sti->setInfo($this->lng->txt('sorting_info_manual'));
449  $sog->addOption($sti);
450 
451  $this->form->addItem($sog);
452 
453  $this->form->addCommandButton('update', $this->lng->txt('save'));
454  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
455  }
456 
457 
458 
459 
465  function updateObject2($a_return_to_parent = false)
466  {
467  $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
468  $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
469  $this->update = $this->object->update();
470 
471  // BEGIN ChangeEvent: Record write event.
472  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
474  {
475  global $ilUser;
476  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
477  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
478  }
479  // END ChangeEvent: Record write event.
480 
481  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
482 
483  if ($a_return_to_parent)
484  {
485  $this->ctrl->returnToParent($this);
486  }
487  else
488  {
489  $this->ctrl->redirect($this);
490  }
491  }
492 
493  // BEGIN ChangeEvent show info screen on folder object
499  function showSummaryObject()
500  {
501  $this->ctrl->setCmd("showSummary");
502  $this->ctrl->setCmdClass("ilinfoscreengui");
503  $this->infoScreen();
504  }
505 
511  function infoScreenObject()
512  {
513  $this->ctrl->setCmd("showSummary");
514  $this->ctrl->setCmdClass("ilinfoscreengui");
515  $this->infoScreen();
516  }
517 
521  function infoScreen()
522  {
523  global $ilAccess;
524 
525  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
526  {
527  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
528  }
529 
530  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
531  $info = new ilInfoScreenGUI($this);
532 
533  $info->enablePrivateNotes();
534 
535  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
536  {
537  $info->enableNews();
538  }
539 
540  // no news editing for files, just notifications
541  $info->enableNewsEditing(false);
542  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
543  {
544  $news_set = new ilSetting("news");
545  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
546 
547  if ($enable_internal_rss)
548  {
549  $info->setBlockProperty("news", "settings", true);
550  $info->setBlockProperty("news", "public_notifications_option", true);
551  }
552  }
553 
554 
555  // standard meta data
556  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
557 
558  // forward the command
559  $this->ctrl->forwardCommand($info);
560  }
561  // END ChangeEvent show info screen on folder object
562 
566  function getTabs(&$tabs_gui)
567  {
568  global $rbacsystem, $ilUser, $lng, $ilCtrl,$ilAccess;
569 
570  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
571 
572  $tabs_gui->setTabActive("");
573  if ($rbacsystem->checkAccess('read',$this->ref_id))
574  {
575  $tabs_gui->addTab("view_content", $lng->txt("content"),
576  $this->ctrl->getLinkTarget($this, ""));
577 
578  //BEGIN ChangeEvent add info tab to category object
579  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
580  || strtolower($_GET["cmdClass"]) == "ilnotegui")
581  ? true
582  : false;
583  $tabs_gui->addTarget("info_short",
584  $this->ctrl->getLinkTargetByClass(
585  array("ilobjfoldergui", "ilinfoscreengui"), "showSummary"),
586  array("showSummary","", "infoScreen"),
587  "", "", $force_active);
588  //END ChangeEvent add info tab to category object
589  }
590 
591  if ($rbacsystem->checkAccess('write',$this->ref_id))
592  {
593  $tabs_gui->addTarget("settings",
594  $this->ctrl->getLinkTarget($this, "edit"), "edit", "", "", ($ilCtrl->getCmd() == "edit"));
595  }
596 
597  // learning progress
598  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
599  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
600  {
601  $tabs_gui->addTarget('learning_progress',
602  $this->ctrl->getLinkTargetByClass(array('ilobjfoldergui','illearningprogressgui'),''),
603  '',
604  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
605  }
606 
607  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
608  {
609  $tabs_gui->addTarget(
610  'export',
611  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
612  'export',
613  'ilexportgui'
614  );
615  }
616 
617 
618  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
619  {
620  $tabs_gui->addTarget("perm_settings",
621  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
622  }
623 
624  // show clipboard in repository
625  if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION['il_rep_clipboard']))
626  {
627  $tabs_gui->addTarget("clipboard",
628  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
629  }
630 
631  }
632 
633  // Methods for ConditionHandlerInterface
634  function initConditionHandlerGUI($item_id)
635  {
636  include_once './classes/class.ilConditionHandlerInterface.php';
637 
638  if(!is_object($this->chi_obj))
639  {
640  if($_GET['item_id'])
641  {
642  $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
643  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
644  }
645  else
646  {
647  $this->chi_obj =& new ilConditionHandlerInterface($this);
648  }
649  }
650  return true;
651  }
652 
656  function __setSubTabs($a_tab)
657  {
658  global $rbacsystem,$ilUser;
659 
660  switch ($a_tab)
661  {
662 
663  case "activation":
664 
665  $this->tabs_gui->addSubTabTarget("activation",
666  $this->ctrl->getLinkTargetByClass('ilCourseItemAdministrationGUI','edit'),
667  "edit", get_class($this));
668  $this->ctrl->setParameterByClass('ilconditionhandlerinterface','item_id',(int) $_GET['item_id']);
669  $this->tabs_gui->addSubTabTarget("preconditions",
670  $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
671  "", "ilConditionHandlerInterface");
672  break;
673  }
674  }
675 
679  function _goto($a_target)
680  {
681  global $ilAccess, $ilErr, $lng;
682 
683  if ($ilAccess->checkAccess("read", "", $a_target))
684  {
685  $_GET["cmd"] = "frameset";
686  $_GET["ref_id"] = $a_target;
687  include("repository.php");
688  exit;
689  }
690  /*
691  else
692  {
693  // to do: force flat view
694 
695  // no info screen for folders
696  if ($ilAccess->checkAccess("visible", "", $a_target))
697  {
698  $_GET["cmd"] = "infoScreen";
699  $_GET["ref_id"] = $a_target;
700  include("repository.php");
701  exit;
702  }
703  else
704  {
705  // This part will never be reached
706  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
707  {
708  $_GET["cmd"] = "frameset";
709  $_GET["target"] = "";
710  $_GET["ref_id"] = ROOT_FOLDER_ID;
711  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
712  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
713  include("repository.php");
714  exit;
715  }
716  }
717  }
718  */
719  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
720  }
721 
722 
723  public function downloadFolderObject () {
724  global $ilAccess, $ilErr, $lng;
725 
726  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
727  {
728  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
729  }
730  $filename = $this->object->downloadFolder();
731  ilUtil::deliverFile($filename, ilUtil::getASCIIFilename($this->object->getTitle().".zip"));
732  }
733 
737  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
738  {
739  global $tree;
740 
741  // if folder is in a course, modify item list gui according to course requirements
742  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
743  {
744  include_once("./Modules/Course/classes/class.ilObjCourse.php");
745  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
746  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
747  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, 'ilcoursecontentgui', $a_item_data, $a_show_path,
748  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
749  $this->object->getRefId());
750  }
751  }
752 
753  protected function forwardToTimingsView()
754  {
755  global $tree;
756 
757  if(!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs'))
758  {
759  return false;
760  }
761  include_once './Modules/Course/classes/class.ilObjCourse.php';
762  if(!$this->ctrl->getCmd() and ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) == ilContainer::VIEW_TIMING)
763  {
764  if(!isset($_SESSION['crs_timings'])) {
765  $_SESSION['crs_timings'] = true;
766  }
767 
768  if($_SESSION['crs_timings'] == true) {
769  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
770  $course_content_obj = new ilCourseContentGUI($this);
771  $this->ctrl->setCmdClass(get_class($course_content_obj));
772  $this->ctrl->setCmd('editUserTimings');
773  $this->ctrl->forwardCommand($course_content_obj);
774  return true;
775  }
776  }
777  $_SESSION['crs_timings'] = false;
778  return false;
779  }
780 
781 
782 } // END class.ilObjFolderGUI
783 ?>