Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev-hide-system-email
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Sep 6, 2024
2 parents 09e9ff1 + 73e5cde commit 92936d9
Show file tree
Hide file tree
Showing 35 changed files with 517 additions and 100 deletions.
11 changes: 9 additions & 2 deletions config/vufind/KohaRest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ host = "http://koha-server/api"
; - updatecharges
; - payout
; - remaining_permissions
; - recalls
; - manage_recalls
;
; Add an API key to the user and copy the values for Client ID and Secret below.
; To add an API key in Koha, go to the patron screen and click More -> Manage API
Expand Down Expand Up @@ -125,6 +127,11 @@ updateFields = frozen:frozenThrough:pickUpLocation
; is false.
;allowCancelInTransit = false

; Uncomment the following line to enable recalls (disabled by default). Requires a
; Koha version that includes
; https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36075
;enableRecalls = true

; This section controls article request behavior. To enable, uncomment (at minimum)
; the HMACKeys and extraFields settings below.
[StorageRetrievalRequests]
Expand Down Expand Up @@ -160,10 +167,10 @@ extraFields = item-issue:acceptTerms:pickUpLocation
; false. Requires Koha REST DI plugin version 23.11.06 or later (earlier versions
; included suspended holds by default).
;includeSuspendedHoldsInQueueLength = false
; This section allows libraries to define different custom itemLimit rules for
; This section allows libraries to define different custom itemLimit rules for
; different biblio-level item types.
; In Koha the biblio-level item type is defined in the 942$c subfield.
; Set 'itemLimit' to set a fallback value that will be used for any item types not given a more
; Set 'itemLimit' to set a fallback value that will be used for any item types not given a more
; specific setting.
; Set 'itemLimitByType' followed by a [] containing a string for the Koha biblio-level item type.
; The string after the equal sign is the number of items to display in the holdings tab.
Expand Down
6 changes: 6 additions & 0 deletions config/vufind/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ theme = sandal
; standard themes since they support responsive design.
;mobile_theme = mobile

; Uncomment the following line to use a different theme for Admin module.
;admin_theme = sandal

; Automatic asset minification and concatenation setting. When active, HeadScript
; and HeadLink will concatenate and minify all viable files to reduce requests and
; load times. This setting is off by default.
Expand Down Expand Up @@ -2060,9 +2063,12 @@ hide_holdings[] = "World Wide Web"
; Available options:
; Channels - Display links to channels of content related to record
; Bookplate - Display a bookplate image or something similar
; MoreByAuthorSolr - Display books from the Solr index matching the current
; record's primary author.
; Similar - Similarity based on Solr lookup
; WorldCatSimilar - Similarity based on WorldCat lookup
related[] = "Similar"
;related[] = "MoreByAuthorSolr"

; The following settings are for the related Bookplate module. They can be
; enabled here by uncommenting below or from another config file of your choice.
Expand Down
1 change: 1 addition & 0 deletions languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ More options = "More options"
More Summon results = "More Summon results…"
More Topics = "More Topics"
more_authors_abbrev = "et al."
more_by_author = "Also by %%name%%"
more_ellipsis = "more…"
more_info_toggle = "Show/hide more info."
more_options_ellipsis = "More options…"
Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/ILS/Driver/Folio.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ protected function getDateTimeFromString(string $str): DateTime
*/
protected function getDueDate($itemId, $showTime)
{
$query = 'itemId==' . $itemId;
$query = 'itemId==' . $itemId . ' AND status.name==Open';
foreach (
$this->getPagedResults(
'loans',
Expand Down
60 changes: 60 additions & 0 deletions module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ public function getMyHolds($patron)
$entry['pickup_library_id'] ?? null
),
'create' => $this->convertDate($entry['hold_date'] ?? null),
'__create' => $entry['hold_date'] ?? null,
'expire' => $available ? null : $expirationDate,
'position' => $entry['priority'],
'available' => $available,
Expand All @@ -921,6 +922,65 @@ public function getMyHolds($patron)
];
}

if ($this->config['Holds']['enableRecalls'] ?? false) {
$result = $this->makeRequest(
[
'path' => 'v1/recalls',
'query' => [
'patron_id' => $patron['id'],
'completed' => 'false',
'_match' => 'exact',
'_per_page' => -1,
],
]
);

foreach ($result['data'] as $entry) {
$biblio = $this->getBiblio($entry['biblio_id']);
$volume = '';
if ($entry['item_id'] ?? null) {
$item = $this->getItem($entry['item_id']);
$volume = $item['serial_issue_number'];
}
$available = !empty($entry['waiting_date']);
$inTransit = !empty($entry['status']) && $entry['status'] == 'in_transit';
$requestId = $entry['recall_id'];
$cancelDetails = '';
$updateDetails = ($available || $inTransit) ? '' : $requestId;
// Note: Expiration date is the last interest date until the hold becomes
// available for pickup. Then it becomes the last pickup date.
$expirationDate = $this->convertDate($entry['expiration_date']);
$holds[] = [
'id' => $entry['biblio_id'],
'item_id' => $entry['recall_id'],
'reqnum' => $requestId,
'location' => $this->getLibraryName(
$entry['pickup_library_id'] ?? null
),
'create' => $this->convertDate($entry['hold_date'] ?? null),
'__create' => $entry['hold_date'] ?? null,
'expire' => $available ? null : $expirationDate,
'position' => $entry['priority'],
'available' => $available,
'last_pickup_date' => $available ? $expirationDate : null,
'in_transit' => $inTransit,
'title' => $this->getBiblioTitle($biblio),
'isbn' => $biblio['isbn'] ?? '',
'issn' => $biblio['issn'] ?? '',
'publication_year' => $biblio['copyright_date']
?? $biblio['publication_year'] ?? '',
'volume' => $volume,
'cancel_details' => $cancelDetails,
'updateDetails' => $updateDetails,
];
}
}
$callback = function ($a, $b) {
return $a['__create'] === $b['__create']
? $a['item_id'] <=> $b['item_id']
: $a['__create'] <=> $b['__create'];
};
usort($holds, $callback);
return $holds;
}

Expand Down
124 changes: 124 additions & 0 deletions module/VuFind/src/VuFind/Related/MoreByAuthorSolr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

/**
* Related Records: Solr-based "more by author"
*
* PHP version 8
*
* Copyright (C) Villanova University 2024.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Related_Records
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:related_records_modules Wiki
*/

namespace VuFind\Related;

use VuFindSearch\Command\SearchCommand;
use VuFindSearch\Query\Query;

use function count;

/**
* Related Records: Solr-based "more by author"
*
* @category VuFind
* @package Related_Records
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:related_records_modules Wiki
*/
class MoreByAuthorSolr implements RelatedInterface
{
/**
* Similar records
*
* @var array
*/
protected array $results = [];

/**
* Author being searched
*
* @var string
*/
protected string $author = '';

/**
* Maximum number of titles to suggest
*
* @var int
*/
protected int $maxRecommendations = 5;

/**
* Constructor
*
* @param \VuFindSearch\Service $searchService Search service
*/
public function __construct(protected \VuFindSearch\Service $searchService)
{
}

/**
* Establishes base settings for making recommendations.
*
* @param string $settings Settings from config.ini
* @param \VuFind\RecordDriver\AbstractBase $driver Record driver object
*
* @return void
*/
public function init($settings, $driver)
{
$this->results = [];
if ($this->author = $driver->tryMethod('getPrimaryAuthor')) {
$queryStr = '"' . addcslashes($this->author, '"') . '"';
$query = new Query($queryStr, 'Author');
$command = new SearchCommand(DEFAULT_SEARCH_BACKEND, $query, 0, $this->maxRecommendations + 1);
foreach ($this->searchService->invoke($command)->getResult() as $result) {
if (count($this->results) >= $this->maxRecommendations) {
break;
}
if ($result->getUniqueID() != $driver->getUniqueID()) {
$this->results[] = $result;
}
}
}
}

/**
* Get name of author being searched for.
*
* @return string
*/
public function getName(): string
{
return $this->author;
}

/**
* Get an array of Record Driver objects representing items similar to the one
* passed to the constructor.
*
* @return array
*/
public function getResults(): array
{
return $this->results;
}
}
2 changes: 2 additions & 0 deletions module/VuFind/src/VuFind/Related/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
'channels' => Channels::class,
'bookplate' => Bookplate::class,
'editions' => Deprecated::class,
'morebyauthorsolr' => MoreByAuthorSolr::class,
'similar' => Similar::class,
'worldcateditions' => Deprecated::class,
'worldcatsimilar' => WorldCatSimilar::class,
Expand All @@ -65,6 +66,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
Channels::class => InvokableFactory::class,
Bookplate::class => BookplateFactory::class,
Deprecated::class => InvokableFactory::class,
MoreByAuthorSolr::class => SimilarFactory::class,
Similar::class => SimilarFactory::class,
WorldCatSimilar::class => SimilarFactory::class,
];
Expand Down
14 changes: 14 additions & 0 deletions module/VuFind/src/VuFind/Role/PermissionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ public function isAuthorized($permission, $context = null)
return false;
}

/**
* Get a list of all configured permissions.
*
* @return string[]
*/
public function getAllConfiguredPermissions(): array
{
$permissions = [];
foreach ($this->config as $value) {
$permissions = array_merge($permissions, (array)($value['permission'] ?? []));
}
return array_values(array_unique($permissions));
}

/**
* Check if a permission rule exists
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"expectedMethod": "GET",
"expectedPath": "\/circulation\/loans",
"expectedParams": {
"query": "itemId==itemid",
"query": "itemId==itemid AND status.name==Open",
"offset": 0,
"limit": 1000
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function gotoRecordWithSearch(
. urlencode("id:($id)")
);
$page = $session->getPage();
$this->clickCss($page, '#result0 a.record-cover-link');
$this->clickCss($page, '#result0 a.getFull');
$this->waitForPageLoad($page);
return $page;
}
Expand Down
Loading

0 comments on commit 92936d9

Please sign in to comment.