Skip to content

Commit 29885be

Browse files
authored
Merge pull request #124 from beluga-core/develop-5
Update master
2 parents fe6f3ad + 9c61539 commit 29885be

File tree

52 files changed

+1198
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1198
-656
lines changed

config/vufind/deliveryGlobal.ini

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[DeliveryDomain]
2+
; the domainname is the key of this configuration part
3+
domain = DeliveryDomain
4+
5+
; plugin configuration is expected below
6+
plugin = Plugin
7+
8+
; how many callnumbers should be collected if several are available?
9+
collectedCallnumbers = 1
10+
; should callnumber be preset within order form?
11+
presetCallnumbers = y
12+
13+
; allowed usertypes
14+
allowed[] =
15+
16+
; configuration of availability; ini-file should be there as well
17+
availability_config = deliveryAvailability
18+
; configuration of order form; ini-file should be there as well
19+
orderdata_config = deliveryOrderData
20+
21+
; whether to show a link to \Delivery\Home or not
22+
template_show_home = y
23+
; title of Home and Order page
24+
template_title =
25+
; text for icon on search pages
26+
template_text =
27+
; icon for search pages
28+
template_icon =
29+
; belugino icon for search pages
30+
template_belugino =
31+
32+
[Plugin]
33+
; plugin configuration parameter: must contain at least a template
34+
orderTemplate =

config/vufind/dependent-works.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
limit =500
44
sort = SORT_REGULAR
5+
;searchfield = hierarchy_top_id ;field to search for records connected to an id, default is hierarchy_top_id
6+
;filter = '-format:Article' ;a filter can be added, default no filter

