Skip to content

Commit

Permalink
Merge branch 'Aspen-Discovery:24.11.00' into 24.11.00
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderBlanchardAC authored Oct 28, 2024
2 parents 4d712b9 + 62783e4 commit 029c7eb
Show file tree
Hide file tree
Showing 68 changed files with 681 additions and 2,175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void getFormatFromPhysicalDescription(AbstractGroupedWorkSolr groupedWork
} else if (audioDiscPattern.matcher(physicalDescriptionData).matches() && !(physicalDescriptionData.contains("cd player") || physicalDescriptionData.contains("cd boombox") || physicalDescriptionData.contains("cd boom box") || physicalDescriptionData.contains("cd/mp3 player"))) {
//Check to see if there is a subfield e. If so, this could be a combined format
Subfield subfieldE = field.getSubfield('e');
if (subfieldE != null && subfieldE.getData().toLowerCase().contains("book")){
if (subfieldE != null && subfieldE.getData().toLowerCase().contains("book") && !subfieldE.getData().toLowerCase().contains("booklet")){
if (groupedWork != null && groupedWork.isDebugEnabled()) {groupedWork.addDebugMessage("Adding bib level format CD+Book based on 300 Physical Description", 2);}
result.add("CD+Book");
}else{
Expand Down Expand Up @@ -363,6 +363,9 @@ public void getFormatFromSubjects(AbstractGroupedWorkSolr groupedWork, org.marc4
}else if (subfieldData.contains("pop-up")) {
if (groupedWork != null && groupedWork.isDebugEnabled()) {groupedWork.addDebugMessage("Adding bib level format Pop-UpBook based on 655 Genre", 2);}
result.add("Pop-UpBook");
}else if (subfieldData.equals("zines")) {
if (groupedWork != null && groupedWork.isDebugEnabled()) {groupedWork.addDebugMessage("Adding bib level format Zines based on 655 Genre", 2);}
result.add("Zines");
}else if (subfieldData.startsWith("manga graphic novel") || subfieldData.equals("manga") || subfieldData.equals("manga.")) {
if (groupedWork != null && groupedWork.isDebugEnabled()) {groupedWork.addDebugMessage("Adding bib level format Manga based on 655 Genre", 2);}
result.add("Manga");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ItemInfoWithNotes createPrintIlsItem(AbstractGroupedWorkSolr groupedWork, Record
if (shelfLocationField != null) {
String shelfLocation = shelfLocationField.getData().toLowerCase();
//noinspection SpellCheckingInspection
if (shelfLocation.equals("xord")) {
if (shelfLocation.equalsIgnoreCase("xord")) {
item.itemInfo.setIsOrderItem();
}
}
Expand Down
48 changes: 27 additions & 21 deletions code/web/Drivers/Koha.php
Original file line number Diff line number Diff line change
Expand Up @@ -3071,7 +3071,7 @@ function freezeHold($patron, $recordId, $itemToFreezeId, $dateToReactivate) : ar
$result = [
'success' => false,
'message' => translate([
'text' => 'Unable to freeze your hold.',
'text' => 'Unable to freeze your hold. ',
'isPublicFacing' => true,
]),
];
Expand All @@ -3086,16 +3086,10 @@ function freezeHold($patron, $recordId, $itemToFreezeId, $dateToReactivate) : ar
'isPublicFacing' => true,
]);

$postParams = [];
$postParams = (object) [];
if (strlen($dateToReactivate) > 0) {
$postParams = [];
[
$year,
$month,
$day,
] = explode('-', $dateToReactivate);
$postParams['end_date'] = "$year-$month-$day";
}
$postParams['end_date'] = $dateToReactivate;
}

$endpoint = "/api/v1/holds/$itemToFreezeId/suspension";
$extraHeaders = ['Accept-Encoding: gzip, deflate','x-koha-library: ' . $patron->getHomeLocationCode()];
Expand All @@ -3104,17 +3098,29 @@ function freezeHold($patron, $recordId, $itemToFreezeId, $dateToReactivate) : ar
if ($response) {
$holdResponse = $response['content'];
if ($response['code'] != 201) {
$result['title'] = translate([
'text' => 'Hold frozen',
'isPublicFacing' => true,
]);
$result['message'] = translate([
'text' => $holdResponse['error'],
'isPublicFacing' => true,
]);
$result['success'] = false;
// Result for API or app use
$result['api']['message'] = $holdResponse['error'];
if (isset($holdResponse['error'])){
$result['title'] = translate([
'text' => 'Hold frozen',
'isPublicFacing' => true,
]);
$result['message'] = translate([
'text' => $holdResponse['error'],
'isPublicFacing' => true,
]);
$result['success'] = false;
// Result for API or app use
$result['api']['message'] = $holdResponse['error'];
} elseif (isset($holdResponse['errors'])) {
foreach ($holdResponse['errors'] as $error) {
$result['message'] .= translate([
'text' => $error['message'],
'isPublicFacing' => true,
]) . '<br/>';
}
} else {
$result['message'] = $holdResponse;
}

} else {
$result['message'] = translate([
'text' => 'Your hold was frozen successfully.',
Expand Down
7 changes: 4 additions & 3 deletions code/web/Drivers/KohaApiUserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ public function get(string $endpoint, string $caller, array $dataToSanitize = []
* Recover specific data of it as properties.
*
* @param string $endpoint e.g "/api/v1/auth/password/validation"
* @param array $requestParameters e.g ['identifier' => $username,'password' => $password,]
* @param array|object $requestParameters e.g ['identifier' => $username,'password' => $password,]
* @param string $caller e.g "koha.PatronLogin"
* @param array $dataToSanitize e.g ['password' => $password]
* @param array|null $extraHeaders e.g ['x-koha-embed: +strings,extended_attributes']
*
* @return array|bool An array containing the response body and response code retrieved by the request or false if authorization fails.
* @access public
*/
public function post(string $endpoint, array $requestParameters, string $caller, array $dataToSanitize = [], array $extraHeaders = null): array|bool {
public function post(string $endpoint, array|object $requestParameters, string $caller, array $dataToSanitize = [], array $extraHeaders = null): array|bool {
// Preparing request
$apiURL = $this->baseURL . $endpoint;
$jsonEncodedParams = json_encode($requestParameters);

if ($this->getAuthorizationHeader($caller)) {
$this->apiCurlWrapper->addCustomHeaders([
$this->getAuthorizationHeader($caller)
Expand All @@ -106,6 +106,7 @@ public function post(string $endpoint, array $requestParameters, string $caller,
$response = $this->apiCurlWrapper->curlSendPage($apiURL, 'POST', $jsonEncodedParams);
$responseCode = $this->apiCurlWrapper->getResponseCode();
$jsonResponse = $this->jsonValidate($response);

ExternalRequestLogEntry::logRequest($caller, 'POST', $apiURL, $this->apiCurlWrapper->getHeaders(), $jsonEncodedParams, $responseCode, $response, $dataToSanitize);
return [
'content' => $jsonResponse,
Expand Down
Loading

0 comments on commit 029c7eb

Please sign in to comment.