Skip to content
Snippets Groups Projects
Commit 54b157c5 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #50215 add menu bibliondemand

parent de7218b2
5 merge requests!2102#57574 : correction orthographe des jours de la semaine,!2080Sandbox detach zf from storm,!2061Master,!2052Dev#50215 explo st omer henin arques sso avec portail departemental fin moissonnage oai,!2049Dev#50215 explo st omer henin arques sso avec portail departemental fin moissonnage oai
Pipeline #542 failed with stage
in 9 minutes and 44 seconds
......@@ -45,13 +45,8 @@ class Class_DigitalResource_Config extends Class_Entity {
public function __construct($digital_resource) {
$this->updateAttributes(
array_merge(
[static::DIGITAL_RESOURCE => $digital_resource],
$this->getConfig()
)
);
$this->setDigitalResource($digital_resource);
$this->updateAttributes($this->getConfig());
$this->_ensurePermission();
}
......@@ -115,7 +110,8 @@ class Class_DigitalResource_Config extends Class_Entity {
public function getFeatures() {
$features = [];
if($this->getBatch())
if($this->getBatch()
|| $this->getHarvesting())
$features[] = static::HARVEST;
if($this->getSsoAction())
......@@ -161,4 +157,9 @@ class Class_DigitalResource_Config extends Class_Entity {
? strtolower($this->getName())
: null;
}
public function withNameSpace($value) {
return $this->getDigitalResource()->withNameSpace($value);
}
}
\ No newline at end of file
......@@ -22,18 +22,42 @@
class Bibliondemand_Config extends Class_DigitalResource_Config {
public function getConfig() {
return ['Introduction' => $this->_('Solution pour bibliothèque numérique.'),
return ['Introduction' => $this->_('Bibliondemand, solution pour bibliothèque numérique.'),
'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO des ressources Bibliondemand'))
->bePrivate()],
'SsoAction' => true];
'SsoAction' => true,
'Harvesting' => true,
'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/Bibliondemand',
'Url' => 'http://www.bibliondemand.com/',
'Icon' => 'http://www.bibliondemand.com/ui/skins/catalogue/images/logo_bod.png',
'MenuLabel' => $this->_('Lien vers Bibliondemand'),
'ModuleMenu' => $this->withNameSpace('ModuleMenu'),
'NotAllowedMessage' => $this->_('Vous devez être abonné pour accéder à cette ressource.'),
];
}
public function getSsoUrl($user, $url) {
if (!$user->isAbonnementValid() || !$url)
public function getSsoUrl($user, $url = '') {
if(!$this->isEnabled())
return '';
if (!$user->isAbonnementValid())
return '';
return $this->getAdminVar('SSO_URL') . '&' . http_build_query(['returnUrl' => $url]);
$sso = $this->getAdminVar('SSO_URL');
if(!$url)
return $sso;
return $sso . '&' . http_build_query(['returnUrl' => $url]);
}
public function isEnabled() {
return '' != $this->getAdminVar('SSO_URL');
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH 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 AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Bibliondemand_ModuleMenu extends Class_DigitalResource_ModuleMenu {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH 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 AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Bibliondemand_Plugin_IndexController extends Class_DigitalResource_Controller {
public function ssoAction() {
$module = $this->_config->getModuleMenu();
$module = new $module($this->_config);
if(!$url = $this->_config->getSsoUrl(Class_Users::getIdentity()))
return $this->willRedirectToMe($module)
->checkNotifyMessage($module, $module->getDynamiqueUrl());
return $this->checkNotifyMessage($module, $url);
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH 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 AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class BibliondemandModulesControllerTest extends AbstractControllerTestCase {
/** @test */
public function shouldHaveAccessForbiddenMessage() {
ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users',
['id' => 1,
'login' => 'Tom',
'password' => 'pwd']));
$this->dispatch('/opac/modules/bibliondemand', true);
$this->assertFlashMessengerContentContains('Vous devez être abonné pour accéder à cette ressource.');
}
/** @test */
public function shouldContainsRedirectToBibliondemand() {
$this->fixture('Class_AdminVar',
['id' => 'Bibliondemand_SSO_URL',
'valeur' => 'https://biblio.org']);
ZendAfi_Auth::getInstance()->logUser(
$this->fixture('Class_Users',
['id' => 1,
'login' => 'Tom',
'password' => 'pwd'])
->beAbonneSIGB());
$this->dispatch('/opac/modules/bibliondemand', true);
$this->assertXpathContentContains('//script', 'window.location="https://biblio.org";', $this->_response->getBody());
}
}
?>
\ No newline at end of file
......@@ -78,6 +78,17 @@ class Admin_BibnumControllerIndexTest extends Admin_AbstractControllerTestCase {
$this->assertNotXPath('//table[@class="digital_connectors"]//tr[@data-code="jamendo"]/td//div[@class="enabled"]');
}
/** @test */
public function bibliondemandShouldBeSsoReady() {
$this->assertXPathContentContains('//table[@class="digital_connectors"]//tr[@data-code="bibliondemand"]/td', 'SSO');
}
/** @test */
public function bibliondemandShouldBeHarvestReady() {
$this->assertXPathContentContains('//table[@class="digital_connectors"]//tr[@data-code="bibliondemand"]/td', 'Recherche fédérée');
}
}
......
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