ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilFileVersionsGUI Class Reference
+ Collaboration diagram for ilFileVersionsGUI:

Public Member Functions

 __construct (private ilObjFile $file)
 ilFileVersionsGUI constructor. More...
 
 executeCommand ()
 
 getFile ()
 

Data Fields

const KEY_FILE_RID = 'file_rid'
 
const KEY_FILE_EXTRACT = 'file_extract'
 
const KEY_FILE_STRUCTURE = 'file_structure'
 
const KEY_COPYRIGHT_OPTION = "copyright_option"
 
const KEY_INHERIT_COPYRIGHT = "inherit_copyright"
 
const KEY_SELECT_COPYRIGHT = "select_copyright"
 
const KEY_COPYRIGHT_ID = "copyright_id"
 
const CMD_DEFAULT = 'index'
 
const CMD_DELETE_VERSIONS = "deleteVersions"
 
const CMD_ROLLBACK_VERSION = "rollbackVersion"
 
const CMD_DOWNLOAD_VERSION = "sendFile"
 
const HIST_ID = 'hist_id'
 
const CMD_CANCEL_DELETE = "cancelDeleteFile"
 
const CMD_CONFIRMED_DELETE_FILE = "confirmDeleteFile"
 
const CMD_CONFIRMED_DELETE_VERSIONS = 'confirmDeleteVersions'
 
const CMD_ADD_NEW_VERSION = 'addNewVersion'
 
const CMD_CREATE_NEW_VERSION = 'saveVersion'
 
const CMD_ADD_REPLACING_VERSION = 'addReplacingVersion'
 
const CMD_CREATE_REPLACING_VERSION = 'createReplacingVersion'
 
const CMD_UNZIP_CURRENT_REVISION = Capabilities::UNZIP->value
 
const CMD_PROCESS_UNZIP = 'processUnzip'
 
const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL = 'renderDeleteSelectedVersionsModal'
 
const CMD_PUBLISH = 'publish'
 
const CMD_UNPUBLISH = 'unpublish'
 

Protected Member Functions

 performCommand ()
 
 setBackTab ()
 
 renderDeleteSelectedVersionsModal ()
 
 getDeleteSelectedVersionsModal ()
 
 checkSanityOfDeletionRequest (array $requested_deletion_version, bool $redirect)
 
 getUIFactory ()
 
 getLanguage ()
 

Protected Attributes

UIServices $ui
 
ilLanguage $lng
 
ilCtrl $ctrl
 
int $version_id = null
 
ilTree $tree
 
int $parent_id
 
Refinery $refinery
 
LOMServices $lom_services
 

Private Member Functions

 unzipCurrentRevision ()
 
 publish ()
 
 unpublish ()
 
 processUnzip ()
 
 index ()
 
 addVersion (int $mode=ilFileVersionFormGUI::MODE_ADD)
 
 saveVersion (int $mode=ilFileVersionFormGUI::MODE_ADD)
 
 downloadVersion ()
 
 rollbackVersion ()
 
 confirmDeleteVersions ()
 
 confirmDeleteFile ()
 
 getVersionIdsFromRequest ()
 
 hasPermission (string $a_permission)
 bugfix mantis 26007: this function was created to ensure that the access check not only works for repository objects but for workspace objects too More...
 
 deleteVersions ()
 
 getFileZipOptionsForm ()
 
 getFileProcessor (bool $keep_structure)
 
 getIdentification ()
 
 getCurrentFileRevision ()
 
 getParentIdType ()
 
 isWorkspaceContext ()
 

Private Attributes

ilToolbarGUI $toolbar
 
ILIAS ResourceStorage Services $storage
 
ActionRepository $action_repo
 
Revision $current_revision
 
ilAccessHandler $access
 
ilWorkspaceAccessHandler $wsp_access
 
int $ref_id
 
Services $http
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilFileServicesSettings $file_service_settings
 
ilObjFileComponentBuilder $file_component_builder
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileVersionsGUI::__construct ( private ilObjFile  $file)

ilFileVersionsGUI constructor.

Definition at line 97 of file class.ilFileVersionsGUI.php.

98 {
99 global $DIC;
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();
111 $this->tree = $this->isWorkspaceContext() ? new ilWorkspaceTree($DIC->user()->getId()) : $DIC->repositoryTree();
112 $this->file_component_builder = new ilObjFileComponentBuilder($this->lng, $this->ui);
113 $this->refinery = $DIC->refinery();
114 $this->lom_services = $DIC->learningObjectMetadata();
115
116 $this->parent_id = $this->tree->getParentId($this->file->getRefId()) ?? $this->getParentIdType();
117 $this->wsp_access = new ilWorkspaceAccessHandler($this->tree);
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())
120 : null;
121 $this->action_repo = new ActionDBRepository($DIC->database());
122 $this->current_revision = $this->getCurrentFileRevision();
123 }
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...
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), getCurrentFileRevision(), getParentIdType(), ILIAS\FileDelivery\http(), isWorkspaceContext(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

Member Function Documentation

◆ addVersion()

ilFileVersionsGUI::addVersion ( int  $mode = ilFileVersionFormGUI::MODE_ADD)
private

Definition at line 344 of file class.ilFileVersionsGUI.php.

344 : void
345 {
346 $this->setBackTab();
347
348 $form = new ilFileVersionFormGUI($this, $mode);
349 $this->tpl->setContent($form->getHTML());
350 }
Class ilFileVersionFormGUI.

References setBackTab().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkSanityOfDeletionRequest()

ilFileVersionsGUI::checkSanityOfDeletionRequest ( array  $requested_deletion_version,
bool  $redirect 
)
protected

Definition at line 533 of file class.ilFileVersionsGUI.php.

533 : void
534 {
535 // Check Sanity of request
536 // Cant delete version if current is a DRAFT
537 if (
538 $this->current_revision->getStatus() === RevisionStatus::DRAFT
539 ) {
540 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('publish_before_delete'), $redirect);
541 if ($redirect) {
542 $this->ctrl->redirect($this, self::CMD_DEFAULT);
543 }
544 }
545
546 // no checkbox has been selected
547 if (count($requested_deletion_version) < 1) {
548 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), $redirect);
549 if ($redirect) {
550 $this->ctrl->redirect($this, self::CMD_DEFAULT);
551 }
552 }
553 }

