From 925b48c183c27c4e83e5320e32ca118455f08a04 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Jan 2024 19:00:53 +0100 Subject: [PATCH 1/3] #1174 Fixed removing multiple files from document --- modules/admin/models/FileImport.php | 2 +- .../modules/admin/controllers/FilemanagerControllerTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/admin/models/FileImport.php b/modules/admin/models/FileImport.php index 9f8bf9065..af503174d 100644 --- a/modules/admin/models/FileImport.php +++ b/modules/admin/models/FileImport.php @@ -147,7 +147,7 @@ public function deleteFile($docId, $fileId) $files = $doc->getFile(); foreach ($files as $index => $file) { - if ($file->getId() !== $fileId) { + if ($file->getId() !== (int) $fileId) { $keepFiles[] = $file; } } diff --git a/tests/modules/admin/controllers/FilemanagerControllerTest.php b/tests/modules/admin/controllers/FilemanagerControllerTest.php index 7cd55321c..10879c1f1 100644 --- a/tests/modules/admin/controllers/FilemanagerControllerTest.php +++ b/tests/modules/admin/controllers/FilemanagerControllerTest.php @@ -384,4 +384,9 @@ public function testDocumentFilesWithoutSortOrder() $positionFile2 = strpos($body, 'datei mit unüblichem Namen.xhtml'); $this->assertTrue($positionFile1 < $positionFile2); } + + public function testRemovingMultipleFilesWorks() + { + $this->markTestIncomplete('Test for https://github.com/OPUS4/application/issues/1174'); + } } From 692e07727aebc45d4e5fcae4b86b4205afdf3d5d Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 9 Jan 2024 14:39:02 +0100 Subject: [PATCH 2/3] #1176 Option for addGuestAccess to files when publishing documents --- application/configs/application.ini | 3 ++ .../review/models/ClearDocumentsHelper.php | 21 +++++++++--- .../models/ClearDocumentsHelperTest.php | 32 +++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index 9ce77faa7..b8910e75c 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -582,6 +582,9 @@ crossref.mailTo = '' ; path to the licences directory that stores licence logos licences.logos.path = APPLICATION_PATH "/public/img/licences" +; Workflow settings +workflow.stateChange.published.addGuestAccess = 1 + ; Staging, Testing and Development configurations ===================================================================== [staging : production] diff --git a/modules/review/models/ClearDocumentsHelper.php b/modules/review/models/ClearDocumentsHelper.php index e02ac7172..91dd539ab 100644 --- a/modules/review/models/ClearDocumentsHelper.php +++ b/modules/review/models/ClearDocumentsHelper.php @@ -38,7 +38,7 @@ /** * Contains code for clearing documents (switching to published state). */ -class Review_Model_ClearDocumentsHelper +class Review_Model_ClearDocumentsHelper extends Application_Model_Abstract { /** * Publishes documents and adds the given Person as referee. @@ -67,9 +67,11 @@ public function clear(?array $docIds = null, $userId = null, $person = null) $document->setPublishedDate($date); } - $guestRole = UserRole::fetchByName('guest'); - foreach ($document->getFile() as $file) { - $guestRole->appendAccessFile($file->getId()); + if ($this->isAddGuestAccessEnabled()) { + $guestRole = UserRole::fetchByName('guest'); + foreach ($document->getFile() as $file) { + $guestRole->appendAccessFile($file->getId()); + } } if (isset($person)) { @@ -86,6 +88,17 @@ public function clear(?array $docIds = null, $userId = null, $person = null) } } + /** + * @return bool + */ + public function isAddGuestAccessEnabled() + { + $config = $this->getConfig(); + + return ! isset($config->workflow->stateChange->published->addGuestAccess) || + filter_var($config->workflow->stateChange->published->addGuestAccess, FILTER_VALIDATE_BOOLEAN); + } + /** * Rejects documents and adds the given Person as referee. * diff --git a/tests/modules/review/models/ClearDocumentsHelperTest.php b/tests/modules/review/models/ClearDocumentsHelperTest.php index d895979a6..49ba393f2 100644 --- a/tests/modules/review/models/ClearDocumentsHelperTest.php +++ b/tests/modules/review/models/ClearDocumentsHelperTest.php @@ -212,4 +212,36 @@ public function testPublishedDateIsNotOverwritten() $this->assertNotNull($publishedDate); $this->assertEquals(0, $expectedDate->compare($publishedDate)); // still yesterday } + + public function testIsAddGuestAccessEnabled() + { + $helper = new Review_Model_ClearDocumentsHelper(); + + $this->assertTrue($helper->isAddGuestAccessEnabled()); + } + + public function testIsAddGuestAccessEnabledNotConfigured() + { + $config = $this->getConfig(); + + unset($config->workflow->stateChange->published); + + $this->assertFalse(isset($config->workflow->stateChange->published->addGuestAccess)); + + $helper = new Review_Model_ClearDocumentsHelper(); + $helper->setConfig($config); + + $this->assertTrue($helper->isAddGuestAccessEnabled()); + } + + public function testIsAddGuestAccessEnabledFalse() + { + $this->adjustConfiguration([ + 'workflow' => ['stateChange' => ['published' => ['addGuestAccess' => 0]]], + ]); + + $helper = new Review_Model_ClearDocumentsHelper(); + + $this->assertFalse($helper->isAddGuestAccessEnabled()); + } } From 30350b2eb4a52cb0cef7af5c32e2153d0badd01a Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 9 Jan 2024 17:46:48 +0100 Subject: [PATCH 3/3] Release preparation for 4.8.0.4 --- CHANGES.md | 5 +++++ README.md | 4 ++-- RELEASE_NOTES.md | 23 +++++++++++++++++++++++ application/configs/application.ini | 2 +- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ab688c108..a1a0e1f1c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # OPUS 4 Change Log +## Release 4.8.0.4 - 2024-01-09 + +https://github.com/OPUS4/application/issues/1174 +https://github.com/OPUS4/application/issues/1176 + ## Release 4.8.0.3 - 2023-11-28 https://github.com/OPUS4/application/issues/1159 diff --git a/README.md b/README.md index 44d0c65e9..4f56670b9 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ redevelopment that was created as part of a DFG ([Deutsche Forschungsgemeinschaf Since then the development has been continued at KOBV ([Kooperativer Bibliotheksverbund Berlin-Brandenburg][KOBV]) mostly. -## OPUS 4.8.0.3(current version) +## OPUS 4.8.0.4 (current version) -The current version of OPUS 4 is __4.8.0.3__. It is available on the [master][MASTER] branch and compatible with +The current version of OPUS 4 is __4.8.0.4__. It is available on the [master][MASTER] branch and compatible with PHP 7.1 to 8.1. [Documentation][DOC] diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index cf31b88ca..92a3613e2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,28 @@ # OPUS 4 Release Notes +## Patch Release 4.8.0.4 - 2024-01-09 + +Fehler beim Löschen mehrerer Dateien von einem Dokument behoben. +https://github.com/OPUS4/application/issues/1174 + +### Review-Modul + +Beim Freischalten im Review-Modul, bekommt die Rolle **guest** automatisch +Zugriff auf die Dateien, der freigeschalteten Dokumente. Das kann nun mit +einer neuen Option (`workflow.stateChange.published.addGuestAccess = 0`) +abgeschaltet werden. +https://github.com/OPUS4/application/issues/1176 + +In der Standardkonfiguration ist die Option aktiviert, um in einem Patch +Release, das Verhalten von OPUS 4 nicht zu verändern. In einer kommenden +Version wird sich der Defaultwert vermutlich ändern. + +Die Zugriffsrechte auf die Dateien werden beim Freischalten einzelner +Dokumente in der Administration nicht verändert, unabhängig von der neuen +Option. Das Verhalten der verschiedenen Möglichkeiten zur Freigabe wird in +Zukunft vereinheitlicht werden. +https://github.com/OPUS4/application/issues/1177 + ## Patch Release 4.8.0.3 - 2023-11-28 Das `bin/opus4` Kommandozeilentool wurde um zwei Kommandos erweitert. diff --git a/application/configs/application.ini b/application/configs/application.ini index b8910e75c..6dc4c722c 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -70,7 +70,7 @@ name = 'OPUS 4' logoLink = home security = 1 workspacePath = APPLICATION_PATH "/workspace" -version = 4.8.0.3 +version = 4.8.0.4 update.latestVersionCheckUrl = "https://api.github.com/repos/opus4/application/releases/latest" ; Determines the implementation of the OPUS 4 data model