From c081379d891c83e11779257953c81b21eb86ec01 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Thu, 3 Nov 2016 18:48:18 +0200 Subject: [PATCH] Minor improvements to getRequestGroups() (#846) - Added hold details parameter to getRequestGroups ILS driver method and added the possibility to include request type (Hold, StorageRetrievalRequest etc.) in request details so that e.g. pickup locations can be filtered by it. --- .../VuFind/src/VuFind/Controller/HoldsTrait.php | 6 ++++-- module/VuFind/src/VuFind/ILS/Driver/Demo.php | 13 +++++++++---- .../src/VuFind/ILS/Driver/MultiBackend.php | 17 ++++++++++++----- .../src/VuFind/ILS/Driver/VoyagerRestful.php | 10 +++++++--- module/VuFind/src/VuFind/ILS/Logic/Holds.php | 3 +++ 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/HoldsTrait.php b/module/VuFind/src/VuFind/Controller/HoldsTrait.php index b3cfa79a82e..41957b1173b 100644 --- a/module/VuFind/src/VuFind/Controller/HoldsTrait.php +++ b/module/VuFind/src/VuFind/Controller/HoldsTrait.php @@ -92,8 +92,10 @@ trait HoldsTrait // Send various values to the view so we can build the form: $requestGroups = $catalog->checkCapability( - 'getRequestGroups', [$driver->getUniqueID(), $patron] - ) ? $catalog->getRequestGroups($driver->getUniqueID(), $patron) : []; + 'getRequestGroups', [$driver->getUniqueID(), $patron, $gatheredDetails] + ) ? $catalog->getRequestGroups( + $driver->getUniqueID(), $patron, $gatheredDetails + ) : []; $extraHoldFields = isset($checkHolds['extraHoldFields']) ? explode(":", $checkHolds['extraHoldFields']) : []; diff --git a/module/VuFind/src/VuFind/ILS/Driver/Demo.php b/module/VuFind/src/VuFind/ILS/Driver/Demo.php index 3da19ce3a25..07809d19e06 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Demo.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Demo.php @@ -1072,17 +1072,22 @@ class Demo extends AbstractBase /** * Get request groups * - * @param int $bibId BIB ID - * @param array $patron Patron information returned by the patronLogin + * @param int $bibId BIB ID + * @param array $patron Patron information returned by the patronLogin * method. + * @param array $holdDetails Optional array, only passed in when getting a list + * in the context of placing a hold; contains most of the same values passed to + * placeHold, minus the patron data. May be used to limit the request group + * options or may be ignored. * * @return array False if request groups not in use or an array of * associative arrays with id and name keys * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function getRequestGroups($bibId = null, $patron = null) - { + public function getRequestGroups($bibId = null, $patron = null, + $holdDetails = null + ) { $this->checkIntermittentFailure(); return [ [ diff --git a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php index 7f7a4364cbe..9bdba22cfe1 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php +++ b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php @@ -701,21 +701,27 @@ class MultiBackend extends AbstractBase /** * Get request groups * - * @param int $id BIB ID - * @param array $patron Patron information returned by the patronLogin + * @param int $id BIB ID + * @param array $patron Patron information returned by the patronLogin * method. + * @param array $holdDetails Optional array, only passed in when getting a list + * in the context of placing a hold; contains most of the same values passed to + * placeHold, minus the patron data. May be used to limit the request group + * options or may be ignored. * * @return array An array of associative arrays with requestGroupId and * name keys */ - public function getRequestGroups($id, $patron) + public function getRequestGroups($id, $patron, $holdDetails = null) { $source = $this->getSource($id); $driver = $this->getDriver($source); if ($driver) { if ($this->getSource($patron['cat_username']) != $source || !$this->methodSupported( - $driver, 'getRequestGroups', compact('id', 'patron') + $driver, + 'getRequestGroups', + compact('id', 'patron', 'holdDetails') ) ) { // Return empty array since the sources don't match or the method @@ -724,7 +730,8 @@ class MultiBackend extends AbstractBase } $groups = $driver->getRequestGroups( $this->stripIdPrefixes($id, $source), - $this->stripIdPrefixes($patron, $source) + $this->stripIdPrefixes($patron, $source), + $this->stripIdPrefixes($holdDetails, $source) ); return $groups; } diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php index 74e03b984bb..ea5a9fd884d 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php +++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php @@ -840,14 +840,18 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte /** * Get request groups * - * @param int $bibId BIB ID - * @param array $patron Patron information returned by the patronLogin + * @param int $bibId BIB ID + * @param array $patron Patron information returned by the patronLogin * method. + * @param array $holdDetails Optional array, only passed in when getting a list + * in the context of placing a hold; contains most of the same values passed to + * placeHold, minus the patron data. May be used to limit the request group + * options or may be ignored. * * @return array False if request groups not in use or an array of * associative arrays with id and name keys */ - public function getRequestGroups($bibId, $patron) + public function getRequestGroups($bibId, $patron, $holdDetails = null) { if (!$this->requestGroupsEnabled) { return false; diff --git a/module/VuFind/src/VuFind/ILS/Logic/Holds.php b/module/VuFind/src/VuFind/ILS/Logic/Holds.php index 358efcb02e5..4f37ad8864f 100644 --- a/module/VuFind/src/VuFind/ILS/Logic/Holds.php +++ b/module/VuFind/src/VuFind/ILS/Logic/Holds.php @@ -488,6 +488,9 @@ class Holds */ protected function getRequestDetails($details, $HMACKeys, $action) { + // Include request type in the details + $details['requestType'] = $action; + // Generate HMAC $HMACkey = $this->hmac->generate($HMACKeys, $details); -- GitLab