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";
46 function ilObjFileGUI($a_data,$a_id,$a_call_by_reference =
true, $a_prepare_output =
true)
49 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference,
false);
50 $this->lng->loadLanguageModule(
'file');
60 global $ilAccess, $ilNavigationHistory,
$ilCtrl;
64 $ilAccess->checkAccess(
"read",
"",
$_GET[
"ref_id"]))
66 $ilNavigationHistory->addItem(
$_GET[
"ref_id"],
67 "repository.php?cmd=infoScreen&ref_id=".
$_GET[
"ref_id"],
"file");
70 $next_class = $this->ctrl->getNextClass($this);
71 $cmd = $this->ctrl->getCmd();
75 include_once
'payment/classes/class.ilPaymentObject.php';
80 $this->tpl->getStandardTemplate();
82 include_once
'Services/Payment/classes/class.ilShopPurchaseGUI.php';
84 $ret = $this->ctrl->forwardCommand($pp);
97 case "ilinfoscreengui":
101 case 'ilmdeditorgui':
103 include_once
'Services/MetaData/classes/class.ilMDEditorGUI.php';
105 $md_gui =&
new ilMDEditorGUI($this->object->getId(), 0, $this->
object->getType());
106 $md_gui->
addObserver($this->
object,
'MDUpdateListener',
'General');
109 $md_gui->addObserver($this->
object,
'MDUpdateListener',
'Technical');
111 $this->ctrl->forwardCommand($md_gui);
114 case 'ilpermissiongui':
115 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
117 $ret =& $this->ctrl->forwardCommand($perm_gui);
120 case 'ilobjectcopygui':
121 include_once
'./Services/Object/classes/class.ilObjectCopyGUI.php';
123 $cp->setType(
'file');
124 $this->ctrl->forwardCommand($cp);
154 if (!$rbacsystem->checkAccess(
"create",
$_GET[
"ref_id"], $new_type))
156 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
162 if ($a_reload_form !=
"single_upload")
166 $this->tpl->setVariable(
"SINGLE_UPLOAD_FORM", $this->single_form_gui->getHtml());
168 if ($a_reload_form !=
"zip_upload")
173 $this->tpl->setVariable(
"ZIP_UPLOAD_FORM", $this->zip_form_gui->getHtml());
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"));
191 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
193 $this->single_form_gui->setMultipart(
true);
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);
204 $this->single_form_gui->addItem($in_descr);
209 $this->single_form_gui->addItem($in_file);
212 if ($a_mode ==
"create")
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"));
224 $this->single_form_gui->setTableWidth(
"60%");
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'));
229 if ($a_mode ==
"create")
231 $this->ctrl->setParameter($this,
"new_type",
"file");
233 $this->single_form_gui->setFormAction($this->ctrl->getFormAction($this));
245 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
247 $this->zip_form_gui->setMultipart(
true);
252 $in_file->setSuffixes(array(
"zip"));
253 $this->zip_form_gui->addItem($in_file);
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);
261 if ($a_mode ==
"create")
263 $this->zip_form_gui->addCommandButton(
"saveUnzip", $this->lng->txt($this->type.
"_add"));
264 $this->zip_form_gui->addCommandButton(
"cancel", $lng->txt(
"cancel"));
272 $this->zip_form_gui->setTableWidth(
"60%");
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'));
277 if ($a_mode ==
"create")
279 $this->ctrl->setParameter($this,
"new_type",
"file");
281 $this->zip_form_gui->setFormAction($this->ctrl->getFormAction($this));
295 if ($rbacsystem->checkAccess(
"create",
$_GET[
"ref_id"],
"file")) {
296 if ($this->zip_form_gui->checkInput())
298 $zip_file = $this->zip_form_gui->getInput(
"zip_file");
299 $adopt_structure = $this->zip_form_gui->getInput(
"adopt_structure");
301 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
311 $permission = $rbacsystem->checkAccess(
"create", $_GET[
"ref_id"],
"cat");
312 $containerType =
"Category";
315 $permission = $rbacsystem->checkAccess(
"create", $_GET[
"ref_id"],
"fold");
316 $containerType =
"Folder";
329 $zip_file[
"tmp_name"],
330 ($adopt_structure && $permission),
342 $this->ctrl->returnToParent($this);
346 $this->zip_form_gui->setValuesByPost();
352 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
367 if ($this->single_form_gui->checkInput())
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");
375 $title = $upload_file[
"name"];
382 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
384 $title .=
'.'.$fileExtension;
390 include_once(
"./Modules/File/classes/class.ilObjFile.php");
392 $fileObj->setTitle(
$title);
393 $fileObj->setDescription($description);
394 $fileObj->setFileName($upload_file[
"name"]);
396 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
398 "", $upload_file[
"name"], $upload_file[
"type"]));
399 $fileObj->setFileSize($upload_file[
"size"]);
401 $fileObj->createReference();
402 $fileObj->putInTree(
$_GET[
"ref_id"]);
403 $fileObj->setPermissions(
$_GET[
"ref_id"]);
405 $fileObj->createDirectory();
406 $fileObj->getUploadFile($upload_file[
"tmp_name"],
407 $upload_file[
"name"]);
410 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
418 $this->ctrl->setParameter($this,
"ref_id", $fileObj->getRefId());
419 if ($this->ctrl->getCmd() ==
"saveAndMeta")
422 $this->ctrl->getLinkTargetByClass(array(
"ilobjfilegui",
"ilmdeditorgui"),
"listSection");
423 $target = str_replace(
"new_type=",
"nt=", $target);
428 $this->ctrl->returnToParent($this);
433 $this->single_form_gui->setValuesByPost();
455 $this->tabs_gui->setTabActive(
'edit');
458 if(!$this->form->checkInput())
460 $this->form->setValuesByPost();
461 $this->tpl->setContent($this->form->getHTML());
465 $data = $this->form->getInput(
'file');
468 while (substr(
$data[
"name"],-1) ==
'/')
474 $title = $this->form->getInput(
'title');
475 if(strlen(trim(
$title)) == 0)
483 $this->
object->setTitle(
$title);
485 if (!empty(
$data[
"name"]))
487 switch($this->form->getInput(
'replace'))
490 $this->
object->deleteVersions();
491 $this->
object->clearDataDirectory();
492 $this->
object->replaceFile(
$data[
'tmp_name'],
$data[
'name']);
495 $this->
object->addFileVersion(
$data[
'tmp_name'],
$data[
'name']);
498 $this->
object->setFileName(
$data[
'name']);
499 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
502 $this->
object->setFileSize(
$data[
'size']);
504 $this->
object->setDescription($this->form->getInput(
'description'));
505 $this->update = $this->
object->update();
508 if (!empty(
$data[
"name"]))
510 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
532 global $rbacsystem, $ilAccess;
534 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id))
536 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
539 $this->tabs_gui->setTabActive(
'edit');
544 $this->tpl->setContent($this->form->getHTML());
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"));
570 $obj_str = ($this->call_by_reference) ?
"" :
"&obj_id=".$this->obj_id;
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"));
584 if($a_mode ==
'edit')
586 $val[
'title'] = $this->
object->getTitle();
587 $val[
'description'] = $this->
object->getLongDescription();
588 $this->form->setValuesByArray($val);
602 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
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'));
611 $title->setValue($this->object->getTitle());
612 $title->setInfo($lng->txt(
"if_no_title_then_filename"));
613 $this->form->addItem(
$title);
616 $file->setRequired(
false);
618 $this->form->addItem(
$file);
623 $replace =
new ilRadioOption($this->lng->txt(
'replace_file'),1);
624 $replace->
setInfo($this->lng->txt(
'replace_file_info'));
625 $group->addOption($replace);
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);
632 $file->addSubItem($group);
637 $this->form->addItem(
$desc);
644 if ($ilAccess->checkAccess(
"read",
"", $this->ref_id))
647 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
656 $this->
object->sendFile(
$_GET[
"hist_id"]);
660 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
673 global $rbacsystem, $ilAccess;
675 if (!$ilAccess->checkAccess(
"write",
"",
$_GET[
"ref_id"]))
677 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
680 require_once(
"classes/class.ilHistoryGUI.php");
687 array(
"ref_id" =>
$_GET[
"ref_id"],
"cmd" =>
"versions",
688 "cmdClass" =>
$_GET[
"cmdClass"],
"cmdNode" =>
$_GET[
"cmdNode"]));
690 $this->tpl->setVariable(
"ADM_CONTENT", $hist_html);
700 $this->ctrl->setCmd(
"showSummary");
701 $this->ctrl->setCmdClass(
"ilinfoscreengui");
712 if (!$ilAccess->checkAccess(
"visible",
"", $this->ref_id))
714 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
717 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
720 if ($ilAccess->checkAccess(
"read",
"sendfile", $this->ref_id))
722 $info->addButton($this->lng->txt(
"file_read"), $this->ctrl->getLinkTarget($this,
"sendfile"));
725 $info->enablePrivateNotes();
727 if ($ilAccess->checkAccess(
"read",
"",
$_GET[
"ref_id"]))
733 $info->enableNewsEditing(
false);
734 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
"ref_id"]))
737 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
739 if ($enable_internal_rss)
741 $info->setBlockProperty(
"news",
"settings",
true);
742 $info->setBlockProperty(
"news",
"public_notifications_option",
true);
748 $info->addMetaDataSections($this->object->getId(),0, $this->
object->getType());
750 $info->addSection($this->lng->txt(
"file_info"));
751 $info->addProperty($this->lng->txt(
"filename"),
752 $this->
object->getFileName());
754 $info->addProperty($this->lng->txt(
"type"),
755 $this->
object->guessFileType());
757 $info->addProperty($this->lng->txt(
"size"),
759 $info->addProperty($this->lng->txt(
"version"),
760 $this->
object->getVersion());
763 $this->ctrl->forwardCommand($info);
770 global $rbacsystem, $ilAccess;
774 $this->ctrl->setParameter($this,
"ref_id",$this->ref_id);
776 if ($ilAccess->checkAccess(
"visible",
"", $this->ref_id))
778 $force_active = ($this->ctrl->getNextClass() ==
"ilinfoscreengui"
779 || strtolower(
$_GET[
"cmdClass"]) ==
"ilnotegui")
782 $tabs_gui->addTarget(
"info_short",
783 $this->ctrl->getLinkTargetByClass(
784 array(
"ilobjfilegui",
"ilinfoscreengui"),
"showSummary"),
785 array(
"showSummary",
"",
"infoScreen"),
786 "",
"", $force_active);
789 if ($ilAccess->checkAccess(
"write",
"", $this->ref_id))
791 $tabs_gui->addTarget(
"edit",
792 $this->ctrl->getLinkTarget($this,
"edit"),
"edit",
"");
796 if ($ilAccess->checkAccess(
"write",
"", $this->ref_id))
798 $tabs_gui->addTarget(
"meta_data",
799 $this->ctrl->getLinkTargetByClass(array(
'ilobjfilegui',
'ilmdeditorgui'),
'listSection'),
800 "",
'ilmdeditorgui');
803 if ($ilAccess->checkAccess(
"write",
"", $this->ref_id))
805 $tabs_gui->addTarget(
"versions",
806 $this->ctrl->getLinkTarget($this,
"versions"),
"versions", get_class($this));
809 if ($ilAccess->checkAccess(
"edit_permission",
"", $this->ref_id))
811 $tabs_gui->addTarget(
"perm_settings",
812 $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
"perm"), array(
"perm",
"info",
"owner"),
'ilpermissiongui');
820 if ($ilAccess->checkAccess(
"visible",
"", $a_target))
822 $_GET[
"cmd"] =
"infoScreen";
823 $_GET[
"ref_id"] = $a_target;
824 include(
"repository.php");
827 else if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
829 $_GET[
"cmd"] =
"frameset";
830 $_GET[
"target"] =
"";
831 $_GET[
"ref_id"] = ROOT_FOLDER_ID;
834 include(
"repository.php");
838 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->FATAL);
849 if (is_object($this->
object))
851 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$_GET[
"ref_id"]);