diff --git a/VERSIONS_HOTLINE/96803 b/VERSIONS_HOTLINE/96803 new file mode 100644 index 0000000000000000000000000000000000000000..1cec179815d01641dae1c263e4937952a5afc381 --- /dev/null +++ b/VERSIONS_HOTLINE/96803 @@ -0,0 +1 @@ + - ticket #96803 : Indexation des articles : ajout du résumé en 330$a, de l'auteur en 701 et de l'année de création en 210$d \ No newline at end of file diff --git a/VERSIONS_HOTLINE/99071 b/VERSIONS_HOTLINE/99071 new file mode 100644 index 0000000000000000000000000000000000000000..60525c546d910031021720772832b4e5bdbf1c89 --- /dev/null +++ b/VERSIONS_HOTLINE/99071 @@ -0,0 +1 @@ + - ticket #99071 : Inscription à une activité : message de confirmation envoyé 20 fois \ No newline at end of file diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index a7d1b4553e5d6bd0474855b15a120f18dc00d5ef..cb7d487fa4255ada263d47832f5fcf1b41eab1fe 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -85,12 +85,21 @@ class AbonneController extends ZendAfi_Controller_Action { public function inscrireSessionAction() { - $this->_redirectToReferer(); + $redirect = $this->_getParam('redirect_url', $this->_getReferer()); + + if (strpos($redirect, 'inscrire-session') !== false) + $redirect = Class_Url::absolute(['controller' => 'abonne', + 'action' => 'activities'], null, true); + + $this->_redirectToUrlOrReferer($redirect); if ((!$session = Class_SessionActivity::find((int)$this->_getParam('id'))) || $session->isInscriptionClosed()) return $this->_helper->notify($this->_('L\'inscription à cette session est fermée')); + if ($session->hasStagiaire($this->_user)) + return $this->_helper->notify($this->_('Vous êtes déjà inscrit à cette session')); + $session->addStagiaire($this->_user); if (!$session->save()) return $this->_helper->notify(implode('<br/>', $session->getErrors())); diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index 6597d0c830c4665349a5dab49116eef2fdca4165..ddb1be1653f1e153675c7450f11560b162481646 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -127,6 +127,7 @@ class Class_Indexation_PseudoNotice { 'date_maj' =>'', 'isbn' => '', 'domaine_ids' => '', + 'resume' => '', 'created_at' => null], array_change_key_case($this->_datas)); } @@ -356,6 +357,7 @@ class Class_Indexation_PseudoNotice { ->visitUrl($this->_datas['url']) ->visitNotes($this->_datas['notes']) ->visitNatures($this->_datas['nature_doc']) + ->visitResume($this->_datas['resume']) ->visitCustomFieldsValues($this->getCustomFieldsValues()); $this->_modelIdAcceptVisitor($visitor); @@ -597,7 +599,13 @@ class Class_Indexation_PseudoNotice_Cms extends Class_Indexation_PseudoNotice{ protected function _prepareDatas() { parent::_prepareDatas(); + $this->_datas['resume'] = strip_tags($this->_datas['description']); $this->_datas['description'] = strip_tags($this->_datas['contenu']); + $this->_datas['auteur'] = $this->_model->hasAuteur() + ? $this->_model->getAuteur()->getNomComplet() + : ''; + + $this->_datas['annee'] = date('Y', strtotime($this->_model->getDateCreation())); } } diff --git a/library/Class/SessionActivity.php b/library/Class/SessionActivity.php index f2d460ad6ea02e21241151e14566f11a45b13b90..b1a6b206f2f601542c0129704bbde913a3234c7b 100644 --- a/library/Class/SessionActivity.php +++ b/library/Class/SessionActivity.php @@ -312,6 +312,13 @@ class Class_SessionActivity extends Storm_Model_Abstract { } + public function hasStagiaire($user) { + return null !== (new Storm_Model_Collection($this->getStagiaires())) + ->detect(function ($stagiaire) use ($user) + { return $stagiaire->getId() == $user->getId();}); + } + + public function toArray() { $intervenant_ids = []; foreach($this->getIntervenants() as $intervenant) diff --git a/library/ZendAfi/Controller/Plugin/AdminAuth.php b/library/ZendAfi/Controller/Plugin/AdminAuth.php index 7bd9242d2b366fa6a33e1a6c00f65fe8b097b193..dd63656e84ae20d4e2335d35d89c09c68d1576a8 100644 --- a/library/ZendAfi/Controller/Plugin/AdminAuth.php +++ b/library/ZendAfi/Controller/Plugin/AdminAuth.php @@ -64,7 +64,7 @@ class ZendAfi_Controller_Plugin_AdminAuth extends Zend_Controller_Plugin_Abstrac if ((!$user = Class_Users::getIdentity()) && $action !== "authenticate" && in_array($controller, ["abonne", 'bookmarked-searches'])) { - $request->setParam('redirect', Class_Url::absolute()); + $request->setParam('redirect', $this->_getRedirect($request, $action)); $controller = 'auth'; $action = ($request->getParam('render') == 'popup') ? 'popup-login' : 'login'; } @@ -76,6 +76,18 @@ class ZendAfi_Controller_Plugin_AdminAuth extends Zend_Controller_Plugin_Abstrac } + protected function _getRedirect($request, $action) { + $redirect = Class_Url::absolute(); + if ($action != 'inscrire-session') + return $redirect; + + if (! $referer = $request->getServer('HTTP_REFERER')) + return $redirect; + + return $redirect.'?redirect_url='.urlencode($referer); + } + + protected function _handleAdmin($request) { Zend_Controller_Front::getInstance() ->getPlugin('Zend_Controller_Plugin_ErrorHandler') diff --git a/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php b/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php index 32ac1fb1c79c1572f2602c14fe3ee775429419fa..bb86afda9033032bad7c56195dbb64cb7c00ec65 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php @@ -896,6 +896,50 @@ class AbonneControllerActivitiesInscritSessionWithoutRightSuivreActivityTest ext +class AbonneControllerActivitiesInscriptionNotLoggedTest extends AbstractAbonneControllerActivitiesTestCase { + public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->clearIdentity(); + $_SERVER['HTTP_REFERER'] = '/myurl'; + $session = Class_SessionActivity::find(31); + $this->dispatch('/opac/abonne/inscrire-session/id/31'); + } + + + /** @test */ + public function redirectHiddenInputShouldReturnRedirectUrl() { + $this->assertXPath('//input[contains(@value,"/abonne/inscrire-session/id/31?redirect_url=%2Fmyurl")]',$this->_response->getBody()); + } +} + + + + +class AbonneControllerActivitiesInscriptionRedirectionTest extends AbstractAbonneControllerActivitiesTestCase { + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_REFERER'] = '/inscrire-session/id/31'; + $session = Class_SessionActivity::find(31); + $session->addStagiaire(Class_Users::find(435))->save(); + $this->dispatch('/opac/abonne/inscrire-session/id/31'); + } + + + /** @test */ + public function redirectOnAbonnePagesIfNoRedirectUrl() { + $this->assertRedirectTo(Class_Url::absolute('/abonne/activities')); + } + + + /** @test */ + public function flashMessageShouldBeYouHaveAlreadySubscribed() { + $this->assertFlashMessengerContentContains('Vous êtes déjà inscrit à cette session'); + } + +} + + + class AbonneControllerActivitiesAmadouDesinscritSessionJuilletPythonTest extends AbstractAbonneControllerActivitiesTestCase { diff --git a/tests/library/Class/Indexation/PseudoNoticeTest.php b/tests/library/Class/Indexation/PseudoNoticeTest.php index 227f65052bca883ebe18fdc219decf2e42696a2e..90112ae9396128f5adbf9a61e9b7ec9f7e215c73 100644 --- a/tests/library/Class/Indexation/PseudoNoticeTest.php +++ b/tests/library/Class/Indexation/PseudoNoticeTest.php @@ -355,10 +355,17 @@ class Class_Indexation_PseudoNoticeArticleTest public function setUp() { parent::setUp(); + $author = $this->fixture('Class_Users', + ['id' => 3, + 'login' => 'gm', + 'nom' => 'Musso', + 'prenom' => 'Guillaume', + 'password' => 'secret']); + $this->fixture('Class_NoticeDomain', ['id' => 189, 'domain_id' => 17, - 'record_alpha_key' => 'MYARTCILE-1-----8']); + 'record_alpha_key' => 'MYARTICLE-1-GUILLAUMEMUSSO----8']); $this->fixture('Class_Catalogue', ['id' => 17, @@ -366,13 +373,17 @@ class Class_Indexation_PseudoNoticeArticleTest $this->fixture('Class_Article', ['id' => 1, - 'titre' => 'My Artcile', + 'titre' => 'My Article', 'contenu' => 'article is about...', + 'description' => 'This is a test', + 'date_creation' => '2018-02-17 10:22:34', + 'auteur' => $author, 'domaine_ids' => '17']); $this->fixture('Class_Article', ['id' => 5, - 'titre' => 'My Artcile bis', + 'titre' => 'My Article bis', + 'auteur' => $author, 'contenu' => 'article is about bis...']); Class_Article::indexAll(); @@ -383,9 +394,42 @@ class Class_Indexation_PseudoNoticeArticleTest public function noticeDomainShouldContainsOnlyOneEnreg() { $this->assertCount(1, Class_NoticeDomain::findAll()); } + + + /** @test */ + public function firstRecordTitleShouldBeMyArticle() { + $this->assertEquals('My Article', Class_Notice::find(1)->getTitrePrincipal()); + } + + + /** @test */ + public function firstRecordSummaryShouldBeThisIsATest() { + $this->assertEquals('This is a test', Class_Notice::find(1)->getResume()); + } + + + /** @test */ + public function secondRecordSummaryShouldBeEmpty() { + $this->assertEmpty(Class_Notice::find(2)->getResume()); + } + + + /** @test */ + public function firstRecordMainAuthorShouldBeMusso() { + $this->assertEquals('Guillaume Musso', Class_Notice::find(1)->getAuteurPrincipal()); + } + + + /** @test */ + public function firstRecord210DShouldContainsCreationYear2018() { + $this->assertEquals(['2018'], + Class_Notice::find(1)->get_subfield('210', 'd')); + } } + + /** @see http://forge.afi-sa.fr/issues/72723 */ class Class_Indexation_PseudoNoticeArticleWithUnknownDomainTest extends Class_Indexation_PseudoNoticeTestCase { @@ -462,6 +506,8 @@ class Class_Indexation_PseudoNoticeArticleUpdateTest } + + /** @see http://forge.afi-sa.fr/issues/69916 */ class Class_Indexation_PseudoNoticeArticleLongContentTest extends Class_Indexation_PseudoNoticeTestCase {