From 37eb218e6263e89f926ecb99fe6f2c421d1ac5ae Mon Sep 17 00:00:00 2001
From: Rasmus Fuhse <fuhse@data-quest.de>
Date: Wed, 3 Jul 2024 10:05:17 +0000
Subject: [PATCH] =?UTF-8?q?Resolve=20"Dateibereich:=20Literaturangaben=20h?=
 =?UTF-8?q?aben=20ungekl=C3=A4rte=20Lizenz"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4361

Merge request studip/studip!3162
---
 app/controllers/library_file.php                 |  8 ++++----
 app/views/file/_file_aside.php                   |  2 +-
 app/views/library_file/_add_edit_form.php        | 16 ++++++++--------
 .../librarysearch/LibraryDocument.class.php      |  4 ++--
 templates/library/library_document_info.php      |  2 +-
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/app/controllers/library_file.php b/app/controllers/library_file.php
index 6331a1ee2d9..abfbf662224 100644
--- a/app/controllers/library_file.php
+++ b/app/controllers/library_file.php
@@ -101,11 +101,11 @@ class LibraryFileController extends AuthenticatedController
         $this->required_properties = [];
         $this->enriched_properties = [];
         foreach ($this->defined_variables as $key => $variable) {
-            if ($variable['required']) {
+            if (!empty($variable['required'])) {
                 $this->required_properties[] = $variable['name'];
                 $key += 100;
             }
-            if (in_array($variable['name'], $this->document_type['properties'])) {
+            if (isset($variable['name']) && in_array($variable['name'], $this->document_type['properties'])) {
                 $this->enriched_properties[$key] = $variable;
                 $property_types[$variable['name']] = $variable['type'];
             }
@@ -241,11 +241,11 @@ class LibraryFileController extends AuthenticatedController
         $this->required_properties = [];
         $this->enriched_properties = [];
         foreach ($this->defined_variables as $key => $variable) {
-            if ($variable['required']) {
+            if (!empty($variable['required'])) {
                 $this->required_properties[] = $variable['name'];
                 $key += 100;
             }
-            if (in_array($variable['name'], $this->document_type['properties'])) {
+            if (isset($variable['name']) && in_array($variable['name'], $this->document_type['properties'])) {
                 $this->enriched_properties[$key] = $variable;
                 $property_types[$variable['name']] = $variable['type'];
             }
diff --git a/app/views/file/_file_aside.php b/app/views/file/_file_aside.php
index e626f324f4e..cdddc26c0e4 100644
--- a/app/views/file/_file_aside.php
+++ b/app/views/file/_file_aside.php
@@ -45,7 +45,7 @@
 
             <? $content_terms_of_use = $file->getTermsOfUse() ?>
 
-            <? if ($content_terms_of_use) : ?>
+            <? if ($content_terms_of_use && !is_a($file, LibraryFile::class)) : ?>
             <tr>
                 <td colspan="2">
                     <h3><?=_('Hinweis zur Nutzung und Weitergabe:')?></h3>
diff --git a/app/views/library_file/_add_edit_form.php b/app/views/library_file/_add_edit_form.php
index 595b96d5b23..d00e70e9503 100644
--- a/app/views/library_file/_add_edit_form.php
+++ b/app/views/library_file/_add_edit_form.php
@@ -13,33 +13,33 @@
                 </span>
                 <? if ($property['type'] == 'number') : ?>
                     <input type="number"
-                           value="<?= htmlReady($document_properties[$property['name']]) ?>"
+                           value="<?= htmlReady($document_properties[$property['name']] ?? '') ?>"
                            name="document_properties[<?= htmlReady($property['name']) ?>]">
                 <? else : ?>
                     <? if ($property['type'] == 'name') : ?>
                         <input type="text" placeholder="<?= _('Nachname') ?>"
-                               value="<?= htmlReady($document_properties[$property['name']][0]['family']) ?>"
+                               value="<?= htmlReady($document_properties[$property['name']][0]['family'] ?? '') ?>"
                                name="document_properties[<?= htmlReady($property['name']) ?>][0][family]">
                         <input type="text" placeholder="<?= _('Vorname') ?>"
-                               value="<?= htmlReady($document_properties[$property['name']][0]['given']) ?>"
+                               value="<?= htmlReady($document_properties[$property['name']][0]['given'] ?? '') ?>"
                                name="document_properties[<?= htmlReady($property['name']) ?>][0][given]">
                         <input type="text" placeholder="<?= _('Namenszusatz') ?>"
-                               value="<?= htmlReady($document_properties[$property['name']][0]['suffix']) ?>"
+                               value="<?= htmlReady($document_properties[$property['name']][0]['suffix'] ?? '') ?>"
                                name="document_properties[<?= htmlReady($property['name']) ?>][0][suffix]">
                         <? elseif ($property['type'] == 'date') : ?>
                         <input type="text" placeholder="<?= _('Jahr') ?>"
-                               value="<?= htmlReady($document_properties[$property['name']]['date-parts'][0][0]) ?>"
+                               value="<?= htmlReady($document_properties[$property['name']]['date-parts'][0][0] ?? '') ?>"
                                name="document_properties[<?= htmlReady($property['name']) ?>][date-parts][0][0]">
                         <input type="text" placeholder="<?= _('Monat') ?>"
-                               value="<?= htmlReady($document_properties[$property['name']]['date-parts'][0][1]) ?>"
+                               value="<?= htmlReady($document_properties[$property['name']]['date-parts'][0][1] ?? '') ?>"
                                name="document_properties[<?= htmlReady($property['name']) ?>][date-parts][0][1]">
                         <input type="text" placeholder="<?= _('Tag') ?>"
-                               value="<?= htmlReady($document_properties[$property['name']]['date-parts'][0][2]) ?>"
+                               value="<?= htmlReady($document_properties[$property['name']]['date-parts'][0][2] ?? '') ?>"
                                name="document_properties[<?= htmlReady($property['name']) ?>][date-parts][0][2]">
 
                     <? else : ?>
                         <input type="text"
-                               value="<?= htmlReady($document_properties[$property['name']]) ?>"
+                               value="<?= htmlReady($document_properties[$property['name']] ?? '') ?>"
                                name="document_properties[<?= htmlReady($property['name']) ?>]">
                     <? endif ?>
                 <? endif ?>
diff --git a/lib/classes/librarysearch/LibraryDocument.class.php b/lib/classes/librarysearch/LibraryDocument.class.php
index 8b74a2efa28..eb0b2b9f915 100644
--- a/lib/classes/librarysearch/LibraryDocument.class.php
+++ b/lib/classes/librarysearch/LibraryDocument.class.php
@@ -197,10 +197,10 @@ class LibraryDocument
     public function getIdentifiers(): string
     {
         $identifiers = [];
-        if ($this->csl_data['ISBN']) {
+        if (!empty($this->csl_data['ISBN'])) {
             $identifiers[] = sprintf(_('ISBN: %s'), $this->csl_data['ISBN']);
         }
-        if ($this->csl_data['ISSN']) {
+        if (!empty($this->csl_data['ISSN'])) {
             $identifiers[] = sprintf(_('ISSN: %s'), $this->csl_data['ISSN']);
         }
         return implode('; ', $identifiers);
diff --git a/templates/library/library_document_info.php b/templates/library/library_document_info.php
index 12471238394..dffdade9c60 100644
--- a/templates/library/library_document_info.php
+++ b/templates/library/library_document_info.php
@@ -2,7 +2,7 @@
 $authors = $document->getAuthorNames();
 $issue_date = $document->getIssueDate(true);
 $identifiers = $document->getIdentifiers();
-$url = ($document->download_url ?: $document->document_url);
+$url = $document->download_url ?? $document->document_url ?? '';
 $is_search = !$document->csl_data;
 ?>
 <? if ($is_search) : ?>
-- 
GitLab