forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FINNA-2767] Add Disec support for reservation lists (#3091)
- Loading branch information
Showing
39 changed files
with
1,740 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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:: | ||
# | ||
|
@@ -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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.