References ILIAS\Repository\ctrl(), ILIAS\ResourceStorage\Revision\DRAFT, and ILIAS\Repository\lng().

Referenced by deleteVersions(), and getDeleteSelectedVersionsModal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteFile()

ilFileVersionsGUI::confirmDeleteFile ( )
private

Definition at line 415 of file class.ilFileVersionsGUI.php.

415 : void
416 {
417 $parent_id = $this->tree->getParentId($this->ref_id);
418
419 ilRepUtil::deleteObjects($parent_id, [$this->ref_id]);
420
421 // redirect to parent object
422 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $parent_id);
423 $this->ctrl->redirectByClass(ilRepositoryGUI::class);
424 }
static deleteObjects(int $a_cur_ref_id, array $a_ids)
Delete objects.

References $parent_id, ILIAS\Repository\ctrl(), and ilRepUtil\deleteObjects().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteVersions()

ilFileVersionsGUI::confirmDeleteVersions ( )
private

Definition at line 402 of file class.ilFileVersionsGUI.php.

402 : void
403 {
404 // delete versions after confirmation
405 $versions_to_delete = $this->getVersionIdsFromRequest();
406 if ($versions_to_delete !== []) {
407 $this->file->deleteVersions($versions_to_delete);
408 $this->tpl->setOnScreenMessage('success', $this->lng->txt("file_versions_deleted"), true);
409 }
410
411 $this->ctrl->setParameter($this, self::HIST_ID, "");
412 $this->ctrl->redirect($this, self::CMD_DEFAULT);
413 }

References ILIAS\Repository\ctrl(), getVersionIdsFromRequest(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteVersions()

ilFileVersionsGUI::deleteVersions ( )
private

Definition at line 557 of file class.ilFileVersionsGUI.php.

557 : void
558 {
559 $version_ids = $this->getVersionIdsFromRequest();
560 $existing_versions = $this->file->getVersions();
561 $remaining_versions = array_udiff(
562 $existing_versions,
563 $version_ids,
564 static function ($a, $b): int|float {
565 if ($a instanceof ilObjFileVersion) {
566 $a = $a->getHistEntryId();
567 }
568 if ($b instanceof ilObjFileVersion) {
569 $b = $b->getHistEntryId();
570 }
571 return $a - $b;
572 }
573 );
574
575 $this->checkSanityOfDeletionRequest($version_ids, true);
576
577 $conf_gui = new ilConfirmationGUI();
578 $conf_gui->setFormAction($this->ctrl->getFormAction($this, self::CMD_DEFAULT));
579 $conf_gui->setCancel($this->lng->txt("cancel"), self::CMD_DEFAULT);
580
581 $icon = ilObject::_getIcon($this->file->getId(), "small", $this->file->getType());
582 $alt = $this->lng->txt("icon") . " " . $this->lng->txt("obj_" . $this->file->getType());
583
584 // only one version left, delete the whole file
585 if (count($remaining_versions) < 1) {
586 // Ask
587 $conf_gui->setHeaderText($this->lng->txt('file_confirm_delete_all_versions'));
588 $conf_gui->setConfirm($this->lng->txt("confirm"), self::CMD_CONFIRMED_DELETE_FILE);
589 $conf_gui->addItem(
590 "id[]",
591 $this->ref_id,
592 $this->file->getTitle(),
593 $icon,
594 $alt
595 );
596 } else {
597 // Ask to delete version
598 $conf_gui->setHeaderText($this->lng->txt('file_confirm_delete_versions'));
599 $conf_gui->setConfirm($this->lng->txt("confirm"), self::CMD_CONFIRMED_DELETE_VERSIONS);
600
601 foreach ($this->file->getVersions($version_ids) as $version) {
602 $a_text = $version['filename'] ?? $version->getFilename() ?? $this->file->getTitle();
603 $version_string = $version['hist_id'] ?? $version->getVersion();
604 $a_text .= " (v" . $version_string . ")";
605 $conf_gui->addItem(
606 "hist_id[]",
607 $version['hist_entry_id'],
608 $a_text,
609 $icon,
610 $alt
611 );
612 }
613 }
614
615 $this->tpl->setContent($conf_gui->getHTML());
616 }
$version
Definition: plugin.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, $version, ilObject\_getIcon(), checkSanityOfDeletionRequest(), ILIAS\Repository\ctrl(), getVersionIdsFromRequest(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ downloadVersion()

ilFileVersionsGUI::downloadVersion ( )
private

Definition at line 366 of file class.ilFileVersionsGUI.php.

366 : void
367 {
368 try {
369 $this->file->sendFile($this->version_id);
370 } catch (FileNotFoundException) {
371 }
372 }
Indicates that a file is missing or not found.

Referenced by performCommand().

+ Here is the caller graph for this function:

◆ executeCommand()

ilFileVersionsGUI::executeCommand ( )

Definition at line 164 of file class.ilFileVersionsGUI.php.

164 : void
165 {
166 // bugfix mantis 26007: use new function hasPermission to ensure that the check also works for workspace files
167 if (!$this->hasPermission('write')) {
168 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
169 $this->ctrl->returnToParent($this);
170 }
171 switch ($this->ctrl->getNextClass()) {
172 case strtolower(ilFileVersionsUploadHandlerGUI::class):
173 $this->ctrl->forwardCommand(
175 $this->file
176 )
177 );
178 return;
179 case strtolower(ilWOPIEmbeddedApplicationGUI::class):
180 $action = $this->action_repo->getEditActionForSuffix(
181 $this->current_revision->getInformation()->getSuffix()
182 );
183
184 $embeded_application = new EmbeddedApplication(
185 $this->current_revision->getIdentification(),
186 $action,
188 new URI(rtrim(ILIAS_HTTP_PATH, "/") . "/" . $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT)),
189 false,
190 $this->lng->getLangKey()
191 );
192
193 $this->ctrl->forwardCommand(
195 $embeded_application
196 )
197 );
198 break;
199 default:
200 $this->performCommand();
201 break;
202 }
203 }
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
hasPermission(string $a_permission)
bugfix mantis 26007: this function was created to ensure that the access check not only works for rep...
Class ilFileVersionsUploadHandlerGUI.
Class ilObjFileStakeholder.

