Skip to content
Snippets Groups Projects
Commit 7862cb9d authored by Robert Lange's avatar Robert Lange
Browse files

Merge branch 'instance/fid' into instance/fid_bbi

parents d0cb33a9 994417b1
No related merge requests found
...@@ -49,4 +49,14 @@ permission = fid.EBooks ...@@ -49,4 +49,14 @@ permission = fid.EBooks
[fid.Acquisitions] [fid.Acquisitions]
role[] = loggedin role[] = loggedin
FidApiPermission[] = limited_access FidApiPermission[] = limited_access
permission = fid.Acquisitions permission = fid.Acquisitions
\ No newline at end of file
[default.DBIS]
role[] = guest
role[] = loggedin
permission = access.DBIS
[default.Licenses]
role[] = loggedin
FidApiPermission[] = full_access
permission = access.Licenses
\ No newline at end of file
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/ */
use fid\Controller\MyResearchController;
use fid\Controller\MyResearchControllerFactory;
use fid\Controller\RecordController; use fid\Controller\RecordController;
use fid\Controller\RecordControllerDelegatorFactory; use fid\Controller\RecordControllerDelegatorFactory;
use fid\Controller\UserController; use fid\Controller\UserController;
...@@ -92,9 +94,11 @@ $config = [ ...@@ -92,9 +94,11 @@ $config = [
'factories' => [ 'factories' => [
RecordController::class => AbstractBaseWithConfigFactory::class, RecordController::class => AbstractBaseWithConfigFactory::class,
UserController::class => UserControllerFactory::class, UserController::class => UserControllerFactory::class,
MyResearchController::class => MyResearchControllerFactory::class,
], ],
'aliases' => [ 'aliases' => [
\VuFind\Controller\RecordController::class => RecordController::class, \VuFind\Controller\RecordController::class => RecordController::class,
\VuFind\Controller\MyResearchController::class => MyResearchController::class,
], ],
'delegators' => [ 'delegators' => [
RecordController::class => [ RecordController::class => [
......
<?php
/**
* MyResearch Controller
*
* PHP version 7
*
* Copyright (C) 2019 Leipzig University Library
*
* 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 Controller
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
namespace fid\Controller;
use fid\Service\Client;
use fid\Service\ClientException;
use fid\Service\DataTransferObject\Library;
use VuFind\Exception\Forbidden;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Controller for the user account area.
*
* @category VuFind
* @package Controller
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
class MyResearchController extends \VuFind\Controller\MyResearchController
{
/**
* @var \Zend\Config\Config
*/
protected $mainConfig;
/**
* @var \fid\Service\Client
*/
protected $fidClient;
/**
* MyResearchController constructor.
*
* @param ServiceLocatorInterface $serviceLocator
* @param array fid config $config
*/
public function __construct(
ServiceLocatorInterface $serviceLocator
) {
parent::__construct($serviceLocator);
$this->mainConfig = $this->getConfig();
}
/**
* @param Client $fidClient
*/
public function setFidClient(Client $fidClient): void
{
$this->fidClient = $fidClient;
}
/**
* Show links for Access to Specific and Press Databases, E-Books
*
* @return mixed
* @throws \VuFind\Exception\ILS
*/
public function databasesAction()
{
if (($user = $this->getUser())) {
$patron = $this->catalogLogin();
}
$hasDbis = $this->hasDbis();
$hasLicenses = $this->hasLicenses();
if (!$hasDbis && !$hasLicenses) {
return $this->forwardTo('MyResearch', 'Profile');
}
$view = $this->createViewModel(['user' => $user ?? null]);
if ($hasDbis) {
$view->isDbisAvailable = true;
if ($this->fidClient->isLoggedOn() && isset($patron['user'])) {
try {
$library = $this->getHomeLibrary($patron);
$view->homeLibrary = $library->getDbis();
$view->map_bibid_to_dbis = false;
} catch (ClientException $exception) {
// TODO: Implement logging (in database?)
$view->homeLibrary = $patron['user']->getHomeLibrary();
$view->map_bibid_to_dbis = true;
}
}
}
if ($hasLicenses) {
$view->licenses = $this->getLicenses();
}
if (!empty($patron)) {
$catalog = $this->getILS();
$this->addAccountBlocksToFlashMessenger($catalog, $patron);
}
$view->setTemplate('myresearch/databases');
return $view;
}
/**
* Check if DBIS module is active and user has permission
*
* @return bool
*/
public function hasDbis(): bool
{
// Is module activated?
if (!isset($this->mainConfig['ExternalDatabases']['DBIS'])
|| $this->mainConfig['ExternalDatabases']['DBIS'] != true) {
return false;
}
// Has user rights to access?
try {
return $this->permission()->check('access.DBIS', 'exception') == null;
} catch (Forbidden $e) {
// Permission Plugin needs cumbersome exception for logged-in users
}
return false;
}
/**
* @param $patron
* @return \fid\Service\DataTransferObject\Library | null
* @throws \fid\Service\ClientException
*/
protected function getHomeLibrary($patron): ?Library
{
if (is_a($patron['user'], 'fid\Service\DataTransferObject\User')
&& $patron['user']->getHomeLibrary())
{
if (isset($patron['libs'][$patron['user']->getHomeLibrary()])) {
return $patron['libs'][$patron['user']->getHomeLibrary()];
}
/* no home library found in patron object? => fetch library from api directly */
return $this->fidClient->requestLibraryById($patron['user']->getHomeLibrary());
}
return null;
}
/**
* Check if licenses are specified and user has permission
*
* @return bool
*/
public function hasLicenses(): bool
{
// Are licenses configured
if (!isset($this->mainConfig['MediaLicenses']) || count($this->mainConfig['MediaLicenses']) == 0) {
return false;
}
// Has user rights to access?
try {
return $this->permission()->check('access.Licenses', 'exception') == null;
} catch (Forbidden $e) {
// Permission Plugin needs cumbersome exception for logged-in users
}
return false;
}
/**
* Get links for licensed resources
*
* @return mixed
*/
protected function getLicenses()
{
$licenses = false;
$configLicenses = $this->mainConfig['MediaLicenses'] ?? [];
if (count($configLicenses) > 0) {
$licenses = [];
$i = 0;
foreach ($configLicenses as $key => $value) {
$licenses[$i]['name'] = $key;
$licenses[$i]['url'] = $value;
$licenses[$i]['desc'] = $this->translate('licenses_' . $key . '_desc', [], '');
$i++;
}
}
return $licenses;
}
}
<?php
/**
* Service MyResearchControllerFactory
*
* PHP version 7
*
* Copyright (C) 2019 Leipzig University Library
*
* 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 Controller
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\Controller;
use fid\Service\Client;
use Psr\Container\ContainerInterface;
use Zend\ServiceManager\ServiceManager;
class MyResearchControllerFactory
{
public function __construct()
{
return null;
}
public function __invoke(ContainerInterface $container)
{
/** @var ServiceManager $serviceManager */
$serviceManager = $container->get(ServiceManager::class);
$controller = new MyResearchController($serviceManager);
$controller->setFidClient($container->get(Client::class));
return $controller;
}
}
...@@ -3,4 +3,20 @@ Username = E-Mail-Adresse ...@@ -3,4 +3,20 @@ Username = E-Mail-Adresse
back_to_form = "weiter ausfüllen" back_to_form = "weiter ausfüllen"
#17495 #17495
Price = "Preis" Price = "Preis"
\ No newline at end of file
; DBIS / Licenses
dbis_hint = "Hinweis"
dbis_licenses_name = "Lizensierte Datenbanken"
dbis_licenses_name_long = "Zugang zu freien und lizenzierten Fachdatenbanken"
dbis_name = "Fachdatenbanken"
dbis_text = "Diese Übersicht zeigt Ihnen alle frei verfügbaren Datenbanken aus DBIS zum Fachgebiet der Kommunikations- und Medienwissenschaft an. Wenn Sie mit Ihrem Nutzerkonto eingeloggt sind, werden Ihnen zusätzlich die bei Ihrer Heimatbibliothek lizenzierten Datenbanken angezeigt. Diese sind i. d. R. nur über Ihr jeweiliges Universitätsnetz bzw. per VPN-Zugang abrufbar."
licenses = "Datenbanken"
licenses_desc_1 = "Momentan haben Sie Zugriff auf:"
licenses_forbidden_login_required = "Diese Lizenzen sind nur für angemeldete Nutzer in bestimmten Nutzergruppen verfügbar."
licenses_forbidden_permission_denied = "Diese Lizenzen sind für Ihre Nutzergruppe leider nicht verfügbar."
licenses_not_available = "Diese Lizenzen sind derzeit leider nicht verfügbar."
licenses_notice_html = "Bitte nutzen Sie die Zeitungsarchive nur für Recherchen in üblichen Maßen. Die eingeräumten Lizenzen sind nicht für einen massenhaften Abruf von Zeitungsseiten ausgelegt (auch nicht für Textmining). Ein Abruf über das übliche Maß hinaus führt zu einem frühen Erschöpfen der lizenzierten Kontingente und geht zu Lasten Ihrer Kolleginnen und Kollegen.<br /><br />Bitte kontaktieren Sie uns immer vorab per E-Mail oder über unser <a data-lightbox href="%%contact_url%%">Kontaktformular</a>, wenn Sie für ein Forschungsprojekt eine größere Anzahl an Dokumenten abrufen bzw. Textmining nutzen möchten. Wir setzen uns dann mit Ihnen in Verbindung. <br /><br />Bitte beachten Sie auch unsere <a data-lightbox="" href="%%terms_url%%">Nutzungsbedingungen</a><br /><br />Herzlichen Dank für Ihr Verständnis!"
licenses_search = "Datenbanken"
licenses_text = "Hier haben Sie Zugang zu Datenbanken, die speziell durch uns für Sie lizenziert wurden. Die Kosten übernehmen wir für Sie."
@parent_ini = ../../languages/en.ini
Username = Email address Username = Email address
back_to_form = "back to previous form" back_to_form = "back to previous form"
\ No newline at end of file
; DBIS / Licenses
dbis_hint = "Notice"
dbis_licenses_name = "Licensed Databases"
dbis_licenses_name_long = "Access to free and licensed databases"
dbis_name = "subject-specific Databases"
dbis_text = "The subject-specific databases shown below and provided by DBIS are free to access. If you are logged in with your user account, additional databases which are specifically licensed by your home library are also listed. As a rule, these can only be accessed via your respective university network or VPN access."
licenses = "Databases"
licenses_desc_1 = "Currently, you have access to:"
licenses_desc_2 = "Further license offers are in preparation. You may also write us your suggestions, which offers should also be licensed. Please use our <a href="../Contact/ContactForm">contact form</a>.<br /><br /><br />Our <a href="../AdlrRegistration/Terms">terms of use</a> apply."
licenses_forbidden_login_required = "These licenses are only available for registered users in certain user groups."
licenses_forbidden_permission_denied = "Licensed resources are not available for your user group."
licenses_not_available = "Licensed resources temporarily not available."
licenses_notice_html = "Please use the newspaper archives for normal searches only. The licences granted are not designed for mass retrieval of newspaper pages (e.g. for text mining). Downloads beyond the usual level will lead to premature expiry of the licensed quotas and is at the expense of your colleagues.<br /><br />Please always contact us in advance by e-mail or via our <a data-lightbox href="%%contact_url%%">contact form</a> if you would like to retrieve a larger number of documents for a research project or use text mining. We will then get in touch with you. <br /><br />Please also note our <a data-lightbox href="%%terms_url%%">Terms of Use</a>.<br /><br />Thank you for your understanding."
licenses_search = "Databases"
licenses_text = "Here you have access to databases that have been specially licensed for you. We cover the costs for you."
<!-- fid: databases -->
<?php
// Set up breadcrumbs:
$this->layout()->breadcrumbs = '<li><a href="' . $this->url('myresearch-home') . '">' . $this->transEsc('Your Account') . '</a></li> <li class="active">' . $this->transEsc('fid::dbis_licenses_name') . '</li>';
// Convenience variable:
$account = $this->auth()->getManager();
?>
<div class="<?= $this->layoutClass('mainbody') ?>">
<?php if ($account->isLoggedIn()): ?>
<?php /* finc V5: adds offcanvas-toggler missing in VF5, compare with finc/fid themes during update - CK */ ?>
<?=$this->render('RecordDriver/DefaultRecord/offcanvas-toggler-myresearch'); ?>
<?php endif; ?>
<!-- fid-adlr: licenses -->
<br />
<h3><?= $this->translate('dbis_licenses_name') ?></h3>
<?php if (!$account->isLoggedIn()): ?>
<?= $this->translate('licenses_forbidden_login_required') ?><br/><br/>
<?php elseif (!$this->permission()->allowDisplay('access.Licenses')) : ?>
<?= $this->translate('licenses_forbidden_permission_denied') ?><br/><br/>
<?php elseif (empty($licenses)) : ?>
<?= $this->translate('licenses_not_available') ?><br/><br/>
<?php else: ?>
<?= $this->translate('licenses_text') ?><br/><br/>
<div class="dbis_description">
<button class="title collapsed" data-toggle="collapse" href="#fid_terms"><?= $this->translate('dbis_hint') ?></button>
<div id="fid_terms" class="collapse">
<p>
<?= $this->translate('licenses_notice_html', ['%%contact_url%%' => $this->url('feedback-home'), '%%terms_url%%' => $this->url('fid/user/terms')]) ?><br/><br/>
</p>
</div>
</div><br/><br/>
<div><?= $this->transEsc('licenses_desc_1') ?></div><br/>
<ul class="licenses">
<?php foreach ($licenses as $license): ?>
<li>
<a href="<?= $license['url'] ?>" target="_blank"><?= $this->translate('licenses_' . $license['name']) ?></a><br/>
<span><?= $license['desc'] ?></span>
<br/><br/>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<!-- fid-adlr: licenses - END -->
<?php if ($this->isDbisAvailable) : ?>
<?= $this->render('myresearch/dbis-content'); ?>
<?php endif; ?>
</div>
<div class="<?= $this->layoutClass('sidebar') ?>">
<?= $this->context($this)->renderInContext("myresearch/menu.phtml", ['active' => 'databases']) ?>
</div>
<!-- fid: databases - END -->
<!-- fid: dbis -->
<br/>
<h3><?= $this->translate('dbis_name') ?></h3>
<div class="dbis_description">
<button class="title collapsed" data-toggle="collapse" href="#dbis_description"><?= $this->translate('dbis_hint') ?></button>
<div id="dbis_description" class="collapse">
<p><?= $this->translate('dbis_text') ?></p>
</div>
</div>
<br/>
<div class="dbis_content" id="dbis_content"><i class="fa fa-spinner fa-spin"></i> <?= $this->transEsc("Loading") ?> ...
</div>
<?php
$dbisId = $this->homeLibrary ?? '';
$dbisRequest = "$(document).ready(function () {
$.ajax({
dataType: 'json',
method: 'GET',
url: VuFind.path + '/AJAX/JSON?method=getDbis&bibId=$dbisId&map_bibid_to_dbis=$this->map_bibid_to_dbis'
})
.done(function(response) {
$('#dbis_content').html(response.data.html);
});
});";
echo $this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $dbisRequest, 'SET');
?>
<!-- fid: dbis - END -->
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment