From c1fe4d29a6b7ad6261deca5acf2f9fba6de08d56 Mon Sep 17 00:00:00 2001
From: Dorian Merz <merz@ub.uni-leipzig.de>
Date: Mon, 6 Dec 2021 14:16:38 +0100
Subject: [PATCH] refs #20473 [finc] add access status subfield readout to
 getUrls()

---
 .../src/finc/RecordDriver/SolrMarcFincTrait.php   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php
index 40b481986aa..fb499209ebb 100644
--- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php
+++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php
@@ -125,6 +125,14 @@ trait SolrMarcFincTrait
             '609' => ['a']
         ];
 
+        // access status mappings for subfield $7
+        $accessStatusMapping = [
+            '0' => 'Open',
+            '1' => 'Restricted',
+            'u' => 'unspecified',
+            'z' => 'Other'
+        ];
+
         foreach ($fieldsToCheck as $field => $subfields) {
             $urls = $this->getMarcRecord()->getFields($field);
             $resultsPerIndicator2 = [];
@@ -172,10 +180,17 @@ trait SolrMarcFincTrait
                             }
                         }
 
+                        $sub7 = $url->getSubfield("7");
+                        if ($sub7) {
+                            $accessStatus = $sub7->getData();
+                        }
+
                         $resultsPerIndicator2[$indicator2][$isil][] = [
                             'url' => $address,
                             'desc' => $desc,
                             'indicators' => $indicator1 . $indicator2,
+                            'accessStatus' => isset($accessStatus)
+                                ? $accessStatusMapping[$accessStatus] : '',
                         ];
                     }
                     if ($field == '609') {
-- 
GitLab