/** * 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: * (disabled, always, availability, driver) * @param array $patron Patron * * @return mixed A url on success, boolean false on failure */ protected function generateHold($id, $type, $patron) { $any_available = false; $addlink = false; $data = ['id' => $id, 'level' => 'title']; // Are holds allows? $checkHolds = $this->catalog->checkFunction('Holds', compact('id', 'patron')); if ($checkHolds != false) { if ($type == 'always') { $addlink = true; } elseif ($type == 'availability') { $holdings = $this->getHoldings($id); foreach ($holdings as $holding) { if ($holding['availability'] && !in_array($holding['location'], $this->hideHoldings)) { $any_available = true; } } $addlink = !$any_available; } if ($addlink) { if ($checkHolds['function'] == 'getHoldLink') { // Return opac link return $this->catalog->getHoldLink($id, $data); } else { // Return non-opac link return $this->getHoldDetails($data, $checkHolds['HMACKeys']); } } } return false; }
/** * Process ILL request information in holdings and set the links accordingly. * * @param array $holdings Holdings * @param string $id Record ID * @param array $patron Patron * * @return array Modified holdings */ protected function processILLRequests($holdings, $id, $patron) { if (!is_array($holdings)) { return $holdings; } // Are storage retrieval requests allowed? $requestConfig = $this->catalog->checkFunction('ILLRequests', compact('id', 'patron')); if (!$requestConfig) { return $holdings; } // Generate Links // Loop through each holding foreach ($holdings as &$location) { foreach ($location as &$copy) { // Is this copy requestable if (isset($copy['addILLRequestLink']) && $copy['addILLRequestLink']) { // If the request is blocked, link to an error page // instead of the form: if ($copy['addILLRequestLink'] === 'block') { $copy['ILLRequestLink'] = $this->getBlockedILLRequestDetails($copy); } else { $copy['ILLRequestLink'] = $this->getRequestDetails($copy, $requestConfig['HMACKeys'], 'ILLRequest'); } // If we are unsure whether request options are // available, set a flag so we can check later via AJAX: $copy['checkILLRequest'] = $copy['addILLRequestLink'] === 'check'; } } } return $holdings; }
/** * Initialize helper with dependencies * * @param IlsConnection $ilsConnection IlsConnection * @param HMAC $hmac Hmac * @param AuthManager $authManager AuthManager * @param IlsAuth $ilsAuth IlsAuth * @param ConfigManager $configManager ConfigManager * @param Translator $translator Translator * @param LocationMap $locationMap LocationMap * @param EbooksOnDemand $ebooksOnDemand EBooksOnDemand * @param Availability $availability Availability * @param BibCode $bibCodeHelper BibCodeHelper * @param Logger $swissbibLogger Logger * * @throws \Exception */ public function __construct(IlsConnection $ilsConnection, HMAC $hmac, AuthManager $authManager, IlsAuth $ilsAuth, ConfigManager $configManager, Translator $translator, LocationMap $locationMap, EbooksOnDemand $ebooksOnDemand, Availability $availability, BibCode $bibCodeHelper, Logger $swissbibLogger) { $this->ils = $ilsConnection; $this->configManager = $configManager; $this->configHoldings = $configManager->get('Holdings'); $this->hmac = $hmac; $this->authManager = $authManager; $this->ilsAuth = $ilsAuth; $this->translator = $translator; $this->locationMap = $locationMap; $this->ebooksOnDemand = $ebooksOnDemand; $this->availability = $availability; $this->bibCodeHelper = $bibCodeHelper; $this->swissbibLogger = $swissbibLogger; /** * Config * * @var Config $relationConfig */ $relationConfig = $configManager->get('libadmin-groups'); // Just ignore missing config to prevent a crashing frontend if ($relationConfig->count() !== null) { $this->institution2group = $relationConfig->institutions->toArray(); $this->groupSorting = $relationConfig->groups->toArray(); } elseif (APPLICATION_ENV == 'development') { throw new \Exception('Missing config file libadmin-groups.ini. Run libadmin sync ' . 'to solve this problem'); } $holdsIlsConfig = $this->ils->checkFunction('Holds'); $this->hmacKeys = $holdsIlsConfig['HMACKeys']; $this->initNetworks(); }