References ILIAS\Repository\ctrl(), hasPermission(), ILIAS\Repository\lng(), and performCommand().

+ Here is the call graph for this function:

◆ getCurrentFileRevision()

ilFileVersionsGUI::getCurrentFileRevision ( )
private

Definition at line 711 of file class.ilFileVersionsGUI.php.

711 : ?Revision
712 {
713 $file_rid = $this->getIdentification();
714 if (null !== $file_rid) {
715 return $this->storage->manage()->getCurrentRevisionIncludingDraft($file_rid);
716 }
717
718 return null;
719 }

References getIdentification().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeleteSelectedVersionsModal()

ilFileVersionsGUI::getDeleteSelectedVersionsModal ( )
protected

Definition at line 498 of file class.ilFileVersionsGUI.php.

498 : ?Interruptive
499 {
500 $deletion_version_ids = $this->getVersionIdsFromRequest();
501 $existing_versions = $this->file->getVersions();
502
503 $non_deletion_versions = array_udiff(
504 $existing_versions,
505 $deletion_version_ids,
506 static function ($a, $b): int|float {
507 if ($a instanceof ilObjFileVersion) {
508 $a = $a->getHistEntryId();
509 }
510 if ($b instanceof ilObjFileVersion) {
511 $b = $b->getHistEntryId();
512 }
513 return $a - $b;
514 }
515 );
516 $this->checkSanityOfDeletionRequest($deletion_version_ids, false);
517
518 // no version will remain after deletion, so we can delete the whole file
519 if (count($non_deletion_versions) < 1) {
520 return $this->file_component_builder->buildConfirmDeleteAllVersionsModal(
521 $this->ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_FILE),
522 $this->file
523 );
524 }
525 // confirm the deletion of the selected versions
526 return $this->file_component_builder->buildConfirmDeleteSpecificVersionsModal(
527 $this->ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_VERSIONS),
528 $this->file,
529 $deletion_version_ids
530 );
531 }

References Vendor\Package\$a, Vendor\Package\$b, checkSanityOfDeletionRequest(), ILIAS\Repository\ctrl(), and getVersionIdsFromRequest().

Referenced by renderDeleteSelectedVersionsModal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFile()

ilFileVersionsGUI::getFile ( )

Definition at line 426 of file class.ilFileVersionsGUI.php.

426 : ilObjFile
427 {
428 return $this->file;
429 }
Class ilObjFile.

Referenced by ilFileVersionsTableGUI\__construct(), and ilFileVersionFormGUI\__construct().

+ Here is the caller graph for this function:

◆ getFileProcessor()

ilFileVersionsGUI::getFileProcessor ( bool  $keep_structure)
private

Definition at line 675 of file class.ilFileVersionsGUI.php.

676 {
677 $context = $this->getParentIdType();
678
679 if ($keep_structure) {
682 new ilObjFileGUI(
683 $this->file->getId(),
684 $context,
685 $this->parent_id
686 ),
687 $this->storage,
688 $this->file_service_settings,
689 $this->tree
690 );
691 }
692
695 new ilObjFileGUI(
696 $this->file->getId(),
697 $context,
698 $this->parent_id
699 ),
700 $this->storage,
701 $this->file_service_settings,
702 $this->tree
703 );
704 }
GUI class for file objects.
Class ilObjFileUnzipFlatProcessor.
Interface ilObjFileProcessorInterface.
$context
Definition: webdav.php:31

References $context, and getParentIdType().

Referenced by processUnzip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileZipOptionsForm()

