diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 99beb0d5f8bde4f7f9550f38e9ca3265b70f29e8..2eafcbea7a8015c258fd0f1275de6464bf1c8466 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -846,7 +846,7 @@ class MyResearchController extends AbstractBase $catalog = $this->getILS(); // Process cancel requests if necessary: - $cancelStatus = $catalog->checkFunction('cancelHolds'); + $cancelStatus = $catalog->checkFunction('cancelHolds', compact('patron')); $view = $this->createViewModel(); $view->cancelResults = $cancelStatus ? $this->holds()->cancelHolds($catalog, $patron) : array(); @@ -905,7 +905,9 @@ class MyResearchController extends AbstractBase $catalog = $this->getILS(); // Process cancel requests if necessary: - $cancelSRR = $catalog->checkFunction('cancelStorageRetrievalRequests'); + $cancelSRR = $catalog->checkFunction( + 'cancelStorageRetrievalRequests', compact('patron') + ); $view = $this->createViewModel(); $view->cancelResults = $cancelSRR ? $this->storageRetrievalRequests()->cancelStorageRetrievalRequests( @@ -968,7 +970,9 @@ class MyResearchController extends AbstractBase $catalog = $this->getILS(); // Process cancel requests if necessary: - $cancelStatus = $catalog->checkFunction('cancelILLRequests'); + $cancelStatus = $catalog->checkFunction( + 'cancelILLRequests', compact('patron') + ); $view = $this->createViewModel(); $view->cancelResults = $cancelStatus ? $this->ILLRequests()->cancelILLRequests( @@ -1024,7 +1028,7 @@ class MyResearchController extends AbstractBase $catalog = $this->getILS(); // Get the current renewal status and process renewal form, if necessary: - $renewStatus = $catalog->checkFunction('Renewals'); + $renewStatus = $catalog->checkFunction('Renewals', compact('patron')); $renewResult = $renewStatus ? $this->renewals()->processRenewals( $this->getRequest()->getPost(), $catalog, $patron diff --git a/module/VuFind/src/VuFind/Controller/RecordController.php b/module/VuFind/src/VuFind/Controller/RecordController.php index ffbc7ad1cf70a91090b1bab6d1b0b6260d41e2b5..2ef48e25e88885387403152b587c821547629efa 100644 --- a/module/VuFind/src/VuFind/Controller/RecordController.php +++ b/module/VuFind/src/VuFind/Controller/RecordController.php @@ -98,18 +98,23 @@ class RecordController extends AbstractRecord { $driver = $this->loadRecord(); + // Stop now if the user does not have valid catalog credentials available: + if (!is_array($patron = $this->catalogLogin())) { + return $patron; + } + // If we're not supposed to be here, give up now! $catalog = $this->getILS(); - $checkHolds = $catalog->checkFunction("Holds", $driver->getUniqueID()); + $checkHolds = $catalog->checkFunction('Holds', + array( + 'id' => $driver->getUniqueID(), + 'patron' => $patron + ) + ); if (!$checkHolds) { return $this->forwardTo('Record', 'Home'); } - // Stop now if the user does not have valid catalog credentials available: - if (!is_array($patron = $this->catalogLogin())) { - return $patron; - } - // Do we have valid information? // Sets $this->logonURL and $this->gatheredDetails $gatheredDetails = $this->holds()->validateRequest($checkHolds['HMACKeys']); @@ -232,21 +237,24 @@ class RecordController extends AbstractRecord { $driver = $this->loadRecord(); + // Stop now if the user does not have valid catalog credentials available: + if (!is_array($patron = $this->catalogLogin())) { + return $patron; + } + // If we're not supposed to be here, give up now! $catalog = $this->getILS(); $checkRequests = $catalog->checkFunction( 'StorageRetrievalRequests', - $driver->getUniqueID() + array( + 'id' => $driver->getUniqueID(), + 'patron' => $patron + ) ); if (!$checkRequests) { return $this->forwardTo('Record', 'Home'); } - // Stop now if the user does not have valid catalog credentials available: - if (!is_array($patron = $this->catalogLogin())) { - return $patron; - } - // Do we have valid information? // Sets $this->logonURL and $this->gatheredDetails $gatheredDetails = $this->storageRetrievalRequests()->validateRequest( @@ -339,21 +347,24 @@ class RecordController extends AbstractRecord { $driver = $this->loadRecord(); + // Stop now if the user does not have valid catalog credentials available: + if (!is_array($patron = $this->catalogLogin())) { + return $patron; + } + // If we're not supposed to be here, give up now! $catalog = $this->getILS(); $checkRequests = $catalog->checkFunction( 'ILLRequests', - $driver->getUniqueID() + array( + 'id' => $driver->getUniqueID(), + 'patron' => $patron + ) ); if (!$checkRequests) { return $this->forwardTo('Record', 'Home'); } - // Stop now if the user does not have valid catalog credentials available: - if (!is_array($patron = $this->catalogLogin())) { - return $patron; - } - // Do we have valid information? // Sets $this->logonURL and $this->gatheredDetails $gatheredDetails = $this->ILLRequests()->validateRequest( diff --git a/module/VuFind/src/VuFind/ILS/Logic/Holds.php b/module/VuFind/src/VuFind/ILS/Logic/Holds.php index e5e277b24e4eb3ac870b4930f9bff3493b9c6fda..507d73f50619b8670413237a6519c2d177aac12e 100644 --- a/module/VuFind/src/VuFind/ILS/Logic/Holds.php +++ b/module/VuFind/src/VuFind/ILS/Logic/Holds.php @@ -169,7 +169,9 @@ class Holds $patron = $this->ilsAuth->storedCatalogLogin(); // Does this ILS Driver handle consortial holdings? - $config = $this->catalog->checkFunction('Holds'); + $config = $this->catalog->checkFunction( + 'Holds', compact('id', 'patron') + ); if (isset($config['consortium']) && $config['consortium'] == true) { $result = $this->catalog->getConsortialHoldings( $id, $patron ? $patron : null, $ids @@ -181,15 +183,17 @@ class Holds $mode = $this->catalog->getHoldsMode(); if ($mode == "disabled") { - $holdings = $this->standardHoldings($result); + $holdings = $this->standardHoldings($result); } else if ($mode == "driver") { - $holdings = $this->driverHoldings($result, $id); + $holdings = $this->driverHoldings($result, $id, $config); } else { - $holdings = $this->generateHoldings($result, $mode); + $holdings = $this->generateHoldings($result, $mode, $config); } - $holdings = $this->processStorageRetrievalRequests($holdings, $id); - $holdings = $this->processILLRequests($holdings, $id); + $holdings = $this->processStorageRetrievalRequests( + $holdings, $id, $patron + ); + $holdings = $this->processILLRequests($holdings, $id, $patron); } return $this->formatHoldings($holdings); } @@ -219,23 +223,21 @@ class Holds /** * Protected method for driver defined holdings * - * @param array $result A result set returned from a driver - * @param string $id Record ID + * @param array $result A result set returned from a driver + * @param string $id Record ID + * @param array $holdConfig Hold configuration from driver * * @return array A sorted results set */ - protected function driverHoldings($result, $id) + protected function driverHoldings($result, $id, $holdConfig) { $holdings = array(); if (count($result)) { - // Are holds allowed? - $checkHolds = $this->catalog->checkFunction("Holds", $id); - foreach ($result as $copy) { $show = !in_array($copy['location'], $this->hideHoldings); if ($show) { - if ($checkHolds) { + if ($holdConfig) { // Is this copy holdable / linkable if (isset($copy['addLink']) && $copy['addLink']) { // If the hold is blocked, link to an error page @@ -243,7 +245,7 @@ class Holds $copy['link'] = $copy['addLink'] === 'block' ? $this->getBlockedDetails($copy) : $this->getRequestDetails( - $copy, $checkHolds['HMACKeys'], 'Hold' + $copy, $holdConfig['HMACKeys'], 'Hold' ); // If we are unsure whether hold options are available, // set a flag so we can check later via AJAX: @@ -262,13 +264,14 @@ class Holds /** * Protected method for vufind (i.e. User) defined holdings * - * @param array $result A result set returned from a driver - * @param string $type The holds mode to be applied from: + * @param array $result A result set returned from a driver + * @param string $type The holds mode to be applied from: * (all, holds, recalls, availability) + * @param array $holdConfig Hold configuration from driver * * @return array A sorted results set */ - protected function generateHoldings($result, $type) + protected function generateHoldings($result, $type, $holdConfig) { $holdings = array(); $any_available = false; @@ -289,10 +292,7 @@ class Holds } } - // Are holds allowed? - $checkHolds = $this->catalog->checkFunction("Holds"); - - if ($checkHolds && is_array($holdings)) { + if ($holdConfig && is_array($holdings)) { // Generate Links // Loop through each holding foreach ($holdings as $location_key => $location) { @@ -327,7 +327,7 @@ class Holds ? ($addlink && $copy['is_holdable']) : $addlink; if ($addlink) { - if ($checkHolds['function'] == "getHoldLink") { + if ($holdConfig['function'] == "getHoldLink") { /* Build opac link */ $holdings[$location_key][$copy_key]['link'] = $this->catalog->getHoldLink( @@ -337,7 +337,7 @@ class Holds /* Build non-opac link */ $holdings[$location_key][$copy_key]['link'] = $this->getRequestDetails( - $copy, $checkHolds['HMACKeys'], 'Hold' + $copy, $holdConfig['HMACKeys'], 'Hold' ); } } @@ -352,11 +352,13 @@ class Holds * Process storage retrieval request information in holdings and set the links * accordingly. * - * @param array $holdings Holdings + * @param array $holdings Holdings + * @param string $id Record ID + * @param array $patron Patron * * @return array Modified holdings */ - protected function processStorageRetrievalRequests($holdings) + protected function processStorageRetrievalRequests($holdings, $id, $patron) { if (!is_array($holdings)) { return $holdings; @@ -364,7 +366,7 @@ class Holds // Are storage retrieval requests allowed? $requestConfig = $this->catalog->checkFunction( - 'StorageRetrievalRequests' + 'StorageRetrievalRequests', compact('id', 'patron') ); if (!$requestConfig) { @@ -405,11 +407,13 @@ class Holds /** * Process ILL request information in holdings and set the links accordingly. * - * @param array $holdings Holdings + * @param array $holdings Holdings + * @param string $id Record ID + * @param array $patron Patron * * @return array Modified holdings */ - protected function processILLRequests($holdings) + protected function processILLRequests($holdings, $id, $patron) { if (!is_array($holdings)) { return $holdings; @@ -417,7 +421,7 @@ class Holds // Are storage retrieval requests allowed? $requestConfig = $this->catalog->checkFunction( - 'ILLRequests' + 'ILLRequests', compact('id', 'patron') ); if (!$requestConfig) { diff --git a/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php b/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php index 0b62135ca709dd749e46392b6e45c077048c01d0..b0011c6aeb2edd6930403da30461a8ee6d3737b7 100644 --- a/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php +++ b/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php @@ -121,8 +121,9 @@ class TitleHolds } return $this->driverHold($id, $patron); } else { + $patron = $this->ilsAuth->storedCatalogLogin(); $mode = $this->checkOverrideMode($id, $mode); - return $this->generateHold($id, $mode); + return $this->generateHold($id, $mode, $patron); } } return false; @@ -190,7 +191,9 @@ class TitleHolds protected function driverHold($id, $patron) { // Get Hold Details - $checkHolds = $this->catalog->checkFunction("Holds"); + $checkHolds = $this->catalog->checkFunction( + 'Holds', compact('id', 'patron') + ); $data = array( 'id' => $id, 'level' => "title" @@ -208,13 +211,14 @@ class TitleHolds /** * Protected method for vufind (i.e. User) defined holds * - * @param string $id A Bib ID - * @param string $type The holds mode to be applied from: + * @param string $id A Bib ID + * @param string $type The holds mode to be applied from: * (disabled, always, availability, driver) + * @param array $patron Patron * * @return mixed A url on success, boolean false on failure */ - protected function generateHold($id, $type) + protected function generateHold($id, $type, $patron) { $any_available = false; $addlink = false; @@ -225,7 +229,9 @@ class TitleHolds ); // Are holds allows? - $checkHolds = $this->catalog->checkFunction("Holds"); + $checkHolds = $this->catalog->checkFunction( + 'Holds', compact('id', 'patron') + ); if ($checkHolds != false) { if ($type == "always") {