diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php index 75ad482395409746262cb3a6fbfa8eefebe2c328..274a32aee469196011aefb260ee24ca2056f3786 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php +++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php @@ -588,7 +588,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $ids = array($sourceRecord); } - return $this->getConsortialHolding($id, $patron, $ids); + return $this->getConsortialHoldings($id, $patron, $ids); } @@ -624,6 +624,8 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function patronLogin($username, $password) { + // TODO: we somehow need to figure out 'patron_agency_id' in the consortium=true case + //$request = $this->getLookupUserRequest($username, $password, 'patron_agency_id'); $request = $this->getLookupUserRequest($username, $password); $response = $this->sendRequest($request); $id = $response->xpath( @@ -672,7 +674,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf { $extras = array('<ns1:LoanedItemsDesired/>'); $request = $this->getLookupUserRequest( - $patron['cat_username'], $patron['cat_password'], $extras + $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); @@ -724,7 +726,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf { $extras = array('<ns1:UserFiscalAccountDesired/>'); $request = $this->getLookupUserRequest( - $patron['cat_username'], $patron['cat_password'], $extras + $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); @@ -785,7 +787,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf { $extras = array('<ns1:RequestedItemsDesired/>'); $request = $this->getLookupUserRequest( - $patron['cat_username'], $patron['cat_password'], $extras + $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); @@ -849,7 +851,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf '</ns1:UserElementType>' ); $request = $this->getLookupUserRequest( - $patron['cat_username'], $patron['cat_password'], $extras + $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); @@ -1043,7 +1045,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf * @return string A location ID * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function getDefaultPickUpLocation($patron = false, $holdDetails = null) + public function getDefaultPickUpLocation($patron, $holdDetails = null) { return $this->pickupLocations[$patron['patron_agency_id']][0]['locationID']; } @@ -1090,11 +1092,11 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf * * @return array Array of the patron's storage retrieval requests. */ - public function getMyStorageRetrievalRequests($patron = false) + public function getMyStorageRetrievalRequests($patron) { $extras = array('<ns1:RequestedItemsDesired/>'); $request = $this->getLookupUserRequest( - $patron['cat_username'], $patron['cat_password'], $extras + $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); @@ -1651,13 +1653,26 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf * * @return string NCIP request XML */ - protected function getLookupUserRequest($username, $password, $extras = array()) + protected function getLookupUserRequest($username, $password, $patron_agency_id = null, $extras = array()) { - return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . + $ret = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . '<ns1:NCIPMessage xmlns:ns1="http://www.niso.org/2008/ncip" ' . 'ns1:version="http://www.niso.org/schemas/ncip/v2_0/imp1/' . 'xsd/ncip_v2_0.xsd">' . - '<ns1:LookupUser>' . + '<ns1:LookupUser>'; + + if (!is_null($patron_agency_id)) { + $ret .= + '<ns1:InitiationHeader>' . + '<ns1:ToAgencyId>' . + '<ns1:AgencyId>' . + htmlspecialchars($patron_agency_id) . + '</ns1:AgencyId>' . + '</ns1:ToAgencyId>' . + '</ns1:InitiationHeader>'; + } + + $ret .= '<ns1:AuthenticationInput>' . '<ns1:AuthenticationInputData>' . htmlspecialchars($username) . @@ -1683,6 +1698,8 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf implode('', $extras) . '</ns1:LookupUser>' . '</ns1:NCIPMessage>'; + + return $ret; } }