Commit 072f0ace authored by Patrick Barroca's avatar Patrick Barroca

version 7.7.5

Merge remote-tracking branch 'refs/remotes/origin/stable' into origin-hotline-master

Conflicts:
	VERSIONS
	library/startup.php
	tests/application/modules/admin/controllers/UsersControllerTest.php
parents da28b68b e099f759
06/10/2016 - v7.7.5
- ticket #48667 : Correction des régressions des droits d'accès administrateurs selon leur rôle.
29/09/2016 - v7.7.4
- ticket #48448 : PNB Dilicom : correction du droit d'accès aux liens de consulation et de téléchargement en fonction de la configuration du GLN de la bibliothèque de l'utilisateur. Ajout d'un message d'erreur si la bibliothèque n'a pas de GLN.
......
......@@ -712,4 +712,63 @@ class Admin_AlbumController extends ZendAfi_Controller_Action {
$resource->deletePoster()->save();
$this->_redirect('admin/album/edit_ressource/id/' . $resource->getId());
}
public function addWebsiteAction() {
$import_form = $this->view
->newForm(['id' => 'import', 'class' => 'form'])
->setMethod('post')
->addElement('url', 'url', ['label' => $this->view->_('URL du site web'),
'required' => true,
'allowEmpty' => false])
->addDisplayGroup(['url'], 'website', ['legend' => $this->view->_('Site web')])
->addElement('submit', 'submit', ['label' => $this->view->_('Importer')]);
if ($this->getRequest()->isPost() && $import_form->isValid($this->getRequest()->getPost())) {
$album = $this->createAlbumFromUrl($this->getRequest()->getPost('url'));
if ($album && $album->save()) {
$this->_redirect('/admin/album/edit_album/id/'.$album->getId());
return;
}
}
$this->view->import_form = $import_form;
}
protected function createAlbumFromUrl($url) {
$html = Class_WebService_SimpleWebClient::getInstance()->open_url($url);
$dom = new Zend_Dom_Query($html);
$category = Class_AlbumCategorie::getOrCreateRootCategory('Sites web');
$album = Class_Album::newInstance(['type_doc_id' => Class_TypeDoc::WEBSITE,
'categorie' => $category]);
$title_node = $dom->queryXpath('//head/title')->current();
$album->setTitre($title_node ? trim($title_node->textContent) : $url);
if ($description_node = $dom->queryXpath('//head/meta[@name="description"]')->current())
$album->setDescription($description_node->getAttribute('content'));
$resource = Class_AlbumRessource::newInstance(['url' => $url,
'titre' => $album->getTitre(),
'description' => $album->getDescription()]);
$album->addRessource($resource);
$album->save();
$thumbnailer = (new Class_WebService_WebSiteThumbnail());
$poster_name = $thumbnailer->fileNameFromUrl($url);
$poster_path = $resource->getPosterPath();
$resource->getFolderManager()->ensure($poster_path);
$thumbnailer->getThumbnailer()->fetchUrlToFile($url, $poster_path . $poster_name, 'medium');
$resource->setPoster($poster_name);
$resource->createThumbnail();
return $album;
}
}
......@@ -45,63 +45,6 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
}
public function createAction() {
$import_form = $this->view
->newForm(['id' => 'import', 'class' => 'form'])
->setMethod('post')
->addElement('url', 'url', ['label' => $this->view->_('URL du site web'),
'required' => true,
'allowEmpty' => false])
->addDisplayGroup(['url'], 'website', ['legend' => $this->view->_('Site web')])
->addElement('submit', 'submit', ['label' => $this->view->_('Importer')]);
if ($this->getRequest()->isPost() && $import_form->isValid($this->getRequest()->getPost())) {
$album = $this->createAlbumFromUrl($this->getRequest()->getPost('url'));
if ($album && $album->save()) {
$this->_redirect('/admin/album/edit_album/id/'.$album->getId());
return;
}
}
$this->view->import_form = $import_form;
}
protected function createAlbumFromUrl($url) {
$html = Class_WebService_SimpleWebClient::getInstance()->open_url($url);
$dom = new Zend_Dom_Query($html);
$category = Class_AlbumCategorie::getOrCreateRootCategory('Sites web');
$album = Class_Album::newInstance(['type_doc_id' => Class_TypeDoc::WEBSITE,
'categorie' => $category]);
$title_node = $dom->queryXpath('//head/title')->current();
$album->setTitre($title_node ? trim($title_node->textContent) : $url);
if ($description_node = $dom->queryXpath('//head/meta[@name="description"]')->current())
$album->setDescription($description_node->getAttribute('content'));
$resource = Class_AlbumRessource::newInstance(['url' => $url,
'titre' => $album->getTitre(),
'description' => $album->getDescription()]);
$album->addRessource($resource);
$album->save();
$thumbnailer = (new Class_WebService_WebSiteThumbnail());
$poster_name = $thumbnailer->fileNameFromUrl($url);
$poster_path = $resource->getPosterPath();
$resource->getFolderManager()->ensure($poster_path);
$thumbnailer->getThumbnailer()->fetchUrlToFile($url, $poster_path . $poster_name, 'medium');
$resource->setPoster($poster_name);
$resource->createThumbnail();
return $album;
}
protected function _updateNewModel($sitotheque) {
if (!$category = Class_SitothequeCategorie::find($this->_getParam('id_cat'))) {
......
......@@ -198,13 +198,13 @@ class Class_UserGroup extends Storm_Model_Abstract {
self::RIGHT_USER_SITOTHEQUE => 'Sitothèque: accès sitothèque',
self::RIGHT_USER_MODO => 'Modération: accès modération',
self::RIGHT_USER_INSCRIPTIONS => 'Modération: accès demandes d\'inscriptions',
self::RIGHT_USER_BIB_NUM => 'Bibliothèque numérique: accès bibliothèque numèrique',
self::RIGHT_USER_BIB_NUM => 'Bibliothèque numérique: accès bibliothèque numérique',
self::RIGHT_USER_OPDS_READ=> 'Bibliothèque numérique: accès OPDS en lecture',
self::RIGHT_USER_NOTICES_LIEES => 'Catalogue: accès notices liées',
self::RIGHT_USER_SIGB_USER_READ => 'Administration: accès en lecture aux fiches adhérents SIGB',
self::RIGHT_USER_CONFIG_FRONT => 'Administration: accès à la configuration des boîtes et modules depuis l\'interface publique',
self::RIGHT_USER_PUBLICATION_DIRECTE => 'Articles: autorise la validation d\'un article par son auteur',
self::RIGHT_USER_ACCES_ARTICLES => 'Articles: accès articles'
self::RIGHT_USER_ACCES_ARTICLES => 'Articles: affiché dans la gestion des permissions'
];
......
......@@ -18,11 +18,6 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//////////////////////////////////////////////////////////////////////////////////////////
// OPAC3 : DEFINITION DES ROLES
//
// @TODO@ : fonctions a suppprimer : voir en bas de page
//////////////////////////////////////////////////////////////////////////////////////////
class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
use Trait_Translator;
......@@ -76,6 +71,7 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
$this->add(new Zend_Acl_Resource('users'));
$this->add(new Zend_Acl_Resource('usergroup'));
$this->add(new Zend_Acl_Resource('formation'));
$this->add(new Zend_Acl_Resource('newsletter'));
$this->add(new Zend_Acl_Resource('profil'));
$this->add(new Zend_Acl_Resource('stat'));
$this->add(new Zend_Acl_Resource('lieu'));
......@@ -83,6 +79,11 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
$this->add(new Zend_Acl_Resource('records'));
$this->add(new Zend_Acl_Resource('modules'));
$this->add(new Zend_Acl_Resource('ajax'));
$this->add(new Zend_Acl_Resource('bibnum'));
$this->add(new Zend_Acl_Resource('album'));
$this->add(new Zend_Acl_Resource('oai'));
$this->add(new Zend_Acl_Resource('frbr-link'));
$this->add(new Zend_Acl_Resource('print'));
$this->add(new Zend_Acl_Resource('external-agendas'));
//Roles
......@@ -104,7 +105,6 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
$this->allow('modo_bib','ajax');
$this->allow('modo_bib','modo');
$this->allow('modo_bib','panier');
$this->allow('modo_bib','rss');
$this->allow('modo_bib','sito');
$this->allow('modo_bib','agenda');
$this->allow('modo_bib','index');
......@@ -113,17 +113,44 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
$this->allow('modo_bib','upload');
$this->allow('modo_bib','records');
$this->allow('modo_bib','modules');
$this->allow('modo_bib','catalogue');
$this->allow('modo_bib','redmine');
$this->allow('admin_bib','rss');
$this->allow('admin_bib','catalogue');
$this->allow('admin_bib','newsletter');
$this->allow('admin_bib','formation');
$this->allow('admin_bib','lieu');
$this->allow('admin_bib','bibnum');
$this->allow('admin_bib','album');
$this->allow('admin_bib','oai');
$this->allow('admin_bib','frbr-link');
$this->allow('admin_bib','users');
$this->allow('admin_bib','bib');
$this->allow('admin_bib','print');
$this->allow('admin_bib','usergroup');
$this->allow('admin_bib','ouvertures');
$this->allow('admin_bib','profil');
$this->allow('admin_bib','modo');
$this->allow('admin_bib','menus');
$this->allow('admin_bib','external-agendas');
$this->deny('modo_portail','catalogue');
$this->deny('modo_portail','rss');
$this->deny('modo_portail','external-agendas');
$this->deny('modo_portail','formation');
$this->deny('modo_portail','lieu');
$this->deny('modo_portail','bibnum');
$this->deny('modo_portail','album');
$this->deny('modo_portail','oai');
$this->deny('modo_portail','frbr-link');
$this->deny('modo_portail','profil');
$this->deny('modo_portail','print');
$this->deny('modo_portail','zone');
$this->deny('modo_portail','bib');
$this->deny('modo_portail','users');
$this->deny('modo_portail','usergroup');
$this->allow('modo_portail');
$this->allow('admin_portail');
$this->allow('super_admin');
......
......@@ -252,7 +252,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form {
public function addVignetteFor($album) {
$vignette_element = new ZendAfi_Form_Element_Image(
'fichier',
['label' => 'Vignette<br/><em style="font-size:80%;font-weight:normal">(jpg, gif, png)</em>',
['label' => 'Vignette (jpg, gif, png)',
'escape' => false,
'basePath' => $album->getBasePath(),
'baseUrl' => $album->getBaseUrl(),
......
......@@ -81,7 +81,7 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdmin extends ZendAfi_View_Helper_Base
['jamendo', $this->_('Jamendo'), '/admin/harvest/jamendo-browse'],
['soundcloud', $this->_('SoundCloud'), '/admin/harvest/soundcloud'],
['assimil', $this->_('ASSIMIL'), '/admin/harvest/assimil-browse'],
['websites', $this->_('Sitothèque'), '/admin/sito/create'],
['websites', $this->_('Sitothèque'), '/admin/album/add-website'],
['toutapprendre', $this->_('Tout Apprendre'), '/admin/harvest/toutapprendre-browse'],
['opds', $this->_('Catalogues OPDS'), '/admin/opds'],
['oai', $this->_('Entrepôts OAI'), '/admin/oai'],
......
......@@ -65,7 +65,7 @@ function defineConstant($name, $value) {
function setupConstants() {
defineConstant('BOKEH_MAJOR_VERSION','7.7');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.4');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.5');
defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/');
......
......@@ -179,7 +179,7 @@ class AdminAuthControllerAlbumAuthorizedByRoleTest extends Admin_AbstractControl
parent::setUp();
Class_Users::getIdentity()
->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL);
->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL);
$this->dispatch('/admin/album', true);
}
......
<?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
*/
abstract class AlbumControllerAddWebsiteFromUrlTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('SITO_IN_ALBUMS', '1');
Class_AdminVar::set('BIBNUM', '1');
}
}
class AlbumControllerAddWebsiteFromUrlTest extends AlbumControllerAddWebsiteFromUrlTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/admin/album/add-website', true);
}
/** @test */
public function formShouldBePreset() {
$this->assertXPath('//form');
}
}
abstract class AlbumControllerAddWebsiteFromUrlPostTestCase extends AlbumControllerAddWebsiteFromUrlTestCase {
protected
$_album,
$_resource;
public function setUp() {
parent::setUp();
Class_WebService_SimpleWebClient::setInstance($this->mock()
->whenCalled('open_url')
->answers($this->_getContent()));
$this->postDispatch('/admin/album/add-website',
['url' => $this->_getUrl()]);
$this->_album = Class_Album::find(1);
$this->_resource = $this->_album->getRessources()[0];
}
protected function _getContent() {
return '';
}
protected function _getUrl() {
return '';
}
}
class AlbumControllerAddWebsiteImportCnedFromUrlTest
extends AlbumControllerAddWebsiteFromUrlPostTestCase {
protected function _getContent() {
return file_get_contents(__DIR__ . '/cned.fr.html');
}
protected function _getUrl() {
return 'http://www.cned.fr';
}
/** @test */
public function titleShouldBeFormationToutAuLongDeLaVie() {
$this->assertEquals('Formation tout au long de la vie - CNED',
$this->_album->getTitre());
}
/** @test */
public function albumShouldBeWebSite() {
$this->assertTrue($this->_album->isWebSite());
}
/** @test */
public function albumCategorieShouldBeSitotheque() {
$this->assertEquals('Sites web', $this->_album->getCategorie()->getLibelle());
}
/** @test */
public function albumShouldHaveOneResourceWithUrlCnedDotFr() {
$this->assertEquals('http://www.cned.fr', $this->_resource->getUrl());
}
/** @test */
public function resourceTitleShouldBeFormationToutAuLongDeLaVie() {
$this->assertEquals('Formation tout au long de la vie - CNED',
$this->_resource->getTitre());
}
/** @test */
public function resourceDescriptionShouldBeFormationsEnLigne() {
$this->assertContains('Formations en ligne et cours',
$this->_resource->getDescription());
}
/** @test */
public function albumDescriptionShouldBeFormationsEnLigne() {
$this->assertContains('Formations en ligne et cours', $this->_album->getDescription());
}
}
class AlbumControllerAddWebsiteImportEnssibFromUrlTest
extends AlbumControllerAddWebsiteFromUrlPostTestCase {
protected function _getContent() {
return file_get_contents(__DIR__ . '/enssib.fr.html');
}
protected function _getUrl() {
return 'http://www.enssib.fr';
}
/** @test */
public function titleShouldBeEnssib() {
$this->assertEquals('Accueil | Enssib',
$this->_album->getTitre());
}
}
class AlbumControllerAddWebsiteImportBnfFromUrlTest
extends AlbumControllerAddWebsiteFromUrlPostTestCase {
protected function _getContent() {
return file_get_contents(__DIR__ . '/bnf.fr.html');
}
protected function _getUrl() {
return 'http://www.bnf.fr';
}
/** @test */
public function titleShouldBeBnfDotFr() {
$this->assertEquals('http://www.bnf.fr', $this->_album->getTitre());
}
}
\ No newline at end of file
......@@ -167,32 +167,11 @@ class BibControllerIndexWidthAdminPortailTest extends BibControllerTestCase {
class BibControllerWithModoPortailTest extends BibControllerTestCase {
protected function _loginHook($account) {
$account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL;
}
/** @test */
function responseToIndexShouldNotBeARedirectToAccueil() {
$this->dispatch('admin/bib/index');
$this->assertNotRedirect();
}
/** @test */
function responseToEditSiteOneShouldBePageEdit() {
$this->dispatch('admin/bib/edit/id/1');
$this->assertNotRedirect('admin/index');
}
}
class BibControllerWithModoPortailAddGallicaTest extends BibControllerTestCase {
class BibControllerWithAdminPortailAddGallicaTest extends BibControllerTestCase {
protected $_bib;
protected function _loginHook($account) {
$account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL;
$account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL;
}
......
......@@ -415,18 +415,19 @@ class CatalogueControllerWithAModoBibWithoutRightAccesDomainesIndexTest extends
ZendAfi_Auth::getInstance()->logUser(
Class_Users::newInstanceWithId(3)->beModoBib());
$this->dispatch('admin/catalogue/index');
$this->dispatch('admin/catalogue/index', true);
}
/** @test */
public function answerShouldRedirectToAdminIndex() {
$this->assertRedirectTo('/admin/index');
public function answerShouldRedirectToOpacIndex() {
$this->assertRedirectTo('/opac/index/index/id_profil/1');
}
}
class CatalogueControllerDisplayDomainesTest extends AbstractControllerTestCase {
protected
$user_group,
......
......@@ -56,7 +56,7 @@ abstract class Admin_ProfilControllerIndexTestCase extends Admin_AbstractControl
->setIdSite(0)));
$this->dispatch('/admin/profil/index');
$this->dispatch('/admin/profil/index', true);
}
}
......@@ -173,14 +173,14 @@ class Admin_ProfilControllerWithAdminPortailIndexTest extends Admin_ProfilContro
class Admin_ProfilControllerWithAdminBibIndexTest extends Admin_ProfilControllerIndexTestCase {
protected function _loginHook($account) {
parent::_loginHook($account);
$account->ROLE_LEVEL = 5;
$account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::ADMIN_BIB;
$account->ID_SITE = 5;
}
/** @test */
public function profilJeunesseShouldBeVisible() {
$this->assertXPathContentContains("//div", "Jeunesse");
$this->assertXPathContentContains("//div", "Jeunesse");
}
......
......@@ -18,7 +18,6 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'AdminAbstractControllerTestCase.php';
abstract class SitothequeControllerTestCase extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
......@@ -597,147 +596,4 @@ class SitothequeControllerDeleteCategorieInformationsTest extends SitothequeCont
public function categorieShouldHaveBeenDeleted() {
$this->assertEmpty(Class_SitothequeCategorie::find(2));
}
}
abstract class SitothequeControllerCreateFromUrlTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_album,
$_resource;
public function setUp() {
parent::setUp();
Class_WebService_SimpleWebClient::setInstance($this->mock()
->whenCalled('open_url')