From 7b6fb4f97b89b18d69d23d37e2635856cd8e9568 Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Wed, 25 Sep 2024 10:48:55 +0200 Subject: [PATCH] public access file on info screen --- components/ILIAS/InfoScreen/PRIVACY.md | 1 + .../classes/class.ilInfoScreenGUI.php | 72 ++++++++++++++++--- lang/ilias_de.lang | 3 + lang/ilias_en.lang | 3 + 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/components/ILIAS/InfoScreen/PRIVACY.md b/components/ILIAS/InfoScreen/PRIVACY.md index fe6f84014f47..28d474d7435b 100755 --- a/components/ILIAS/InfoScreen/PRIVACY.md +++ b/components/ILIAS/InfoScreen/PRIVACY.md @@ -32,6 +32,7 @@ Since the component itself does not store any data, all data being presented is - Notes and comments, see [Notes Service](../../ILIAS/Notes/PRIVACY.md) - (Personal) learning progress status - Metadata, incl. author and contributor information +- If available, a public access export file of the object. See the privacy information of the individual objects for what the export files contain. - Object creation date and owner (this presentation requires "edit settings" (write) permission) - Personal Tags, see [Tagging Service](../../ILIAS/Tagging/PRIVACY.md) - Locking user (if WebDav is activated) diff --git a/components/ILIAS/InfoScreen/classes/class.ilInfoScreenGUI.php b/components/ILIAS/InfoScreen/classes/class.ilInfoScreenGUI.php index 9f6ebc1c7149..67d0befeeb74 100755 --- a/components/ILIAS/InfoScreen/classes/class.ilInfoScreenGUI.php +++ b/components/ILIAS/InfoScreen/classes/class.ilInfoScreenGUI.php @@ -19,7 +19,9 @@ *********************************************************************/ use ILIAS\InfoScreen\StandardGUIRequest; -use ILIAS\MetaData\Services\Services as Metadata; +use ILIAS\MetaData\Services\ServicesInterface as Metadata; +use ILIAS\Export\ExportHandler\ilFactory as ExportServices; +use ILIAS\Data\Factory as DataFactory; /** * Class ilInfoScreenGUI @@ -41,6 +43,7 @@ class ilInfoScreenGUI protected ilTree $tree; protected ilSetting $settings; protected Metadata $metadata; + protected DataFactory $data_factory; public ilLanguage $lng; public ilCtrl $ctrl; public ?object $gui_object; @@ -94,6 +97,7 @@ public function __construct(?object $a_gui_object = null) $this->ui = $DIC->ui(); $this->request = $DIC->infoScreen()->internal()->gui()->standardRequest(); $this->html = $DIC->infoScreen()->internal()->gui()->html(); + $this->data_factory = new DataFactory(); } /** @@ -322,6 +326,7 @@ public function addMetaDataSections(int $a_rep_obj_id, int $a_obj_id, string $a_ $lng = $this->lng; $lng->loadLanguageModule("meta"); + $lng->loadLanguageModule('export'); $md_reader = $this->metadata->read($a_rep_obj_id, $a_obj_id, $a_type); $md_paths = $this->metadata->paths(); @@ -340,6 +345,10 @@ public function addMetaDataSections(int $a_rep_obj_id, int $a_obj_id, string $a_ $author_data = $md_reader->allData($md_paths->authors()); $author = $md_data_helper->makePresentableAsList(', ', ...$author_data); + // learning time + $learning_time_data = $md_reader->firstData($md_paths->firstTypicalLearningTime()); + $learning_time = $md_data_helper->makePresentable($learning_time_data); + // copyright $copyright_description = $md_reader->firstData($md_paths->copyright())->value(); if ($copyright_description) { @@ -348,9 +357,8 @@ public function addMetaDataSections(int $a_rep_obj_id, int $a_obj_id, string $a_ $copyright = ilMDUtils::_getDefaultCopyright(); } - // learning time - $learning_time_data = $md_reader->firstData($md_paths->firstTypicalLearningTime()); - $learning_time = $md_data_helper->makePresentable($learning_time_data); + // public access export + $public_access_export = $this->buildPublicAccessExportLink($a_rep_obj_id, $a_obj_id); // output @@ -381,20 +389,68 @@ public function addMetaDataSections(int $a_rep_obj_id, int $a_obj_id, string $a_ $author ); } - if ($copyright != "") { // copyright + if ($learning_time != "") { // typical learning time + $this->addProperty( + $lng->txt("meta_typical_learning_time"), + $learning_time + ); + } + + // licence and use section + if ($copyright === '' && $public_access_export === '') { + return; + } + $this->addSection($lng->txt('meta_info_licence_section')); + + if ($copyright !== '') { // copyright $this->addProperty( $lng->txt("meta_copyright"), $copyright ); } - if ($learning_time != "") { // typical learning time + + if ($public_access_export !== '') { // public access export $this->addProperty( - $lng->txt("meta_typical_learning_time"), - $learning_time + $lng->txt('export_info_public_access'), + $copyright ); } } + protected function buildPublicAccessExportLink(int $rep_obj_id, int $obj_id): string + { + /* + * This should be replaced by a proper export API + * when it is available. + */ + $export_services = new ExportServices(); + $public_access = $export_services->publicAccess()->handler(); + + /* + * Make sure we are not in a subobject, and that we will get + * the ref_id via the GUI from the correct object. + */ + if ( + $rep_obj_id !== $this->gui_object->getObject()->getId() || + ($obj_id !== 0 && $obj_id !== $rep_obj_id) + ) { + return ''; + } + + if (!$public_access->hasPublicAccessFile($rep_obj_id)) { + return ''; + } + + $ref_id = $this->gui_object->getObject()->getRefId(); + + return $this->ui->renderer()->render( + $this->ui->factory()->link()->standard( + $this->lng->txt('export_info_public_access_download'), + $public_access->downloadLinkOfPublicAccessFile($this->data_factory->refId($ref_id)) + ) + ); + } + /** * @throws ilDatabaseException * @throws ilDateTimeException diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 6efed721a65d..0009ffa71361 100755 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -9729,6 +9729,8 @@ export#:#export_create#:#Neu erstellen export#:#export_create_new_file#:#Neue Exportdatei erstellen export#:#export_existing#:#Wiederverwenden export#:#export_export_date#:#Exportdatum +export#:#export_info_public_access#:#Öffentlich zugänglicher Export +export#:#export_info_public_access_download#:#Download export#:#export_last_export#:#Letzter Export export#:#export_last_export_file#:#Letzte Exportdatei benutzen export#:#export_last_file#:#Letzte Datei @@ -12239,6 +12241,7 @@ meta#:#meta_idea#:#Idee meta#:#meta_identifier#:#Kennung meta#:#meta_identifier_plural#:#Kennungen meta#:#meta_index#:#Index +meta#:#meta_info_licence_section#:#Lizenz und Nachbenutzung meta#:#meta_info_only_repository_objects#:#Nachfolgend werden nur Magazinobjekte angezeigt, nicht aber Medienobjekte oder Lernmodulseiten. meta#:#meta_initiator#:#Initiator meta#:#meta_installation_remarks#:#Installationsanmerkungen diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index c394d86732d0..ac868bc9fb3e 100755 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -9703,6 +9703,8 @@ export#:#export_create#:#Create export#:#export_create_new_file#:#Create New Export File export#:#export_existing#:#Reuse export#:#export_export_date#:#Export Date +export#:#export_info_public_access#:#Public Access Export +export#:#export_info_public_access_download#:#Download export#:#export_last_export#:#Last Export export#:#export_last_export_file#:#Use Last Export File export#:#export_last_file#:#Last File @@ -12212,6 +12214,7 @@ meta#:#meta_idea#:#Idea meta#:#meta_identifier#:#Identifier meta#:#meta_identifier_plural#:#Identifiers meta#:#meta_index#:#Index +meta#:#meta_info_licence_section#:#Licence and Use meta#:#meta_info_only_repository_objects#:#Only repository objects are listed below (but not media objects or learning module pages). meta#:#meta_initiator#:#Initiator meta#:#meta_installation_remarks#:#Installation Notes