ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFileGUI.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 
26 require_once "./classes/class.ilObjectGUI.php";
27 require_once "./Modules/File/classes/class.ilObjFile.php";
28 require_once "./Modules/File/classes/class.ilObjFileAccess.php";
29 
41 {
46  function ilObjFileGUI($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true)
47  {
48  $this->type = "file";
49  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
50  $this->lng->loadLanguageModule('file');
51  }
52 
53  function _forwards()
54  {
55  return array();
56  }
57 
58  function &executeCommand()
59  {
60  global $ilAccess, $ilNavigationHistory,$ilCtrl;
61 
62  // add entry to navigation history
63  if (!$this->getCreationMode() &&
64  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
65  {
66  $ilNavigationHistory->addItem($_GET["ref_id"],
67  "repository.php?cmd=infoScreen&ref_id=".$_GET["ref_id"], "file");
68  }
69 
70  $next_class = $this->ctrl->getNextClass($this);
71  $cmd = $this->ctrl->getCmd();
72 
73  if(!$this->getCreationMode())
74  {
75  include_once 'payment/classes/class.ilPaymentObject.php';
76  if(ilPaymentObject::_isBuyable($this->object->getRefId()) &&
77  !ilPaymentObject::_hasAccess($this->object->getRefId()))
78  {
79  $this->setLocator();
80  $this->tpl->getStandardTemplate();
81 
82  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
83  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
84  $ret = $this->ctrl->forwardCommand($pp);
85  return true;
86  }
87  }
88 
89  $this->prepareOutput();
90 
91 //var_dump($_GET);
92 //var_dump($_POST);
93 //var_dump($_SESSION);
94 //echo "-$cmd-";
95  switch ($next_class)
96  {
97  case "ilinfoscreengui":
98  $this->infoScreen(); // forwards command
99  break;
100 
101  case 'ilmdeditorgui':
102 
103  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
104 
105  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
106  $md_gui->addObserver($this->object,'MDUpdateListener','General');
107 
108  // todo: make this work
109  $md_gui->addObserver($this->object,'MDUpdateListener','Technical');
110 
111  $this->ctrl->forwardCommand($md_gui);
112  break;
113 
114  case 'ilpermissiongui':
115  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
116  $perm_gui =& new ilPermissionGUI($this);
117  $ret =& $this->ctrl->forwardCommand($perm_gui);
118  break;
119 
120  case 'ilobjectcopygui':
121  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
122  $cp = new ilObjectCopyGUI($this);
123  $cp->setType('file');
124  $this->ctrl->forwardCommand($cp);
125  break;
126 
127 
128  default:
129  if (empty($cmd))
130  {
131  // does not seem to work
132  //$this->ctrl->returnToParent($this);
133  //$cmd = "view";
134  $cmd = "infoScreen";
135  }
136 
137  $cmd .= "Object";
138  $this->$cmd();
139  break;
140  }
141  }
142 
148  function createObject($a_reload_form = "")
149  {
150  global $rbacsystem, $ilCtrl;
151 
152  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
153 
154  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
155  {
156  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
157  }
158 
159  // fill in saved values in case of error
160  $this->getTemplateFile("new",$this->type);
161 
162  if ($a_reload_form != "single_upload")
163  {
164  $this->initSingleUploadForm("create");
165  }
166  $this->tpl->setVariable("SINGLE_UPLOAD_FORM", $this->single_form_gui->getHtml());
167 
168  if ($a_reload_form != "zip_upload")
169  {
170  $this->initZipUploadForm("create");
171  }
172 
173  $this->tpl->setVariable("ZIP_UPLOAD_FORM", $this->zip_form_gui->getHtml());
174 
175  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
176  $this->tpl->setVariable("TXT_TAKE_OVER_STRUCTURE", $this->lng->txt("take_over_structure"));
177  $this->tpl->setVariable("TXT_HEADER_ZIP", $this->lng->txt("header_zip"));
178 
179  $this->fillCloneTemplate('DUPLICATE','file');
180  }
181 
187  public function initSingleUploadForm($a_mode = "create")
188  {
189  global $lng;
190 
191  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
192  $this->single_form_gui = new ilPropertyFormGUI();
193  $this->single_form_gui->setMultipart(true);
194 
195  // File Title
196  $in_title = new ilTextInputGUI($lng->txt("title"), "title");
197  $in_title->setInfo($this->lng->txt("if_no_title_then_filename"));
198  $in_title->setMaxLength(128);
199  $in_title->setSize(40);
200  $this->single_form_gui->addItem($in_title);
201 
202  // File Description
203  $in_descr = new ilTextAreaInputGUI($lng->txt("description"), "description");
204  $this->single_form_gui->addItem($in_descr);
205 
206  // File
207  $in_file = new ilFileInputGUI($lng->txt("file"), "upload_file");
208  $in_file->setRequired(true);
209  $this->single_form_gui->addItem($in_file);
210 
211  // save and cancel commands
212  if ($a_mode == "create")
213  {
214  $this->single_form_gui->addCommandButton("save", $this->lng->txt($this->type."_add"));
215  $this->single_form_gui->addCommandButton("saveAndMeta", $this->lng->txt("file_add_and_metadata"));
216  $this->single_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
217  }
218  else
219  {
220  //$this->single_form_gui->addCommandButton("update", $lng->txt("save"));
221  //$this->single_form_gui->addCommandButton("cancelUpdate", $lng->txt("cancel"));
222  }
223 
224  $this->single_form_gui->setTableWidth("60%");
225  $this->single_form_gui->setTarget($this->getTargetFrame("save"));
226  $this->single_form_gui->setTitle($this->lng->txt($this->type."_new"));
227  $this->single_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.gif'), $this->lng->txt('obj_file'));
228 
229  if ($a_mode == "create")
230  {
231  $this->ctrl->setParameter($this, "new_type", "file");
232  }
233  $this->single_form_gui->setFormAction($this->ctrl->getFormAction($this));
234  }
235 
241  public function initZipUploadForm($a_mode = "create")
242  {
243  global $lng;
244 
245  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
246  $this->zip_form_gui = new ilPropertyFormGUI();
247  $this->zip_form_gui->setMultipart(true);
248 
249  // File
250  $in_file = new ilFileInputGUI($lng->txt("file"), "zip_file");
251  $in_file->setRequired(true);
252  $in_file->setSuffixes(array("zip"));
253  $this->zip_form_gui->addItem($in_file);
254 
255  // Take over structure
256  $in_str = new ilCheckboxInputGUI($this->lng->txt("take_over_structure"), "adopt_structure");
257  $in_str->setInfo($this->lng->txt("take_over_structure_info"));
258  $this->zip_form_gui->addItem($in_str);
259 
260  // save and cancel commands
261  if ($a_mode == "create")
262  {
263  $this->zip_form_gui->addCommandButton("saveUnzip", $this->lng->txt($this->type."_add"));
264  $this->zip_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
265  }
266  else
267  {
268  //$this->zip_form_gui->addCommandButton("update", $lng->txt("save"));
269  //$this->zip_form_gui->addCommandButton("cancelUpdate", $lng->txt("cancel"));
270  }
271 
272  $this->zip_form_gui->setTableWidth("60%");
273  $this->zip_form_gui->setTarget($this->getTargetFrame("save"));
274  $this->zip_form_gui->setTitle($this->lng->txt("header_zip"));
275  $this->zip_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.gif'), $this->lng->txt('obj_file'));
276 
277  if ($a_mode == "create")
278  {
279  $this->ctrl->setParameter($this, "new_type", "file");
280  }
281  $this->zip_form_gui->setFormAction($this->ctrl->getFormAction($this));
282  }
283 
289  function saveUnzipObject()
290  {
291  global $rbacsystem;
292 
293  $this->initZipUploadForm("create");
294 
295  if ($rbacsystem->checkAccess("create", $_GET["ref_id"], "file")) {
296  if ($this->zip_form_gui->checkInput())
297  {
298  $zip_file = $this->zip_form_gui->getInput("zip_file");
299  $adopt_structure = $this->zip_form_gui->getInput("adopt_structure");
300 
301  include_once ("Services/Utilities/classes/class.ilFileUtils.php");
302 
303  // Create unzip-directory
304  $newDir = ilUtil::ilTempnam();
305  ilUtil::makeDir($newDir);
306 
307  // Check if permission is granted for creation of object, if necessary
308  $type = ilObject::_lookupType((int) $_GET['ref_id'],true);
309  if($type == 'cat' or $type == 'root')
310  {
311  $permission = $rbacsystem->checkAccess("create", $_GET["ref_id"], "cat");
312  $containerType = "Category";
313  }
314  else {
315  $permission = $rbacsystem->checkAccess("create", $_GET["ref_id"], "fold");
316  $containerType = "Folder";
317  }
318 
319  // processZipFile (
320  // Dir to unzip,
321  // Path to uploaded file,
322  // should a structure be created (+ permission check)?
323  // ref_id of parent
324  // object that contains files (folder or category)
325  // should sendInfo be persistent?)
326  try
327  {
328  $processDone = ilFileUtils::processZipFile( $newDir,
329  $zip_file["tmp_name"],
330  ($adopt_structure && $permission),
331  $_GET["ref_id"],
332  $containerType,
333  true);
334  ilUtil::sendSuccess($this->lng->txt("file_added"),true);
335  }
336  catch (ilFileUtilsException $e)
337  {
338  ilUtil::sendFailure($e->getMessage(), true);
339  }
340 
341  ilUtil::delDir($newDir);
342  $this->ctrl->returnToParent($this);
343  }
344  else
345  {
346  $this->zip_form_gui->setValuesByPost();
347  $this->createObject("zip_upload");
348  }
349  }
350  else
351  {
352  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
353  }
354  }
355 
361  function saveObject()
362  {
363  global $rbacsystem, $objDefinition, $ilUser;
364 
365  $this->initSingleUploadForm("create");
366 
367  if ($this->single_form_gui->checkInput())
368  {
369  $title = $this->single_form_gui->getInput("title");
370  $description = $this->single_form_gui->getInput("description");
371  $upload_file = $this->single_form_gui->getInput("upload_file");
372 
373  if (trim($title) == "")
374  {
375  $title = $upload_file["name"];
376  }
377  else
378  {
379  // BEGIN WebDAV: Ensure that object title ends with the filename extension
380  $fileExtension = ilObjFileAccess::_getFileExtension($upload_file["name"]);
381  $titleExtension = ilObjFileAccess::_getFileExtension($title);
382  if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
383  {
384  $title .= '.'.$fileExtension;
385  }
386  // END WebDAV: Ensure that object title ends with the filename extension
387  }
388 
389  // create and insert file in grp_tree
390  include_once("./Modules/File/classes/class.ilObjFile.php");
391  $fileObj = new ilObjFile();
392  $fileObj->setTitle($title);
393  $fileObj->setDescription($description);
394  $fileObj->setFileName($upload_file["name"]);
395  //$fileObj->setFileType($upload_file["type"]);
396  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
397  $fileObj->setFileType(ilMimeTypeUtil::getMimeType(
398  "", $upload_file["name"], $upload_file["type"]));
399  $fileObj->setFileSize($upload_file["size"]);
400  $fileObj->create();
401  $fileObj->createReference();
402  $fileObj->putInTree($_GET["ref_id"]);
403  $fileObj->setPermissions($_GET["ref_id"]);
404  // upload file to filesystem
405  $fileObj->createDirectory();
406  $fileObj->getUploadFile($upload_file["tmp_name"],
407  $upload_file["name"]);
408 
409  // BEGIN ChangeEvent: Record write event.
410  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
412  {
413  ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
414  }
415  // END ChangeEvent: Record write event.
416  ilUtil::sendSuccess($this->lng->txt("file_added"),true);
417 
418  $this->ctrl->setParameter($this, "ref_id", $fileObj->getRefId());
419  if ($this->ctrl->getCmd() == "saveAndMeta")
420  {
421  $target =
422  $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilmdeditorgui"), "listSection");
423  $target = str_replace("new_type=", "nt=", $target);
424  ilUtil::redirect($this->getReturnLocation("save", $target));
425  }
426  else
427  {
428  $this->ctrl->returnToParent($this);
429  }
430  }
431  else
432  {
433  $this->single_form_gui->setValuesByPost();
434  $this->createObject("single_upload");
435  }
436  }
437 
443  function saveAndMetaObject()
444  {
445  $this->saveObject();
446  }
447 
453  function updateObject()
454  {
455  $this->tabs_gui->setTabActive('edit');
456 
457  $this->initPropertiesForm('edit');
458  if(!$this->form->checkInput())
459  {
460  $this->form->setValuesByPost();
461  $this->tpl->setContent($this->form->getHTML());
462  return false;
463  }
464 
465  $data = $this->form->getInput('file');
466 
467  // delete trailing '/' in filename
468  while (substr($data["name"],-1) == '/')
469  {
470  $data["name"] = substr($data["name"],0,-1);
471  }
472 
473  $filename = empty($data["name"]) ? $this->object->getFileName() : $data["name"];
474  $title = $this->form->getInput('title');
475  if(strlen(trim($title)) == 0)
476  {
477  $title = $filename;
478  }
479  else
480  {
481  $title = $this->object->checkFileExtension($filename,$title);
482  }
483  $this->object->setTitle($title);
484 
485  if (!empty($data["name"]))
486  {
487  switch($this->form->getInput('replace'))
488  {
489  case 1:
490  $this->object->deleteVersions();
491  $this->object->clearDataDirectory();
492  $this->object->replaceFile($data['tmp_name'],$data['name']);
493  break;
494  case 0:
495  $this->object->addFileVersion($data['tmp_name'],$data['name']);
496  break;
497  }
498  $this->object->setFileName($data['name']);
499  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
500  $this->object->setFileType(ilMimeTypeUtil::getMimeType(
501  "", $data["name"], $data["type"]));
502  $this->object->setFileSize($data['size']);
503  }
504  $this->object->setDescription($this->form->getInput('description'));
505  $this->update = $this->object->update();
506 
507  // BEGIN ChangeEvent: Record update event.
508  if (!empty($data["name"]))
509  {
510  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
512  {
513  global $ilUser;
514  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
515  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
516  }
517  }
518  // END ChangeEvent: Record update event.
519 
520  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
521  ilUtil::redirect($this->ctrl->getLinkTarget($this,'edit'));
522  }
523 
524 
530  function editObject()
531  {
532  global $rbacsystem, $ilAccess;
533 
534  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
535  {
536  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
537  }
538 
539  $this->tabs_gui->setTabActive('edit');
540 
541  $this->initPropertiesForm('edit');
542  $this->getPropertiesValues('edit');
543 
544  $this->tpl->setContent($this->form->getHTML());
545  return true;
546 
547 
548  $fields = array();
549 
550  if ($_SESSION["error_post_vars"])
551  {
552  // fill in saved values in case of error
553  $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
554  $fields["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"], true);
555  }
556  else
557  {
558  $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
559  $fields["desc"] = ilUtil::prepareFormOutput($this->object->getLongDescription());
560  }
561 
562  $this->getTemplateFile("edit");
563  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
564  $this->tpl->setVariable("TITLE", $fields["title"]);
565  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
566  $this->tpl->setVariable("DESC", $fields["desc"]);
567  $this->tpl->setVariable("TXT_REPLACE_FILE", $this->lng->txt("replace_file"));
568  //$this->tpl->parseCurrentBlock();
569 
570  $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
571 
572  $this->tpl->setVariable("FORMACTION", $this->getFormAction("update",$this->ctrl->getFormAction($this, "update").$obj_str));
573  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
574  $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
575  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
576  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
577  $this->tpl->setVariable("CMD_SUBMIT", "update");
578  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
579  //$this->tpl->parseCurrentBlock();
580  }
581 
582  protected function getPropertiesValues($a_mode = 'edit')
583  {
584  if($a_mode == 'edit')
585  {
586  $val['title'] = $this->object->getTitle();
587  $val['description'] = $this->object->getLongDescription();
588  $this->form->setValuesByArray($val);
589  }
590  return true;
591  }
592 
598  protected function initPropertiesForm($a_mode)
599  {
600  global $lng;
601 
602  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
603 
604  $this->form = new ilPropertyFormGUI();
605  $this->form->setFormAction($this->ctrl->getFormAction($this),'update');
606  $this->form->setTitle($this->lng->txt('file_edit'));
607  $this->form->addCommandButton('update',$this->lng->txt('save'));
608  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
609 
610  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
611  $title->setValue($this->object->getTitle());
612  $title->setInfo($lng->txt("if_no_title_then_filename"));
613  $this->form->addItem($title);
614 
615  $file = new ilFileInputGUI($this->lng->txt('obj_file'),'file');
616  $file->setRequired(false);
617 // $file->enableFileNameSelection('title');
618  $this->form->addItem($file);
619 
620  $group = new ilRadioGroupInputGUI('','replace');
621  $group->setValue(0);
622 
623  $replace = new ilRadioOption($this->lng->txt('replace_file'),1);
624  $replace->setInfo($this->lng->txt('replace_file_info'));
625  $group->addOption($replace);
626 
627 
628  $keep = new ilRadioOption($this->lng->txt('file_new_version'),0);
629  $keep->setInfo($this->lng->txt('file_new_version_info'));
630  $group->addOption($keep);
631 
632  $file->addSubItem($group);
633 
634  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
635  $desc->setRows(3);
636  #$desc->setCols(40);
637  $this->form->addItem($desc);
638  }
639 
640  function sendFileObject()
641  {
642  global $ilAccess;
643 
644  if ($ilAccess->checkAccess("read", "", $this->ref_id))
645  {
646  // BEGIN ChangeEvent: Record read event.
647  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
649  {
650  global $ilUser;
651  // Record read event and catchup with write events
652  ilChangeEvent::_recordReadEvent($this->object->getId(), $ilUser->getId());
653  }
654  // END ChangeEvent: Record read event.
655 
656  $this->object->sendFile($_GET["hist_id"]);
657  }
658  else
659  {
660  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
661  }
662  return true;
663  }
664 
665 
671  function versionsObject()
672  {
673  global $rbacsystem, $ilAccess;
674 
675  if (!$ilAccess->checkAccess("write", "", $_GET["ref_id"]))
676  {
677  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
678  }
679 
680  require_once("classes/class.ilHistoryGUI.php");
681 
682  $hist_gui =& new ilHistoryGUI($this->object->getId());
683 
684  // not nice, should be changed, if ilCtrl handling
685  // has been introduced to administration
686  $hist_html = $hist_gui->getVersionsTable(
687  array("ref_id" => $_GET["ref_id"], "cmd" => "versions",
688  "cmdClass" =>$_GET["cmdClass"], "cmdNode" =>$_GET["cmdNode"]));
689 
690  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
691  }
692 
698  function infoScreenObject()
699  {
700  $this->ctrl->setCmd("showSummary");
701  $this->ctrl->setCmdClass("ilinfoscreengui");
702  $this->infoScreen();
703  }
704 
708  function infoScreen()
709  {
710  global $ilAccess;
711 
712  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
713  {
714  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
715  }
716 
717  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
718  $info = new ilInfoScreenGUI($this);
719 
720  if ($ilAccess->checkAccess("read", "sendfile", $this->ref_id))
721  {
722  $info->addButton($this->lng->txt("file_read"), $this->ctrl->getLinkTarget($this, "sendfile"));
723  }
724 
725  $info->enablePrivateNotes();
726 
727  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
728  {
729  $info->enableNews();
730  }
731 
732  // no news editing for files, just notifications
733  $info->enableNewsEditing(false);
734  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
735  {
736  $news_set = new ilSetting("news");
737  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
738 
739  if ($enable_internal_rss)
740  {
741  $info->setBlockProperty("news", "settings", true);
742  $info->setBlockProperty("news", "public_notifications_option", true);
743  }
744  }
745 
746 
747  // standard meta data
748  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
749 
750  $info->addSection($this->lng->txt("file_info"));
751  $info->addProperty($this->lng->txt("filename"),
752  $this->object->getFileName());
753  // BEGIN WebDAV Guess file type.
754  $info->addProperty($this->lng->txt("type"),
755  $this->object->guessFileType());
756  // END WebDAV Guess file type.
757  $info->addProperty($this->lng->txt("size"),
758  ilFormat::formatSize(ilObjFile::_lookupFileSize($this->object->getId()),'long'));
759  $info->addProperty($this->lng->txt("version"),
760  $this->object->getVersion());
761 
762  // forward the command
763  $this->ctrl->forwardCommand($info);
764  }
765 
766 
767  // get tabs
768  function getTabs(&$tabs_gui)
769  {
770  global $rbacsystem, $ilAccess;
771 
772 //echo "-".$this->ctrl->getCmd()."-";
773 
774  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
775 
776  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
777  {
778  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
779  || strtolower($_GET["cmdClass"]) == "ilnotegui")
780  ? true
781  : false;
782  $tabs_gui->addTarget("info_short",
783  $this->ctrl->getLinkTargetByClass(
784  array("ilobjfilegui", "ilinfoscreengui"), "showSummary"),
785  array("showSummary","", "infoScreen"),
786  "", "", $force_active);
787  }
788 
789  if ($ilAccess->checkAccess("write", "", $this->ref_id))
790  {
791  $tabs_gui->addTarget("edit",
792  $this->ctrl->getLinkTarget($this, "edit"), "edit", "");
793  }
794 
795  // meta data
796  if ($ilAccess->checkAccess("write", "", $this->ref_id))
797  {
798  $tabs_gui->addTarget("meta_data",
799  $this->ctrl->getLinkTargetByClass(array('ilobjfilegui','ilmdeditorgui'),'listSection'),
800  "", 'ilmdeditorgui');
801  }
802 
803  if ($ilAccess->checkAccess("write", "", $this->ref_id))
804  {
805  $tabs_gui->addTarget("versions",
806  $this->ctrl->getLinkTarget($this, "versions"), "versions", get_class($this));
807  }
808 
809  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
810  {
811  $tabs_gui->addTarget("perm_settings",
812  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
813  }
814  }
815 
816  function _goto($a_target)
817  {
818  global $ilAccess, $ilErr, $lng;
819 
820  if ($ilAccess->checkAccess("visible", "", $a_target))
821  {
822  $_GET["cmd"] = "infoScreen";
823  $_GET["ref_id"] = $a_target;
824  include("repository.php");
825  exit;
826  }
827  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
828  {
829  $_GET["cmd"] = "frameset";
830  $_GET["target"] = "";
831  $_GET["ref_id"] = ROOT_FOLDER_ID;
832  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
834  include("repository.php");
835  exit;
836  }
837 
838  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
839 
840  }
841 
845  function addLocatorItems()
846  {
847  global $ilLocator;
848 
849  if (is_object($this->object))
850  {
851  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
852  }
853  }
854 
855 } // END class.ilObjFileGUI
856 ?>