Skip to content

Commit

Permalink
public access file on info screen
Browse files Browse the repository at this point in the history
  • Loading branch information
schmitz-ilias committed Sep 25, 2024
1 parent 2765c6e commit 7b6fb4f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 8 deletions.
1 change: 1 addition & 0 deletions components/ILIAS/InfoScreen/PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
72 changes: 64 additions & 8 deletions components/ILIAS/InfoScreen/classes/class.ilInfoScreenGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7b6fb4f

Please sign in to comment.