diff --git a/.gitignore b/.gitignore index e659caa9a52c037da1fec331dfae84a2e328ebd0..87e1ddd7895e3a573e414a65458f0362ef1c4575 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,4 @@ userfiles/image/* userfiles/js/* userfiles/photoBib/* userfiles/photobib/* -userfiles/web_thumbnails/* \ No newline at end of file +userfiles/web_thumbnails/* diff --git a/application/modules/admin/controllers/AccueilController.php b/application/modules/admin/controllers/AccueilController.php index 09e3a9c5551627be0d30c149c3bcd07f88141428..65a6b0157804bb007069798ccbcfcdd6e3352222 100644 --- a/application/modules/admin/controllers/AccueilController.php +++ b/application/modules/admin/controllers/AccueilController.php @@ -141,6 +141,11 @@ class Admin_AccueilController extends Zend_Controller_Action { public function loginAction() { + $this->view->getHelper('ComboProfils') + ->setTagId('profil_redirect') + ->setTagName('profil_redirect') + ->addEmptyOption(); + $this->_simpleAction(); } diff --git a/application/modules/admin/views/scripts/modules/auth_form.phtml b/application/modules/admin/views/scripts/modules/auth_form.phtml index f61f52738e7bf9f7face6edee5739c7d14efc092..4b8f12f734ffab60176177fd84a3fda077958262 100644 --- a/application/modules/admin/views/scripts/modules/auth_form.phtml +++ b/application/modules/admin/views/scripts/modules/auth_form.phtml @@ -72,3 +72,10 @@ <td class="gauche"><input type="text" name="lien_creer_compte" size="50" value="<?php print($this->preferences["lien_creer_compte"]); ?>"></td> </tr> +<tr> + <td class="droite">Basculer automatiquement sur le profil: </td> + <td class="gauche"> + <?php echo $this->ComboProfils('ALL', 'ALL', $this->preferences['profil_redirect']); + ?> + </td> +</tr> diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index 392303edd3a6780ee590fafb0bcb49d2395076e9..2e01b25c91ba8fb4fa66383f19100c50960036c9 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -125,7 +125,6 @@ class AuthController extends ZendAfi_Controller_Action { function boiteLoginAction() { $this->view->preferences = Class_Profil::getCurrentProfil()->getModuleAccueilPreferencesByType('auth'); - $strategy = Auth_Strategy_Abstract::strategyForController($this); $strategy->setDefaultUrl($this->_request->getServer('HTTP_REFERER')); $strategy->processLogin(); diff --git a/application/modules/opac/views/scripts/auth/ajax-login.phtml b/application/modules/opac/views/scripts/auth/ajax-login.phtml index 4ffe141ddaa3c1a6ff25c2b50f9ff53f906afe07..1f4b42be82952448a62328fa8fb37b1256e58b94 100644 --- a/application/modules/opac/views/scripts/auth/ajax-login.phtml +++ b/application/modules/opac/views/scripts/auth/ajax-login.phtml @@ -22,7 +22,7 @@ function submit() { <?php if($user = Class_Users::getLoader()->getIdentity()) { echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff()); - echo sprintf('<a href="%s/abonne/fiche" target="_parent">» %s</a>', $this->url(['controller'=>'abonne','action'=>'fiche']), $this->_($this->preferences['lien_compte'])); + echo sprintf('<a href="%s/abonne/fiche" target="_parent">» %s</a>', $this->url(['controller'=>'abonne','action'=>'fiche'],null,true), $this->_($this->preferences['lien_compte'])); if ($user->hasIdabon()) echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations()); echo sprintf('<a href="%s" target="_parent">» %s</a>', $this->url(['controller'=>'auth','action'=>'logout']), $this->_($this->preferences['lien_deconnection'])); diff --git a/application/modules/opac/views/scripts/auth/boite-login.phtml b/application/modules/opac/views/scripts/auth/boite-login.phtml index 968a5642fc6996e5f4a4940265bce103befb2fe8..90872411e2b9afd1c9b64b0fcbc8756b764666bf 100644 --- a/application/modules/opac/views/scripts/auth/boite-login.phtml +++ b/application/modules/opac/views/scripts/auth/boite-login.phtml @@ -1,23 +1,26 @@ <div class="form"> -<?php -if($user = Class_Users::getLoader()->getIdentity()) { - echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff()); - echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'abonne', - 'action'=>'fiche']), $this->_($this->preferences['lien_compte'])); - if ($user->hasIdabon()) - echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations()); - echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'auth', - 'action'=>'logout']), $this->_($this->preferences['lien_deconnection'])); -} else { - $form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge( - $this->preferences, - ['redirect_url' => $this->redirect, - 'service' => $this->service, - 'id_notice' => $this->id_notice]), - 'action' => $this->url(['controller' => 'auth', - 'action' => 'boite-login', - 'id_module' => $this->id_module])]); - echo $this->renderForm($form); -} -?> -</div> \ No newline at end of file + <?php + if($user = Class_Users::getLoader()->getIdentity()) { + echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff()); + + echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'abonne', + 'action'=>'fiche', + 'id_profil'=>$this->preferences['profil_redirect'] > 0 ? $this->preferences['profil_redirect'] : Class_Profil::getCurrentProfil()->getId()],null,true), $this->_($this->preferences['lien_compte'])); + if ($user->hasIdabon()) + echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations()); + echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'auth', + 'action'=>'logout', + 'id_profil'=>$this->preferences['profil_redirect'] > 0 ? $this->preferences['profil_redirect'] : Class_Profil::getCurrentProfil()->getId()],null,true), $this->_($this->preferences['lien_deconnection'])); + } else { + $form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge( + $this->preferences, + ['redirect_url' => $this->redirect, + 'service' => $this->service, + 'id_notice' => $this->id_notice]), + 'action' => $this->url(['controller' => 'auth', + 'action' => 'boite-login', + 'id_module' => $this->id_module])]); + echo $this->renderForm($form); + } + ?> +</div> diff --git a/library/Class/Notice.php b/library/Class/Notice.php index bdf581859440a0897ef137b109c727c4b8d71e87..5f4ce5342e67012bc19ae2e1804ffe2e709b0a3b 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1780,7 +1780,6 @@ class Class_Notice extends Storm_Model_Abstract { public function getPaniersLibelles() { - xdebug_break(); $list_panier = $this->getPaniers(); if(($nb_paniers = count($list_panier)) < 1) return ''; diff --git a/library/Class/Systeme/ModulesAccueil/Login.php b/library/Class/Systeme/ModulesAccueil/Login.php index 80126d766bd778563e32e398c3698e25a8f8b140..5a91f2973f49eae71f7c60a14d608499f9ba3603 100644 --- a/library/Class/Systeme/ModulesAccueil/Login.php +++ b/library/Class/Systeme/ModulesAccueil/Login.php @@ -54,7 +54,8 @@ class Class_Systeme_ModulesAccueil_Login extends Class_Systeme_ModulesAccueil_Nu 'message_connecte' => 'Bienvenue', 'lien_compte' => '» Mon compte', 'lien_deconnection' => '» Se déconnecter', - 'autocomplete_off' => 1 // si == 1, rajoute autocomplete="off" au formulaire + 'autocomplete_off' => 1 ,// si == 1, rajoute autocomplete="off" au formulaire + 'profil_redirect' => '0' ]; } ?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index 9f05a8053b1f2a133c7bfc7296a8964d832ae2bf..2a3b9dc2cd8da8c253e21afa2be59ef05069492d 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -204,7 +204,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form { } public function addAffichageFor($album) { - xdebug_break(); return $this ->addElement('cochesSuggestion', 'bibliotheques', ['label' => 'Bibliotheques', diff --git a/library/ZendAfi/Form/Decorator/CochesSuggestion.php b/library/ZendAfi/Form/Decorator/CochesSuggestion.php index c84dde73fd0e0b44b1dcbb933f1d886ed97e18f2..ca6a7693ed606621c6e9e7448ffc5f63851de75a 100644 --- a/library/ZendAfi/Form/Decorator/CochesSuggestion.php +++ b/library/ZendAfi/Form/Decorator/CochesSuggestion.php @@ -25,7 +25,6 @@ class ZendAfi_Form_Decorator_CochesSuggestion extends Zend_Form_Decorator_Abstra */ public function render($content) { $helper = $this->_element->getView()->getHelper('tagListeCoches'); - xdebug_break(); $helper->setSelectedAllMeansNothing($this->_element->getSelectedAllMeansNothing()); return $content .$this->_element->getView()->tagListeCoches( diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index 8626d6bcbd5f0357a594a7345167c7488bc1ed4c..c400ef6ec62222f9ffe279ef6d6df0f029b9cbb7 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -472,15 +472,22 @@ class AccueilControllerConfigBoiteLoginTest extends Admin_AbstractControllerTest public function setUp() { parent::setUp(); Class_Profil::getCurrentProfil() - ->updateModuleConfigAccueil(25, - array('type_module' => 'LOGIN', - 'division' => 4, - 'id_module' => 32, - 'preferences' => array())); + ->updateModuleConfigAccueil(32, + ['type_module' => 'LOGIN', + 'division' => 4, + 'id_module' => 32, + 'preferences' => ['profil_redirect'=>'1', + 'mot_de_pass_exemple' => 'dd/mm/aaaa']]); $this->dispatch('/admin/accueil/login?config=accueil&type_module=LOGIN&id_module=32', true); } + /** @test */ + public function selectProfilRedirectShouldContainsProfil1() { + $this->assertXPathContentContains('//select[@id="profil_redirect"][@name="profil_redirect"]/optgroup/option[@value="1"][@selected="selected"]', 'portail: Accueil', $this->_response->getBody()); + } + + /** @test */ public function inputTitreShouldBeSeConnecter() { $this->assertXPath('//input[@name="titre"][@value="Se connecter"]'); @@ -533,6 +540,18 @@ class AccueilControllerConfigBoiteLoginTest extends Admin_AbstractControllerTest public function profilShouldBeValid() { $this->assertTrue(Class_Profil::getCurrentProfil()->isValid()); } + + + /** @test **/ + public function configShouldContainsSelectProfil() { + $this->assertXPath('//td/select[@name="profil_redirect"][@id="profil_redirect"]'); + } + + + /** @test **/ + public function selectProfilShloudBeEmptyValue() { + $this->assertXPath('//td/select[@id="profil_redirect"]/option'); + } } diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index cb40bc44f8efb3570086b7c15b0e0d6c7278b096..9ef2957ade1f792d51b46bdb7044af25c9674a75 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -38,7 +38,8 @@ abstract class PortailWithOneLoginModuleTestCase extends AbstractControllerTestC 'mot_de_passe_exemple' => '1983', 'titre_connecte' => 'Vous êtes connecté(e)', 'lien_connexion' => 'please, log me', - 'lien_mot_de_passe_oublie' => 'me rappelle plus']]], + 'lien_mot_de_passe_oublie' => 'me rappelle plus', + 'profil_redirect' => 1]]], 'options' => []]; Class_Profil::getCurrentProfil() @@ -113,6 +114,13 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa } + + /** @test */ + public function redirectProfilShouldBeProfil1(){ + $this->assertXPath('//a[contains(@href,"abonne/fiche/id_profil/1")]',$this->_response->getBody()); + } + + /** @test */ public function linkPretsShouldBePresent() { $this->assertXPathContentContains('//div[@id="boite_login"]//a[contains(@href, "prets")]', '3'); @@ -228,6 +236,7 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedBoiteLoginTest extends Aut $this->assertXPathContentContains('//h1','Se connecter'); } + public function testLinkSeConnecter() { $this->assertXPath('//div[@id="boite_login"]//a[contains(@onclick,"submit")]'); $this->assertXPathContentContains('//div[@id="boite_login"]//a[contains(@onclick, "submit")]', @@ -954,4 +963,71 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedRegisterTest extends AuthC } } + + +class portailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_IntBib') + ->whenCalled('findAllBy') + ->answers([]); + + $cfg_accueil = ['modules' => [4 => ['division' => '4', + 'id_module' => 4, + 'type_module' => 'LOGIN', + 'preferences' => [ + 'identifiant' => 'Numéro de carte', + 'mot_de_passe'=> 'Année de naissance', + 'identifiant_exemple' => 'jj-mm-aaaa', + 'mot_de_passe_exemple' => '1983', + 'titre_connecte' => 'Vous êtes connecté(e)', + 'lien_connexion' => 'please, log me', + 'lien_mot_de_passe_oublie' => 'me rappelle plus', + 'profil_redirect' => 0]]], + 'options' => []]; + + Class_Profil::getCurrentProfil() + ->setBrowser('opac') + ->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil)); + + + ZendAfi_Auth::getInstance()->logUser( + Class_Users::newInstanceWithId(5, + ['login' => 'Pioup', + 'idabon' => 48, + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 1, + 'fiche_sigb' => []])); + + + + $this->dispatch('/opac/'); + } + + + /** @test */ + public function redirectProfilForLoginShouldBeProfil2(){ + $this->assertXPath('//a[contains(@href,"abonne/fiche/id_profil/2")]',$this->_response->getBody()); + } + + + /** @test */ + public function redirectProfilForLoginShouldNotBeProfil0(){ + $this->assertNotXPath('//a[contains(@href,"abonne/fiche/id_profil/0")]',$this->_response->getBody()); + } + + + /** @test */ + public function redirectProfilForLogoutShouldNotBeProfil2(){ + $this->assertXPath('//a[contains(@href,"auth/logout/id_profil/2")]',$this->_response->getBody()); + } + + + /** @test */ + public function redirectProfilForLogoutShouldNotBeProfil0(){ + $this->assertNotXPath('//a[contains(@href,"abonne/logout/id_profil/0")]',$this->_response->getBody()); + } + +} ?> \ No newline at end of file diff --git a/tests/library/Class/Systeme/ModulesMenuTest.php b/tests/library/Class/Systeme/ModulesMenuTest.php index b2820bb952111c308e1d72799c00fdb3f19f48ec..aa8e97c239026bd6eab4eb9f78f2ceb8aaeef09b 100644 --- a/tests/library/Class/Systeme/ModulesMenuTest.php +++ b/tests/library/Class/Systeme/ModulesMenuTest.php @@ -168,7 +168,6 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase { public function vodeclicUrlWithAbonnementInvalidShouldBeJSAlertAbonnementInvalid() { $this->_logUserGaston(); $vodeclic= new Class_Systeme_ModulesMenu_Vodeclic(); - xdebug_break(); $url = $vodeclic->getDynamiqueUrl(); $this->assertContains('Votre abonnement est terminé', $vodeclic->getMessage());