From f54d54a76e255a23884e2053aa991ef4e05c2b42 Mon Sep 17 00:00:00 2001
From: Laurent Laffont <llaffont@afi-sa.fr>
Date: Tue, 24 Aug 2021 10:50:19 +0200
Subject: [PATCH] hotline #133092 Administration : back to site link use
 current profil custom url

---
 VERSIONS_HOTLINE/133092                              |  1 +
 library/ZendAfi/View/Helper/Admin/Nav.php            |  2 +-
 .../admin/controllers/IndexControllerTest.php        | 12 ++++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 VERSIONS_HOTLINE/133092

diff --git a/VERSIONS_HOTLINE/133092 b/VERSIONS_HOTLINE/133092
new file mode 100644
index 00000000000..3e364a4ec59
--- /dev/null
+++ b/VERSIONS_HOTLINE/133092
@@ -0,0 +1 @@
+ - ticket #133092 : Administration : le lien "retour au site" utilise l'URL personnalisée du profil courant
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/Admin/Nav.php b/library/ZendAfi/View/Helper/Admin/Nav.php
index d1eb5defd36..1b8b5aeb4e1 100644
--- a/library/ZendAfi/View/Helper/Admin/Nav.php
+++ b/library/ZendAfi/View/Helper/Admin/Nav.php
@@ -50,7 +50,7 @@ class ZendAfi_View_Helper_Admin_Nav extends ZendAfi_View_Helper_BaseHelper {
               ['icon' => 'back_to_front',
                'label' => $this->_('Retour au site'),
                'title' => $this->_('Retourner sur la partie publique du portail'),
-               'url' => $this->view->url(['id_profil' => Class_Profil::getCurrentProfil()->getId()], null, true)],
+               'url' => Class_Profil::getCurrentProfil()->getUrl()],
 
               ['icon' => 'identity',
                'label' => $identity->getLogin() . ' (' . $identity->getLibelleRole() . ')',
diff --git a/tests/application/modules/admin/controllers/IndexControllerTest.php b/tests/application/modules/admin/controllers/IndexControllerTest.php
index 26dac1e4cf6..df84ae729b3 100644
--- a/tests/application/modules/admin/controllers/IndexControllerTest.php
+++ b/tests/application/modules/admin/controllers/IndexControllerTest.php
@@ -126,6 +126,12 @@ class Admin_IndexControllerTest extends Admin_IndexControllerTestCase {
 
     Class_BokehVersion::setWebClient($mock_http);
 
+    $this->fixture(Class_Profil::class,
+                   ['id' => 4,
+                    'libelle' => 'ludotek',
+                    'rewrite_url' => 'ludotek'])
+         ->beCurrentProfil();
+
     $this->dispatch('/admin/index/index', true);
   }
 
@@ -173,6 +179,12 @@ class Admin_IndexControllerTest extends Admin_IndexControllerTestCase {
   }
 
 
+  /** @test */
+  public function menuBackToSiteLinkShouldBeSlashLudotek() {
+    $this->assertXPathContentContains('//div[@class="menu barre_nav"]//a[text()="Retour au site"]/@href', '/ludotek');
+  }
+
+
   /** @test */
   public function linkToGoogleGroupShouldBePresent() {
     $this->assertXPathContentContains('//a[contains(@href, "utilisateurs-bokeh")]', 'Google group Bokeh');
-- 
GitLab