ilFileVersionsGUI::getFileZipOptionsForm ( )
private

Definition at line 618 of file class.ilFileVersionsGUI.php.

618 : Form
619 {
620 $inputs = [];
621 $copyright_options = [];
622 $form_action = $this->ctrl->getFormActionByClass(self::class, self::CMD_PROCESS_UNZIP);
623
624 $inputs[self::KEY_FILE_RID] = $this->ui->factory()->input()->field()->hidden()->withValue(
625 $this->file->getResourceId()
626 );
627 $inputs[self::KEY_FILE_STRUCTURE] = $this->ui->factory()->input()->field()->checkbox(
628 $this->lng->txt('take_over_structure'),
629 $this->lng->txt('take_over_structure_info'),
630 );
631
632 if (!$this->lom_services->copyrightHelper()->isCopyrightSelectionActive()) {
633 return $this->ui->factory()->input()->container()->form()->standard($form_action, $inputs);
634 }
635
636 $lom_reader = $this->lom_services->read($this->file->getId(), 0, $this->file->getType());
637 $lom_cp_helper = $this->lom_services->copyrightHelper();
638
639 if ($lom_cp_helper->hasPresetCopyright($lom_reader)) {
640 $zip_copyright = $lom_cp_helper->readPresetCopyright($lom_reader);
641 $zip_copyright_id = $zip_copyright->identifier();
642 $zip_copyright_title = $zip_copyright->title();
643 } else {
644 $zip_copyright_id = $zip_copyright_title = $lom_cp_helper->readCustomCopyright($lom_reader);
645 }
646 if ($zip_copyright_id !== '') {
647 $copyright_inheritance_input = $this->ui->factory()->input()->field()->hidden()->withValue(
648 $zip_copyright_id
649 );
650 $copyright_options[self::KEY_INHERIT_COPYRIGHT] = $this->ui->factory()->input()->field()->group(
651 [self::KEY_COPYRIGHT_ID => $copyright_inheritance_input],
652 $this->lng->txt("copyright_inherited"),
653 sprintf(
654 $this->lng->txt("copyright_inherited_info"),
655 $zip_copyright_title
656 )
657 );
658 }
659
660 $copyright_selection_input = $this->getCopyrightSelectionInput('set_license_for_all_files');
661 $copyright_options[self::KEY_SELECT_COPYRIGHT] = $this->ui->factory()->input()->field()->group(
662 [self::KEY_COPYRIGHT_ID => $copyright_selection_input],
663 $this->lng->txt("copyright_custom"),
664 $this->lng->txt("copyright_custom_info")
665 );
666
667 $inputs[self::KEY_COPYRIGHT_OPTION] = $this->ui->factory()->input()->field()->switchableGroup(
668 $copyright_options,
669 $this->lng->txt("md_copyright")
670 )->withValue(self::KEY_SELECT_COPYRIGHT);
671
672 return $this->ui->factory()->input()->container()->form()->standard($form_action, $inputs);
673 }
This describes commonalities between all forms.
Definition: Form.php:33

References ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\Repository\ctrl(), KEY_COPYRIGHT_OPTION, KEY_FILE_RID, KEY_FILE_STRUCTURE, KEY_INHERIT_COPYRIGHT, KEY_SELECT_COPYRIGHT, ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by processUnzip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdentification()

ilFileVersionsGUI::getIdentification ( )
private

Definition at line 706 of file class.ilFileVersionsGUI.php.

707 {
708 return $this->storage->manage()->find($this->file->getResourceId());
709 }

Referenced by getCurrentFileRevision(), publish(), and unpublish().

+ Here is the caller graph for this function:

◆ getLanguage()

ilFileVersionsGUI::getLanguage ( )
protected

Definition at line 738 of file class.ilFileVersionsGUI.php.

739 {
740 return $this->lng;
741 }
language handling

References $lng.

◆ getParentIdType()

ilFileVersionsGUI::getParentIdType ( )
private

Definition at line 721 of file class.ilFileVersionsGUI.php.

721 : int
722 {
723 return ($this->isWorkspaceContext()) ?
726 }

References isWorkspaceContext(), ilObject2GUI\REPOSITORY_NODE_ID, and ilObject2GUI\WORKSPACE_NODE_ID.

Referenced by __construct(), and getFileProcessor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

ilFileVersionsGUI::getUIFactory ( )
protected

Definition at line 733 of file class.ilFileVersionsGUI.php.

734 {
735 return $this->ui->factory();
736 }
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ getVersionIdsFromRequest()

ilFileVersionsGUI::getVersionIdsFromRequest ( )
private

in case request is triggered by

See also
self::CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL

Definition at line 431 of file class.ilFileVersionsGUI.php.

