diff --git a/VERSIONS b/VERSIONS index d58d557c7df74d530c491b0e840f6b1063541984..dac32c05a1a1d35a58e8588970692170292ff865 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,10 @@ +06/03/2017 - v7.9.5 + + - ticket #56622 : Espace abonné : correction de bug dans la liste de prêts et de réservations. + + - ticket #56230 : Formulaire de contact : Le message ne doit pas contenir de HTML + + 02/03/2017 - v7.9.4 - ticket #56994 : Outils de migration de comptes lecteurs diff --git a/application/modules/opac/controllers/ErrorController.php b/application/modules/opac/controllers/ErrorController.php index 66b1cc675cd1f397da81002885a6ae603bf735ee..139abfda47ebf262b1d497d8bcf8c6221ba12fb7 100644 --- a/application/modules/opac/controllers/ErrorController.php +++ b/application/modules/opac/controllers/ErrorController.php @@ -29,8 +29,11 @@ class ErrorController extends Zend_Controller_Action { $this->_response->clearBody(); if (($this->_request->getServer('HTTP_HOST') == 'localhost') - || ((null != ($user = Class_Users::getLoader()->getIdentity())) - && $user->isAdmin())) { + || (($ig = Zend_Controller_Front::getInstance() + ->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget')) + && $ig->isEnabled()) + || ((null != ($user = Class_Users::getLoader()->getIdentity())) + && $user->isAdmin())) { $this->view->errors = $errors; return; } diff --git a/library/Class/CodifAuteur.php b/library/Class/CodifAuteur.php index 759737f2bb8b51045cb95e27a782ff6f6cd937f8..b6b0c088d0a75a3c83412d913eedd0c04c65ce1c 100644 --- a/library/Class/CodifAuteur.php +++ b/library/Class/CodifAuteur.php @@ -21,6 +21,25 @@ class CodifAuteurLoader extends Storm_Model_Loader { + public function findWithFullName($author) { + if(!$author) + return null; + + $indexation = new Class_Indexation(); + $alpha_author = $indexation->alphaMaj($author); + + if(1 == count(($names = explode(' ', $author)))) + return Class_CodifAuteur::findByCodeAlpha($alpha_author); + + if(2 < count($names)) + return Class_CodifAuteur::findFirstBy(['libelle' => $alpha_author]); + + return ($found = Class_CodifAuteur::findByLastNameFirstName($names[0], $names[1])) + ? $found + : Class_CodifAuteur::findByLastNameFirstName($names[1], $names[0]); + } + + public function findByLastNameFirstName($lastname, $firstname) { $code_alpha = str_replace(' ', 'x', diff --git a/library/ZendAfi/Form/ContactForm.php b/library/ZendAfi/Form/ContactForm.php index 4979be5f7435156c3e0e0a3814efeea20da523bd..bb3dad2c531786991ff231774211223700b59cee 100644 --- a/library/ZendAfi/Form/ContactForm.php +++ b/library/ZendAfi/Form/ContactForm.php @@ -66,32 +66,43 @@ class ZendAfi_Form_ContactForm extends ZendAfi_Form { 'size' => 50, 'required' => true, 'allowEmpty' => false]) + ->addElement('text', 'prenom', ['label' => $this->_('Prénom').' *', 'size' => 50, 'required' => true, 'allowEmpty' => false]) + ->addElement('text', 'adresse', ['label' => $this->_('Adresse'), 'size' => 50]) + ->addElement('text', 'code_postal', ['label' => $this->_('Code postal').' *', 'size' => 8, 'required' => true, 'allowEmpty' => false]) + ->addElement('text', 'ville', ['label' => $this->_('Ville'), 'size' => 50]) + ->addElement('email', 'mail', ['label' => $this->_('E-mail').' *', 'size' => 50, 'required' => true, 'allowEmpty' => false]) + ->addElement('text', 'sujet', [ 'label' => $this->_('Sujet').' *', 'size' => 50, 'required' => true, 'allowEmpty' => false]) + ->addElement('textarea', 'message', ['label' => $this->_('Message').' *', 'cols' => 60, 'required' => true, - 'allowEmpty' => false]) + 'allowEmpty' => false, + 'validators' => ['NoHtml'] + ]) + ->addElement('text', 'emailCheck', ['data-spambots' => 'true']) + ->addElement('timer', 'timer', ['session' => Zend_Registry::get('session'), 'salt' => __CLASS__, 'delaySeconds' => 10]); diff --git a/library/ZendAfi/Validate/NoHtml.php b/library/ZendAfi/Validate/NoHtml.php new file mode 100644 index 0000000000000000000000000000000000000000..49757e8861d7cc777a5be874bac45f135f1a0d54 --- /dev/null +++ b/library/ZendAfi/Validate/NoHtml.php @@ -0,0 +1,36 @@ +<?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 ZendAfi_Validate_NoHtml extends Zend_Validate_Abstract { + const CONTAINS_HTML = 'containsHtml'; + + protected $_messageTemplates = [self::CONTAINS_HTML => 'La mise en forme HTML n\'est pas autorisée']; + + + public function isValid($value) { + if ($value == strip_tags($value)) + return true; + + $this->_error(self::CONTAINS_HTML); + return false; + } +} diff --git a/library/ZendAfi/View/Helper/AuthorAnchor.php b/library/ZendAfi/View/Helper/AuthorAnchor.php index e2872b1eb8e7b7048f90eba0a9481d7ac02f9032..73d83fa71216180257a7c0d11a4b7369be0342c9 100644 --- a/library/ZendAfi/View/Helper/AuthorAnchor.php +++ b/library/ZendAfi/View/Helper/AuthorAnchor.php @@ -26,15 +26,14 @@ class ZendAfi_View_Helper_AuthorAnchor extends ZendAfi_View_Helper_BaseHelper { if(!$author) return ''; - if(!$facet = Class_CodifAuteur::findFirstBy(['libelle' => $author])) - return $author; + if($facet = Class_CodifAuteur::findWithFullName($author)) + $params = array_merge(['controller' => 'recherche', + 'action' => 'simple', + 'facette' => Class_CodifAuteur::CODE_FACETTE . $facet->getId()], + $params); - $params = array_merge(['controller' => 'recherche', - 'action' => 'simple', - 'facette' => Class_CodifAuteur::CODE_FACETTE . $facet->getId()], - $params); - return - $this->view->tagAnchor($this->view->url($params, null, true), $author); + return $this->view->tagAnchor($this->view->url($params, null, true), + $author); } } ?> \ No newline at end of file diff --git a/library/startup.php b/library/startup.php index 83c14f605b06b2bf1589faee91e377a718112c7a..967d7a4ccde7be3df61fae7ce7d648c260c3bf14 100644 --- a/library/startup.php +++ b/library/startup.php @@ -83,7 +83,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.9'); - 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/'); diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index bf1b6f902ff4b0330c004ab30adf393a964f0913..cc5102028b59469bafc302378d250fb47937d2ad 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -285,7 +285,7 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT parent::setUp(); $this->fixture('Class_CodifAuteur', ['id' => 565, - 'libelle' => 'QuinRose']); + 'libelle' => 'QUINROSE']); $this->dispatch('/opac/abonne/prets', true); } @@ -512,7 +512,7 @@ abstract class AbonneControllerPretsListReservationTestCase extends AbstractAbon $this->fixture('Class_CodifAuteur', ['id' => 456, - 'libelle' => 'Joanne Kathleen Rowling']); + 'libelle' => 'JOANNE KATHLEEN ROWLING']); $potter = (new Class_WebService_SIGB_Reservation('12', diff --git a/tests/application/modules/opac/controllers/FormulaireContactTest.php b/tests/application/modules/opac/controllers/FormulaireContactTest.php index 497d2299d2d13931e7dac77716b0d4302ab78044..de7969656c38fd3fc58ddf331f931a66bb09ce70 100644 --- a/tests/application/modules/opac/controllers/FormulaireContactTest.php +++ b/tests/application/modules/opac/controllers/FormulaireContactTest.php @@ -79,8 +79,9 @@ class FormulaireContactInvalidPostTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); $this->postDispatch('/opac/index/formulairecontact', - array('ville' => 'Annecy', - 'mail' => 'blabla')); + ['ville' => 'Annecy', + 'mail' => 'blabla', + 'message' => 'String containing <a href="#">HTML</a>']); } /** @test */ @@ -88,14 +89,22 @@ class FormulaireContactInvalidPostTest extends AbstractControllerTestCase { $this->assertXPath('//input[@name="ville"]', 'Annecy'); } + /** @test */ public function errorsShouldDisplayEmailInvalide() { $this->assertXPathContentContains('//ul[@class="errors"]', 'blabla'); } + + + /** @test */ + public function errorsShouldDisplayNoHtmlAllowed() { + $this->assertXPathContentContains('//ul[@class="errors"]', 'La mise en forme HTML'); + } } + class FormulaireContactInvalidEmailHoneyPotPostTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); diff --git a/tests/library/ZendAfi/View/Helper/AuthorAnchorTest.php b/tests/library/ZendAfi/View/Helper/AuthorAnchorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6b508ab7d5d640b7864e72739a0f62bd3557f32f --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/AuthorAnchorTest.php @@ -0,0 +1,66 @@ +<?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 ZendAfi_View_Helper_AnchorAuthorSimpleTest extends ViewHelperTestCase { + protected + $_storm_default_to_volatile = true; + + public function setup() { + parent::setUp(); + + $brisson = $this->fixture('Class_CodifAuteur', + ['id' => 10, + 'libelle' => 'Stéphanie BRISSON', + 'formes' => 'BRISSONxSTEPHANIE']); + + $kondu = $this->fixture('Class_CodifAuteur', + ['id' => 11, + 'libelle' => 'Marie Kond?', + 'formes' => 'KONDxxMARIE']); + + $this->onLoaderOfModel('Class_CodifAuteur') + + ->whenCalled('findByLastNameFirstName') + ->with('Stéphanie', 'BRISSON') + ->answers($brisson) + + ->whenCalled('findByLastNameFirstName') + ->with('Marie', 'KondÅ') + ->answers($kondu); + + + $this->_helper = new ZendAfi_View_Helper_AuthorAnchor(); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + } + + + /** @test */ + public function shouldReturnAnchorWithFacetA10() { + $this->assertContains('/recherche/simple/facette/A10">Stéphanie BRISSON</a>', $this->_helper->authorAnchor('Stéphanie BRISSON')); + } + + + /** @test */ + public function shouldReturnAnchorWithFacetA11() { + $this->assertContains('/recherche/simple/facette/A11">Marie KondÅ</a>', $this->_helper->authorAnchor('Marie KondÅ')); + } +} \ No newline at end of file