/** * @param User $user * @param null $overDriveInfo * @return array */ public function getOverDriveHolds($user, $overDriveInfo = null, $forSummary = false) { //Cache holds for the user just for this call. if (isset($this->holds[$user->id])) { return $this->holds[$user->id]; } global $configArray; $holds = array(); $holds['holds'] = array('available' => array(), 'unavailable' => array()); if (!$this->isUserValidForOverDrive($user)) { return $holds; } $url = $configArray['OverDrive']['patronApiUrl'] . '/v1/patrons/me/holds'; $response = $this->_callPatronUrl($user, $url); if (isset($response->holds)) { foreach ($response->holds as $curTitle) { $hold = array(); $hold['overDriveId'] = $curTitle->reserveId; if ($curTitle->emailAddress) { $hold['notifyEmail'] = $curTitle->emailAddress; } else { //print_r($curTitle); } $hold['holdQueueLength'] = $curTitle->numberOfHolds; $hold['holdQueuePosition'] = $curTitle->holdListPosition; $hold['available'] = isset($curTitle->actions->checkout); if ($hold['available']) { $hold['expirationDate'] = strtotime($curTitle->holdExpires); } $hold['holdSource'] = 'OverDrive'; //Figure out which eContent record this is for. require_once ROOT_DIR . '/RecordDrivers/OverDriveRecordDriver.php'; if (!$forSummary) { $overDriveRecord = new OverDriveRecordDriver($hold['overDriveId']); $hold['recordId'] = $overDriveRecord->getUniqueID(); $hold['coverUrl'] = $overDriveRecord->getCoverUrl('medium'); $hold['recordUrl'] = $configArray['Site']['path'] . '/OverDrive/' . $overDriveRecord->getUniqueID() . '/Home'; $hold['title'] = $overDriveRecord->getTitle(); $hold['author'] = $overDriveRecord->getAuthor(); $hold['linkUrl'] = $overDriveRecord->getLinkUrl(false); $hold['format'] = $overDriveRecord->getFormats(); $hold['ratingData'] = $overDriveRecord->getRatingData(); } $key = $hold['holdSource'] . $hold['overDriveId']; if ($hold['available']) { $holds['holds']['available'][$key] = $hold; } else { $holds['holds']['unavailable'][$key] = $hold; } } } if (!$forSummary) { $this->holds[$user->id] = $holds; } return $holds; }