diff --git a/VERSIONS_HOTLINE/123670 b/VERSIONS_HOTLINE/123670 new file mode 100644 index 0000000000000000000000000000000000000000..6a04a96fe0f45be9391dd8ac713b53dc8f26ae3b --- /dev/null +++ b/VERSIONS_HOTLINE/123670 @@ -0,0 +1 @@ + - ticket #123670 : Magasin de thèmes : amélioration de la boite de connexion dans le thème Chili. Il est maintenant possible d'utiliser un menu dans la boite login en mode formulaire à bascule pour gérer les liens qui seront affichés en mode déconnecté. \ No newline at end of file diff --git a/library/Class/Profil/Promoter.php b/library/Class/Profil/Promoter.php index d98121f3fbaa0f05e0c8fa33eefcfe773901c256..48dfd4431de529d4b60d5892b2c7cfce25d1bb97 100644 --- a/library/Class/Profil/Promoter.php +++ b/library/Class/Profil/Promoter.php @@ -97,7 +97,7 @@ class Class_Profil_Promoter { if ( is_array($value)) $new_cfg = $this->_upgradeCfg($new_cfg, $key, $value, $old_id); - if (in_array($key, ['menu', 'use_profil', 'authenticated_menu'])) + if (in_array($key, ['menu', 'use_profil', 'authenticated_menu', 'not_authenticated_menu'])) $new_cfg [$key] = str_replace($old_id, Class_Profil::DEFAULT_PROFIL, $value); } diff --git a/library/Class/Systeme/ModulesMenu.php b/library/Class/Systeme/ModulesMenu.php index 127846901b3c723477f0a659e28081fd8611d920..3f5422607b288676976c3efa6e9678cde21b2632 100644 --- a/library/Class/Systeme/ModulesMenu.php +++ b/library/Class/Systeme/ModulesMenu.php @@ -56,6 +56,7 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract { 'PANIER' => Class_Systeme_ModulesMenu_Paniers::class, 'REGISTER' => Class_Systeme_ModulesMenu_Register::class, 'PREREGISTRATION' => Class_Systeme_ModulesMenu_PreRegistration::class, + 'LOST_PASSWORD' => Class_Systeme_ModulesMenu_LostPassword::class, 'ABON_AVIS' => Class_Systeme_ModulesMenu_AbonneAvis::class, 'ABON_FICHE' => Class_Systeme_ModulesMenu_AbonneFiche::class, 'ABON_MODIF_FICHE' => Class_Systeme_ModulesMenu_AbonneModificationFiche::class, diff --git a/library/Class/Systeme/ModulesMenu/LostPassword.php b/library/Class/Systeme/ModulesMenu/LostPassword.php new file mode 100644 index 0000000000000000000000000000000000000000..1aa143624f99045e859b3edc99e66809f64d66a4 --- /dev/null +++ b/library/Class/Systeme/ModulesMenu/LostPassword.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright (c) 2012-2020, 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 Class_Systeme_ModulesMenu_LostPassword extends Class_Systeme_ModulesMenu_Null { + + protected + $_group = Class_Systeme_ModulesMenu::GROUP_MENU_NAVIGATION, + $_type_module = 'LOST_PASSWORD', + $_isPhone = false, + $_url = ['controller' => 'auth', + 'action' => 'lostpass']; + + + public function __construct() { + $this->_libelle = $this->_('Lien vers la page de réinitialisation du mot de passe.'); + } +} \ No newline at end of file diff --git a/library/templates/Chili/Library/FormCustomizer/Login.php b/library/templates/Chili/Library/FormCustomizer/Login.php index 96e67548b950c2b2a140813209e3cdb4710fc4fd..1b9481565e015187b99823328358f5446e9ee904 100644 --- a/library/templates/Chili/Library/FormCustomizer/Login.php +++ b/library/templates/Chili/Library/FormCustomizer/Login.php @@ -24,16 +24,24 @@ class Chili_Library_FormCustomizer_Login extends Intonation_Library_FormCustomiz public function getForm() { Class_ScriptLoader::getInstance() - ->addJQueryReady('radioToggleVisibilityForElement("input[name=\'' . Class_Template::current()->withNameSpace('form_style') . '\']", $("#authenticated_menu").closest("tr"), ["toggle"]);'); + ->addJQueryReady('radioToggleVisibilityForElement("input[name=\'' . Class_Template::current()->withNameSpace('form_style') . '\']", $("#authenticated_menu, #not_authenticated_menu").closest("tr"), ["toggle"]);'); + + $menus = (new Class_Systeme_ModulesAccueil_MenuVertical())->getMenus(); $this->_form ->addElement('select', 'authenticated_menu', ['label' => $this->_('Menu à afficher en étant connecté'), 'registerInArrayValidator' => false, - 'multiOptions' => (new Class_Systeme_ModulesAccueil_MenuVertical())->getMenus()]) + 'multiOptions' => $menus]) + + ->addElement('select', + 'not_authenticated_menu', + ['label' => $this->_('Menu à afficher en mode déconnecté'), + 'registerInArrayValidator' => false, + 'multiOptions' => $menus]) - ->addToDisplayGroup(['authenticated_menu'], + ->addToDisplayGroup(['authenticated_menu', 'not_authenticated_menu'], Class_Template::current()->withNameSpace('group')); return $this; diff --git a/library/templates/Chili/Library/ProfilePatcher.php b/library/templates/Chili/Library/ProfilePatcher.php index c9ca8e5f69ddd695eab04d9eee98f3e3383b00e7..aa9d259910ad72aaadc03209f09c7e476ff61cfa 100644 --- a/library/templates/Chili/Library/ProfilePatcher.php +++ b/library/templates/Chili/Library/ProfilePatcher.php @@ -25,9 +25,10 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { protected $_main_menu, $_search_menu, - $_login_menu, $_network_menu, - $_legal_mentions_menu; + $_legal_mentions_menu, + $_login_menu, + $_not_logged_menu; protected function _upgradeProfile() { @@ -38,6 +39,7 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { ->setLibelle($this->_('Accueil Chili')); Class_AdminVar::set('MENU_BOITE', 1); + Class_AdminVar::set('ENABLE_IDENTITY_PROVIDERS', 1); return $this; } @@ -173,7 +175,7 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { ]]); $this->_login_menu = $this->_profile - ->addMenu(['libelle' => $this->_('Boite de connexion'), + ->addMenu(['libelle' => $this->_('Boite de connexion : menu connecté'), 'picto' => '', 'menus' => [ ['type_menu' => 'ABON_FICHE', @@ -207,6 +209,30 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { 'url' => ''], ]]); + $this->_not_logged_menu = $this->_profile + ->addMenu(['libelle' => $this->_('Boite de connexion : menu déconnecté'), + 'picto' => '', + 'menus' => [ + ['type_menu' => 'LOST_PASSWORD', + 'libelle' => $this->_('Mot de passe oublié ?')], + + ['type_menu' => 'PREREGISTRATION', + 'libelle' => $this->_('Je n\'ai pas encore de compte !')], + + ['type_menu' => 'FORM_CONTACT', + 'libelle' => $this->_('Un problème ? Contactez-nous !')], + + ['type_menu' => 'MODULE_ACCUEIL_IDENTITY_PROVIDER', + 'type_module' => 'MODULE_ACCUEIL_IDENTITY_PROVIDER', + 'libelle' => $this->_('Connecteurs tiers'), + 'preferences' => ['titre' => $this->_('Connecteurs tierces'), + 'boite' => ['no_border', 'no_border_radius', 'no_shadow', 'm-auto', 'no_overflow', 'p-0'], + $this->_template->withNameSpace('width_xsmall') => 12, + $this->_template->withNameSpace('show_header') => 0, + $this->_template->withNameSpace('show_content') => 0, + $this->_template->withNameSpace('show_footer') => 0]], + ]]); + $this->_network_menu = $this->_profile ->addMenu(['libelle' => $this->_('Le réseau'), 'picto' => '', @@ -317,11 +343,12 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { 'mot_de_passe_exemple' => $this->_('Mot de passe *'), 'lien_connexion' => $this->_('Se connecter'), 'lien_deconnection' => $this->_('Se déconnecter'), - 'lien_mot_de_passe_oublie' => $this->_('Mot de passe oublié ?'), + 'lien_mot_de_passe_oublie' => '', 'lien_compte' => $this->_('SE CONNECTER'), 'lien_creer_compte' => '', - 'pre_registration' => $this->_('Je n\'ai pas encore de compte'), + 'pre_registration' => '', 'authenticated_menu' => $this->_profile_id . '-' . $this->_login_menu, + 'not_authenticated_menu' => $this->_profile_id . '-' . $this->_not_logged_menu, $this->_template->withNameSpace('form_style') => 'toggle', $this->_template->withNameSpace('width_xsmall') => 2, $this->_template->withNameSpace('show_header') => 0, diff --git a/library/templates/Chili/Library/Widget/Login/View.php b/library/templates/Chili/Library/Widget/Login/View.php index d175e7a4040166ccd9de4d164b0752be68985eaf..d1101c0dd36bf5d23798718feaa7c654ac400052 100644 --- a/library/templates/Chili/Library/Widget/Login/View.php +++ b/library/templates/Chili/Library/Widget/Login/View.php @@ -33,6 +33,20 @@ class Chili_Library_Widget_Login_View extends Intonation_Library_Widget_Login_Vi class ChililLoginRenderToggle extends IntonationLoginRenderToggle { + + protected function _parentRenderLogin() { + $form_html = parent::_parentRenderLogin(); + + $id_menu = $this->_settings->getNotAuthenticatedMenu(); + $helper = new Intonation_Library_Widget_Menu_View(1, ['type_module' => 'MENU', + 'preferences' => ['menu' => $id_menu]]); + $helper->setView($this->_view); + $menu_html = $helper->getContent(); + + return $form_html . $menu_html; + } + + public function renderLogged() { $id_menu = $this->_settings->getAuthenticatedMenu(); diff --git a/library/templates/Intonation/Library/Widget/Login/View.php b/library/templates/Intonation/Library/Widget/Login/View.php index 1990a6d06d1b9deeceee8875a58eff21180fcae2..52217f1cb85206907f4d492b2e7a521c2b6efb49 100644 --- a/library/templates/Intonation/Library/Widget/Login/View.php +++ b/library/templates/Intonation/Library/Widget/Login/View.php @@ -302,7 +302,12 @@ class IntonationLoginRenderInline extends IntonationLoginRenderAbstract { class IntonationLoginRenderToggle extends IntonationLoginRenderAbstract { public function renderLogin() { - return $this->_view->renderDropdown(parent::renderLogin(), $this->_settings->getTitre(), '', 'dropdown-menu-right'); + return $this->_view->renderDropdown($this->_parentRenderLogin(), $this->_settings->getTitre(), '', 'dropdown-menu-right'); + } + + + protected function _parentRenderLogin() { + return parent::renderLogin(); } diff --git a/tests/scenarios/Templates/ChiliLoginTest.php b/tests/scenarios/Templates/ChiliLoginTest.php index 538f4056d54b2bf05f0b96064567a4139e85c348..434a182d9fd79ab3ac3ae699504274e6edb78408 100644 --- a/tests/scenarios/Templates/ChiliLoginTest.php +++ b/tests/scenarios/Templates/ChiliLoginTest.php @@ -78,6 +78,13 @@ class ChiliLoginWidgetAdminFormsTest extends ChiliLoginWidgetTestCase { } + /** @test */ + public function pageShouldContainsFormWithNotAuthenticatedMenuSelectorWithHomeSubmenu() { + $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/4'); + $this->assertXPath('//form//select[@name="not_authenticated_menu"]//option[@label="Authenticated menu"]'); + } + + /** @test */ public function editMenuMyLoansWithIdTwoShouldContainsCheckboxDisplayCounter() { $this->dispatch('/admin/widget/edit-menu/id/2/id_profil/4/parent/0'); diff --git a/tests/scenarios/Templates/ChiliTest.php b/tests/scenarios/Templates/ChiliTest.php index 7f0ec000eac55888b210c313f29cbc7168a8fc82..3fee5e11fc78b572e67bcaf51781172544d6be43 100644 --- a/tests/scenarios/Templates/ChiliTest.php +++ b/tests/scenarios/Templates/ChiliTest.php @@ -729,4 +729,43 @@ class ChiliViewNoticeTest extends AbstractControllerTestCase { $this->assertXPath('//div[@class="carousel-inner"]//p[@class="model_description_Class_Notice"]', $this->_response->getBody()); } +} + + + + +class ChiliTemplateOpacIndexWithNoLogedUserTest extends ChiliTemplateTestCase { + public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->clearIdentity(); + + $this->fixture('Class_IdentityProvider', + ['id' => 1, + 'label' => 'France connect', + 'type' => 'franceconnect', + 'config' => json_encode(['url' => 'http://afi.fr', + 'client_id' => '1234', + 'client_secret' => '9999']) + ]); + + $this->dispatch('/opac/index/index'); + } + + + /** @test */ + public function loginWidgetShouldContainsNotAuthenticatedMenuWithFranceConnect() { + $this->assertXPath('//div[contains(@class, "boite login")]//button[contains(@data-url, "identity-providers/authenticate/id/1")]'); + } + + + /** @test */ + public function loginWidgetShouldContainsNotAuthenticatedMenuWithPreRegisterLink() { + $this->assertXPath('//div[contains(@class, "boite login")]//a[contains(@class, "nav-link")][contains(@href, "/auth/pre-registration")]'); + } + + + /** @test */ + public function loginWidgetShouldContainsNotAuthenticatedMenuWithLostPassLink() { + $this->assertXPath('//div[contains(@class, "boite login")]//a[contains(@class, "nav-link")][contains(@href, "/auth/lostpass")]'); + } } \ No newline at end of file