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