431 : array
432 {
433 if ('GET' === $this->http->request()->getMethod() &&
434 $this->http->wrapper()->query()->has(self::HIST_ID)
435 ) {
436 return [
437 $this->http->wrapper()->query()->retrieve(self::HIST_ID, $this->refinery->kindlyTo()->int()),
438 ];
439 }
440
442 if ($this->http->wrapper()->post()->has('interruptive_items')) {
443 return $this->http->wrapper()->post()->retrieve(
444 'interruptive_items',
445 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
446 );
447 }
448
449 if ($this->http->wrapper()->post()->has(self::HIST_ID)) {
450 return $this->http->wrapper()->post()->retrieve(
451 self::HIST_ID,
452 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
453 );
454 }
455
456 return [];
457 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by confirmDeleteVersions(), deleteVersions(), getDeleteSelectedVersionsModal(), and rollbackVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasPermission()

ilFileVersionsGUI::hasPermission ( string  $a_permission)
private

bugfix mantis 26007: this function was created to ensure that the access check not only works for repository objects but for workspace objects too

Definition at line 464 of file class.ilFileVersionsGUI.php.

464 : bool
465 {
466 // determine if the permission check concerns a workspace- or repository-object
467 if ($this->isWorkspaceContext()) {
468 // permission-check concerning a workspace object
469 if ($this->wsp_access->checkAccess($a_permission, "", $this->ref_id)) {
470 return true;
471 }
472 } elseif ($this->access->checkAccess($a_permission, '', $this->ref_id)) {
473 // permission-check concerning a repository object
474 return true;
475 }
476
477 return false;
478 }

References ILIAS\Repository\access(), and isWorkspaceContext().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index()

ilFileVersionsGUI::index ( )
private

Definition at line 276 of file class.ilFileVersionsGUI.php.

276 : void
277 {
278 // Buttons
279 $status = $this->current_revision?->getStatus();
280
281 $btn_add_version = $this->ui->factory()->button()->standard(
282 $this->lng->txt('file_new_version'),
283 $this->ctrl->getLinkTarget($this, self::CMD_ADD_NEW_VERSION)
284 );
285 if ($status === RevisionStatus::DRAFT) {
286 $btn_add_version = $btn_add_version->withUnavailableAction();
287 }
288 $this->toolbar->addComponent($btn_add_version);
289
290 $btn_replace_version = $this->ui->factory()->button()->standard(
291 $this->lng->txt('replace_file'),
292 $this->ctrl->getLinkTarget($this, self::CMD_ADD_REPLACING_VERSION)
293 );
294 if ($status === RevisionStatus::DRAFT) {
295 $btn_replace_version = $btn_replace_version->withUnavailableAction();
296 }
297 $this->toolbar->addComponent($btn_replace_version);
298
299 // only add unzip button if the current revision is a zip.
300 if (null !== $this->current_revision &&
301 in_array($this->current_revision->getInformation()->getMimeType(), [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED], true)
302 ) {
303 $btn_unzip = $this->ui->factory()->button()->standard(
304 $this->lng->txt('unzip'),
305 $this->ctrl->getLinkTarget($this, self::CMD_UNZIP_CURRENT_REVISION)
306 );
307 $this->toolbar->addComponent($btn_unzip);
308 }
309
310 // Editor
311 $this->current_revision?->getInformation()?->getSuffix();
312
313 if ($this->action_repo->hasEditActionForSuffix(
314 $this->current_revision->getInformation()->getSuffix()
315 )) {
316 $external_editor = $this->ui->factory()
317 ->button()
318 ->standard(
319 $this->lng->txt('open_external_editor'),
320 $this->ctrl->getLinkTargetByClass(
321 [self::class, ilWOPIEmbeddedApplicationGUI::class],
323 )
324 );
325 $this->toolbar->addComponent($external_editor);
326 }
327
328
329 // Publish
330 if ($status === RevisionStatus::DRAFT) {
331 $this->tpl->setOnScreenMessage('info', $this->lng->txt('file_version_draft_info'));
332
333 $btn_publish = $this->ui->factory()->button()->standard(
334 $this->lng->txt('file_publish'),
335 $this->ctrl->getLinkTarget($this, self::CMD_PUBLISH)
336 );
337 $this->toolbar->addComponent($btn_publish);
338 }
339
340 $table = new ilFileVersionsTableGUI($this, self::CMD_DEFAULT);
341 $this->tpl->setContent($table->getHTML());
342 }
Class ilFileVersionsTableGUI.

References ilWOPIEmbeddedApplicationGUI\CMD_EDIT, ILIAS\ResourceStorage\Revision\DRAFT, ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isWorkspaceContext()

ilFileVersionsGUI::isWorkspaceContext ( )
private

Definition at line 728 of file class.ilFileVersionsGUI.php.

728 : bool
729 {
730 return $this->http->wrapper()->query()->has('wsp_id');
731 }

References ILIAS\FileDelivery\http().

Referenced by __construct(), getParentIdType(), and hasPermission().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performCommand()

ilFileVersionsGUI::performCommand ( )
protected
Exceptions
NoSuchElementException
IllegalStateException

Definition at line 131 of file class.ilFileVersionsGUI.php.

131 : void
132 {
133 match ($this->ctrl->getCmd(self::CMD_DEFAULT)) {
134 self::CMD_DEFAULT => $this->index(),
135 self::CMD_DOWNLOAD_VERSION => $this->downloadVersion(),
136 self::CMD_DELETE_VERSIONS => $this->deleteVersions(),
137 self::CMD_ROLLBACK_VERSION => $this->rollbackVersion(),
138 self::CMD_ADD_NEW_VERSION => $this->addVersion(ilFileVersionFormGUI::MODE_ADD),
139 self::CMD_ADD_REPLACING_VERSION => $this->addVersion(ilFileVersionFormGUI::MODE_REPLACE),
140 self::CMD_CREATE_NEW_VERSION => $this->saveVersion(ilFileVersionFormGUI::MODE_ADD),
141 self::CMD_CREATE_REPLACING_VERSION => $this->saveVersion(ilFileVersionFormGUI::MODE_REPLACE),
142 self::CMD_CONFIRMED_DELETE_VERSIONS => $this->confirmDeleteVersions(),
143 self::CMD_CONFIRMED_DELETE_FILE => $this->confirmDeleteFile(),
144 self::CMD_UNZIP_CURRENT_REVISION => $this->unzipCurrentRevision(),
145 self::CMD_PROCESS_UNZIP => $this->processUnzip(),
146 self::CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL => $this->renderDeleteSelectedVersionsModal(),
147 self::CMD_PUBLISH => $this->publish(),
148 self::CMD_UNPUBLISH => $this->unpublish()
149 };
150 }
saveVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
addVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)

