Commit 873dba9e authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #78216 plug view record

parent 6bff96dd
Pipeline #4724 failed with stage
in 40 minutes and 12 seconds
......@@ -40,7 +40,6 @@ class Class_Album_Renderer {
'gallicaPlayer' => function($album) { return $album->isGallica(); },
'tagVideo' => function($album) { return $album->isArteVod(); },
'tagFormationVodeclic' => function($album) { return $album->isFormationVodeclic(); },
'tagCoursToutApprendre' => function($album) { return $album->isCoursToutApprendre(); },
'monocleReaderServerSide' => function($album) { return $album->isEPUB(); },
'tagJamendoPlayer' => function($album) { return $album->isJamendo(); },
'tagSoundCloudPlayer' => function($album) { return $album->isSoundCloud(); },
......
......@@ -213,6 +213,9 @@ class Class_DigitalResource_Config extends Class_Entity {
if($album = $this->_albumFromParams($params))
return $this->getAlbumSsoUrl($user, $album);
if($resource = $this->_albumResourceFromParams($params))
return $this->getAlbumResourceSsoUrl($user, $resource);
return $this->getSsoUrl($user);
}
......@@ -231,6 +234,13 @@ class Class_DigitalResource_Config extends Class_Entity {
}
protected function _albumResourceFromParams($params) {
return array_key_exists('resource_id', $params)
? Class_AlbumRessource::find($params['resource_id'])
: null;
}
public function getSsoUrl($user) {
return '';
}
......@@ -244,6 +254,17 @@ class Class_DigitalResource_Config extends Class_Entity {
}
public function getAlbumResourceSsoUrl($user, $resource) {
if (!$resource)
return '';
if (!$album = $resource->getAlbum())
return '';
return $album->getExternalUri();
}
public function getHarvestUrl($page = 1) {
return '';
}
......
<?php
/**
* Copyright (c) 2012, 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_WebService_BibNumerique_ToutApprendre_Formation extends Class_WebService_BibNumerique_RessourceNumerique {
protected $_tags = [],
$_duration = '';
public function fillAlbum($album) {
$album
->beCoursToutApprendre()
->addAuthor('Tout Apprendre')
->setDateMaj($this->getDateMaj())
->setAnnee($this->getAnnee())
->setDuration($this->_duration)
->setDescription($this->getDescription())
->setTags($this->mergeTags($album->getTags()));
}
public function getRessourceCategorieLibelle() {
return 'Cours en ligne Tout Apprendre';
}
public function getBaseUrl(){
return Class_WebService_BibNumerique_ToutApprendre::BASE_URL;
}
public function mergeTags($tags) {
return implode(';',array_unique(
array_filter(
array_merge(explode(';',$tags),$this->_tags))));
}
public function addTag($tag) {
$this->_tags[] = $tag;
}
public function setDuration($text) {
$this->_duration = $text;
}
protected function updateAlbum($album) {
$album->setTags($this->mergeTags($album->getTags()));
return parent::updateAlbum($album);
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, 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 ZendAfi_View_Helper_TagCoursToutApprendre extends ZendAfi_View_Helper_TagRessourceNumerique {
public function tagCoursToutApprendre($album) {
$current_user = Class_Users::getIdentity();
if (!$this->canAccessRessourceNumerique())
return '<p>'.$this->_('Vous devez être connecté sous un compte avec abonnement valide pour pouvoir accéder au cours en ligne').'</p>';
$toutapprendre = Class_ToutApprendreLink::forUser($current_user);
$html='';
foreach ($album->getRessources() as $ressource) {
$toutapprendre= Class_ToutApprendreLink::forRessourceAndUser($ressource, $current_user);
$html.= '<li>'
.$this->view->tagAnchor($toutapprendre->url(),
$ressource->getTitre(),
['title' => $ressource->getTitre(),
'target' => '_blank'])
.'</li>';
}
return '<ul>'.$html.'</ul>';
}
function hasRightAccesRessourcesNumeriques($user) {
return true;
}
}
\ No newline at end of file
......@@ -83,6 +83,11 @@ class ToutApprendre_Config extends Class_DigitalResource_Config {
}
public function getAlbumResourceSsoUrl($user, $resource) {
return $this->getAlbumSsoUrl($user, $resource);
}
public function getHarvestUrl() {
return $this->getAdminVar('HARVEST_URL')
. '?'
......
......@@ -20,4 +20,33 @@
*/
class ToutApprendre_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {}
\ No newline at end of file
class ToutApprendre_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {
public function album($album) {
if(!$album)
return '';
$html = [];
foreach ($album->getRessources() as $resource)
$html [] = $this->_renderResourceLink($resource);
$html = implode(array_filter($html));
return $html ? $this->_tag('ul', $html) : '';
}
protected function _renderResourceLink($resource) {
$url = $this->view->url(['module' => 'opac',
'controller' => 'modules',
'action' => $this->_config->getSsoAction(),
'resource_id' => $resource->getId()],
null,
true);
return $this->_tag('li',
$this->view->tagAnchor($url,
$this->_('Accéder à "%s" dans un nouvel onglet', $resource->getTitre()),
['target' => '_blank']));
}
}
\ No newline at end of file
......@@ -103,10 +103,10 @@ class ToutApprendreDashboardActivatedTest extends ToutApprendreActivatedTestCase
parent::setUp();
$album = $this->fixture('Class_Album',
['id' => 20,
'titre' => '10 moutons',
'type_doc_id' => 'ToutApprendre'
]);
['id' => 20,
'titre' => '10 moutons',
'type_doc_id' => 'ToutApprendre'
]);
ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users',
['id' => 2,
......@@ -172,7 +172,7 @@ class ToutApprendreBatchDispatchTest extends ToutApprendreActivatedTestCase {
class ToutApprendreHarvestTest extends ToutApprendreActivatedTestCase {
abstract class ToutApprendreHarvestTestCase extends ToutApprendreActivatedTestCase {
protected
$_service,
......@@ -203,10 +203,23 @@ class ToutApprendreHarvestTest extends ToutApprendreActivatedTestCase {
->whenCalled('getNextOrderFor')
->answers(1);
$this->fixture('Class_CodifTypeDoc',
['id' => ToutApprendre_Config::getInstance()->getDocType(),
'famille_id' => Class_CodifTypeDoc::INCONNU,
'bibliotheques' => '1;8',
'annexes' => '10;12',
'sections' => '18;19']);
$this->_service->harvest();
$this->_first_album = $this->_service->getRessourcesNumeriques()[0];
}
}
class ToutApprendreHarvestTest extends ToutApprendreHarvestTestCase {
/** @test */
......@@ -251,14 +264,14 @@ class ToutApprendreHarvestTest extends ToutApprendreActivatedTestCase {
}
/** @test */
/** @test */
public function posterToutApprendreShouldBeURIJacketURL(){
$this->assertEquals('http://www.toutapprendre.com/img/min/4742.gif',
$this->_first_album->getPoster());
}
/** @test */
/** @test */
public function bibliothequeShouldBeImportedInFirstAlbum() {
$this->assertEquals('1;8',$this->_first_album->getBibliotheques());
}
......@@ -307,4 +320,48 @@ class ToutApprendreHarvestTest extends ToutApprendreActivatedTestCase {
$this->assertNull(Class_AlbumRessource::find(56));
}
}
class ToutApprendreViewRecordTest extends ToutApprendreHarvestTestCase {
public function setUp() {
parent::setUp();
$this->_first_album->index();
$this->dispatch('/noticeajax/resnumeriques/id/1', true);
}
/** @test */
public function linkToMiseEnFormeDeLaFeuilleShouldBePresent() {
$this->assertXPathContentContains('//li/a[contains(@href, "modules/tout-apprendre/resource_id/8")]',
utf8_encode('Accéder à "Mise en forme de la feuille" dans un nouvel onglet'));
}
/** @test */
public function linkToLaMiseEnPageShouldBePresent() {
$this->assertXPathContentContains('//li/a[contains(@href, "/modules/tout-apprendre/resource_id/9")]',
utf8_encode('Accéder à "La mise en page" dans un nouvel onglet'));
}
}
class ToutApprendreSsoResourceTest extends ToutApprendreHarvestTestCase {
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->logUser($this->_user);
$this->dispatch('/opac/modules/tout-apprendre/resource_id/8', true);
}
/** @test */
public function shouldRedirectToResource() {
$this->assertXPathContentContains('//script' , 'document.location.href="http://biblio.toutapprendre.com/ws/wsUrl.aspx?iduser=tom&etablissement=2220&d=201808141210&hash=ed57ad5fe457c2ea7b3ec14eaee50bef&pkl=179";');
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, 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
*/
require_once('ViewHelperTestCase.php');
class ZendAfi_View_Helper_TagCoursToutApprendreTest extends ViewHelperTestCase {
/** @var ZendAfi_View_Helper_TagCoursToutApprendre */
protected $_helper;
/** @var Class_Album */
protected $_album;
/** @var string */
protected $_html;
/** @var Class_Users */
protected $_normand;
public function setUp() {
parent::setUp();
$this->_normand = Class_Users::newInstanceWithId(45)
->setIdabon(45)
->setPrenom('Normand')
->setNom('Baillargeon')
->setMail('normand@test.com')
->setUserGroups([]);
$identity = new StdClass();
$identity->ID_USER = 45;
ZendAfi_Auth::getInstance()->getStorage()->write($identity);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroup')
->whenCalled('findAllBy')
->answers([]);
$this->group_multimedia = $this->fixture('Class_UserGroup',
['id' => 20,
'libelle' => 'Numerique']);
$this->_album = Class_Album::getLoader()
->newInstanceWithId(33)
->setTitre('Petit cours d\'autodefense intellectuelle')
->beCoursToutApprendre()
->setRessources([ '0' => Class_AlbumRessource::getLoader()
->newInstanceWithId('8')
->setIdOrigine('889')
->setTitre('Pourquoi étudier la pensée critique ?'),
'1' => Class_AlbumRessource::getLoader()
->newInstanceWithId('9')
->setIdOrigine('890')
->setTitre('Quelques remarques sur le language'),
'2' => Class_AlbumRessource::getLoader()
->newInstanceWithId('10')
->setIdOrigine('891')
->setTitre('Deux expériences de psychologie sociale'),
]);
$view = new ZendAfi_Controller_Action_Helper_View();
$this->_helper = new ZendAfi_View_Helper_TagCoursToutApprendre();
$this->_helper->setView($view);
}
/** @test */
public function withCurrentUserAbonneSigbShouldDisplayToutApprendreLinkPsychologieSociale() {
$this->_normand
->setUserGroups([$this->group_multimedia])
->setDateFin('2023-09-12')
->beAbonneSIGB();
$this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album),
'//a[contains(@href, "&pkl=891")][@target="_blank"]',
'psychologie sociale');
}
/** @test */
public function withCurrentUserAbonneSigbInvalidShouldNotDisplayLinkPsychologieSociale() {
$this->_normand
->setUserGroups([$this->group_multimedia])
->setDateFin('2003-09-12')
->beAbonneSIGB();
$this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album),
'//a[contains(@href, "&pkl=891")]');
}
/** @test */
public function withCurrentUserAbonneSigbThatNotInToutApprendreGroupShouldNotDisplayLinkFullPlay() {
$this->_normand
->setDateFin('2023-09-12')
->beAbonneSIGB();
$this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album),
'//a[contains(@href, "&pkl=891")]');
}
/** @test */
public function withCurrentUserNotAbonneShouldNotDisplayLinkToutApprendre() {
$this->_normand->beInvite();
$this->assertNotXPath($this->_helper->tagCoursToutApprendre($this->_album),
'//a[contains(@href, "&pkl=891")]');
}
/** @test */
public function withCurrentUserNotAbonneToutApprendreShouldDisplayErrorMessage() {
$this->_normand->beInvite();
$this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album),
'//p', 'abonnement valide');
}
/** @test */
public function withNoCurrentUserForToutApprendreShouldDisplayErrorMessage() {
ZendAfi_Auth::getInstance()->getStorage()->clear();
$this->assertXPathContentContains($this->_helper->tagCoursToutApprendre($this->_album),
'//p', 'abonnement valide');
}
}
?>
\ No newline at end of file
Markdown is supported
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