From 1df10dd78a51a5021273176f8f46a8b736e8b93d Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Wed, 15 Jul 2015 14:57:07 +0200 Subject: [PATCH] dev #24821 valence user notices RT fixes --- library/Class/User/ILSSubscription.php | 64 +++++++++---------- library/Class/Users.php | 30 ++++----- .../View/Helper/RenderNotifications.php | 19 +++--- .../AbonneControllerWebkioskTest.php | 2 +- tests/library/Class/UsersTest.php | 8 +-- .../Class/WebService/SIGB/KohaTest.php | 3 +- .../WebService/SIGB/OpsysServiceTest.php | 24 +++---- 7 files changed, 74 insertions(+), 76 deletions(-) diff --git a/library/Class/User/ILSSubscription.php b/library/Class/User/ILSSubscription.php index 8b37966c7c5..b2ed3afa5c9 100644 --- a/library/Class/User/ILSSubscription.php +++ b/library/Class/User/ILSSubscription.php @@ -11,40 +11,40 @@ * * 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 + * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_User_ILSSubscription { - use Trait_Translator; + use Trait_Translator; - protected $_user; + protected $_user; - public function __construct($user) { - $this->_user = $user; - } + public function __construct($user) { + $this->_user = $user; + } - public function isILSExpirable() { - return $this->_user->isAbonne() && $this->_user->hasDateFin(); - } + public function isILSExpirable() { + return $this->_user->isAbonne() && $this->_user->hasDateFin(); + } public function isILSExpired() { - return - $this->isILSExpirable() - && ($this->_user->getDateFin() < date("Y-m-d")); + return + $this->isILSExpirable() + && ($this->_user->getDateFin() < date("Y-m-d")); } public function isILSAboutToExpire() { return - $this->isILSExpirable() - && ($this->ilsExpireIn() >= 0) + $this->isILSExpirable() + && ($this->ilsExpireIn() >= 0) && (Class_AdminVar::getValueOrDefault('NDAYS_EXPIRY_NOTICE') >= $this->ilsExpireIn()); } @@ -57,29 +57,29 @@ class Class_User_ILSSubscription { } - public function isValid() { - if (! $this->_user->isAbonne()) return false; + public function isValid() { + if (! $this->_user->isAbonne()) return false; if (! $this->_user->hasDateFin()) return true; return ($this->_user->getDateFin() >= date("Y-m-d")); - } + } - public function registerNotificationsOn($notifiable) { - if ($this->isILSExpired()) - $notifiable - ->notify($this->_('Abonnement expiré - Merci de contacter la médiathèque')); + public function registerNotificationsOn($notifiable) { + if ($this->isILSExpired()) + $notifiable + ->notify($this->_('Abonnement expiré - Merci de contacter la médiathèque')); - if ($this->isILSAboutToExpire()) - $notifiable - ->notify( - $this->_plural($this->ilsExpireIn(), - 'Votre abonnement expire aujourd\'hui.', - 'Votre abonnement arrivera à expiration demain.', - 'Votre abonnement arrivera à expiration dans %d jours.', + if ($this->isILSAboutToExpire()) + $notifiable + ->notify( + $this->_plural($this->ilsExpireIn(), + 'Votre abonnement expire aujourd\'hui.', + 'Votre abonnement arrivera à expiration demain.', + 'Votre abonnement arrivera à expiration dans %d jours.', $this->ilsExpireIn()) - ); - return $this; - } + ); + return $this; + } } ?> \ No newline at end of file diff --git a/library/Class/Users.php b/library/Class/Users.php index 8926b061180..1afa1fd420e 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -11,16 +11,16 @@ * * 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 + * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class UsersLoader extends Storm_Model_Loader { - public function getNewslettersReceivers($id_newsletter, $recipient_size) { + public function getNewslettersReceivers($id_newsletter, $recipient_size) { // do not use Storm as it must be ordered by mail AND filtered by joined column $req = 'select bib_admin_users.* from bib_admin_users join newsletters_users on bib_admin_users.id_user = newsletters_users.user_id where newsletter_id = ' . $id_newsletter . ' and newsletters_users.send is false order by bib_admin_users.mail limit ' . $recipient_size; @@ -47,7 +47,7 @@ class UsersLoader extends Storm_Model_Loader { if ($by_right !== null) $sql_template .= 'inner join user_group_memberships on user_group_memberships.user_id = bib_admin_users.id_user '. - 'inner join user_groups on user_group_memberships.user_group_id = user_groups.id '. + 'inner join user_groups on user_group_memberships.user_group_id = user_groups.id '. 'where (user_groups.rights_token & %1$d = %1$d) and '; else $sql_template .= 'where '; @@ -175,7 +175,7 @@ class UsersLoader extends Storm_Model_Loader { * @return array */ public function getAllBorrowers() { - return $this->findAllBy(['role_level' => 2]); + return $this->findAllBy(['role_level' => 2]); } public function getBorrowersModifiedAfter($dateMaj){ @@ -246,7 +246,7 @@ class Class_Users extends Storm_Model_Abstract { protected $_table_name = 'bib_admin_users'; protected $_table_primary = 'ID_USER'; - protected $_loader_class = 'UsersLoader'; + protected $_loader_class = 'UsersLoader'; protected $_has_many = [ 'subscriptions' => ['model' => 'Class_NewsletterSubscription', 'role' => 'user', @@ -512,7 +512,7 @@ class Class_Users extends Storm_Model_Abstract { * @return bool */ public function isAbonnementValid() { - return (new Class_User_ILSSubscription($this))->isValid(); + return (new Class_User_ILSSubscription($this))->isValid(); } @@ -533,12 +533,12 @@ class Class_Users extends Storm_Model_Abstract { return null; $arr1 = explode('/', $date_naissance); - $arr2 = explode('/', $this->getToday()); + $arr2 = explode('/', $this->getToday()); - if(($arr1[1] < $arr2[1]) || (($arr1[1] == $arr2[1]) && ($arr1[2] <= $arr2[2]))) + if(($arr1[1] < $arr2[1]) || (($arr1[1] == $arr2[1]) && ($arr1[2] <= $arr2[2]))) return $arr2[0] - $arr1[0]; - return $arr2[0] - $arr1[0] - 1; + return $arr2[0] - $arr1[0] - 1; } @@ -625,7 +625,7 @@ class Class_Users extends Storm_Model_Abstract { public function getLastAvis() { return Class_AvisNotice::findAllBy(['id_user' => $this->getId(), 'order' => 'date_avis desc', - 'limit' => 10]); + 'limit' => 10]); } @@ -1354,7 +1354,7 @@ class Class_Users extends Storm_Model_Abstract { public function getEditablePaniers() { - $user_paniers = $this->getPaniers(); + $user_paniers = $this->getPaniers(); if ($this->canAccessBackend()) $user_paniers = array_filter(array_unique(array_merge($user_paniers, Class_PanierNotice::findAllWithCatalogue()))); @@ -1390,7 +1390,7 @@ class Class_Users extends Storm_Model_Abstract { public function getPaniersDomainesJson() { $paniers = $this->getPaniers(); - $paniers_domaines= []; + $paniers_domaines= []; foreach($paniers as $panier) { if(!$domaines = $panier->getCatalogues()) @@ -1451,7 +1451,7 @@ class Class_Users extends Storm_Model_Abstract { public function isAlreadyRegisteredTo($newsletter) { return 0 < Class_NewsletterSubscription::countBy(['user_id' => $this->getId(), 'newsletter_id' => $newsletter->getId()]); -} + } public function getLoginOrFullName() { @@ -1513,7 +1513,7 @@ class Class_Users extends Storm_Model_Abstract { public function registerNotificationsOn($notifiable) { - (new Class_User_ILSSubscription($this))->registerNotificationsOn($notifiable); + (new Class_User_ILSSubscription($this))->registerNotificationsOn($notifiable); $this ->_notifyOn($notifiable, $this->getNbEmpruntsRetard(), diff --git a/library/ZendAfi/View/Helper/RenderNotifications.php b/library/ZendAfi/View/Helper/RenderNotifications.php index cba22ec2e37..5ca87103b1a 100644 --- a/library/ZendAfi/View/Helper/RenderNotifications.php +++ b/library/ZendAfi/View/Helper/RenderNotifications.php @@ -1,6 +1,3 @@ - - - <?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. @@ -14,12 +11,12 @@ * * 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 + * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_RenderNotifications extends ZendAfi_View_Helper_BaseHelper { @@ -28,14 +25,14 @@ class ZendAfi_View_Helper_RenderNotifications extends ZendAfi_View_Helper_BaseHe public function renderNotifications($user) { $user->registerNotificationsOn($this); - if (!$this->_messages) - return ''; + if (!$this->_messages) + return ''; $html = $this->view->tag('p', - implode('<br>', $this->_messages), - ['class' => 'user_notifications']); - $this->_messages = []; - return $html; + implode('<br>', $this->_messages), + ['class' => 'user_notifications']); + $this->_messages = []; + return $html; } diff --git a/tests/application/modules/opac/controllers/AbonneControllerWebkioskTest.php b/tests/application/modules/opac/controllers/AbonneControllerWebkioskTest.php index 52ef7b550a3..f0ba6b5e4a6 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerWebkioskTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerWebkioskTest.php @@ -3,7 +3,7 @@ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * * BOKEH is free software; you can redistribute it and/or modify -g * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * 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 diff --git a/tests/library/Class/UsersTest.php b/tests/library/Class/UsersTest.php index 4dbc9868ce2..7323139e745 100644 --- a/tests/library/Class/UsersTest.php +++ b/tests/library/Class/UsersTest.php @@ -716,13 +716,13 @@ class UsersFicheAbonneTest extends ModelTestCase { } - /** @test */ - public function withoutDateFinPatrickNotificationsShouldBeEmpty() { - $this->patrick->setDateFin(''); + /** @test */ + public function withoutDateFinPatrickNotificationsShouldBeEmpty() { + $this->patrick->setDateFin(''); $this->patrick->registerNotificationsOn($this->_notifiable); $this->assertEmpty($this->_notifications); - } + } /** @test */ diff --git a/tests/library/Class/WebService/SIGB/KohaTest.php b/tests/library/Class/WebService/SIGB/KohaTest.php index 4510c0c4b8c..d2e1a42721f 100644 --- a/tests/library/Class/WebService/SIGB/KohaTest.php +++ b/tests/library/Class/WebService/SIGB/KohaTest.php @@ -415,7 +415,8 @@ class KohaGetEmprunteurLaureAfondTest extends KohaTestCase { /** @test */ - public function firstReservationShouldExists() { $this->assertNotNull($this->laurent->getReservationAt(0)); + public function firstReservationShouldExists() { + $this->assertNotNull($this->laurent->getReservationAt(0)); $this->assertNotNull($this->laurent->getReservationAt(0)); return $this->laurent->getReservationAt(0); } diff --git a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php index 4e5eb665ab2..127fdf09ad6 100644 --- a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php +++ b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php @@ -1282,7 +1282,7 @@ class OpsysServiceReservationEmittedTest extends Storm_Test_ModelTestCase { public function setUp(){ $this->reservation = new Class_WebService_SIGB_Reservation('23', new Class_WebService_SIGB_Exemplaire('potter')); $this->reservation->parseExtraAttributes([ - 'Etat' => 'Réservation émise le 22/02/2014']); + 'Etat' => 'Réservation émise le 22/02/2014']); } public function testRangDefaultToOne() { @@ -1299,10 +1299,10 @@ class OpsysServiceReservationEmittedTest extends Storm_Test_ModelTestCase { } - /** @test */ - public function waitingToBePulledShouldBeFalse() { - $this->assertFalse($this->reservation->isWaitingToBePulled()); - } + /** @test */ + public function waitingToBePulledShouldBeFalse() { + $this->assertFalse($this->reservation->isWaitingToBePulled()); + } } @@ -1311,9 +1311,9 @@ class OpsysServiceReservationEmittedTest extends Storm_Test_ModelTestCase { class OpsysServiceReservationAvailableTest extends Storm_Test_ModelTestCase { public function setUp(){ $this->reservation = new Class_WebService_SIGB_Opsys_Reservation('23', - new Class_WebService_SIGB_Exemplaire('potter')); + new Class_WebService_SIGB_Exemplaire('potter')); $this->reservation->parseExtraAttributes([ - 'Etat' => 'Réservation satisfaite. disponible à la médiathèque']); + 'Etat' => 'Réservation satisfaite. disponible à la médiathèque']); } @@ -1322,10 +1322,10 @@ class OpsysServiceReservationAvailableTest extends Storm_Test_ModelTestCase { } - /** @test */ - public function waitingToBePulledShouldBeTrue() { - $this->assertTrue($this->reservation->isWaitingToBePulled()); - } + /** @test */ + public function waitingToBePulledShouldBeTrue() { + $this->assertTrue($this->reservation->isWaitingToBePulled()); + } } @@ -1526,7 +1526,7 @@ class OpsysServiceTestReserverExemplaireTest extends OpsysServiceWithSessionTest ->answers($reserverResponse); $notice_sigb = (new Class_WebService_SIGB_Notice('ido344')) - ->addExemplaire((new Class_WebService_SIGB_Exemplaire('id_ex_344')) + ->addExemplaire((new Class_WebService_SIGB_Exemplaire('id_ex_344')) ->setCodeBarre('cb344')); $this->opsys->getNoticeCache()->cacheNotice($notice_sigb); -- GitLab