References addVersion(), confirmDeleteFile(), confirmDeleteVersions(), ILIAS\Repository\ctrl(), deleteVersions(), downloadVersion(), index(), ilFileVersionFormGUI\MODE_ADD, ilFileVersionFormGUI\MODE_REPLACE, processUnzip(), publish(), renderDeleteSelectedVersionsModal(), rollbackVersion(), saveVersion(), unpublish(), and unzipCurrentRevision().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processUnzip()

ilFileVersionsGUI::processUnzip ( )
private

Definition at line 238 of file class.ilFileVersionsGUI.php.

238 : void
239 {
240 $form = $this->getFileZipOptionsForm()->withRequest($this->http->request());
241 $data = $form->getData();
242
243 if (!empty($data)) {
244 $file_rid = $this->storage->manage()->find($data[self::KEY_FILE_RID]);
245 if (null !== $file_rid) {
246 $copyright_id = $data[self::KEY_COPYRIGHT_OPTION][1][self::KEY_COPYRIGHT_ID] ?? null;
247 $processor = $this->getFileProcessor($data[self::KEY_FILE_STRUCTURE]);
248 $processor->process($file_rid, null, null, $copyright_id);
249
250 if ($processor->getInvalidFileNames() !== []) {
251 $this->ui->mainTemplate()->setOnScreenMessage(
252 'info',
253 sprintf(
254 $this->lng->txt('file_upload_info_file_with_critical_extension'),
255 implode(', ', $processor->getInvalidFileNames())
256 ),
257 true
258 );
259 }
260
261 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_unzip_success'), true);
262 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $this->parent_id);
263 $this->ctrl->redirectByClass(ilRepositoryGUI::class);
264 }
265
266 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('file_not_found'));
267 }
268
269 $this->tpl->setContent(
270 $this->ui->renderer()->render(
271 $this->getFileZipOptionsForm()
272 )
273 );
274 }
getFileProcessor(bool $keep_structure)

References $data, ILIAS\Repository\ctrl(), getFileProcessor(), getFileZipOptionsForm(), ILIAS\FileDelivery\http(), KEY_COPYRIGHT_ID, KEY_COPYRIGHT_OPTION, ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ publish()

ilFileVersionsGUI::publish ( )
private

Definition at line 215 of file class.ilFileVersionsGUI.php.

215 : void
216 {
217 $this->file->enableNotification();
218 $this->storage->manage()->publish($this->getIdentification());
219 $this->file->updateObjectFromCurrentRevision();
220 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
221 $this->ctrl->redirect($this, self::CMD_DEFAULT);
222 }

References ILIAS\Repository\ctrl(), getIdentification(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderDeleteSelectedVersionsModal()

ilFileVersionsGUI::renderDeleteSelectedVersionsModal ( )
protected

Definition at line 480 of file class.ilFileVersionsGUI.php.

480 : void
481 {
482 $delete_selected_versions_modal = $this->getDeleteSelectedVersionsModal();
483
484 $this->http->saveResponse(
485 $this->http->response()->withBody(
486 Streams::ofString(
487 (null !== $delete_selected_versions_modal) ?
488 $this->ui->renderer()->renderAsync([$delete_selected_versions_modal]) :
489 ''
490 )
491 )->withHeader('Content-Type', 'application/json; charset=utf-8')
492 );
493
494 $this->http->sendResponse();
495 $this->http->close();
496 }

References getDeleteSelectedVersionsModal(), and ILIAS\FileDelivery\http().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rollbackVersion()

ilFileVersionsGUI::rollbackVersion ( )
private

Definition at line 374 of file class.ilFileVersionsGUI.php.

374 : void
375 {
376 $version_ids = $this->getVersionIdsFromRequest();
377
378 // more than one entry selected?
379 if (count($version_ids) !== 1) {
380 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("file_rollback_select_exact_one"), true);
381 $this->ctrl->redirect($this, self::CMD_DEFAULT);
382 }
383
384 if ($this->current_revision->getStatus() === RevisionStatus::DRAFT) {
385 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("file_rollback_rollback_first"), true);
386 $this->ctrl->redirect($this, self::CMD_DEFAULT);
387 }
388
389 // rollback the version
390 $version_id = $version_ids[0];
391 if ($version_id === $this->current_revision->getVersionNumber()) {
392 $this->tpl->setOnScreenMessage('info', $this->lng->txt("file_rollback_same_version"), true);
393 $this->ctrl->redirect($this, self::CMD_DEFAULT);
394 }
395
396 $this->file->rollback($version_id);
397
398 $this->tpl->setOnScreenMessage('success', sprintf($this->lng->txt("file_rollback_done"), (string) $version_id), true);
399 $this->ctrl->redirect($this, self::CMD_DEFAULT);
400 }

