diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php index 42f0464bd3841d7f57efe506c0689eb81cb1edc5..1984f10ba3ebbf9333ce269dbfebf556db26edb2 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php @@ -133,9 +133,13 @@ class Backend extends AbstractBackend implements RetrieveBatchInterface */ public function retrieve($id, ParamBag $params = null) { + $onCampus = (null !== $params) ? $params->get('onCampus') : [false]; + $onCampus = $onCampus ? $onCampus[0] : false; try { $response = $this->connector - ->getRecord($id, $this->connector->getInstitutionCode()); + ->getRecord( + $id, $this->connector->getInstitutionCode(), $onCampus + ); } catch (\Exception $e) { throw new BackendException( $e->getMessage(), @@ -158,6 +162,9 @@ class Backend extends AbstractBackend implements RetrieveBatchInterface */ public function retrieveBatch($ids, ParamBag $params = null) { + $onCampus = (null !== $params) ? $params->get('onCampus') : [false]; + $onCampus = $onCampus ? $onCampus[0] : false; + // Load 100 records at a time; this is a good number to avoid memory // problems while still covering a lot of ground. $pageSize = 100; @@ -169,7 +176,7 @@ class Backend extends AbstractBackend implements RetrieveBatchInterface try { $response = $this->connector->getRecords( - $currentPage, $this->connector->getInstitutionCode() + $currentPage, $this->connector->getInstitutionCode(), $onCampus ); } catch (\Exception $e) { throw new BackendException( diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php index 71a51d7a089b14e9133baa0ee720c0f63803c166..ed2069ff94e24b1a89e3299012bcae346832e3bd 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php @@ -595,11 +595,12 @@ class Connector implements \Zend\Log\LoggerAwareInterface * * @param string $recordId The document to retrieve from the Primo API * @param string $inst_code Institution code (optional) + * @param bool $onCampus Whether the user is on campus * * @throws \Exception * @return string The requested resource */ - public function getRecord($recordId, $inst_code = null) + public function getRecord($recordId, $inst_code = null, $onCampus = false) { // Query String Parameters if (isset($recordId)) { @@ -607,7 +608,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface $qs[] = 'query=rid,exact,"' . urlencode(addcslashes($recordId, '"')) . '"'; $qs[] = "institution=$inst_code"; - $qs[] = "onCampus=true"; + $qs[] = 'onCampus=' . ($onCampus ? 'true' : 'false'); $qs[] = "indx=1"; $qs[] = "bulkSize=1"; $qs[] = "loc=adaptor,primo_central_multiple_fe"; @@ -626,11 +627,12 @@ class Connector implements \Zend\Log\LoggerAwareInterface * * @param array $recordIds The documents to retrieve from the Primo API * @param string $inst_code Institution code (optional) + * @param bool $onCampus Whether the user is on campus * * @throws \Exception * @return string The requested resource */ - public function getRecords($recordIds, $inst_code = null) + public function getRecords($recordIds, $inst_code = null, $onCampus = false) { // Callback function for formatting IDs: $formatIds = function ($i) { @@ -643,7 +645,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface $recordIds = array_map($formatIds, $recordIds); $qs[] = 'query=rid,contains,' . urlencode(implode(' OR ', $recordIds)); $qs[] = "institution=$inst_code"; - $qs[] = "onCampus=true"; + $qs[] = 'onCampus=' . ($onCampus ? 'true' : 'false'); $qs[] = "indx=1"; $qs[] = "bulkSize=" . count($recordIds); $qs[] = "loc=adaptor,primo_central_multiple_fe";