75 private ?VersionsTable
$table =
null;
76 private \ILIAS\ResourceStorage\Services
$storage;
104 $this->
ctrl = $DIC->ctrl();
105 $this->tpl =
$DIC->ui()->mainTemplate();
106 $this->
tabs = $DIC->tabs();
107 $this->
http = $DIC->http();
108 $this->
lng = $DIC->language();
109 $this->ref_id = $this->
http->wrapper()->query()->retrieve(
'ref_id', $DIC->refinery()->kindlyTo()->int());
110 $this->
toolbar = $DIC->toolbar();
111 $this->
access = $DIC->access();
112 $this->storage =
$DIC->resourceStorage();
113 $this->file_service_settings =
$DIC->fileServiceSettings();
114 $this->
ui = $DIC->ui();
118 $this->lom_services =
$DIC->learningObjectMetadata();
120 $this->parent_id = $this->tree->getParentId($this->file->getRefId()) ?? $this->
getParentIdType();
122 $this->version_id = $this->
http->wrapper()->query()->has(self::HIST_ID)
123 ? $this->
http->wrapper()->query()->retrieve(self::HIST_ID,
$DIC->refinery()->kindlyTo()->int())
137 match ($this->
ctrl->getCmd(self::CMD_DEFAULT)) {
138 self::CMD_DEFAULT => $this->
index(),
150 self::CMD_PUBLISH => $this->
publish(),
151 self::CMD_UNPUBLISH => $this->
unpublish()
160 $this->
tabs->clearTargets();
161 $this->
tabs->setBackTarget(
162 $this->
lng->txt(
'back'),
163 $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT)
171 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
172 $this->
ctrl->returnToParent($this);
174 switch ($this->
ctrl->getNextClass()) {
175 case strtolower(ilFileVersionsUploadHandlerGUI::class):
176 $this->
ctrl->forwardCommand(
182 case strtolower(ilWOPIEmbeddedApplicationGUI::class):
183 $action = $this->action_repo->getEditActionForSuffix(
184 $this->current_revision->getInformation()->getSuffix()
188 $cap = $this->capabilities->getBestOf(
189 Capabilities::MANAGE_VERSIONS,
190 Capabilities::VIEW_EXTERNAL,
191 Capabilities::INFO_PAGE
193 $goto_link = $cap->getUri();
196 $this->current_revision->getIdentification(),
201 $this->
lng->getLangKey()
204 $this->
ctrl->forwardCommand(
219 $this->tpl->setContent(
220 $this->
ui->renderer()->render(
221 $this->getFileZipOptionsForm()
228 $this->file->enableNotification();
230 $this->file->updateObjectFromCurrentRevision();
231 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
232 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
237 $this->file->enableNotification();
238 if ($this->current_revision->getVersionNumber() === 1) {
239 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_cant_unpublish'),
true);
240 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
244 $this->file->updateObjectFromCurrentRevision();
245 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
246 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
252 $data = $form->getData();
255 $file_rid = $this->storage->manage()->find(
$data[self::KEY_FILE_RID]);
256 if (
null !== $file_rid) {
259 $processor->process($file_rid,
null,
null, $copyright_id);
261 if ($processor->getInvalidFileNames() !== []) {
262 $this->
ui->mainTemplate()->setOnScreenMessage(
265 $this->
lng->txt(
'file_upload_info_file_with_critical_extension'),
266 implode(
', ', $processor->getInvalidFileNames())
272 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_unzip_success'),
true);
273 $this->
ctrl->setParameterByClass(ilRepositoryGUI::class,
"ref_id", $this->parent_id);
274 $this->
ctrl->redirectByClass(ilRepositoryGUI::class);
277 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'file_not_found'));
280 $this->tpl->setContent(
281 $this->
ui->renderer()->render(
282 $this->getFileZipOptionsForm()
290 $status = $this->current_revision?->getStatus();
292 $btn_add_version = $this->
ui->factory()->button()->standard(
293 $this->
lng->txt(
'file_new_version'),
294 $this->ctrl->getLinkTarget($this, self::CMD_ADD_NEW_VERSION)
297 $btn_add_version = $btn_add_version->withUnavailableAction();
299 $this->
toolbar->addComponent($btn_add_version);
301 $btn_replace_version = $this->
ui->factory()->button()->standard(
302 $this->
lng->txt(
'replace_file'),
303 $this->ctrl->getLinkTarget($this, self::CMD_ADD_REPLACING_VERSION)
306 $btn_replace_version = $btn_replace_version->withUnavailableAction();
308 $this->
toolbar->addComponent($btn_replace_version);
311 if (
null !== $this->current_revision &&
312 in_array($this->current_revision->getInformation()->getMimeType(), [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED],
true)
314 $btn_unzip = $this->
ui->factory()->button()->standard(
315 $this->
lng->txt(
'unzip'),
316 $this->ctrl->getLinkTarget($this, self::CMD_UNZIP_CURRENT_REVISION)
318 $this->
toolbar->addComponent($btn_unzip);
322 $this->current_revision?->getInformation()?->getSuffix();
324 if ($this->action_repo->hasEditActionForSuffix(
325 $this->current_revision->getInformation()->getSuffix()
327 $external_editor = $this->
ui->factory()
330 $this->
lng->txt(
'open_external_editor'),
331 $this->ctrl->getLinkTargetByClass(
332 [self::class, ilWOPIEmbeddedApplicationGUI::class],
336 $this->
toolbar->addComponent($external_editor);
342 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'file_version_draft_info'));
344 $btn_publish = $this->
ui->factory()->button()->standard(
345 $this->
lng->txt(
'file_publish'),
346 $this->ctrl->getLinkTarget($this, self::CMD_PUBLISH)
348 $this->
toolbar->addComponent($btn_publish);
351 $this->tpl->setContent($this->
getTable()->getHTML());
359 $this->tpl->setContent($form->getHTML());
369 if ($form->saveObject()) {
370 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
371 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
373 $this->tpl->setContent($form->getHTML());
379 $this->file->sendFile($this->version_id);
389 if (count($version_ids) !== 1) {
390 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"file_rollback_select_exact_one"),
true);
391 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
395 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"file_rollback_rollback_first"),
true);
396 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
401 if (
$version_id === $this->current_revision->getVersionNumber()) {
402 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"file_rollback_same_version"),
true);
403 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
408 $this->tpl->setOnScreenMessage(
'success', sprintf($this->
lng->txt(
"file_rollback_done"), (
string) $version_id),
true);
409 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
416 if ($versions_to_delete !== []) {
417 $this->file->deleteVersions($versions_to_delete);
418 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"file_versions_deleted"),
true);
421 $this->
ctrl->setParameter($this, self::HIST_ID,
"");
422 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
427 $parent_id = $this->tree->getParentId($this->ref_id);
432 $this->
ctrl->setParameterByClass(ilRepositoryGUI::class,
"ref_id",
$parent_id);
433 $this->
ctrl->redirectByClass(ilRepositoryGUI::class);
443 return $this->table ??=
new VersionsTable($this);
448 $token_name = $this->
getTable()->getIdToken()->getName();
449 $query_params = $this->
http->request()->getQueryParams();
451 if (array_key_exists($token_name, $query_params)) {
452 $raw = $query_params[$token_name];
453 $values = is_array($raw) ? $raw : [$raw];
454 return array_values(array_map(
static fn($v):
int => (
int) $v, $values));
458 if ($this->
http->wrapper()->post()->has(
'interruptive_items')) {
459 return $this->
http->wrapper()->post()->retrieve(
460 'interruptive_items',
461 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
465 if ($this->
http->wrapper()->query()->has(self::HIST_ID)) {
467 $this->
http->wrapper()->query()->retrieve(self::HIST_ID, $this->
refinery->kindlyTo()->int()),
484 if ($this->wsp_access->checkAccess($a_permission,
"", $this->ref_id)) {
487 } elseif ($this->
access->checkAccess($a_permission,
'', $this->ref_id)) {
499 $this->
http->saveResponse(
500 $this->
http->response()->withBody(
502 (
null !== $delete_selected_versions_modal) ?
503 $this->ui->renderer()->renderAsync([$delete_selected_versions_modal]) :
506 )->withHeader(
'Content-Type',
'application/json; charset=utf-8')
509 $this->
http->sendResponse();
510 $this->
http->close();
516 $existing_versions = $this->file->getVersions();
518 $non_deletion_versions = array_udiff(
520 $deletion_version_ids,
521 static function (
$a,
$b):
int|
float {
523 $a =
$a->getHistEntryId();
526 $b =
$b->getHistEntryId();
534 if (count($non_deletion_versions) < 1) {
535 return $this->file_component_builder->buildConfirmDeleteAllVersionsModal(
536 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_FILE),
541 return $this->file_component_builder->buildConfirmDeleteSpecificVersionsModal(
542 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_VERSIONS),
544 $deletion_version_ids
555 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'publish_before_delete'), $redirect);
557 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
562 if (count($requested_deletion_version) < 1) {
563 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_checkbox"), $redirect);
565 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
573 $copyright_options = [];
574 $form_action = $this->
ctrl->getFormActionByClass(self::class, self::CMD_PROCESS_UNZIP);
577 $this->file->getResourceId()
580 $this->
lng->txt(
'take_over_structure'),
581 $this->lng->txt(
'take_over_structure_info'),
584 if (!$this->lom_services->copyrightHelper()->isCopyrightSelectionActive()) {
585 return $this->
ui->factory()->input()->container()->form()->standard($form_action,
$inputs);
588 $lom_reader = $this->lom_services->read($this->file->getId(), 0, $this->file->getType());
589 $lom_cp_helper = $this->lom_services->copyrightHelper();
591 if ($lom_cp_helper->hasPresetCopyright($lom_reader)) {
592 $zip_copyright = $lom_cp_helper->readPresetCopyright($lom_reader);
593 $zip_copyright_id = $zip_copyright->identifier();
594 $zip_copyright_title = $zip_copyright->title();
596 $zip_copyright_id = $zip_copyright_title = $lom_cp_helper->readCustomCopyright($lom_reader);
598 if ($zip_copyright_id !==
'') {
599 $copyright_inheritance_input = $this->
ui->factory()->input()->field()->hidden()->withValue(
603 [self::KEY_COPYRIGHT_ID => $copyright_inheritance_input],
604 $this->
lng->txt(
"copyright_inherited"),
606 $this->
lng->txt(
"copyright_inherited_info"),
612 $copyright_selection_input = $this->getCopyrightSelectionInput(
'set_license_for_all_files');
614 [self::KEY_COPYRIGHT_ID => $copyright_selection_input],
615 $this->
lng->txt(
"copyright_custom"),
616 $this->lng->txt(
"copyright_custom_info")
621 $this->
lng->txt(
"md_copyright")
622 )->withValue(self::KEY_SELECT_COPYRIGHT);
624 return $this->
ui->factory()->input()->container()->form()->standard($form_action,
$inputs);
631 if ($keep_structure) {
635 $this->file->getId(),
640 $this->file_service_settings,
648 $this->file->getId(),
653 $this->file_service_settings,
660 return $this->storage->manage()->find($this->file->getResourceId());
666 if (
null !== $file_rid) {
667 return $this->storage->manage()->getCurrentRevisionIncludingDraft($file_rid);
682 return $this->
http->wrapper()->query()->has(
'wsp_id');
687 return $this->
ui->factory();
Provides fluid interface to RBAC services.
The scope of this class is split ilias-conform URI's into components.
Class MetadataNotFoundException.
Class IllegalStateException.
Indicates that a file is missing or not found.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Class ResourceIdentification.
Class ilCtrl provides processing control methods.
ActionRepository $action_repo
renderDeleteSelectedVersionsModal()
ILIAS ResourceStorage Services $storage
const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL
getFileProcessor(bool $keep_structure)
__construct(private ilObjFile $file, private CapabilityCollection $capabilities)
ilFileVersionsGUI constructor.
ilObjFileComponentBuilder $file_component_builder
const KEY_COPYRIGHT_OPTION
ilGlobalTemplateInterface $tpl
checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect)
const CMD_CREATE_REPLACING_VERSION
saveVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
Revision $current_revision
const CMD_CONFIRMED_DELETE_FILE
const CMD_ROLLBACK_VERSION
const KEY_INHERIT_COPYRIGHT
const CMD_CREATE_NEW_VERSION
addVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
hasPermission(string $a_permission)
bugfix mantis 26007: this function was created to ensure that the access check not only works for rep...
ilFileServicesSettings $file_service_settings
ilWorkspaceAccessHandler $wsp_access
const CMD_DOWNLOAD_VERSION
getVersionIdsFromRequest()
const CMD_ADD_REPLACING_VERSION
const CMD_UNZIP_CURRENT_REVISION
const CMD_CONFIRMED_DELETE_VERSIONS
const CMD_ADD_NEW_VERSION
getDeleteSelectedVersionsModal()
LOMServices $lom_services
const KEY_SELECT_COPYRIGHT
Class ilFileVersionsUploadHandlerGUI.
GUI class for file objects.
Class ilObjFileStakeholder.
Class ilObjFileUnzipFlatProcessor.
Class ilObjFileUnzipRecursiveProcessor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
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...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
Interface ilObjFileProcessorInterface.
static http()
Fetches the global http state from ILIAS.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples