Commit d2ebc81e authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch 'hotline' into 'master'

Hotline

See merge request !3456
parents c8e3d139 9f588f6c
Pipeline #9769 passed with stage
in 45 minutes and 18 seconds
- ticket #101969 : Suppression d'une balise html <br /> pouvant apparaître dans les messages liés aux réservations
\ No newline at end of file
- ticket #102336 : horaires formation : correction sur la suppression de l'horaire de formation lors d'une inscription
\ No newline at end of file
- ticket #104010 : OPAC : Suppression des dates par défaut erronées (début événement, fin événement) dans l'affichage des articles.
\ No newline at end of file
- ticket #108377 : Ressources numériques : Correction du calcul du quota de réservation pour les invités
\ No newline at end of file
- ticket #99121 : Correction de la fonction "mot de passe oublié" lorsqu'une personne s'enregistre, active son compte mais n'a pas encore été validé par un administrateur
\ No newline at end of file
......@@ -469,7 +469,7 @@ class AbonneController extends ZendAfi_Controller_Action {
$cards = new Class_User_Cards($this->_user);
if ($delete = $this->_getParam('id_delete')) {
$title = $cards->getHoldTitle($delete);
$title = strip_tags($cards->getHoldTitle($delete));
$result = $cards->cancelHold($delete);
$message = array_key_exists('erreur', $result) && $result['erreur']
? $result['erreur']
......
......@@ -856,11 +856,13 @@ class RechercheController extends ZendAfi_Controller_Action {
|| !($notice = $item->getNotice()))
return '';
$title = strip_tags($notice->getTitrePrincipal());
if(!$notice->getAuteurPrincipal())
return sprintf(" '%s'",$notice->getTitrePrincipal());
return sprintf(" '%s'", $title);
return sprintf(" '%s / %s'",
$notice->getTitrePrincipal(),
$title,
$notice->getAuteurPrincipal());
}
......
......@@ -24,12 +24,18 @@ class Class_Hold_PnbLoader extends Storm_Model_Loader {
if (!$user)
return [];
return array_unique(
array_merge(
Class_Hold_Pnb::findAllBy(['user_id' => $user->getId(),
'order' => 'hold_date']),
Class_Hold_Pnb::findAllBy(['subscriber_id' => $user->getIdabon(),
'order' => 'hold_date'])));
$by_user_id = $this->findAllOngoingBy(['user_id' => $user->getId()]);
if (!$user->isAbonne())
return $by_user_id;
return array_unique(array_merge($by_user_id,
$this->findAllOngoingBy(['subscriber_id' => $user->getIdabon()])));
}
public function findAllOngoingBy($params) {
return Class_Hold_Pnb::findAllBy(array_merge(['order' => 'hold_date'],
$params));
}
......@@ -160,17 +166,19 @@ class Class_Hold_Pnb extends Storm_Model_Abstract {
public function getUser() {
$user = parent::_get('user');
return $user
if ($user = parent::_get('user'))
return $user;
return $this->hasSubscriberId() && ($user = Class_Users::findFirstBy(['idabon' => $this->getSubscriberId()]))
? $user
: Class_Users::findFirstBy(['idabon' => $this->getSubscriberId()]);
: null;
}
public function getUserId() {
return ($user = $this->getUser())
? $user->getId()
: null;
: parent::_get('user_id');
}
......
......@@ -21,6 +21,9 @@
class Class_Loan_PnbLoader extends Storm_Model_Loader {
public function findAllOngoingOfUser($user) {
if (!$user)
return [];
$loans = $this->_ongoingOf($user);
(new Class_WebService_BibNumerique_Dilicom_Hub())->updateLoansReturnDate($loans);
......
......@@ -429,10 +429,11 @@ class Class_SessionActivity_Article
protected function _synchronize($model, $dependent, $force_content=false) {
$dependent
->setTitre($model->getLibelleActivity())
->setEventsDebut($model->getDateDebut())
->setEventsFin($model->hasDateFin()
? $model->getDateFin()
: $model->getDateDebut())
->setEventsDebut($this->_replaceDateInto($dependent->getEventsDebut(), $model->getDateDebut()))
->setEventsFin($this->_replaceDateInto($dependent->getEventsFin(),
$model->hasDateFin()
? $model->getDateFin()
: $model->getDateDebut()))
->setLieu($model->getLieu());
if (!$dependent->getContenu() || $force_content)
......@@ -443,6 +444,12 @@ class Class_SessionActivity_Article
}
protected function _replaceDateInto($old_datetime, $new_date) {
return $new_date
. (10 < strlen($old_datetime) ? substr($old_datetime, 10) : '');
}
protected function _contentFrom($model) {
return
$model->getActivityDescription()
......
......@@ -24,7 +24,7 @@ class Class_User_Cards extends Storm_Model_Collection {
use Trait_Translator;
public function __construct($user) {
if ($user->isAbonne())
if ($user->isAbonne() || $user->hasPnbLoans() || $user->hasPnbHolds())
$this->append($user);
$this->addAll($user->getChildCards());
......
......@@ -381,6 +381,7 @@ class Class_Users extends Storm_Model_Abstract {
protected
$_fiche_sigb,
$_loans,
$_ongoing_pnb_holds,
$_table_name = 'bib_admin_users',
$_table_primary = 'ID_USER',
$_loader_class = 'UsersLoader',
......@@ -1236,6 +1237,11 @@ class Class_Users extends Storm_Model_Abstract {
}
public function hasPnbLoans() {
return !$this->getEmprunts()->selectPNB()->isEmpty();
}
public function getPanierCourant() {
return ($panier_courant = parent::getPanierCourant())
? $panier_courant
......@@ -1290,10 +1296,21 @@ class Class_Users extends Storm_Model_Abstract {
* @return int
*/
public function getNbReservations() {
return $this->getEmprunteur()->getNbReservations()
+ (new Storm_Model_Collection(Class_Hold_Pnb::findAllOngoingOfUser($this)))
->reject('isExpired')
->count();
return $this->getEmprunteur()->getNbReservations() + $this->_getOngoingPnbHolds()->count();
}
public function hasPnbHolds() {
return 0 < $this->_getOngoingPnbHolds()->count();
}
protected function _getOngoingPnbHolds() {
if ($this->_ongoing_pnb_holds)
return $this->_ongoing_pnb_holds;
return $this->_ongoing_pnb_holds = (new Storm_Model_Collection(Class_Hold_Pnb::findAllOngoingOfUser($this)))
->reject('isExpired');
}
......
......@@ -138,6 +138,11 @@ class Class_UsersNonValid extends Storm_Model_Abstract {
}
public function isNotActivated() {
return !$this->hasUser();
}
protected function _escalateRole() {
if (($bib = $this->getBib())
&& $bib->shouldEscalateRegistrationRole()){
......
......@@ -33,9 +33,9 @@ class ZendAfi_Validate_LostUsername extends Zend_Validate_Abstract {
$this->_messageTemplates =
[static::NO_USER => $this->_('Identifiant inconnu.'),
static::NO_MAIL => $this->_("Votre mail n'est pas renseigné dans votre compte lecteur. Merci de vous adresser à la bibliothèque pour récupérer votre mot de passe ou bien le remplacer par un nouveau."),
static::NO_MAIL => $this->_('Votre mail n\'est pas renseigné dans votre compte lecteur. Merci de vous adresser à la bibliothèque pour récupérer votre mot de passe ou bien le remplacer par un nouveau.'),
static::NO_ACTIVE_USER => $this->_("Votre compte n\'a pas encore été activé. Veuillez utiliser le lien d\'activation reçu précédemment par mail ou vous adresser à la bibliothèque si vous ne l\'avez pas reçu.")];
static::NO_ACTIVE_USER => $this->_('Votre compte n\'a pas encore été activé. Veuillez utiliser le lien d\'activation reçu précédemment par mail ou vous adresser à la bibliothèque si vous ne l\'avez pas reçu.')];
}
......@@ -47,7 +47,8 @@ class ZendAfi_Validate_LostUsername extends Zend_Validate_Abstract {
public function isValid($value, array $fields_values = array()) {
$value = ZendAfi_Filters_Post::filterStatic($value);
if ($user = Class_UsersNonValid::findFirstBy(['login' => $value])) {
if (($user = Class_UsersNonValid::findFirstBy(['login' => $value]))
&& $user->isNotActivated()) {
$this->_error(static::NO_ACTIVE_USER);
return false;
}
......
......@@ -46,12 +46,16 @@ class ZendAfi_View_Helper_TagArticleInfo extends ZendAfi_View_Helper_BaseHelper
protected function _dayMonth($strdate) {
return strftime('%a %d %b', strtotime($strdate));
return $strdate
? strftime('%a %d %b', strtotime($strdate))
: '';
}
protected function _hour($strdate) {
return strftime('%Hh%M', strtotime($strdate));
return $strdate
? strftime('%Hh%M', strtotime($strdate))
: '';
}
......
......@@ -1042,7 +1042,7 @@ class Admin_ActivityControllerPostSessionLearnJavaTest extends Admin_ActivityCon
/** @test */
public function linkedArticleEventsFinShouldBeUpdates() {
public function linkedArticleEventsFinShouldBeUpdated() {
$this->assertEquals('2012-05-29', $this->_article->getEventsFin());
}
......
......@@ -144,6 +144,16 @@ abstract class AbstractAbonneControllerActivitiesTestCase
'stagiaires' => [],
'date_limite_inscription' => '2015-01-20']);
$this->_session_java_fevrier->setArticle($this->fixture('Class_Article',
['id' => 10,
'titre' => 'Java est mort, vive python !',
'contenu' => 'Java has been'])
->setDateMaj('2020-04-11 08:00:00')
->setEventsDebut('2020-04-11 12:00:00')
->setEventsFin('2020-04-11 17:00:00'))
->save();
$this->_session_java_mars = $this->fixture('Class_SessionActivity',
['id' => 32,
'activity' => $this->_learn_java,
......@@ -639,6 +649,7 @@ class AbonneControllerActivitiesAmadouInscritSessionMarsJavaClosedTest extends A
public function notificationShouldContainsSessionClosed() {
$this->assertFlashMessengerContentContains('cette session est fermée');
}
}
......@@ -656,6 +667,9 @@ class AbonneControllerActivitiesAmadouInscritSessionFebruaryJavaOpenTest extends
$this->dispatch('/opac/abonne/inscrire-session/id/31', true);
Class_SessionActivity::clearCache();
Class_Article::clearCache();
$this->_mails = $this->_mail_transport->getSentMails();
}
......@@ -679,6 +693,14 @@ class AbonneControllerActivitiesAmadouInscritSessionFebruaryJavaOpenTest extends
}
/** @test */
public function sessionJavaMarsShouldChangeDatesButKeepTimes() {
$article = Class_SessionActivity::find(31)->getArticle();
$this->assertEquals('2015-02-10 12:00', $article->getEventsDebut());
$this->assertEquals('2015-02-20 17:00', $article->getEventsFin());
}
/** @test */
function aNewInscriptionShouldHaveBeenCreated() {
$this->assertCount(1, Class_SessionActivityInscription::findAllBy(['stagiaire_id' => 435,
......
......@@ -216,3 +216,132 @@ class AbonneControllerFicheActionWithLoggedUserTest extends AbstractAbonneContro
}
}
abstract class AbonneControllerFicheActionLoggedGuestWithPnbTestCase extends AbstractAbonneControllerFicheTest {
public function setUp() {
parent::setUp();
$user = $this->fixture('Class_Users',
['id' => 88,
'login' => 'guest',
'password' => 'roxor',
'id_site' => 1,
'user_groups' => [Class_UserGroup::find(20)],
'role' => ZendAfi_Acl_AdminControllerRoles::INVITE,
]);
ZendAfi_Auth::getInstance()->logUser($user);
}
public function tearDown() {
Class_Loan_Pnb::setTimeSource(null);
Class_Hold_Pnb::setTimeSource(null);
Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient(null);
parent::tearDown();
}
}
class AbonneControllerFicheActionLoggedGuestWithPnbNoHoldNorLoanTest
extends AbonneControllerFicheActionLoggedGuestWithPnbTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/abonne/fiche', true);
}
/** @test */
public function loansLinkShouldNotBePresent() {
$this->assertNotXPath('//div//a[contains(@href, "/abonne/prets")]');
}
/** @test */
public function holdsLinkShouldNotBePresent() {
$this->assertNotXPath('//div//a[contains(@href, "/abonne/reservations")]');
}
}
class AbonneControllerFicheActionLoggedGuestWithPnbHoldsTest
extends AbonneControllerFicheActionLoggedGuestWithPnbTestCase {
public function setUp() {
parent::setUp();
Class_Hold_Pnb::setTimeSource(new TimeSourceForTest('2022-06-10 10:23:10'));
Class_AdminVar::set('DILICOM_PNB_ENABLE_HOLDS', 1);
$second = $this->fixture('Class_Hold_Pnb',
['id' => 2,
'user_id' => 88,
'subscriber_id' => '',
'record_origin_id' => 'Dilicom-88817216',
'hold_date' => '2022-06-07 20:10:00',
'expiration_date' => '2022-06-15 20:10:00']);
$this->dispatch('/abonne/fiche', true);
}
/** @test */
public function loansLinkShouldBePresent() {
$this->assertXPath('//div//a[contains(@href, "/abonne/prets")]');
}
/** @test */
public function holdsLinkShouldBePresent() {
$this->assertXPath('//div//a[contains(@href, "/abonne/reservations")]');
}
}
class AbonneControllerFicheActionLoggedGuestWithPnbLoansTest
extends AbonneControllerFicheActionLoggedGuestWithPnbTestCase {
public function setUp() {
parent::setUp();
Class_Loan_Pnb::setTimeSource(new TimeSourceForTest('2017-11-14 10:23:10'));
Class_AdminVar::set('DILICOM_PNB_ENABLE_HOLDS', 1);
$http = $this->mock()->whenCalled('open_url')->answers(null);
Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient($http);
$this->fixture('Class_Loan_Pnb',
['id' => 3,
'record_origin_id' => 'Dilicom-3663608260879',
'subscriber_id' => '',
'user_id' => 88,
'expected_return_date' => '2017-12-13 13:57:33',
'loan_date' => '2017-11-13 13:57:33',
'loan_link' => 'https://pnb-dilicom.centprod.com/v2//XXXXXXXX.do',
'order_line_id' => '584837a045ce56ef0a072a8b',]);
$this->dispatch('/abonne/fiche', true);
}
/** @test */
public function loansLinkShouldBePresent() {
$this->assertXPath('//div//a[contains(@href, "/abonne/prets")]');
}
/** @test */
public function holdsLinkShouldBePresent() {
$this->assertXPath('//div//a[contains(@href, "/abonne/reservations")]');
}
}
......@@ -96,7 +96,7 @@ class AuthControllerLostPasswordActionTest extends AuthControllerLostPasswordTes
class AuthControllerLostPasswordValidPostTest extends AuthControllerLostPasswordTestCase {
protected $_mail_transport, $_mail;
protected $_mail;
public function setUp() {
parent::setUp();
......@@ -151,6 +151,49 @@ class AuthControllerLostPasswordValidPostTest extends AuthControllerLostPassword
class AuthControllerLostPasswordValidPostWithUserNotValidatedYetTest extends AuthControllerLostPasswordTestCase {
protected $_mail;
public function setUp() {
parent::setUp();
$this->fixture('Class_Users',
['id' => 78,
'login' => 'toutnouveau',
'password' => 'secret',
'idabon' => '93658',
'mail' => 'toutnouveau@here.fr']);
$this->fixture('Class_UsersNonValid',
['id' => 1,
'login' => 'toutnouveau',
'password' => 'secret',
'bib_user_id' => 78]);
$this->postDispatch('/opac/auth/lostpass', ['lost_username' => 'toutnouveau']);
$this->_mail = $this->_mail_transport->sent_mail;
}
/** @test */
public function mailShouldContainsVousAvezFaitUneDemande() {
$this->assertContains('Vous avez fait une demande',
$this->_mail->getBodyText(true));
}
/** @test */
public function pageShouldContainsUnLienVientDeVousEtreEnvoye() {
$this->assertXPathContentContains('//p',
'Un mail vient de vous être envoyé contenant un lien de réinitialisation du mot de passe');
}
}
class AuthControllerLostPasswordUnknownPostTest extends AuthControllerLostPasswordTestCase {
/** @test */
public function withUnknowUserShouldDisplayError() {
......@@ -168,6 +211,19 @@ class AuthControllerLostPasswordUnknownPostTest extends AuthControllerLostPasswo
'Une valeur est requise',
$this->_response->getBody());
}
/** @test */
public function withUserNonValidShouldDisplayErrorAccountNotActivated() {
$this->fixture('Class_UsersNonValid',
['id' => 1,
'login' => 'toutnouveau',
'password' => 'secret']);
$this->postDispatch('/opac/auth/lostpass', ['lost_username' => 'toutnouveau']);
$this->assertXPathContentContains('//ul[@class="errors"]//li',
'Votre compte n\'a pas encore été activé',
$this->_response->getBody());
}
}
......
......@@ -967,6 +967,46 @@ class CmsControllerArticleWithBibRewriteUrlViewTest extends CmsControllerWithFet
class CmsControllerArticleWithoutEventDatesTest extends CmsControllerWithFeteDeLaFriteTestCase {
public function setUp() {
parent::setUp();
Class_Article::find(224)->setDateDebut('2020-01-10')
->setDateFin('')
->setEventsDebut('')
->setEventsFin('')
->assertSave();
$this->dispatch('/cms/articleview/id/224', true);
}
/** @test */
public function pageShouldNotContainDTEventStartDate() {
$this->assertNotXPath('//dt[@class="event_start_date"]');
}
/** @test */
public function pageShouldNotContainDTEventEndDate() {
$this->assertNotXPath('//dt[@class="event_end_date"]');
}
/** @test */
public function pageShouldNotContainDTEventStartHour() {
$this->assertNotXPath('//dt[@class="event_start_hour"]');
}
/** @test */
public function pageShouldNotContainDTEventEndHour() {
$this->assertNotXPath('//dt[@class="event_end_hour"]');
}
}
class CmsControllerArticleViewTest extends CmsControllerWithFeteDeLaFriteTestCase {
protected function _loginHook($account) {
$account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB;
......
......@@ -497,18 +497,18 @@ class RechercheControllerReservationWithWebServiceKohaTest
/** @test */
public function withMatchingHoldAndRecordMessageShouldContainsPickupLocationAndRecordTitleAuthor() {
public function withMatchingHoldAndRecordWithBRInTitleMessageShouldContainsPickupLocationAndRecordTitleAuthor() {
$exemplaire = $this->fixture('Class_Exemplaire',
['id' => 456,
'code_barres' => 123,
'id_int_bib' => 1,
'notice' => $this->fixture('Class_Notice',
['id' => 8890,
'titre_principal' => 'Arcadia',
'titre_principal' => 'Albator <br /> Arcadia',
'auteur_principal' => 'Matsumoto'])]);
$this->_dispatchWithEmprunteurAndAssertContentEquals(
$this->_prepareEmprunteurHolding($exemplaire, 'Valensole'),
'Votre réservation est enregistrée.<br>Nous vous informerons quand le document \'Arcadia / Matsumoto\' sera disponible pour être retiré à : Valensole');
'Votre réservation est enregistrée.<br>Nous vous informerons quand le document \'Albator Arcadia / Matsumoto\' sera disponible pour être retiré à : Valensole');
}
......
......@@ -459,7 +459,7 @@ abstract class Scenario_AbonneMultiCardsAccountOfEwokTestCase extends Scenario_A
->getExemplaire()->setTitre('Alice');
$arcadia = (new Class_WebService_SIGB_Reservation('78',
(new Class_WebService_SIGB_Exemplaire(44))->setTitre('Arcadia')))
(new Class_WebService_SIGB_Exemplaire(44))->setTitre('Albator <br /> Arcadia')))
->setWaitingToBePulled();
$emprunteur = (new Class_WebService_SIGB_Emprunteur('2', 'luke'))
......@@ -703,10 +703,18 @@ class Scenario_AbonneMultiCardsAccountOfEwokCancelReservationsActionTest
public function shouldCallCancelArcadiaHoldOfLuke() {
$this->assertTrue($this->_comm->methodHasBeenCalledWithParams('supprimerReservation', [Class_Users::find(2), 78]));
}
/** @test */
public function popupShouldContainsMessageVotreReservationDuDocumentAlbatorArcadiaWithoutBrABienEteSupprime() {
$this->assertFlashMessengerContentContains('Votre réservation du document Albator Arcadia a bien été supprimée',
$this->_response->getBody());
}
}
class Scenario_AbonneMultiCardsLoginNotificationTest
extends Scenario_AbonneMultiCardsTestCase {
......
......@@ -4212,6 +4212,61 @@ class PnbDilicomAbonneHoldsTest extends PnbDilicomBibNumeriqueControllerTestCase
/** @see http://forge.afi-sa.fr/issues/108377 */
class PnbDilicomAbonneHoldsGuestTest extends PnbDilicomBibNumeriqueControllerTestCase {
public function setUp() {
parent::setUp();
$user = $this->fixture('Class_Users',
['id' => 88,
'login' => 'guest',
'password' => 'roxor',
'id_site' => 1,
'user_groups' => [Class_UserGroup::find(20)],
'role' => ZendAfi_Acl_AdminControllerRoles::INVITE,
]);
ZendAfi_Auth::getInstance()->logUser($user);
$timesource = new TimeSourceForTest('2022-06-10 10:23:10');
Class_Hold_Pnb::setTimeSource($timesource);
Class_AdminVar::set('DILICOM_PNB_ENABLE_HOLDS', 1);
$this->fixture('Class_Hold_Pnb',
['id' => 1,
'user_id' => 789,
'subscriber_id' => '',
'record_origin_id' => 'Dilicom-88817216',
'hold_date' => '2022-06-08 20:10:00']);
$this->fixture('Class_Hold_Pnb',
['id' => 2,
'user_id' => 88,
'subscriber_id' => '',
'record_origin_id' => 'Dilicom-88817216',
'hold_date' => '2022-06-07 20:10:00',
'expiration_date' => '2022-06-15 20:10:00']);
$this->dispatch('/abonne/reservations');
}
/** @test */
public function pageShouldContainsTableIdBorrowerHoldsPnb() {
$this->assertXPath('//table[@id="borrower_holds_pnb"]');
}
/** @test */
public function tableShouldContainsOneRow() {
$this->assertXPathCount('//table[@id="borrower_holds_pnb"]/tbody/tr', 1);
}
}
class PnbDilicomAbonneDeletePnbHoldTest extends PnbDilicomBibNumeriqueControllerTestCase {
public function setUp() {
parent::setUp();
......
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