Commit d2d31da4 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #78216 first commit migration tout apprendre to digital resource plugin

parent 3ff825f5
Pipeline #4721 failed with stage
in 44 minutes and 49 seconds
<?php
(new Class_Migration_DigitalResource_ToutApprendre())->run();
\ No newline at end of file
......@@ -108,6 +108,15 @@ class Class_DigitalResource extends Class_Entity {
}
public function getSsoActionForPlugin($name) {
return $this->getPlugins()
->detect(function($config) use ($name)
{
return ($name == $config->getName()) ? $config->getSsoAction() : '';
});
}
public function getPluginsDescription() {
return $this->pluginsByName(function($config)
{
......
<?php
/**
* Copyright (c) 2012-2014, 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 Class_Migration_DigitalResource_ToutApprendre extends Class_Migration_DigitalResource_Abstract {
protected function _getOldRightToken() {
return 6;
}
protected function _getAdminVarMapping() {
return ['TOUTAPPRENDRE_BIB_ID' => 'ToutApprendre_BIB_ID',
'TOUTAPPRENDRE_KEY' => 'ToutApprendre_KEY'];
}
protected function _getConfig() {
return ToutApprendre_Config::getInstance();
}
protected function _getOldMenuName() {
return 'TOUTAPPRENDRE';
}
protected function _getOldBatchName() {
return 'MOISSONNAGE_TOUTAPPRENDRE';
}
}
\ No newline at end of file
......@@ -34,9 +34,6 @@ class Class_Systeme_ModulesMenu_ToutApprendre extends Class_Systeme_ModulesMenu_
public function urlForUser($user) {
if (!$user->hasRightAccesToutApprendre())
return '';
return Class_ToutApprendreLink::forUser($user)->url();
}
......
......@@ -136,7 +136,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
const RIGHT_ACCES_ARTEVOD = 2;
const RIGHT_ACCES_NUMILOG = 3;
const RIGHT_ACCES_VODECLIC = 5;
const RIGHT_ACCES_TOUTAPPRENDRE = 6;
const RIGHT_ACCES_NUMERIQUEPREMIUM = 20;
const RIGHT_ACCES_CYBERLIBRIS = 22;
const RIGHT_ACCES_MYCOW = 24;
......@@ -179,7 +178,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
self::RIGHT_ACCES_NUMILOG => 'Bibliothèque numérique: accéder à Numilog',
self::RIGHT_ACCES_CYBERLIBRIS => 'Bibliothèque numérique: accéder à Cyberlibris',
self::RIGHT_ACCES_VODECLIC => 'Bibliothèque numérique: accéder à Vodéclic',
self::RIGHT_ACCES_TOUTAPPRENDRE => 'Bibliothèque numérique: accéder à Tout Apprendre',
self::RIGHT_ACCES_NUMERIQUEPREMIUM => 'Bibliothèque numérique: accéder à Numérique Premium',
self::RIGHT_ACCES_MYCOW => 'Bibliothèque numérique: accéder à MyCOW.EU',
self::RIGHT_ACCES_PLANETNEMO => 'Bibliothèque numérique: accéder à planetnemo.fr',
......@@ -229,7 +227,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
'ArteVod' => [Class_UserGroup::RIGHT_ACCES_ARTEVOD],
'Numilog' => [Class_UserGroup::RIGHT_ACCES_NUMILOG],
'Vodeclic' => [Class_UserGroup::RIGHT_ACCES_VODECLIC],
'ToutApprendre' => [Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE],
'NumeriquePremium' => [Class_UserGroup::RIGHT_ACCES_NUMERIQUEPREMIUM],
'MyCow' => [Class_UserGroup::RIGHT_ACCES_MYCOW],
'Kidilangues' => [Class_UserGroup::RIGHT_ACCES_KIDILANGUES],
......
......@@ -917,11 +917,6 @@ class Class_Users extends Storm_Model_Abstract {
}
public function hasRightAccesToutApprendre() {
return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE);
}
public function hasRightAccessCyberlibris() {
return $this->isAbonneAndHasRightToAccess(Class_UserGroup::RIGHT_ACCES_CYBERLIBRIS);
}
......
......@@ -94,6 +94,4 @@ class Class_WebService_BibNumerique_ToutApprendre extends Class_WebService_BibNu
public function getName() {
return 'Tout Apprendre';
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -44,8 +44,6 @@ class ZendAfi_View_Helper_TagCoursToutApprendre extends ZendAfi_View_Helper_TagR
function hasRightAccesRessourcesNumeriques($user) {
return $user->hasRightAccesToutApprendre();
return true;
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, 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 ToutApprendre_Batch extends Class_DigitalResource_Batch {}
\ 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 ToutApprendre_Config extends Class_DigitalResource_Config {
public function getConfig() {
return ['Introduction' => $this->_('ToutApprendre'),
'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/ToutApprendre',
'Url' => '',
'Icon' => '',
'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource ToutApprendre'),
'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'),
'SsoAction' => true,
'MenuLabel' => $this->_('Lien vers ToutApprendre'),
'ModuleMenu' => $this->withNameSpace('ModuleMenu'),
'Service' => $this->withNameSpace('Service'),
'Batch' => $this->withNameSpace('Batch'),
'DocTypeLabel' => $this->_('Cours en ligne Tout Apprendre'),
'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme ToutApprendre'),
['value' => 'http://biblio.toutapprendre.com/ws/wsUrl.aspx'])->bePrivate(),
'HARVEST_URL' => Class_AdminVar_Meta::newDefault($this->_('URL du catalogue de la plateforme ToutApprendre'),
['value' => 'http://biblio.toutapprendre.com/cours/catalogue.aspx'])->bePrivate()]
];
}
public function isEnabled() {
return '' != $this->getAdminVar('SSO_URL');
}
public function getSsoUrl($user) {
if(!$user)
return '';
return $this->getAdminVar('SSO_URL');
}
public function getAlbumSsoUrl($user, $album) {
if(!$album)
return '';
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 ToutApprendre_ModuleMenu extends Class_DigitalResource_ModuleMenu {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, 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 ToutApprendre_Service extends Class_DigitalResource_Service {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, 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 ToutApprendre_Service_Album extends Class_WebService_BibNumerique_RessourceNumerique {
public function getBaseUrl() {
return ToutApprendre_Config::getInstance()->getAdminVar('SSO_URL');
}
protected function getTypeDoc() {
return ToutApprendre_Config::getInstance()->getDocType();
}
public function fillAlbum($album) {
$album
->setTypeDocId($this->getTypeDoc());
return $this;
}
public function getRessourceCategorieLibelle() {
return ToutApprendre_Config::getInstance()->getDocTypeLabel();
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, 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 ToutApprendre_Service_Parser {
protected
$_albums = [],
$_current_album;
public function parseXML($xml) {
$this->_parser = new Class_WebService_FasterXMLParser();
$this->_parser->setElementHandler($this);
$this->_parser->parse($xml);
return $this;
}
public function startAlbum($attributes) {
$this->_current_album = new ToutApprendre_Service_Album();
}
public function endAlbum() {
$this->_albums[] = $this->_current_album;
}
public function getAlbums() {
return $this->_albums;
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, 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 ToutApprendre_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, 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 ToutApprendre_Plugin_IndexController extends Class_DigitalResource_Controller {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, 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
*/
abstract class ToutApprendreActivatedTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_user;
public function setUp() {
parent::setUp();
Class_AdminVar::set('ToutApprendre_SSO_URL', 'https://test.org/api/bokeh/login');
$group = $this->fixture('Class_UserGroup',
['id' => 1,
'libelle' => 'Digital resources']);
$this->_user = $this->fixture('Class_Users',
['id' => 1,
'login' => 'Tom',
'password' => 'pwd'])
->setUserGroups([$group]);
$this->fixture('Class_Permission',
['id' => 1,
'code' => 'ToutApprendre'])
->permitTo($group, new Class_Entity());
}
}
class ToutApprendreSsoTest extends ToutApprendreActivatedTestCase {
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->logUser($this->_user);
$this->dispatch('/opac/modules/' . Class_DigitalResource::getSsoActionForPlugin('ToutApprendre'), true);
}
/** @test */
public function shouldRedirectToResource() {
$this->assertXPathContentContains('//script' , 'document.location.href="PLACEHOLDER', $this->_response->getBody());
}
/** @test */
public function scriptShouldContainsCheckUrl() {
$this->assertXPathContentContains('//script[contains(text(), "&check_url=")]' , '/ToutApprendre_Plugin/auth/validate');
}
}
class ToutApprendreDashboardUnactivatedTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->dispatch('/ToutApprendre_Plugin', true);
}
/** @test */
public function shouldDisplayDeactivated() {
$this->assertXPathContentContains('//button', 'Désactivé');
}
/** @test */
public function ssoUrlShoudlBeDisplay() {
$this->assertXPathContentContains('//table', 'ToutApprendre_SSO_URL');
}
}
class ToutApprendreDashboardActivatedTest extends ToutApprendreActivatedTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$album = $this->fixture('Class_Album',
['id' => 20,
'titre' => '10 moutons',
'type_doc_id' => 'ToutApprendre'
]);
ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users',
['id' => 2,
'login' => 'admin',
'password' => 'admin',
'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN]));
$this->dispatch('/ToutApprendre_Plugin', true);
}
/** @test */
public function shouldDisplayActivated() {
$this->assertXPathContentContains('//button', 'Activé');
}
/** @test */
public function urlSsoTitleBeDisplay() {
$this->assertXPathContentContains('//h4', 'URL SSO générée par /modules/story-play-r pour l\'utilisateur "ToutApprendre_test_user"');
}
/** @test */
public function testSsoValidateUrlMessageShoudlBeDisplay() {
$this->assertXPathContentContains('//h4', 'URL de validation du ticket de connexion générée pour l\'utilisateur "ToutApprendre_test_user"');
}
/** @test */
public function testSsoValidateUrlShoudlBeDisplay() {
$this->assertXPathContentContains('//pre', '/ToutApprendre_Plugin/auth/validate?sessionid=ST-');
}
/** @test */
public function sourceImageShouldBeValid() {
$this->assertXPathContentContains('//pre','Image source : https://preprod');
}
/** @test */
public function vignetteShouldBePresent() {
$this->assertXPath("//img[contains(@src,'userfiles/album/20/thumb_20_large_10Moutons.jpeg')]");
}
/** @test */
public function doctypeImageUrlShouldBePresent() {
$this->assertXPath('//h4/img[contains(@src, "/digital-resource/typedoc-icon/id/ToutApprendre")]');