module/BelugaConfig/src/BelugaConfig/AjaxHandler/GetResultCount.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function handleRequest(Params $params)
8484
foreach ($queryArray as $queryItem) {
8585
$arrayKey = false;
8686
list($key, $value) = explode('=', $queryItem, 2);
87-
if (preg_match('/[0-9](\[\]$)/', $key, $matches)) {
87+
if (preg_match('/(\[\]$)/', $key, $matches)) {
8888
$key = str_replace($matches[1], '', $key);
8989
$arrayKey = true;
9090
}

module/Delivery/src/Delivery/AjaxHandler/CheckAvailability.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
namespace Delivery\AjaxHandler;
2929

3030
use Delivery\AvailabilityHelper;
31+
use Delivery\ConfigurationManager;
3132
use VuFind\AjaxHandler\AbstractBase;
33+
use VuFind\Config\PluginManager as ConfigManager;
3234
use VuFind\Search\Results\PluginManager as ResultsManager;
3335
use Zend\Http\PhpEnvironment\Request;
3436
use Zend\Mvc\Controller\Plugin\Params;
@@ -52,7 +54,7 @@ class CheckAvailability extends AbstractBase
5254
*
5355
* @var Request
5456
*/
55-
protected $AvailabilityHelper;
57+
protected $configManager;
5658

5759
protected $resultsManager;
5860

@@ -65,8 +67,9 @@ class CheckAvailability extends AbstractBase
6567
* @param TabManager $pm RecordTab plugin manager
6668
* @param RendererInterface $renderer Renderer
6769
*/
68-
public function __construct($config, ResultsManager $resultsManager) {
69-
$this->AvailabilityHelper = new AvailabilityHelper(null, $config['default']);
70+
public function __construct(ConfigManager $configManager, ResultsManager $resultsManager)
71+
{
72+
$this->configManager = $configManager;
7073
$this->resultsManager = $resultsManager;
7174
}
7275

@@ -79,6 +82,11 @@ public function __construct($config, ResultsManager $resultsManager) {
7982
*/
8083
public function handleRequest(Params $params)
8184
{
85+
$deliveryDomain = $params->fromQuery('domain', 'main');
86+
$configurationManager = new ConfigurationManager($this->configManager, $deliveryDomain);
87+
$availabilityConfig = $configurationManager->getAvailabilityConfig();
88+
$availabilityHelper = new AvailabilityHelper(null, $availabilityConfig['default']);
89+
8290
$ppn = $params->fromQuery('ppn');
8391
$backend = $params->fromQuery('source', DEFAULT_SEARCH_BACKEND);
8492
$backend = DEFAULT_SEARCH_BACKEND;
@@ -88,8 +96,8 @@ public function handleRequest(Params $params)
8896

8997
$records = $results->getResults();
9098
$driver = $records[0];
91-
$this->AvailabilityHelper->setSolrDriver($driver);
92-
$available = ($this->AvailabilityHelper->checkSignature()) ? 'available' : 'not available';
99+
$availabilityHelper->setSolrDriver($driver);
100+
$available = ($availabilityHelper->checkSignature()) ? 'available' : 'not available';
93101
return $this->formatResponse(['available' => $available]);
94102
}
95103
}

module/Delivery/src/Delivery/AjaxHandler/CheckAvailabilityFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public function __invoke(ContainerInterface $container, $requestedName,
6363
if (!empty($options)) {
6464
throw new \Exception('Unexpected options passed to factory.');
6565
}
66-
$config = $container->get('VuFind\Config\PluginManager')->get('deliveryAvailability');
66+
#$config = $container->get('VuFind\Config\PluginManager')->get('deliveryAvailability');
6767
return new $requestedName(
68-
$config,
68+
$container->get('VuFind\Config\PluginManager'),
6969
$container->get('VuFind\Search\Results\PluginManager')
7070
);
7171
}

module/Delivery/src/Delivery/Auth/DeliveryAuthenticator.php

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030
use VuFind\Auth\ILSAuthenticator;
3131
use VuFind\Auth\Manager;
32-
use VuFind\ILS\Connection as ILSConnection;
32+
use VuFind\Config\PluginManager as ConfigManager;
33+
use PAIAplus\ILS\Connection as ILSConnection;
34+
use Delivery\ConfigurationManager;
3335

3436
/**
3537
* Class for managing ILS-specific authentication.
@@ -43,7 +45,7 @@
4345
*/
4446
class DeliveryAuthenticator extends ILSAuthenticator
4547
{
46-
protected $config;
48+
protected $configurationManager;
4749

4850
protected $table;
4951

@@ -55,10 +57,10 @@ class DeliveryAuthenticator extends ILSAuthenticator
5557
* @param Manager $auth Auth manager
5658
* @param ILSConnection $catalog ILS connection
5759
*/
58-
public function __construct(Manager $auth, ILSConnection $catalog,
59-
$config, $table)
60+
public function __construct(Manager $auth, ILSConnection $catalog,
61+
ConfigManager $configManager, $table)
6062
{
61-
$this->setConfig($config);
63+
$this->configurationManager = new ConfigurationManager($configManager);
6264
$this->setTable($table);
6365
parent::__construct($auth, $catalog);
6466
}
@@ -68,19 +70,15 @@ public function __construct(Manager $auth, ILSConnection $catalog,
6870
*
6971
* @return \VuFind\Db\Table\User
7072
*/
71-
protected function setConfig($config)
73+
protected function getAllowedPatronTypes($deliveryDomain)
7274
{
73-
$this->config = $config;
74-
}
75-
76-
/**
77-
* Get access to the user table.
78-
*
79-
* @return \VuFind\Db\Table\User
80-
*/
81-
protected function getConfig()
82-
{
83-
return $this->config;
75+
$this->configurationManager->setConfigurations($deliveryDomain);
76+
$config = $this->configurationManager->getMainConfig();
77+
$allowedTypes = $config['allowed'];
78+
if (!is_array($allowedTypes)) {
79+
$allowedTypes = [];
80+
}
81+
return $allowedTypes;
8482
}
8583

8684
/**
@@ -125,19 +123,21 @@ private function extractUserType($rawType)
125123
*
126124
* @return array|bool
127125
*/
128-
public function authenticate($asAdmin = false)
126+
public function authenticate($deliveryDomain = 'main', $asAdmin = false)
129127
{
130128
if (!$user = $this->auth->isLoggedIn()) {
131129
return 'not_logged_in';
132130
}
133-
$config = $this->getConfig()->toArray();
134-
$allowedTypes = $config['Patron']['allowed'];
135-
if (!is_array($allowedTypes)) {
136-
$allowedTypes = [];
137-
}
138131

139132
$patron = $this->storedCatalogLogin();
133+
$expireDate = new \DateTime($patron['expires']);
134+
$today = new \DateTime('today');
135+
if ($expireDate < $today) {
136+
return 'not_authorized';
137+
}
138+
140139
$patronTypes = array_map([$this, 'extractUserType'], $patron['type']);
140+
$allowedTypes = $this->getAllowedPatronTypes($deliveryDomain);
141141

142142
if (!empty(array_intersect($patronTypes, $allowedTypes))) {
143143
$userDeliveryTable = $this->getTable();
@@ -171,4 +171,22 @@ public function getUser()
171171
{
172172
return $this->user;
173173
}
174+
175+
public function getDeliveryDomains()
176+
{
177+
return $this->configurationManager->getDeliveryDomains();
178+
}
179+
180+
public function getTemplateParams($deliveryDomain)
181+
{
182+
$this->configurationManager->setConfigurations($deliveryDomain);
183+
$config = $this->configurationManager->getMainConfig();
184+
$templateParams = [];
185+
$templateParams['show_home'] = $config['template_show_home'] ?: '';
186+
$templateParams['title'] = $config['template_title'] ?: '';
187+
$templateParams['text'] = $config['template_text'] ?: '';
188+
$templateParams['icon'] = $config['template_icon'] ?: '';
189+
$templateParams['belugino'] = $config['template_belugino'] ?: '';
190+
return $templateParams;
191+
}
174192
}

module/Delivery/src/Delivery/Auth/DeliveryAuthenticatorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __invoke(ContainerInterface $container, $requestedName,
7070
// Generate wrapped object:
7171
$auth = $container->get('VuFind\Auth\Manager');
7272
$catalog = $container->get('PAIAplus\ILS\Connection');
73-
$config = $container->get('VuFind\Config\PluginManager')->get('deliveryGlobal');
73+
$config = $container->get('VuFind\Config\PluginManager');
7474
$table = $container->get('Delivery\Db\Table\PluginManager')->get('userDelivery');
7575
$wrapped = new $requestedName($auth, $catalog, $config, $table);
7676

module/Delivery/src/Delivery/AvailabilityHelper.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AvailabilityHelper {
2222

2323
protected $solrDriver;
2424

25-
protected $signature;
25+
protected $signatureList;
2626

2727
public function __construct($solrDriver = null, $deliveryConfig = null)
2828
{
@@ -57,14 +57,13 @@ public function setSolrDriver($driver)
5757

5858
public function setDeliveryConfig($config)
5959
{
60-
$this->deliveryConfig = $config->toArray();
60+
$this->deliveryConfig = $config;
6161
}
6262

63-
public function checkParent()
63+
public function getParentId()
6464
{
6565
$format = array_shift(array_shift($this->getMarcData('Format')));
6666
if (in_array($format, $this->deliveryConfig['formats'])) {
67-
$parentId = '';
6867
$articleData = $this->getMarcData('DeliveryDataArticle');
6968
foreach ($articleData as $articleDate) {
7069
if (!empty($articleDate['ppn'])) {
@@ -75,10 +74,10 @@ public function checkParent()
7574
return null;
7675
}
7776

78-
public function getSignature()
77+
public function getSignatureList()
7978
{
8079
$this->checkSignature();
81-
return $this->signature;
80+
return $this->signatureList;
8281
}
8382

8483
public function checkSignature()
@@ -88,23 +87,24 @@ public function checkSignature()
8887
$signatureData = $this->getMarcData('Signature');
8988
$licenceData = $this->getMarcData('Licence');
9089

91-
$this->signature = '';
90+
$checkPassed = false;
91+
$this->signatureList = [];
9292

9393
$sortedSignatureData = [];
9494
foreach ($deliveryConfig['sigel_all'] as $sigel) {
9595
foreach ($signatureData as $index => $signatureDate) {
9696
if (isset($signatureDate['sigel']) && preg_match('#'.$sigel.'$#', $signatureDate['sigel'])) {
9797
$sortedSignatureData[] = $signatureDate;
9898
unset($signatureData[$index]);
99-
break;
99+
//break;
100100
}
101101
}
102102
}
103103
if (in_array($format, $deliveryConfig['formats'])) {
104104
if (empty($sortedSignatureData)) {
105105
foreach ($signatureData as $signatureDate) {
106106
if ($this->checkSigel($signatureDate, $format)) {
107-
$this->signature = '!!';
107+
$this->signatureList[] = '!!';
108108
return true;
109109
}
110110
}
@@ -121,12 +121,12 @@ public function checkSignature()
121121
}
122122
}
123123
}
124-
$this->signature = '!' . $sigel . '! ' . $signature;
125-
return true;
124+
$this->signatureList[] = '!' . $sigel . '! ' . $signature;
125+
$checkPassed = true;
126126
}
127127
}
128128
}
129-
return false;
129+
return $checkPassed;
130130
}
131131

132132
private function performCheck($item, $data, $format)
@@ -158,14 +158,16 @@ private function performCheck($item, $data, $format)
158158
private function checkSigel($signatureDate, $format, $sigelOnly = false)
159159
{
160160
$sigel = $signatureDate['sigel'] ?? '';
161+
$indicator = $signatureDate['indicator'] ?? '';
161162
$licencenote = $signatureDate['licencenote'] ?? '';
162163
$footnote = $signatureDate['footnote'] ?? '';
163164
$location = $signatureDate['location'] ?? '';
164165
$format = str_replace(' ', '_', $format);
165166

166167
$sigelOk = $this->performCheck('sigel', $sigel, $format);
167168
if ($sigelOk && !$sigelOnly) {
168-
$sigelOk = $this->performCheck('licencenote', $licencenote, $format);
169+
$sigelOk = $this->performCheck('indicator', $indicator, $format);
170+
$sigelOk = $sigelOk && $this->performCheck('licencenote', $licencenote, $format);
169171
$sigelOk = $sigelOk && $this->performCheck('footnote', $footnote, $format);
170172
$sigelOk = $sigelOk && $this->performCheck('location', $location, $format);
171173
}

0 commit comments

Comments
 (0)