From 04f35c654a15b4e72e15d6b54de298f2d6e45d4c Mon Sep 17 00:00:00 2001
From: lbrun <lbrun@afi-sa.fr>
Date: Wed, 23 Sep 2015 15:11:15 +0200
Subject: [PATCH] hotline #28305 "Nom du domaine : Modifier" only available for
 admins and super admin

---
 VERSIONS_HOTLINE/28305                        |  1 +
 .../admin/views/scripts/index/index.phtml     | 19 ++++++-----
 .../controllers/AdminIndexControllerTest.php  | 33 +++++++++++++++++++
 3 files changed, 44 insertions(+), 9 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/28305

diff --git a/VERSIONS_HOTLINE/28305 b/VERSIONS_HOTLINE/28305
new file mode 100644
index 00000000000..57a3bb92a4e
--- /dev/null
+++ b/VERSIONS_HOTLINE/28305
@@ -0,0 +1 @@
+ - ticket #28305 : seul les admins et le super admin ont la possibilité de modifier le nom du domaine
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/index/index.phtml b/application/modules/admin/views/scripts/index/index.phtml
index 4ed4d8fa28a..50aed3678a9 100644
--- a/application/modules/admin/views/scripts/index/index.phtml
+++ b/application/modules/admin/views/scripts/index/index.phtml
@@ -9,7 +9,7 @@ echo $this->tag('h2',
    <h2><?php echo $this->traduire('Paramètres du site');?>&nbsp;:</h2>
 <?php
 $profil = Class_Profil::getCurrentProfil();
-$lien_edit_site = $lien = '';
+$lien_edit_site = $lien = $edit_domain_name = '';
 if ($this->user->isAdmin()) {
   $lien = sprintf('<a href="admin?setsiteok=%s" style="margin-left:30px">&raquo;&nbsp;%s&nbsp;&laquo;</a>',
                   $this->href_site, $this->lien_site);
@@ -17,19 +17,20 @@ if ($this->user->isAdmin()) {
                             $this->url(array('controller' => 'profil',
                                              'action' => 'accueil',
                                              'id_profil' => $profil->getId())));
+
+  $edit_domain_name = $this->tagAnchor($this->url(['module' => 'admin',
+                                                   'controller' => 'index',
+                                                   'action' => 'adminvaredit',
+                                                   'cle'=> 'NOM_DOMAINE']),
+                                       '» Modifier «',
+                                       ['style' => 'margin-left: 30px;',
+                                        'data-popup' => 'true']);
 }
 
 echo $this->ligneInfos("Etat du site", $this->etat_site . $lien)
   . $this->ligneInfos("Profil", $profil->getLibelle() . $lien_edit_site)
   . $this->ligneInfos("Thème", $profil->getSkin())
-  . $this->ligneInfos('Nom du domaine',
-                      Class_AdminVar::get('NOM_DOMAINE') . $this->tagAnchor($this->url(['module' => 'admin',
-                                                                          'controller' => 'index',
-                                                                          'action' => 'adminvaredit',
-                                                                          'cle'=> 'NOM_DOMAINE']),
-                                                              '» Modifier «',
-                                                              ['style' => 'margin-left: 30px;',
-                                                               'data-popup' => 'true']));
+  . $this->ligneInfos('Nom du domaine', Class_AdminVar::get('NOM_DOMAINE') . $edit_domain_name);
 ?>
 
 <h2><?php echo $this->traduire('Accès');?>&nbsp;:</h2>
diff --git a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php
index 84ea24a939f..8749bc6df5f 100644
--- a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php
+++ b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php
@@ -664,3 +664,36 @@ class AdminIndexControllerAdminVarEditComboInvalidPostActionTest
     $this->assertNotEquals(19, Class_AdminVar::get('NEWSLETTER_ID_PROFIL'));
   }
 }
+
+
+
+class AdminIndexControllerDisplayModifierNomDomaineTest extends AbstractControllerTestCase {
+
+  /** @test */
+  public function ModifierNomDomaineShouldBePresent() {
+    $user = $this->fixture('Class_Users', ['id' => 8,
+                                           'login' => 'joe',
+                                           'password' => 'foo',
+                                           'role_level' => ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL]);
+
+    ZendAfi_Auth::getInstance()->logUser($user);
+
+    $this->dispatch('/admin/index', true);
+
+    $this->assertXpathContentContains('//div[@class="modules"]//a', 'Modifier');
+  }
+
+  /** @test */
+  public function ModifierNomDomaineShouldNotBePresent() {
+    $user = $this->fixture('Class_Users', ['id' => 8,
+                                           'login' => 'joe',
+                                           'password' => 'foo',
+                                           'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL]);
+
+    ZendAfi_Auth::getInstance()->logUser($user);
+
+    $this->dispatch('/admin/index', true);
+
+    $this->assertNotXpathContentContains('//div[@class="modules"]//a', 'Modifier');
+  }
+}
-- 
GitLab