From 074bbcea72a69fe076a89bac4cd966a10da9c954 Mon Sep 17 00:00:00 2001
From: Chris Delis <cedelis@uillinois.edu>
Date: Fri, 17 Oct 2014 08:19:48 -0400
Subject: [PATCH] First steps to "consortialize" (see pull request #166).

---
 module/VuFind/src/VuFind/ILS/Logic/Holds.php       | 14 +++++++++++---
 module/VuFind/src/VuFind/RecordDriver/SolrMarc.php | 12 +++++++++++-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/module/VuFind/src/VuFind/ILS/Logic/Holds.php b/module/VuFind/src/VuFind/ILS/Logic/Holds.php
index 66a86a2cd22..80273e28f0d 100644
--- a/module/VuFind/src/VuFind/ILS/Logic/Holds.php
+++ b/module/VuFind/src/VuFind/ILS/Logic/Holds.php
@@ -153,11 +153,11 @@ class Holds
      * holding method to call
      *
      * @param string $id A Bib ID
+     * @param array $ids A list of Source Records (if catalog is for a consortium)
      *
      * @return array A sorted results set
      */
-
-    public function getHoldings($id)
+    public function getHoldings($id, $ids = null)
     {
         $holdings = array();
 
@@ -167,7 +167,15 @@ class Holds
             // controller and view to inform the user that these credentials are
             // needed for hold data.
             $patron = $this->ilsAuth->storedCatalogLogin();
-            $result = $this->catalog->getHolding($id, $patron ? $patron : null);
+
+            // Does this ILS Driver handle consortial holdings?
+            $config = $this->catalog->getConfig('Holds');
+            if (isset($config['consortium']) && $config['consortium'] == true) {
+               $result = $this->catalog->getConsortialHoldings($id, $patron ? $patron : null, $ids);
+            } else {
+               $result = $this->catalog->getHolding($id, $patron ? $patron : null);
+            }
+
             $mode = $this->catalog->getHoldsMode();
 
             if ($mode == "disabled") {
diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php
index 471bedac046..5744fe5d92e 100644
--- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php
+++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php
@@ -1062,7 +1062,7 @@ class SolrMarc extends SolrDefault
     public function getRealTimeHoldings()
     {
         return $this->hasILS()
-            ? $this->holdLogic->getHoldings($this->getUniqueID())
+            ? $this->holdLogic->getHoldings($this->getUniqueID(), $this->getConsortialIDs())
             : array();
     }
 
@@ -1135,4 +1135,14 @@ class SolrMarc extends SolrDefault
             'record-rdf-mods.xsl', trim($this->marcRecord->toXML())
         );
     }
+
+    /**
+     * Return the list of "source records" for this consortial record.
+     *
+     * @return array
+     */
+    public function getConsortialIDs()
+    {
+        return $this->getFieldArray('035', 'a', true);
+    }
 }
-- 
GitLab