4 require_once
"./Services/Object/classes/class.ilObject2GUI.php";
5 require_once
"./Modules/File/classes/class.ilObjFile.php";
6 require_once
"./Modules/File/classes/class.ilObjFileAccess.php";
37 $next_class = $this->ctrl->getNextClass($this);
38 $cmd = $this->ctrl->getCmd();
40 if($this->id_type == self::WORKSPACE_NODE_ID)
42 include_once
"Services/Form/classes/class.ilFileInputGUI.php";
49 if(IS_PAYMENT_ENABLED)
51 include_once
'./Services/Payment/classes/class.ilPaymentObject.php';
52 if(ANONYMOUS_USER_ID == $ilUser->getId() && isset(
$_GET[
'transaction']))
54 $transaction =
$_GET[
'transaction'];
55 include_once
'./Services/Payment/classes/class.ilPaymentBookings.php';
60 ?
$_GET[
'purchasetype'] : NULL) ))
63 $this->tpl->getStandardTemplate();
65 include_once
'./Services/Payment/classes/class.ilShopPurchaseGUI.php';
67 $ret = $this->ctrl->forwardCommand($pp);
71 else if($this->id_type == self::REPOSITORY_NODE_ID
74 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id", $this->node_id);
75 $link = $ilCtrl->getLinkTargetByClass(
"ilrepositorygui",
"infoScreen");
76 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id",
$_GET[
"ref_id"]);
79 $ilNavigationHistory->addItem($this->node_id,
88 case "ilinfoscreengui":
95 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->WARNING);
98 $ilTabs->activateTab(
"id_meta");
100 include_once
'Services/MetaData/classes/class.ilMDEditorGUI.php';
102 $md_gui =&
new ilMDEditorGUI($this->object->getId(), 0, $this->
object->getType());
103 $md_gui->
addObserver($this->
object,
'MDUpdateListener',
'General');
106 $md_gui->addObserver($this->
object,
'MDUpdateListener',
'Technical');
108 $this->ctrl->forwardCommand($md_gui);
112 case 'ilpermissiongui':
113 $ilTabs->activateTab(
"id_permissions");
114 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
116 $ret =& $this->ctrl->forwardCommand($perm_gui);
120 $ilTabs->activateTab(
"export");
121 include_once(
"./Services/Export/classes/class.ilExportGUI.php");
123 $exp_gui->addFormat(
"xml");
124 $ret = $this->ctrl->forwardCommand($exp_gui);
127 case 'ilobjectcopygui':
128 include_once
'./Services/Object/classes/class.ilObjectCopyGUI.php';
130 $cp->setType(
'file');
131 $this->ctrl->forwardCommand($cp);
135 case "ilworkspaceaccessgui";
136 $ilTabs->activateTab(
"id_permissions");
137 include_once(
'./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php');
139 $this->ctrl->forwardCommand($wspacc);
142 case "ilcommonactiondispatchergui":
143 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
145 $this->ctrl->forwardCommand($gui);
150 if($this->id_type == self::WORKSPACE_NODE_ID)
157 $ilCtrl->setCmd(
"infoScreen");
159 $ilTabs->clearTargets();
179 if($this->id_type == self::WORKSPACE_NODE_ID)
181 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
184 $this->lng->loadLanguageModule(
"file");
186 $this->ctrl->redirect($this,
"cancel");
191 require_once(
"Services/FileUpload/classes/class.ilFileUploadSettings.php");
203 if($this->id_type != self::WORKSPACE_NODE_ID)
218 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
220 $single_form_gui->setMultipart(
true);
224 $in_title->
setInfo($this->lng->txt(
"if_no_title_then_filename"));
227 $single_form_gui->addItem($in_title);
231 $single_form_gui->addItem($in_descr);
236 $single_form_gui->addItem($in_file);
238 $single_form_gui->addCommandButton(
"save", $this->lng->txt($this->type.
"_add"));
239 $single_form_gui->addCommandButton(
"saveAndMeta", $this->lng->txt(
"file_add_and_metadata"));
240 $single_form_gui->addCommandButton(
"cancel", $lng->txt(
"cancel"));
242 $single_form_gui->setTableWidth(
"600px");
244 $single_form_gui->setTitle($this->lng->txt($this->type.
"_new"));
245 $single_form_gui->setTitleIcon(
ilUtil::getImagePath(
'icon_file.png'), $this->lng->txt(
'obj_file'));
247 $this->ctrl->setParameter($this,
"new_type",
"file");
249 $single_form_gui->setFormAction($this->ctrl->getFormAction($this,
"save"));
251 return $single_form_gui;
265 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
270 if ($single_form_gui->checkInput())
272 $title = $single_form_gui->getInput(
"title");
273 $description = $single_form_gui->getInput(
"description");
274 $upload_file = $single_form_gui->getInput(
"upload_file");
276 if (trim($title) ==
"")
278 $title = $upload_file[
"name"];
285 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
287 $title .=
'.'.$fileExtension;
293 include_once(
"./Modules/File/classes/class.ilObjFile.php");
295 $fileObj->setTitle($title);
296 $fileObj->setDescription($description);
297 $fileObj->setFileName($upload_file[
"name"]);
299 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
301 "", $upload_file[
"name"], $upload_file[
"type"]));
302 $fileObj->setFileSize($upload_file[
"size"]);
303 $this->object_id = $fileObj->create();
308 $fileObj->createDirectory();
309 $fileObj->getUploadFile($upload_file[
"tmp_name"],
310 $upload_file[
"name"]);
315 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
321 if ($this->ctrl->getCmd() ==
"saveAndMeta")
323 $this->ctrl->setParameter($this,
"new_type",
"");
324 $target = $this->ctrl->getLinkTargetByClass(array(
"ilobjfilegui",
"ilmdeditorgui"),
"listSection",
"",
false,
false);
329 $this->ctrl->returnToParent($this);
334 $single_form_gui->setValuesByPost();
335 $this->tpl->setContent($single_form_gui->getHTML());
356 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
358 $zip_form_gui->setMultipart(
true);
363 $in_file->setSuffixes(array(
"zip"));
364 $zip_form_gui->addItem($in_file);
367 $in_str =
new ilCheckboxInputGUI($this->lng->txt(
"take_over_structure"),
"adopt_structure");
368 $in_str->
setInfo($this->lng->txt(
"take_over_structure_info"));
369 $zip_form_gui->addItem($in_str);
371 $zip_form_gui->addCommandButton(
"saveUnzip", $this->lng->txt($this->type.
"_add"));
372 $zip_form_gui->addCommandButton(
"cancel", $lng->txt(
"cancel"));
374 $zip_form_gui->setTableWidth(
"600px");
376 $zip_form_gui->setTitle($this->lng->txt(
"header_zip"));
377 $zip_form_gui->setTitleIcon(
ilUtil::getImagePath(
'icon_file.png'), $this->lng->txt(
'obj_file'));
379 $this->ctrl->setParameter($this,
"new_type",
"file");
381 $zip_form_gui->setFormAction($this->ctrl->getFormAction($this,
"saveUnzip"));
383 return $zip_form_gui;
397 if ($zip_form_gui->checkInput())
399 $zip_file = $zip_form_gui->getInput(
"zip_file");
400 $adopt_structure = $zip_form_gui->getInput(
"adopt_structure");
402 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
409 if($this->id_type != self::WORKSPACE_NODE_ID)
426 $containerType =
"WorkspaceFolder";
435 $containerType =
"Category";
441 $containerType =
"Folder";
454 $zip_file[
"tmp_name"],
455 ($adopt_structure && $permission),
468 $this->ctrl->returnToParent($this);
472 $zip_form_gui->setValuesByPost();
473 $this->tpl->setContent($zip_form_gui->getHTML());
478 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
492 if(!$form->checkInput())
494 $ilTabs->activateTab(
"settings");
495 $form->setValuesByPost();
496 $this->tpl->setContent($form->getHTML());
500 $data = $form->getInput(
'file');
503 while (substr(
$data[
"name"],-1) ==
'/')
509 $title = $form->getInput(
'title');
510 if(strlen(trim($title)) == 0)
516 $title = $this->
object->checkFileExtension(
$filename,$title);
518 $this->
object->setTitle($title);
520 if (!empty(
$data[
"name"]))
522 switch($form->getInput(
'replace'))
525 $this->
object->deleteVersions();
526 $this->
object->clearDataDirectory();
527 $this->
object->replaceFile(
$data[
'tmp_name'],
$data[
'name']);
530 $this->
object->addFileVersion(
$data[
'tmp_name'],
$data[
'name']);
533 $this->
object->setFileName(
$data[
'name']);
534 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
537 $this->
object->setFileSize(
$data[
'size']);
540 $this->
object->setDescription($form->getInput(
'description'));
541 $this->
object->setRating($form->getInput(
'rating'));
543 $this->
update = $this->
object->update();
546 if (!empty(
$data[
"name"]))
548 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
556 include_once
'Modules/File/classes/class.ilECSFileSettings.php';
558 $ecs->handleSettingsUpdate();
575 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"));
578 $ilTabs->activateTab(
"settings");
583 $val[
'title'] = $this->
object->getTitle();
584 $val[
'description'] = $this->
object->getLongDescription();
585 $val[
'rating'] = $this->
object->hasRating();
586 $form->setValuesByArray($val);
589 include_once
'Modules/File/classes/class.ilECSFileSettings.php';
591 $ecs->addSettingsToForm($form,
'file');
593 $this->tpl->setContent($form->getHTML());
604 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
606 $this->lng->loadLanguageModule(
'file');
609 $form->setFormAction($this->ctrl->getFormAction($this),
'update');
610 $form->setTitle($this->lng->txt(
'file_edit'));
611 $form->addCommandButton(
'update',$this->lng->txt(
'save'));
612 $form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
615 $title->
setValue($this->object->getTitle());
616 $title->setInfo($this->lng->txt(
"if_no_title_then_filename"));
617 $form->addItem($title);
619 $upload_possible =
true;
620 if($this->id_type == self::WORKSPACE_NODE_ID)
622 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
629 $file->setRequired(
false);
631 $form->addItem(
$file);
636 $replace =
new ilRadioOption($this->lng->txt(
'replace_file'),1);
637 $replace->
setInfo($this->lng->txt(
'replace_file_info'));
638 $group->addOption($replace);
641 $keep =
new ilRadioOption($this->lng->txt(
'file_new_version'),0);
642 $keep->
setInfo($this->lng->txt(
'file_new_version_info'));
643 $group->addOption($keep);
645 $file->addSubItem($group);
650 $file->setValue($this->lng->txt(
"personal_workspace_quota_exceeded_warning"));
651 $form->addItem(
$file);
657 $form->addItem($desc);
659 if($this->id_type == self::REPOSITORY_NODE_ID)
661 $this->lng->loadLanguageModule(
'rating');
663 $rate->
setInfo($this->lng->txt(
'rating_activate_rating_info'));
664 $form->addItem($rate);
674 if(ANONYMOUS_USER_ID == $ilUser->getId() && isset(
$_GET[
'transaction']) )
676 $this->
object->sendFile(
$_GET[
"hist_id"]);
682 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
686 $this->
object->getId(), $ilUser->getId());
689 $this->
object->sendFile(
$_GET[
"hist_id"]);
693 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
708 $ilTabs->activateTab(
"id_versions");
712 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
716 $versions = $this->
object->getVersions();
719 require_once(
"Modules/File/classes/class.ilFileVersionTableGUI.php");
721 $table->setMaxCount(
sizeof($versions));
722 $table->setData($versions);
724 $this->tpl->setVariable(
"ADM_CONTENT", $table->getHTML());
734 $this->ctrl->setCmd(
"showSummary");
735 $this->ctrl->setCmdClass(
"ilinfoscreengui");
746 $ilTabs->activateTab(
"id_info");
750 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_read"));
753 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
759 $this->lng->loadLanguageModule(
"file");
762 if ($this->id_type == self::REPOSITORY_NODE_ID)
765 $info->addButton($this->lng->txt(
"file_download"), $this->ctrl->getLinkTarget($this,
"sendfile"),
"",
"top",
true);
768 $info->enablePrivateNotes();
776 $info->enableNewsEditing(
false);
780 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
782 if ($enable_internal_rss)
784 $info->setBlockProperty(
"news",
"settings",
true);
785 $info->setBlockProperty(
"news",
"public_notifications_option",
true);
791 $info->addMetaDataSections($this->object->getId(),0, $this->
object->getType());
793 $info->addSection($this->lng->txt(
"file_info"));
794 $info->addProperty($this->lng->txt(
"filename"),
795 $this->
object->getFileName());
797 $info->addProperty($this->lng->txt(
"type"),
798 $this->
object->guessFileType());
800 $info->addProperty($this->lng->txt(
"size"),
802 $info->addProperty($this->lng->txt(
"version"),
803 $this->
object->getVersion());
806 $uploader = $this->
object->getVersions();
807 $uploader = array_shift($uploader);
808 $uploader = $uploader[
"user_id"];
810 $this->lng->loadLanguageModule(
"file");
811 include_once
"Services/User/classes/class.ilUserUtil.php";
815 if ($this->id_type == self::REPOSITORY_NODE_ID && $this->
checkPermissionBool(
"read",
"sendfile"))
817 $tpl =
new ilTemplate(
"tpl.download_link.html",
true,
true,
"Modules/File");
819 $info->addProperty($this->lng->txt(
"download_link"),
$tpl->get());
822 if($this->id_type == self::WORKSPACE_NODE_ID)
828 include_once(
"./Services/Preview/classes/class.ilPreview.php");
829 if (!$this->ctrl->isAsynch() &&
833 include_once(
"./Services/Preview/classes/class.ilPreviewGUI.php");
837 switch ($this->id_type)
839 case self::WORKSPACE_NODE_ID:
840 case self::WORKSPACE_OBJECT_ID:
850 $info->addProperty($this->lng->txt(
"preview"),
$preview->getInlineHTML());
856 $this->ctrl->forwardCommand($info);
863 global $ilTabs,
$lng, $ilHelp;
865 $ilHelp->setScreenIdComponent(
"file");
867 $this->ctrl->setParameter($this,
"ref_id",$this->node_id);
871 $ilTabs->addTab(
"id_info",
872 $lng->txt(
"info_short"),
873 $this->ctrl->getLinkTargetByClass(array(
"ilobjfilegui",
"ilinfoscreengui"),
"showSummary"));
878 $ilTabs->addTab(
"settings",
880 $this->ctrl->getLinkTarget($this,
"edit"));
885 $ilTabs->addTab(
"id_versions",
886 $lng->txt(
"versions"),
887 $this->ctrl->getLinkTarget($this,
"versions"));
893 $ilTabs->addTab(
"id_meta",
894 $lng->txt(
"meta_data"),
895 $this->ctrl->getLinkTargetByClass(array(
'ilobjfilegui',
'ilmdeditorgui'),
'listSection'));
901 $ilTabs->addTab(
"export",
903 $this->ctrl->getLinkTargetByClass(
"ilexportgui",
""));
910 function _goto($a_target, $a_additional = null)
914 if($a_additional && substr($a_additional, -3) ==
"wsp")
916 $_GET[
"baseClass"] =
"ilsharedresourceGUI";
917 $_GET[
"wsp_id"] = $a_target;
918 include(
"ilias.php");
923 if($a_additional && substr($a_additional, -8) ==
"download")
930 if ($ilAccess->checkAccess(
"visible",
"", $a_target))
934 else if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
941 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->FATAL);
951 if (is_object($this->
object))
953 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$this->node_id);
964 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
966 $dnd_form_gui->setMultipart(
true);
967 $dnd_form_gui->setHideLabels();
970 include_once(
"Services/Form/classes/class.ilDragDropFileInputGUI.php");
973 $dnd_input->setCommandButtonNames(
"uploadFiles",
"cancel");
974 $dnd_form_gui->addItem($dnd_input);
977 $dnd_form_gui->addCommandButton(
"uploadFiles", $this->lng->txt(
"upload_files"));
978 $dnd_form_gui->addCommandButton(
"cancel", $this->lng->txt(
"cancel"));
980 $dnd_form_gui->setTableWidth(
"100%");
982 $dnd_form_gui->setTitle($this->lng->txt(
"upload_files_title"));
983 $dnd_form_gui->setTitleIcon(
ilUtil::getImagePath(
'icon_file.gif'), $this->lng->txt(
'obj_file'));
985 $this->ctrl->setParameter($this,
"new_type",
"file");
986 $dnd_form_gui->setFormAction($this->ctrl->getFormAction($this,
"uploadFiles"));
988 return $dnd_form_gui;
996 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
998 $response =
new stdClass();
999 $response->error = null;
1000 $response->debug = null;
1006 if ($dnd_form_gui->checkInput())
1012 $response->error = $this->lng->txt(
"permission_denied");
1017 $fileresult = $this->
handleFileUpload($dnd_form_gui->getInput(
"upload_files"));
1019 $response = (object)array_merge((array)$response, (array)$fileresult);
1024 $response->error = $ex->getMessage() .
" ## " . $ex->getTraceAsString();
1029 $dnd_input = $dnd_form_gui->getItemByPostVar(
"upload_files");
1030 $response->error = $dnd_input->getAlert();
1034 header(
'Vary: Accept');
1035 header(
'Content-type: text/plain');
1056 $temp_name = $file_upload[
"tmp_name"];
1065 $response =
new stdClass();
1067 $response->fileSize = intval(
$size);
1068 $response->fileType = $type;
1069 $response->fileUnzipped = $extract;
1070 $response->error = null;
1076 $adopt_structure = $keep_structure;
1078 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
1085 if($this->id_type != self::WORKSPACE_NODE_ID)
1101 $containerType =
"WorkspaceFolder";
1110 $containerType =
"Category";
1116 $containerType =
"Folder";
1132 ($adopt_structure && $permission),
1140 $response->error = $e->getMessage();
1144 $response->error = $ex->getMessage();
1151 if (trim($title) ==
"")
1160 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
1162 $title .=
'.'.$fileExtension;
1168 include_once(
"./Modules/File/classes/class.ilObjFile.php");
1170 $fileObj->setTitle($title);
1171 $fileObj->setDescription($description);
1174 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1176 $fileObj->setFileSize(
$size);
1177 $this->object_id = $fileObj->create();
1182 $fileObj->createDirectory();
1183 $fileObj->raiseUploadError(
false);
1184 $fileObj->getUploadFile($temp_name,
$filename);
1189 require_once(
'./Services/Tracking/classes/class.ilChangeEvent.php');
1202 global $ilTabs, $ilLocator;
1206 $version_ids = isset(
$_GET[
"hist_id"]) ? array(
$_GET[
"hist_id"]) :
$_POST[
"hist_id"];
1208 if (count($version_ids) < 1)
1211 $this->ctrl->redirect($this,
"versions");
1215 $ilTabs->activateTab(
"id_versions");
1218 $versionsToKeep = array_udiff($this->object->getVersions(), $version_ids, array($this,
"compareHistoryIds"));
1219 if (count($versionsToKeep) < 1)
1225 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
1227 $conf_gui->setFormAction($this->ctrl->getFormAction($this,
"versions"));
1228 $conf_gui->setCancel($this->lng->txt(
"cancel"),
"cancelDeleteFile");
1229 $conf_gui->setConfirm($this->lng->txt(
"confirm"),
"confirmDeleteFile");
1231 $conf_gui->addItem(
"id[]", $this->ref_id, $this->object->getTitle(),
1233 $this->lng->txt(
"icon").
" ".$this->lng->txt(
"obj_".$this->object->getType()));
1235 $html = $conf_gui->getHTML();
1239 include_once(
"./Modules/File/classes/class.ilFileVersionTableGUI.php");
1242 $versions = $this->
object->getVersions($version_ids);
1245 $table->setMaxCount(
sizeof($versions));
1246 $table->setData($versions);
1248 $html = $table->getHTML();
1251 $this->tpl->setVariable(
'ADM_CONTENT', $html);
1265 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"), $this->ilErr->MESSAGE);
1269 if (count(
$_POST[
"hist_id"]) > 0)
1271 $this->
object->deleteVersions(
$_POST[
"hist_id"]);
1275 $this->ctrl->setParameter($this,
"hist_id",
"");
1276 $this->ctrl->redirect($this,
"versions");
1284 $this->ctrl->redirect($this,
"versions");
1295 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"), $this->ilErr->MESSAGE);
1299 include_once(
"./Services/Repository/classes/class.ilRepUtilGUI.php");
1301 $ru->deleteObjects($this->parent_id, array($this->ref_id));
1304 $this->ctrl->setParameterByClass(
"ilrepositorygui",
"ref_id", $this->parent_id);
1305 $this->ctrl->redirectByClass(
"ilrepositorygui");
1313 $this->ctrl->redirect($this,
"versions");
1326 $v1 = (int)$v1[
"hist_entry_id"];
1327 else if (!is_int($v1))
1331 $v2 = (
int)$v2[
"hist_entry_id"];
1332 else if (!is_int($v2))
1348 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"), $this->ilErr->MESSAGE);
1353 $version_ids = isset(
$_GET[
"hist_id"]) ? array(
$_GET[
"hist_id"]) :
$_POST[
"hist_id"];
1356 if (count($version_ids) != 1)
1359 $this->ctrl->redirect($this,
"versions");
1363 $new_version = $this->
object->rollback($version_ids[0]);
1365 ilUtil::sendSuccess(sprintf($this->lng->txt(
"file_rollback_done"), $new_version[
"rollback_version"]),
true);
1366 $this->ctrl->redirect($this,
"versions");
1374 if($this->object->hasRating())
1376 $lg->enableRating(
true, null,
false,
1377 array(
"ilcommonactiondispatchergui",
"ilratinggui"));