From d9c01c914c5a7d428e96a1178e702d507cf0b540 Mon Sep 17 00:00:00 2001
From: Gregor Gawol <gawol@ub.uni-leipzig.de>
Date: Fri, 26 Mar 2021 12:21:24 +0100
Subject: [PATCH] refs #19307 [finc] profile changes

* added EnhancedRenderArray to finc
* fixed profileMapper bug
* added X-LIBRARY-BORROWER-BLACK-LIST-INDICATOR and X-LIBRARY-BORROWER-BLACK-LIST-DESCRIPTION
---
 module/finc/src/finc/ILS/Driver/FincILS.php   | 12 ++++
 .../View/Helper/Root/EnhancedRenderArray.php  | 67 +++++++++++++++++++
 2 files changed, 79 insertions(+)
 create mode 100644 module/finc/src/finc/View/Helper/Root/EnhancedRenderArray.php

diff --git a/module/finc/src/finc/ILS/Driver/FincILS.php b/module/finc/src/finc/ILS/Driver/FincILS.php
index 0ab8821c741..ae3a88631dd 100644
--- a/module/finc/src/finc/ILS/Driver/FincILS.php
+++ b/module/finc/src/finc/ILS/Driver/FincILS.php
@@ -580,6 +580,14 @@ class FincILS extends PAIA implements LoggerAwareInterface
                             (string)$vcard->{'X-LIBRARY-ILS-PATRON-EDIT-ALLOW'}
                         );
                     }
+                    if (isset($vcard->{'X-LIBRARY-BORROWER-BLACK-LIST-INDICATOR'})) {
+                        $statuscodeInd
+                            = (string)$vcard->{'X-LIBRARY-BORROWER-BLACK-LIST-INDICATOR'};
+                    }
+                    if (isset($vcard->{'X-LIBRARY-BORROWER-BLACK-LIST-DESCRIPTION'})) {
+                        $statuscodeDesc
+                            = (string)$vcard->{'X-LIBRARY-BORROWER-BLACK-LIST-DESCRIPTION'};
+                    }
                 } catch (Exception $e) {
                     throw $e;
                 }
@@ -632,6 +640,10 @@ class FincILS extends PAIA implements LoggerAwareInterface
                     ? $this->convertDate($patron['expires']) : null,
                 'statuscode' => isset($patron['status'])
                     ? $patron['status'] : null,
+                'statuscodeInd' => isset($statuscodeInd)
+                    ? $statuscodeInd : null,
+                'statuscodeDesc' => isset($statuscodeDesc)
+                    ? $statuscodeDesc : null,
                 'note' => isset($patron['note'])
                     ? $patron['note'] : null,
                 'canWrite'   => in_array(self::SCOPE_WRITE_ITEMS, $this->getSession()->scope),
diff --git a/module/finc/src/finc/View/Helper/Root/EnhancedRenderArray.php b/module/finc/src/finc/View/Helper/Root/EnhancedRenderArray.php
new file mode 100644
index 00000000000..f2cd204de7f
--- /dev/null
+++ b/module/finc/src/finc/View/Helper/Root/EnhancedRenderArray.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * View helper to render a portion of an array.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2010.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * @category VuFind
+ * @package  View_Helpers
+ * @author   Demian Katz <demian.katz@villanova.edu>
+ * @author   Gregor Gawol <gawol@ub.uni-leipzig.de>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     https://vufind.org/wiki/development Wiki
+ */
+namespace finc\View\Helper\Root;
+use Zend\View\Helper\AbstractHelper;
+
+/**
+ * View helper to render a portion of an array.
+ *
+ * @category VuFind
+ * @package  View_Helpers
+ * @author   Demian Katz <demian.katz@villanova.edu>
+ * @author   Gregor Gawol <gawol@ub.uni-leipzig.de>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     https://vufind.org/wiki/development Wiki
+ */
+class EnhancedRenderArray extends AbstractHelper
+{
+    /**
+     * Render a portion of an array.
+     *
+     * @param string $tpl  A template for displaying each row.  This should
+     * include %%KEY&&, %%LABEL%%, %%VALUE%% and %%DISABLED%% placeholders
+     * @param array  $arr  An associative array of possible values to display
+     * @param array  $rows A label => profile key associative array specifying
+     * which rows of $arr to display
+     *
+     * @return string
+     */
+    public function __invoke($tpl1, $tpl2, $arr, $rows)
+    {
+        $html = '';
+        foreach ($rows as $label => $key) {
+            $html .= str_replace(
+              ['%%KEY%%', '%%LABEL%%', '%%VALUE%%'],
+              [$key, $label, $this->view->escapeHtml((isset($arr[$key]) ? $arr[$key] : ''))],
+              (isset($arr['disabled'][$key]) && ($arr['disabled'][$key] === true) ? $tpl1 : $tpl2)
+            );
+        }
+        return $html;
+    }
+}
-- 
GitLab