References $version_id, ILIAS\Repository\ctrl(), ILIAS\ResourceStorage\Revision\DRAFT, getVersionIdsFromRequest(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveVersion()

ilFileVersionsGUI::saveVersion ( int  $mode = ilFileVersionFormGUI::MODE_ADD)
private
Exceptions
NoSuchElementException
IllegalStateException

Definition at line 356 of file class.ilFileVersionsGUI.php.

356 : void
357 {
358 $form = new ilFileVersionFormGUI($this, $mode);
359 if ($form->saveObject()) {
360 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
361 $this->ctrl->redirect($this, self::CMD_DEFAULT);
362 }
363 $this->tpl->setContent($form->getHTML());
364 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBackTab()

ilFileVersionsGUI::setBackTab ( )
protected
Exceptions
ilCtrlException

Definition at line 155 of file class.ilFileVersionsGUI.php.

155 : void
156 {
157 $this->tabs->clearTargets();
158 $this->tabs->setBackTarget(
159 $this->lng->txt('back'),
160 $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT)
161 );
162 }

References ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by addVersion(), and unzipCurrentRevision().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unpublish()

ilFileVersionsGUI::unpublish ( )
private

Definition at line 224 of file class.ilFileVersionsGUI.php.

224 : void
225 {
226 $this->file->enableNotification();
227 if ($this->current_revision->getVersionNumber() === 1) {
228 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_cant_unpublish'), true);
229 $this->ctrl->redirect($this, self::CMD_DEFAULT);
230 }
231
232 $this->storage->manage()->unpublish($this->getIdentification());
233 $this->file->updateObjectFromCurrentRevision();
234 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
235 $this->ctrl->redirect($this, self::CMD_DEFAULT);
236 }

References ILIAS\Repository\ctrl(), getIdentification(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzipCurrentRevision()

ilFileVersionsGUI::unzipCurrentRevision ( )
private

Definition at line 205 of file class.ilFileVersionsGUI.php.

205 : void
206 {
207 $this->setBackTab();
208 $this->tpl->setContent(
209 $this->ui->renderer()->render(
210 $this->getFileZipOptionsForm()
211 )
212 );
213 }

References setBackTab(), and ILIAS\Repository\ui().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilFileVersionsGUI::$access
private

Definition at line 78 of file class.ilFileVersionsGUI.php.

◆ $action_repo

ActionRepository ilFileVersionsGUI::$action_repo
private

Definition at line 75 of file class.ilFileVersionsGUI.php.

◆ $ctrl

ilCtrl ilFileVersionsGUI::$ctrl
protected

Definition at line 84 of file class.ilFileVersionsGUI.php.

◆ $current_revision

Revision ilFileVersionsGUI::$current_revision
private

Definition at line 76 of file class.ilFileVersionsGUI.php.

◆ $file_component_builder

ilObjFileComponentBuilder ilFileVersionsGUI::$file_component_builder
private

Definition at line 87 of file class.ilFileVersionsGUI.php.

◆ $file_service_settings

ilFileServicesSettings ilFileVersionsGUI::$file_service_settings
private

Definition at line 86 of file class.ilFileVersionsGUI.php.

◆ $http

Services ilFileVersionsGUI::$http
private

Definition at line 82 of file class.ilFileVersionsGUI.php.

◆ $lng

ilLanguage ilFileVersionsGUI::$lng
protected

Definition at line 81 of file class.ilFileVersionsGUI.php.

Referenced by getLanguage().

◆ $lom_services

LOMServices ilFileVersionsGUI::$lom_services
protected

Definition at line 92 of file class.ilFileVersionsGUI.php.

◆ $parent_id

int ilFileVersionsGUI::$parent_id
protected

Definition at line 90 of file class.ilFileVersionsGUI.php.

Referenced by confirmDeleteFile().

◆ $ref_id

int ilFileVersionsGUI::$ref_id
private

Definition at line 80 of file class.ilFileVersionsGUI.php.

◆ $refinery

Refinery ilFileVersionsGUI::$refinery
protected

Definition at line 91 of file class.ilFileVersionsGUI.php.

◆ $storage

ILIAS ResourceStorage Services ilFileVersionsGUI::$storage
private

Definition at line 74 of file class.ilFileVersionsGUI.php.

◆ $tabs

ilTabsGUI ilFileVersionsGUI::$tabs
private

Definition at line 83 of file class.ilFileVersionsGUI.php.

◆ $toolbar

ilToolbarGUI ilFileVersionsGUI::$toolbar
private

Definition at line 73 of file class.ilFileVersionsGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilFileVersionsGUI::$tpl
private

Definition at line 85 of file class.ilFileVersionsGUI.php.

◆ $tree

ilTree ilFileVersionsGUI::$tree
protected

Definition at line 89 of file class.ilFileVersionsGUI.php.

◆ $ui

UIServices ilFileVersionsGUI::$ui
protected

Definition at line 77 of file class.ilFileVersionsGUI.php.

◆ $version_id

int ilFileVersionsGUI::$version_id = null
protected

Definition at line 88 of file class.ilFileVersionsGUI.php.

Referenced by rollbackVersion().

◆ $wsp_access

ilWorkspaceAccessHandler ilFileVersionsGUI::$wsp_access
private

Definition at line 79 of file class.ilFileVersionsGUI.php.

◆ CMD_ADD_NEW_VERSION

const ilFileVersionsGUI::CMD_ADD_NEW_VERSION = 'addNewVersion'

Definition at line 63 of file class.ilFileVersionsGUI.php.

◆ CMD_ADD_REPLACING_VERSION

const ilFileVersionsGUI::CMD_ADD_REPLACING_VERSION = 'addReplacingVersion'

Definition at line 65 of file class.ilFileVersionsGUI.php.

◆ CMD_CANCEL_DELETE

const ilFileVersionsGUI::CMD_CANCEL_DELETE = "cancelDeleteFile"

Definition at line 60 of file class.ilFileVersionsGUI.php.

◆ CMD_CONFIRMED_DELETE_FILE

const ilFileVersionsGUI::CMD_CONFIRMED_DELETE_FILE = "confirmDeleteFile"

Definition at line 61 of file class.ilFileVersionsGUI.php.

◆ CMD_CONFIRMED_DELETE_VERSIONS

const ilFileVersionsGUI::CMD_CONFIRMED_DELETE_VERSIONS = 'confirmDeleteVersions'

Definition at line 62 of file class.ilFileVersionsGUI.php.

◆ CMD_CREATE_NEW_VERSION

const ilFileVersionsGUI::CMD_CREATE_NEW_VERSION = 'saveVersion'

◆ CMD_CREATE_REPLACING_VERSION

const ilFileVersionsGUI::CMD_CREATE_REPLACING_VERSION = 'createReplacingVersion'

◆ CMD_DEFAULT

const ilFileVersionsGUI::CMD_DEFAULT = 'index'

Definition at line 55 of file class.ilFileVersionsGUI.php.

Referenced by ilObjFileGUI\setTabs().

◆ CMD_DELETE_VERSIONS

const ilFileVersionsGUI::CMD_DELETE_VERSIONS = "deleteVersions"

Definition at line 56 of file class.ilFileVersionsGUI.php.

Referenced by ilFileVersionsTableGUI\__construct().

◆ CMD_DOWNLOAD_VERSION

const ilFileVersionsGUI::CMD_DOWNLOAD_VERSION = "sendFile"

Definition at line 58 of file class.ilFileVersionsGUI.php.

Referenced by ilFileVersionsTableGUI\fillRow().

◆ CMD_PROCESS_UNZIP

const ilFileVersionsGUI::CMD_PROCESS_UNZIP = 'processUnzip'

Definition at line 68 of file class.ilFileVersionsGUI.php.

◆ CMD_PUBLISH

const ilFileVersionsGUI::CMD_PUBLISH = 'publish'

Definition at line 70 of file class.ilFileVersionsGUI.php.

Referenced by ilFileVersionsTableGUI\fillRow().

◆ CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL

const ilFileVersionsGUI::CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL = 'renderDeleteSelectedVersionsModal'

Definition at line 69 of file class.ilFileVersionsGUI.php.

Referenced by ilFileVersionsTableGUI\fillRow().

◆ CMD_ROLLBACK_VERSION

const ilFileVersionsGUI::CMD_ROLLBACK_VERSION = "rollbackVersion"

◆ CMD_UNPUBLISH

const ilFileVersionsGUI::CMD_UNPUBLISH = 'unpublish'

Definition at line 71 of file class.ilFileVersionsGUI.php.

Referenced by ilFileVersionsTableGUI\fillRow().

◆ CMD_UNZIP_CURRENT_REVISION

const ilFileVersionsGUI::CMD_UNZIP_CURRENT_REVISION = Capabilities::UNZIP->value

Definition at line 67 of file class.ilFileVersionsGUI.php.

◆ HIST_ID

const ilFileVersionsGUI::HIST_ID = 'hist_id'

Definition at line 59 of file class.ilFileVersionsGUI.php.

Referenced by ilFileVersionsTableGUI\fillRow().

◆ KEY_COPYRIGHT_ID

const ilFileVersionsGUI::KEY_COPYRIGHT_ID = "copyright_id"

Definition at line 53 of file class.ilFileVersionsGUI.php.

Referenced by processUnzip().

◆ KEY_COPYRIGHT_OPTION

const ilFileVersionsGUI::KEY_COPYRIGHT_OPTION = "copyright_option"

Definition at line 50 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm(), and processUnzip().

◆ KEY_FILE_EXTRACT

const ilFileVersionsGUI::KEY_FILE_EXTRACT = 'file_extract'

Definition at line 48 of file class.ilFileVersionsGUI.php.

◆ KEY_FILE_RID

const ilFileVersionsGUI::KEY_FILE_RID = 'file_rid'

Definition at line 47 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().

◆ KEY_FILE_STRUCTURE

const ilFileVersionsGUI::KEY_FILE_STRUCTURE = 'file_structure'

Definition at line 49 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().

◆ KEY_INHERIT_COPYRIGHT

const ilFileVersionsGUI::KEY_INHERIT_COPYRIGHT = "inherit_copyright"

Definition at line 51 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().

◆ KEY_SELECT_COPYRIGHT

const ilFileVersionsGUI::KEY_SELECT_COPYRIGHT = "select_copyright"

Definition at line 52 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().


The documentation for this class was generated from the following file: