Skip to content

Commit

Permalink
[FINNA-2767] Add Disec support for reservation lists (#3091)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha authored Jan 15, 2025
1 parent d8ebe10 commit aa1588d
Show file tree
Hide file tree
Showing 39 changed files with 1,740 additions and 229 deletions.
44 changes: 0 additions & 44 deletions local/config/finna/FeedbackForms.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -341,47 +341,3 @@ forms:
label: feedback_message
settings:
- [rows, 3]
ReservationListRequest:
allowLocalOverride: true
title: ReservationList::form_title
enabled: true
sendMethod: "email"
onlyForLoggedUsers: true
emailSubject: ReservationList::form_email_subject
response: ReservationList::form_response
hideSenderInfo: true
hideRecipientInfo: true
primaryHandler: email
senderNameRequired: true
includePatronId: true
help:
pre: ReservationList::request_pre_info_html
post: ReservationList::request_post_info_html

fields:
- name: record_ids
type: textarea
label: ReservationList::Reservation Resources
settings:
- [rows, 3]
- [readonly, true]
- name: name
type: text
label: feedback_name
- name: email
type: email
label: Email
- name: phone
type: text
label: Phone
- name: pickup_date
type: date
label: ReservationList::Delivery Time Request
minValue: now + 2 days
maxValue: now + 1 year
required: true
- name: message
type: textarea
label: ReservationList::Message
settings:
- [rows, 3]
69 changes: 66 additions & 3 deletions local/config/finna/ReservationList.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
# List can contain same information as under institution information to be more specific
# about where the order is being delivered
# LibraryCardSources is used to check for active connection to ILS to be able to use lists
# Connection holds information about type of lists, currently only value supported is type: Database
# and is the default value, if omitted
# Connection defines how the orders are handled with institutions:
# Type:
# email: Uses email to place orders
# Sender:
# name: Name to be shown as the sender of the email
# email: Email address to be shown as where the email was sent
# subject: Subject to be shown in the email
# disec: Uses Disec api for sending orders
# base_url: Api base url
# secret: Api specific secret
# use_cat_id: [Optional] Use catalog id for user instead of firstName, lastName, email. Default false.
#
# Each list declared uses their own translation keys under translation domain ReservationList::
#
Expand Down Expand Up @@ -43,7 +52,61 @@ Institutions:
Address: teststreet 10
Postal: 000001
City: Test city
Forms:
- PlaceOrder: default
LibraryCardSources:
- connection_established_to_use_lists
Connection:
type: Database
type: email
Sender:
name: Service sender
email: [email protected]
subject: Reservation List
PlaceOrder:
default:
allowLocalOverride: false
title: ReservationList::form_title
enabled: true
onlyForLoggedUsers: true
emailSubject: ReservationList::form_email_subject
response: ReservationList::form_response
hideSenderInfo: true
hideRecipientInfo: true
senderNameRequired: true
includePatronId: true
help:
pre: ReservationList::request_pre_info_html
post: ReservationList::request_post_info_html

fields:
- name: record_ids_text
type: textarea
label: ReservationList::Reservation Resources
settings:
- [rows, 3]
- [readonly, true]
- name: firstName
type: text
label: First Name
required: true
- name: lastName
type: text
label: Last Name
required: true
- name: email
type: email
label: Email
- name: phone
type: text
label: Phone
- name: pickup_date
type: date
label: ReservationList::Delivery Time Request
minValue: now + 2 days
maxValue: now + 1 year
required: true
- name: message
type: textarea
label: ReservationList::Message
settings:
- [rows, 3]
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/en-gb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Reservation lists name"
Send Reservation Request = "Send reservation request"
select_desired_contact_method = "Select desired contact method"
Select = "Select"

; List statuses:
status_unknown = ""
status_delivered = "Delivered"
status_in_process = "In process"
status_canceled = "Cancelled"
status_on_loan = "On Loan"
status_returned = "Returned"
status_renewed = "Renewed"
status_pending = "Pending"
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Varauslistan nimi"
Send Reservation Request = "Lähetä varauspyyntö"
select_desired_contact_method = "Valitse haluamasi yhteydenottotapa"
Select = "Valitse"

; List statuses:
status_unknown = ""
status_delivered = "Toimitettu"
status_in_process = "Käsittelyssä"
status_canceled = "Peruutettu"
status_on_loan = "Lainassa"
status_returned = "Palautettu"
status_renewed = "Uusittu"
status_pending = "Odottaa"
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/se.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = ""
Send Reservation Request = ""
select_desired_contact_method = ""
Select = ""

; List statuses:
status_unknown = ""
status_delivered = ""
status_in_process = ""
status_canceled = ""
status_on_loan = ""
status_returned = ""
status_renewed = ""
status_pending = ""
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Namn för bokningslista"
Send Reservation Request = "Skicka bokningsförfrågan"
select_desired_contact_method = "Välj önskad kontaktmetod"
Select = "Välj"

; List statuses:
status_unknown = ""
status_delivered = "Levererad"
status_in_process = "Behandlas"
status_canceled = "Annullerad"
status_on_loan = "Utlånad"
status_returned = "Returnerad"
status_renewed = "Förnyad"
status_pending = "Väntar"
6 changes: 6 additions & 0 deletions module/Finna/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@
'Finna\Service\UserPreferenceService' => 'Finna\Service\UserPreferenceServiceFactory',
'Finna\Statistics\Driver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'Finna\Statistics\EventHandler' => 'Finna\Statistics\EventHandlerFactory',
\Finna\ReservationList\Form\Form::class => \Finna\Form\FormFactory::class,
\Finna\ReservationList\ReservationListService::class => \Finna\ReservationList\ReservationListServiceFactory::class,
\Finna\ReservationList\Handler\PluginManager::class => \VuFind\ServiceManager\AbstractPluginManagerFactory::class,
'Finna\Favorites\FavoritesService' => 'Finna\Favorites\FavoritesServiceFactory',
'Finna\View\CustomElement\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'Finna\Video\Handler\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
Expand Down Expand Up @@ -493,6 +495,8 @@
'Finna\AjaxHandler\GetUserListFactory',
'Finna\AjaxHandler\GetUserLists' =>
'Finna\AjaxHandler\GetUserListsFactory',
'Finna\AjaxHandler\ReservationList' =>
'Finna\AjaxHandler\ReservationListFactory',
'Finna\AjaxHandler\ImportFavorites' =>
'Finna\AjaxHandler\ImportFavoritesFactory',
'Finna\AjaxHandler\OnlinePaymentNotify' =>
Expand Down Expand Up @@ -533,6 +537,7 @@
'getSearchTabsRecommendations' => 'Finna\AjaxHandler\GetSearchTabsRecommendations',
'getSimilarRecords' => 'Finna\AjaxHandler\GetSimilarRecords',
'getUserList' => 'Finna\AjaxHandler\GetUserList',
'reservationList' => 'Finna\AjaxHandler\ReservationList',
'importFavorites' => 'Finna\AjaxHandler\ImportFavorites',
'onlinePaymentNotify' => 'Finna\AjaxHandler\OnlinePaymentNotify',
'registerOnlinePayment' => 'Finna\AjaxHandler\RegisterOnlinePayment',
Expand Down Expand Up @@ -765,6 +770,7 @@
],
'onlinepayment_handler' => [ /* see Finna\OnlinePayment\Handler\PluginManager for defaults */ ],
'video_handler' => [ /* see Finna\Video\Handler\PluginManager for defaults */ ],
'reservationlist_handler' => [ /* see Finna\ReservationList\Handler\PluginManager for defaults */ ],
'recommend' => [
'factories' => [
'VuFind\Recommend\CollectionSideFacets' => 'Finna\Recommend\Factory::getCollectionSideFacets',
Expand Down
3 changes: 2 additions & 1 deletion module/Finna/sql/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ CREATE TABLE `finna_resource_list` (
`list_type` varchar(200) NOT NULL DEFAULT 'resourcelist',
`ordered` datetime DEFAULT NULL,
`pickup_date` datetime DEFAULT NULL,
`connection` varchar(40) NOT NULL DEFAULT 'database',
`connection` varchar(40) NOT NULL DEFAULT 'email',
`external_id` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `resource_list_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
Expand Down
109 changes: 109 additions & 0 deletions module/Finna/src/Finna/AjaxHandler/ReservationList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

/**
* Reservation list ajax handler
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 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 AjaxHandler
* @author Juha Luoma <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/

namespace Finna\AjaxHandler;

use Finna\ReservationList\Handler\PluginManager;
use Finna\ReservationList\ReservationListService;
use Laminas\Mvc\Controller\Plugin\Params;
use VuFind\Db\Entity\UserEntityInterface;
use VuFind\I18n\Translator\TranslatorAwareInterface;

/**
* Reservation list ajax handler
*
* @category VuFind
* @package AjaxHandler
* @author Juha Luoma <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/
class ReservationList extends \VuFind\AjaxHandler\AbstractBase implements TranslatorAwareInterface
{
use \VuFind\I18n\Translator\TranslatorAwareTrait;

/**
* Constructor
*
* @param ?UserEntityInterface $user Logged in user (or null)
* @param ReservationListService $reservationListService Reservation list service
* @param PluginManager $connectionHandler Reservation List connection handler
*/
public function __construct(
protected ?UserEntityInterface $user,
protected ReservationListService $reservationListService,
protected PluginManager $connectionHandler,
) {
}

/**
* Handle a request.
*
* @param Params $params Parameter helper from controller
*
* @return array [response data, HTTP status code]
*/
public function handleRequest(Params $params)
{
if ($this->user === null) {
return $this->formatResponse(
$this->translate('You must be logged in first'),
self::STATUS_HTTP_NEED_AUTH
);
}
$listId = (int)$params->fromQuery('list_id');
if (!$listId) {
return $this->formatResponse(
'Bad request',
self::STATUS_HTTP_BAD_REQUEST
);
}
$list = $this->reservationListService->getListById($listId, $this->user);
if (!$list) {
return $this->formatResponse(
'Bad request',
self::STATUS_HTTP_BAD_REQUEST
);
}
$result = [];
$type = $params->fromQuery('type');
if ('status' === $type) {
$listProperties = $this->reservationListService->getListProperties(
$list->getInstitution(),
$list->getListConfigIdentifier()
)['properties'];
$handler = $this->connectionHandler->getWithConfig($listProperties);
$response = $handler->getListStatus($list, $this->user);
$result['status'] = $this->translate($response);
} else {
return $this->formatResponse('Bad request', self::STATUS_HTTP_BAD_REQUEST);
}
return $this->formatResponse($result);
}
}
Loading

0 comments on commit aa1588d

Please sign in to comment.