ILIAS  Release_3_10_x_branch Revision 61812
 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-2008 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 
40 require_once "./Services/Container/classes/class.ilContainerGUI.php";
41 
43 {
44  var $folder_tree; // folder tree
45 
50  function ilObjFolderGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = false)
51  {
52  $this->type = "fold";
53  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output, false);
54  }
55 
56 
57  function viewObject()
58  {
59  global $tree;
60 
61  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
62  {
64  return true;
65  }
66 // else if(!$tree->checkForParentType($this->ref_id,'crs'))
67 // {
68  //$this->ctrl->returnToParent($this);
69  $this->renderObject();
70 // }
71 // else
72 // {
73  // BEGIN ChangeEvent record read event
74 // require_once('Services/Tracking/classes/class.ilChangeEvent.php');
75 // if (ilChangeEvent::_isActive())
76 // {
77 // global $ilUser;
78 // ilChangeEvent::_recordReadEvent($this->object->getId(), $ilUser->getId());
79 // }
80  // END ChangeEvent record read event
81 // include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
82 // $course_content_obj = new ilCourseContentGUI($this);
83 
84 // $this->ctrl->setCmdClass(get_class($course_content_obj));
85 // $this->ctrl->forwardCommand($course_content_obj);
86 // }
87  $this->tabs_gui->setTabActive('view_content');
88  return true;
89  }
90 
91 
92 
93  function &executeCommand()
94  {
95  global $ilUser;
96 
97  $next_class = $this->ctrl->getNextClass($this);
98  $cmd = $this->ctrl->getCmd();
99 
100  switch ($next_class)
101  {
102  case "ilconditionhandlerinterface":
103  $this->prepareOutput();
104  include_once './classes/class.ilConditionHandlerInterface.php';
105 
106  if($_GET['item_id'])
107  {
108  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
109  $this->__setSubTabs('activation');
110  $this->tabs_gui->setTabActive('view_content');
111 
112  $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
113  $this->ctrl->forwardCommand($new_gui);
114  }
115  else
116  {
117  $new_gui =& new ilConditionHandlerInterface($this);
118  $this->ctrl->forwardCommand($new_gui);
119  }
120  break;
121 
122  case 'ilpermissiongui':
123  $this->prepareOutput();
124  include_once("./classes/class.ilPermissionGUI.php");
125  $perm_gui =& new ilPermissionGUI($this);
126  $ret =& $this->ctrl->forwardCommand($perm_gui);
127  break;
128 
129  case 'ilcoursecontentgui':
130  $this->prepareOutput();
131  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
132  $course_content_obj = new ilCourseContentGUI($this);
133  $this->ctrl->forwardCommand($course_content_obj);
134  break;
135 
136  case 'ilcourseitemadministrationgui':
137  $this->prepareOutput();
138  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
139  $this->tabs_gui->clearSubTabs();
140  $this->ctrl->setReturn($this,'view');
141  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_REQUEST['item_id']);
142  $this->ctrl->forwardCommand($item_adm_gui);
143  break;
144 
145  case "illearningprogressgui":
146  $this->prepareOutput();
147  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
148 
150  $this->object->getRefId(),
151  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
152  $this->ctrl->forwardCommand($new_gui);
153  $this->tabs_gui->setTabActive('learning_progress');
154  break;
155 
156  // container page editing
157  case "ilpageobjectgui":
158  $this->prepareOutput(false);
159  $this->checkPermission("write");
160  $ret = $this->forwardToPageObject();
161  if ($ret != "")
162  {
163  $this->tpl->setContent($ret);
164  }
165  break;
166 
167  case 'ilinfoscreengui':
168  $this->prepareOutput();
169  $this->infoScreen();
170  break;
171 
172  default:
173 
174  $this->prepareOutput();
175  // Dirty hack for course timings view
176  if($this->forwardToTimingsView())
177  {
178  break;
179  }
180 
181  if (empty($cmd))
182  {
183  $cmd = "view";
184  }
185  $cmd .= "Object";
186  $this->$cmd();
187  break;
188  }
189  }
190 
194  function setFolderTree($a_tree)
195  {
196  $this->folder_tree =& $a_tree;
197  }
198 
204  function createObject()
205  {
206  global $lng;
207 
208  $this->lng =& $lng;
209 
210  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
211 
212  // fill in saved values in case of error
213  $data = array();
214  $data["fields"] = array();
215  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
216  $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
217 
218  $this->getTemplateFile("edit",$new_type);
219 
220  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_fold.gif'));
221  $this->tpl->setVariable("ALT_IMG", $this->lng->txt('obj_fold'));
222 
223  foreach ($data["fields"] as $key => $val)
224  {
225  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
226  $this->tpl->setVariable(strtoupper($key), $val);
227  }
228 
229  $this->tpl->setVariable("FORMACTION", $this->getFormAction("save",$this->ctrl->getFormAction($this, "save")."&new_type=".$new_type));
230  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->type."_new"));
231  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
232  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($this->type."_add"));
233  $this->tpl->setVariable("CMD_SUBMIT", "save");
234  $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
235  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
236 
237  if($this->withReferences())
238  {
239  $this->fillCloneTemplate('CLONE_WIZARD','fold');
240  }
241 
242  }
243 
249  function saveObject($a_parent = 0)
250  {
251  global $lng;
252 
253  $this->lng =& $lng;
254 
255  if ($a_parent == 0)
256  {
257  $a_parent = $_GET["ref_id"];
258  }
259 
260  // create and insert Folder in grp_tree
261  include_once("./Modules/Folder/classes/class.ilObjFolder.php");
262  $folderObj = new ilObjFolder(0,$this->withReferences());
263  $folderObj->setType($this->type);
264  $folderObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
265  $folderObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
266  $folderObj->create();
267  $this->object =& $folderObj;
268 
269  if (is_object($this->folder_tree)) // groups gui should call ObjFolderGUI->setFolderTree also
270  {
271  $folderObj->setFolderTree($this->folder_tree);
272  }
273  else
274  {
275  $folderObj->setFolderTree($this->tree);
276  }
277 
278  if ($this->withReferences()) // check if this folders use references
279  { // note: e.g. folders in media pools don't
280  $folderObj->createReference();
281  $folderObj->setPermissions($a_parent);
282  }
283 
284  $folderObj->putInTree($a_parent);
285 
286  // BEGIN ChangeEvent: Record write event.
287  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
289  {
290  global $ilUser;
291  ilChangeEvent::_recordWriteEvent($folderObj->getId(), $ilUser->getId(), 'create');
292  }
293  // END ChangeEvent: Record write event.
294 
295  ilUtil::sendInfo($this->lng->txt("fold_added"),true);
296  $this->ctrl->returnToParent($this);
297  //$this->ctrl->redirect($this,"");
298  }
299 
305  function updateObject($a_return_to_parent = false)
306  {
307  $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
308  $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
309  $this->update = $this->object->update();
310 
311  // BEGIN ChangeEvent: Record write event.
312  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
314  {
315  global $ilUser;
316  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
317  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
318  }
319  // END ChangeEvent: Record write event.
320 
321  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
322 
323  if ($a_return_to_parent)
324  {
325  $this->ctrl->returnToParent($this);
326  }
327  else
328  {
329  $this->ctrl->redirect($this);
330  }
331  }
332 
333  // BEGIN ChangeEvent show info screen on folder object
339  function showSummaryObject()
340  {
341  $this->ctrl->setCmd("showSummary");
342  $this->ctrl->setCmdClass("ilinfoscreengui");
343  $this->infoScreen();
344  }
345 
351  function infoScreenObject()
352  {
353  $this->ctrl->setCmd("showSummary");
354  $this->ctrl->setCmdClass("ilinfoscreengui");
355  $this->infoScreen();
356  }
357 
361  function infoScreen()
362  {
363  global $ilAccess;
364 
365  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
366  {
367  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
368  }
369 
370  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
371  $info = new ilInfoScreenGUI($this);
372 
373  $info->enablePrivateNotes();
374 
375  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
376  {
377  $info->enableNews();
378  }
379 
380  // no news editing for files, just notifications
381  $info->enableNewsEditing(false);
382  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
383  {
384  $news_set = new ilSetting("news");
385  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
386 
387  if ($enable_internal_rss)
388  {
389  $info->setBlockProperty("news", "settings", true);
390  $info->setBlockProperty("news", "public_notifications_option", true);
391  }
392  }
393 
394 
395  // standard meta data
396  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
397 
398  // forward the command
399  $this->ctrl->forwardCommand($info);
400  }
401  // END ChangeEvent show info screen on folder object
402 
403  // get tabs
404  function getTabs(&$tabs_gui)
405  {
406  global $rbacsystem,$ilUser;
407 
408  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
409 
410  $tabs_gui->setTabActive("");
411  if ($rbacsystem->checkAccess('read',$this->ref_id))
412  {
413  $tabs_gui->addTarget("view_content",
414  $this->ctrl->getLinkTarget($this, ""),
415  array("", "view", "cciMove", "enableAdministrationPanel",
416  "disableAdministrationPanel", "render"),
417  get_class($this));
418 
419  //BEGIN ChangeEvent add info tab to category object
420  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
421  || strtolower($_GET["cmdClass"]) == "ilnotegui")
422  ? true
423  : false;
424  $tabs_gui->addTarget("info_short",
425  $this->ctrl->getLinkTargetByClass(
426  array("ilobjfoldergui", "ilinfoscreengui"), "showSummary"),
427  array("showSummary","", "infoScreen"),
428  "", "", $force_active);
429  //END ChangeEvent add info tab to category object
430  }
431 
432  if ($rbacsystem->checkAccess('write',$this->ref_id))
433  {
434  $tabs_gui->addTarget("edit_properties",
435  $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this));
436  }
437 
438  // learning progress
439  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
440  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
441  {
442  $tabs_gui->addTarget('learning_progress',
443  $this->ctrl->getLinkTargetByClass(array('ilobjfoldergui','illearningprogressgui'),''),
444  '',
445  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
446  }
447 
448  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
449  {
450  $tabs_gui->addTarget("perm_settings",
451  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
452  }
453 
454  // show clipboard in repository
455  if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION['il_rep_clipboard']))
456  {
457  $tabs_gui->addTarget("clipboard",
458  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
459  }
460 
461  }
462 
463  // Methods for ConditionHandlerInterface
464  function initConditionHandlerGUI($item_id)
465  {
466  include_once './classes/class.ilConditionHandlerInterface.php';
467 
468  if(!is_object($this->chi_obj))
469  {
470  if($_GET['item_id'])
471  {
472  $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
473  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
474  }
475  else
476  {
477  $this->chi_obj =& new ilConditionHandlerInterface($this);
478  }
479  }
480  return true;
481  }
482 
486  function __setSubTabs($a_tab)
487  {
488  global $rbacsystem,$ilUser;
489 
490  switch ($a_tab)
491  {
492 
493  case "activation":
494 
495  $this->tabs_gui->addSubTabTarget("activation",
496  $this->ctrl->getLinkTargetByClass('ilCourseItemAdministrationGUI','edit'),
497  "edit", get_class($this));
498  $this->ctrl->setParameterByClass('ilconditionhandlerinterface','item_id',(int) $_GET['item_id']);
499  $this->tabs_gui->addSubTabTarget("preconditions",
500  $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
501  "", "ilConditionHandlerInterface");
502  break;
503  }
504  }
505 
509  function _goto($a_target)
510  {
511  global $ilAccess, $ilErr, $lng;
512 
513  if ($ilAccess->checkAccess("read", "", $a_target))
514  {
515  $_GET["cmd"] = "frameset";
516  $_GET["ref_id"] = $a_target;
517  include("repository.php");
518  exit;
519  }
520  /*
521  else
522  {
523  // to do: force flat view
524 
525  // no info screen for folders
526  if ($ilAccess->checkAccess("visible", "", $a_target))
527  {
528  $_GET["cmd"] = "infoScreen";
529  $_GET["ref_id"] = $a_target;
530  include("repository.php");
531  exit;
532  }
533  else
534  {
535  // This part will never be reached
536  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
537  {
538  $_GET["cmd"] = "frameset";
539  $_GET["target"] = "";
540  $_GET["ref_id"] = ROOT_FOLDER_ID;
541  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
542  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
543  include("repository.php");
544  exit;
545  }
546  }
547  }
548  */
549  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
550  }
551 
552 
553  public function downloadFolderObject () {
554  global $ilAccess, $ilErr, $lng;
555 
556  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
557  {
558  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
559  }
560  $filename = $this->object->downloadFolder();
561  ilUtil::deliverFile($filename, ilUtil::getASCIIFilename($this->object->getTitle().".zip"));
562  }
563 
567  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
568  {
569  global $tree;
570 
571  // if folder is in a course, modify item list gui according to course requirements
572  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
573  {
574  include_once("./Modules/Course/classes/class.ilObjCourse.php");
575  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
576  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
577  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path,
578  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
579  $this->object->getRefId());
580  }
581  }
582 
583  protected function forwardToTimingsView()
584  {
585  global $tree;
586 
587  if(!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs'))
588  {
589  return false;
590  }
591  include_once './Modules/Course/classes/class.ilObjCourse.php';
592  if(!$this->ctrl->getCmd() and ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) == ilContainer::VIEW_TIMING)
593  {
594  if(!isset($_SESSION['crs_timings'])) {
595  $_SESSION['crs_timings'] = true;
596  }
597 
598  if($_SESSION['crs_timings'] == true) {
599  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
600  $course_content_obj = new ilCourseContentGUI($this);
601  $this->ctrl->setCmdClass(get_class($course_content_obj));
602  $this->ctrl->setCmd('editUserTimings');
603  $this->ctrl->forwardCommand($course_content_obj);
604  return true;
605  }
606  }
607  $_SESSION['crs_timings'] = false;
608  return false;
609  }
610 
611 
612 } // END class.ilObjFolderGUI
613 ?>