Skip to content
Snippets Groups Projects
Commit 7822da89 authored by Robert Lange's avatar Robert Lange
Browse files

refs #20183 [finc] move uncritical FincLibero functions to finc

* isTitleHold
* placeTitleHold
* extendPickUpLocation
parent 67e92d6c
Branches
Tags
No related merge requests found
......@@ -711,4 +711,109 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
{
return [];
}
/**
* Check if item is a pretended dummy to signify there is a title order
* possible.
*
* @param array $item DAIA item
*
* @return mixed
*/
public function isTitleHold($item)
{
foreach ($this->titleHoldLimitations as $limitation) {
$regex = '/^' . trim($limitation) . '$/';
if (0 < preg_match($regex, $item['id'])) {
return true;
}
}
return null;
}
/**
* Place Title Hold
*
* Attempts to place a hold or recall on a particular item and returns
* an array with result details
*
* Make a request on a specific record
*
* @param array $holdDetails An array of item and patron data
*
* @return mixed An array of data on the request including
* whether or not it was successful and a system message (if available)
*/
public function placeTitleHold($holdDetails)
{
$item = $holdDetails['item_id'];
$patron = $holdDetails['patron'];
$doc = [];
$doc['item'] = stripslashes($item);
if ($confirm = $this->getConfirmations(
$this->extendPickUpLocation($holdDetails)
)) {
$doc["confirm"] = $confirm;
}
$post_data['doc'][] = $doc;
try {
$array_response = $this->paiaPostAsArray(
'core/'.$patron['cat_username'].'/request', $post_data
);
} catch (Exception $e) {
$this->debug($e->getMessage());
return [
'success' => false,
'sysMessage' => $e->getMessage(),
];
}
$details = [];
if (array_key_exists('error', $array_response)) {
$details = [
'success' => false,
'sysMessage' => $array_response['error_description']
];
} else {
$elements = $array_response['doc'];
foreach ($elements as $element) {
if (array_key_exists('error', $element)) {
$details = [
'success' => false,
'sysMessage' => $element['error']
];
} else {
// FincLibero supports more expressive responses from paialibero
// which should be shown instead to the user (localIlsStatus)
$details = [
'success' => true,
'sysMessage' => isset($element['localIlsStatus'])
? $element['localIlsStatus'] : 'Successfully requested'
];
// if caching is enabled for DAIA remove the cached data for the
// current item otherwise the changed status will not be shown
// before the cache expires
if ($this->daiaCacheEnabled) {
$this->removeCachedData($holdDetails['doc_id']);
}
}
}
}
return $details;
}
/**
* Extend pickup location with base department URI
*
* @param array $holdDetails An array of item and patron data.
*
* @return array $holdDetails;
*/
protected function extendPickUpLocation($holdDetails)
{
if (isset($holdDetails['pickUpLocation'])) {
$holdDetails['pickUpLocation']
= $this->departmentLocationBase . $holdDetails['pickUpLocation'];
}
return $holdDetails;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment