74 private \ILIAS\ResourceStorage\Services
$storage;
100 $this->
ctrl = $DIC->ctrl();
101 $this->tpl = $DIC->ui()->mainTemplate();
102 $this->
tabs = $DIC->tabs();
103 $this->
http = $DIC->http();
104 $this->
lng = $DIC->language();
105 $this->ref_id = $this->
http->wrapper()->query()->retrieve(
'ref_id', $DIC->refinery()->kindlyTo()->int());
106 $this->
toolbar = $DIC->toolbar();
107 $this->
access = $DIC->access();
108 $this->storage = $DIC->resourceStorage();
109 $this->file_service_settings = $DIC->fileServiceSettings();
110 $this->
ui = $DIC->ui();
114 $this->lom_services = $DIC->learningObjectMetadata();
116 $this->parent_id = $this->tree->getParentId($this->file->getRefId()) ?? $this->
getParentIdType();
118 $this->version_id = $this->
http->wrapper()->query()->has(self::HIST_ID)
119 ? $this->
http->wrapper()->query()->retrieve(self::HIST_ID, $DIC->refinery()->kindlyTo()->int())
133 match ($this->
ctrl->getCmd(self::CMD_DEFAULT)) {
134 self::CMD_DEFAULT => $this->
index(),
147 self::CMD_PUBLISH => $this->
publish(),
148 self::CMD_UNPUBLISH => $this->
unpublish()
157 $this->
tabs->clearTargets();
158 $this->
tabs->setBackTarget(
159 $this->
lng->txt(
'back'),
160 $this->
ctrl->getLinkTarget($this, self::CMD_DEFAULT)
168 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
169 $this->
ctrl->returnToParent($this);
171 switch ($this->
ctrl->getNextClass()) {
172 case strtolower(ilFileVersionsUploadHandlerGUI::class):
173 $this->
ctrl->forwardCommand(
179 case strtolower(ilWOPIEmbeddedApplicationGUI::class):
180 $action = $this->action_repo->getEditActionForSuffix(
181 $this->current_revision->getInformation()->getSuffix()
185 $this->current_revision->getIdentification(),
188 new URI(rtrim(ILIAS_HTTP_PATH,
"/") .
"/" . $this->
ctrl->getLinkTarget($this, self::CMD_DEFAULT))
191 $this->
ctrl->forwardCommand(
206 $this->tpl->setContent(
207 $this->
ui->renderer()->render(
215 $this->file->enableNotification();
217 $this->file->updateObjectFromCurrentRevision();
218 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
219 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
224 $this->file->enableNotification();
225 if ($this->current_revision->getVersionNumber() === 1) {
226 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_cant_unpublish'),
true);
227 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
231 $this->file->updateObjectFromCurrentRevision();
232 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
233 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
239 $data = $form->getData();
242 $file_rid = $this->storage->manage()->find(
$data[self::KEY_FILE_RID]);
243 if (
null !== $file_rid) {
244 $copyright_id =
$data[self::KEY_COPYRIGHT_OPTION][1][self::KEY_COPYRIGHT_ID] ??
null;
246 $processor->process($file_rid, null, null, $copyright_id);
248 if ($processor->getInvalidFileNames() !== []) {
249 $this->
ui->mainTemplate()->setOnScreenMessage(
252 $this->
lng->txt(
'file_upload_info_file_with_critical_extension'),
253 implode(
', ', $processor->getInvalidFileNames())
259 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_unzip_success'),
true);
260 $this->
ctrl->setParameterByClass(ilRepositoryGUI::class,
"ref_id", $this->parent_id);
261 $this->
ctrl->redirectByClass(ilRepositoryGUI::class);
264 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'file_not_found'));
267 $this->tpl->setContent(
268 $this->
ui->renderer()->render(
277 $status = $this->current_revision?->getStatus();
279 $btn_add_version = $this->
ui->factory()->button()->standard(
280 $this->
lng->txt(
'file_new_version'),
281 $this->
ctrl->getLinkTarget($this, self::CMD_ADD_NEW_VERSION)
284 $btn_add_version = $btn_add_version->withUnavailableAction();
286 $this->
toolbar->addComponent($btn_add_version);
288 $btn_replace_version = $this->
ui->factory()->button()->standard(
289 $this->
lng->txt(
'replace_file'),
290 $this->
ctrl->getLinkTarget($this, self::CMD_ADD_REPLACING_VERSION)
293 $btn_replace_version = $btn_replace_version->withUnavailableAction();
295 $this->
toolbar->addComponent($btn_replace_version);
298 if (
null !== $this->current_revision &&
299 in_array($this->current_revision->getInformation()->getMimeType(), [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED],
true)
301 $btn_unzip = $this->
ui->factory()->button()->standard(
302 $this->
lng->txt(
'unzip'),
303 $this->
ctrl->getLinkTarget($this, self::CMD_UNZIP_CURRENT_REVISION)
305 $this->
toolbar->addComponent($btn_unzip);
309 $suffix = $this->current_revision?->getInformation()?->getSuffix();
311 if ($this->action_repo->hasEditActionForSuffix(
312 $this->current_revision->getInformation()->getSuffix()
314 $external_editor = $this->
ui->factory()
317 $this->
lng->txt(
'open_external_editor'),
318 $this->
ctrl->getLinkTargetByClass(
319 [self::class, ilWOPIEmbeddedApplicationGUI::class],
323 $this->
toolbar->addComponent($external_editor);
329 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'file_version_draft_info'));
331 $btn_publish = $this->
ui->factory()->button()->standard(
332 $this->
lng->txt(
'file_publish'),
333 $this->
ctrl->getLinkTarget($this, self::CMD_PUBLISH)
335 $this->
toolbar->addComponent($btn_publish);
339 $this->tpl->setContent($table->getHTML());
347 $this->tpl->setContent($form->getHTML());
357 if ($form->saveObject()) {
358 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
359 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
361 $this->tpl->setContent($form->getHTML());
367 $this->file->sendFile($this->version_id);
377 if (count($version_ids) !== 1) {
378 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"file_rollback_select_exact_one"),
true);
379 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
383 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"file_rollback_rollback_first"),
true);
384 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
388 $version_id = $version_ids[0];
389 if ($version_id === $this->current_revision->getVersionNumber()) {
390 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"file_rollback_same_version"),
true);
391 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
394 $this->file->rollback($version_id);
396 $this->tpl->setOnScreenMessage(
'success', sprintf($this->
lng->txt(
"file_rollback_done"), (string) $version_id),
true);
397 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
404 if (is_array($versions_to_delete) && $versions_to_delete !== []) {
405 $this->file->deleteVersions($versions_to_delete);
406 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"file_versions_deleted"),
true);
409 $this->
ctrl->setParameter($this, self::HIST_ID,
"");
410 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
415 $parent_id = $this->tree->getParentId($this->ref_id);
420 $this->
ctrl->setParameterByClass(ilRepositoryGUI::class,
"ref_id", $parent_id);
421 $this->
ctrl->redirectByClass(ilRepositoryGUI::class);
431 if (
'GET' === $this->
http->request()->getMethod() &&
432 $this->
http->wrapper()->query()->has(self::HIST_ID)
435 $this->
http->wrapper()->query()->retrieve(self::HIST_ID, $this->
refinery->kindlyTo()->int()),
440 if ($this->
http->wrapper()->post()->has(
'interruptive_items')) {
441 return $this->
http->wrapper()->post()->retrieve(
442 'interruptive_items',
447 if ($this->
http->wrapper()->post()->has(self::HIST_ID)) {
448 return $this->
http->wrapper()->post()->retrieve(
459 $versions_to_keep = $this->file->getVersions();
460 array_udiff($versions_to_keep, $version_ids,
static function ($v1, $v2):
bool {
462 $v1 = (
int) $v1[
"hist_entry_id"];
463 } elseif (!is_numeric($v1)) {
467 if (is_array($v2) || $v2 instanceof ilObjFileVersion) {
468 $v2 = (
int) $v2[
"hist_entry_id"];
469 } elseif (!is_numeric($v2)) {
476 return $versions_to_keep;
489 if ($this->wsp_access->checkAccess($a_permission,
"", $this->ref_id)) {
492 } elseif ($this->
access->checkAccess($a_permission,
'', $this->ref_id)) {
504 $this->
http->saveResponse(
505 $this->
http->response()->withBody(
507 (
null !== $delete_selected_versions_modal) ?
508 $this->
ui->renderer()->renderAsync([$delete_selected_versions_modal]) :
511 )->withHeader(
'Content-Type',
'application/json; charset=utf-8')
514 $this->
http->sendResponse();
515 $this->
http->close();
521 $existing_versions = $this->file->getVersions();
523 $non_deletion_versions = array_udiff(
525 $deletion_version_ids,
526 static function (
$a,
$b):
int|
float {
528 $a =
$a->getHistEntryId();
530 if (
$b instanceof ilObjFileVersion) {
531 $b =
$b->getHistEntryId();
539 if (count($non_deletion_versions) < 1) {
540 return $this->file_component_builder->buildConfirmDeleteAllVersionsModal(
541 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_FILE),
547 if (count($non_deletion_versions) >= 1) {
548 return $this->file_component_builder->buildConfirmDeleteSpecificVersionsModal(
549 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_VERSIONS),
551 $deletion_version_ids
564 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'publish_before_delete'), $redirect);
566 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
571 if (count($requested_deletion_version) < 1) {
572 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_checkbox"), $redirect);
574 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
584 $existing_versions = $this->file->getVersions();
585 $remaining_versions = array_udiff(
588 static function (
$a,
$b):
int|
float {
590 $a =
$a->getHistEntryId();
592 if (
$b instanceof ilObjFileVersion) {
593 $b =
$b->getHistEntryId();
602 $conf_gui->setFormAction($this->
ctrl->getFormAction($this, self::CMD_DEFAULT));
603 $conf_gui->setCancel($this->
lng->txt(
"cancel"), self::CMD_DEFAULT);
606 $alt = $this->
lng->txt(
"icon") .
" " . $this->
lng->txt(
"obj_" . $this->file->getType());
609 if (count($remaining_versions) < 1) {
611 $conf_gui->setHeaderText($this->
lng->txt(
'file_confirm_delete_all_versions'));
612 $conf_gui->setConfirm($this->
lng->txt(
"confirm"), self::CMD_CONFIRMED_DELETE_FILE);
616 $this->file->getTitle(),
622 $conf_gui->setHeaderText($this->
lng->txt(
'file_confirm_delete_versions'));
623 $conf_gui->setConfirm($this->
lng->txt(
"confirm"), self::CMD_CONFIRMED_DELETE_VERSIONS);
625 foreach ($this->file->getVersions($version_ids) as
$version) {
626 $a_text =
$version[
'filename'] ??
$version->getFilename() ?? $this->file->getTitle();
628 $a_text .=
" (v" . $version_string .
")";
639 $this->tpl->setContent($conf_gui->getHTML());
645 $copyright_options = [];
646 $form_action = $this->
ctrl->getFormActionByClass(self::class, self::CMD_PROCESS_UNZIP);
648 $inputs[self::KEY_FILE_RID] = $this->
ui->factory()->input()->field()->hidden()->withValue(
649 $this->file->getResourceId()
651 $inputs[self::KEY_FILE_STRUCTURE] = $this->
ui->factory()->input()->field()->checkbox(
652 $this->
lng->txt(
'take_over_structure'),
653 $this->
lng->txt(
'take_over_structure_info'),
656 if (!$this->lom_services->copyrightHelper()->isCopyrightSelectionActive()) {
657 return $this->
ui->factory()->input()->container()->form()->standard($form_action,
$inputs);
660 $lom_reader = $this->lom_services->read($this->file->getId(), 0, $this->file->getType());
661 $lom_cp_helper = $this->lom_services->copyrightHelper();
663 if ($lom_cp_helper->hasPresetCopyright($lom_reader)) {
664 $zip_copyright = $lom_cp_helper->readPresetCopyright($lom_reader);
665 $zip_copyright_id = $zip_copyright->identifier();
666 $zip_copyright_title = $zip_copyright->title();
668 $zip_copyright_id = $zip_copyright_title = $lom_cp_helper->readCustomCopyright($lom_reader);
670 if ($zip_copyright_id !==
'') {
671 $copyright_inheritance_input = $this->
ui->factory()->input()->field()->hidden()->withValue(
674 $copyright_options[self::KEY_INHERIT_COPYRIGHT] = $this->
ui->factory()->input()->field()->group(
675 [self::KEY_COPYRIGHT_ID => $copyright_inheritance_input],
676 $this->
lng->txt(
"copyright_inherited"),
678 $this->
lng->txt(
"copyright_inherited_info"),
684 $copyright_selection_input = $this->getCopyrightSelectionInput(
'set_license_for_all_files');
685 $copyright_options[self::KEY_SELECT_COPYRIGHT] = $this->
ui->factory()->input()->field()->group(
686 [self::KEY_COPYRIGHT_ID => $copyright_selection_input],
687 $this->
lng->txt(
"copyright_custom"),
688 $this->
lng->txt(
"copyright_custom_info")
691 $inputs[self::KEY_COPYRIGHT_OPTION] = $this->
ui->factory()->input()->field()->switchableGroup(
693 $this->
lng->txt(
"md_copyright")
694 )->
withValue(self::KEY_SELECT_COPYRIGHT);
696 return $this->
ui->factory()->input()->container()->form()->standard($form_action,
$inputs);
703 if ($keep_structure) {
707 $this->file->getId(),
712 $this->file_service_settings,
720 $this->file->getId(),
725 $this->file_service_settings,
732 return $this->storage->manage()->find($this->file->getResourceId());
738 if (
null !== $file_rid) {
739 return $this->storage->manage()->getCurrentRevisionIncludingDraft($file_rid);
754 return $this->
http->wrapper()->query()->has(
'wsp_id');
759 return $this->
ui->factory();
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getVersionIdsFromRequest()
const CMD_DELETE_VERSIONS
Class ilObjFileStakeholder.
__construct(private ilObjFile $file)
ilFileVersionsGUI constructor.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
getDeleteSelectedVersionsModal()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilObjFileProcessorInterface.
saveVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
Interface Observer Contains several chained tasks and infos about them.
static deleteObjects(int $a_cur_ref_id, array $a_ids)
Delete objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS ResourceStorage Services $storage
const CMD_DOWNLOAD_VERSION
LOMServices $lom_services
ilGlobalTemplateInterface $tpl
const CMD_CONFIRMED_DELETE_VERSIONS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Provides fluid interface to RBAC services.
Revision $current_revision
static http()
Fetches the global http state from ILIAS.
ilWorkspaceAccessHandler $wsp_access
const KEY_SELECT_COPYRIGHT
hasPermission(string $a_permission)
bugfix mantis 26007: this function was created to ensure that the access check not only works for rep...
addVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
const CMD_UNZIP_CURRENT_REVISION
Class ResourceIdentification.
Class ilFileVersionsUploadHandlerGUI.
ilObjFileComponentBuilder $file_component_builder
Class ilFileVersionsTableGUI.
const CMD_CONFIRMED_DELETE_FILE
renderDeleteSelectedVersionsModal()
const CMD_ADD_REPLACING_VERSION
getVersionsToKeep(array $version_ids)
GUI class for file objects.
const KEY_INHERIT_COPYRIGHT
ActionRepository $action_repo
const CMD_ADD_NEW_VERSION
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
ilFileServicesSettings $file_service_settings
Indicates that a file is missing or not found.
const CMD_ROLLBACK_VERSION
getFileProcessor(bool $keep_structure)
Class ilObjFileUnzipRecursiveProcessor.
const KEY_COPYRIGHT_OPTION
const CMD_CREATE_REPLACING_VERSION
const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL
const CMD_CREATE_NEW_VERSION
checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect)
Class ilObjFileUnzipFlatProcessor.