From a7b20a95a48c13b3e1f039ef54b5c80a9744aa74 Mon Sep 17 00:00:00 2001 From: pbarroca <pbarroca@afi-sa.fr> Date: Tue, 8 Nov 2016 15:43:21 +0100 Subject: [PATCH] user info block deleted, user role in horizontal menu --- application/modules/admin/views/scripts/head.phtml | 2 +- .../modules/admin/views/scripts/index/index.phtml | 11 ----------- library/Class/Users.php | 13 ++++++------- library/ZendAfi/Acl/AdminControllerGroup.php | 4 ++-- .../View/Helper/Admin/MenuHorizontalAdmin.php | 10 ++++------ .../admin/controllers/AdminControllerTest.php | 7 ++----- .../admin/controllers/UsersControllerTest.php | 2 +- 7 files changed, 16 insertions(+), 33 deletions(-) diff --git a/application/modules/admin/views/scripts/head.phtml b/application/modules/admin/views/scripts/head.phtml index 999fa04d47d..2d9406df7da 100644 --- a/application/modules/admin/views/scripts/head.phtml +++ b/application/modules/admin/views/scripts/head.phtml @@ -2,7 +2,7 @@ <html lang="fr-FR"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> - <title><?php echo $this->getTitre(); ?></title> + <title><?php echo strip_tags($this->getTitre()); ?></title> <?php $head_scripts = Class_ScriptLoader::newInstance() diff --git a/application/modules/admin/views/scripts/index/index.phtml b/application/modules/admin/views/scripts/index/index.phtml index 35ea741f97c..84ad98f2797 100644 --- a/application/modules/admin/views/scripts/index/index.phtml +++ b/application/modules/admin/views/scripts/index/index.phtml @@ -25,17 +25,6 @@ echo $this->ligneInfos("Etat du site", $this->etat_site . $lien) . $this->ligneInfos('Nom du domaine', Class_AdminVar::get('NOM_DOMAINE') . $edit_domain_name); ?> -<h2><?php echo $this->traduire('Accès');?> :</h2> -<?php -$acl = new ZendAfi_Acl_AdminControllerRoles(); -echo $this->ligneInfos($this->traduire("Utilisateur"), $this->user->getLogin()); -echo $this->ligneInfos("Pseudo", $this->user->getNomAff()); -echo $this->ligneInfos("Rôle", $acl->getLibelleRole($this->user->getRoleLevel())); -$bib = $this->user->getBib(); -$bib = (!$bib) ? $this->_('Portail') : $bib->getLibelle(); -echo $this->ligneInfos("Bibliothèque", $bib); -?> - <h2><?php echo $this->traduire('Données en attente de modération');?> : <a class="rss" href="<?php echo $this->url(array('module' => 'opac', diff --git a/library/Class/Users.php b/library/Class/Users.php index efe95ee1a4f..b9bf1e30d41 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -718,7 +718,8 @@ class Class_Users extends Storm_Model_Abstract { if ($this->hasIdabon()) $groupes[]='abonne'; - $groupes[]=$this->getLibelleRole(); + + $groupes[] = $this->getNomRole(); return $groupes; } @@ -776,10 +777,11 @@ class Class_Users extends Storm_Model_Abstract { /** * @return string */ - public function getLibelleRole(){ - return ZendAfi_Acl_AdminControllerRoles::getNomRole($this->getRoleLevel()); + public function getLibelleRole() { + return ZendAfi_Acl_AdminControllerRoles::getLibelleRole($this->getRoleLevel()); } + /** * @return array */ @@ -798,10 +800,7 @@ class Class_Users extends Storm_Model_Abstract { } - /** - * @return int - */ - public function getRole() { + public function getNomRole() { return ZendAfi_Acl_AdminControllerRoles::getNomRole($this->getRoleLevel()); } diff --git a/library/ZendAfi/Acl/AdminControllerGroup.php b/library/ZendAfi/Acl/AdminControllerGroup.php index 15e8a63711c..4894e2b5b61 100644 --- a/library/ZendAfi/Acl/AdminControllerGroup.php +++ b/library/ZendAfi/Acl/AdminControllerGroup.php @@ -86,11 +86,11 @@ class ZendAfi_Acl_AdminControllerGroup { return $this->_isAllowedByGroup($user, $right); $acl = $this->getAcl(); - if ($acl->isAllowed($user->getRole(), + if ($acl->isAllowed($user->getNomRole(), $acl->has($controller . '/' . $action) ? $controller . '/' . $action : null)) return true; - return $acl->isAllowed($user->getRole(), + return $acl->isAllowed($user->getNomRole(), $acl->has($controller) ? $controller : null); } diff --git a/library/ZendAfi/View/Helper/Admin/MenuHorizontalAdmin.php b/library/ZendAfi/View/Helper/Admin/MenuHorizontalAdmin.php index 490f260321a..dfa069e33ec 100644 --- a/library/ZendAfi/View/Helper/Admin/MenuHorizontalAdmin.php +++ b/library/ZendAfi/View/Helper/Admin/MenuHorizontalAdmin.php @@ -18,9 +18,7 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 - Menu admin horizontal -////////////////////////////////////////////////////////////////////////////////////////// + class ZendAfi_View_Helper_Admin_MenuHorizontalAdmin extends ZendAfi_View_Helper_BaseHelper { protected $_current_skin; @@ -28,7 +26,6 @@ class ZendAfi_View_Helper_Admin_MenuHorizontalAdmin extends ZendAfi_View_Helper_ public function menuHorizontalAdmin() { $this->_current_skin = Class_Admin_Skin::current(); - $redmine = Class_AdminVar::isRedmineEnabled() ? ['icon' => 'redmine', 'label' => $this->_('Assistance'), @@ -38,6 +35,7 @@ class ZendAfi_View_Helper_Admin_MenuHorizontalAdmin extends ZendAfi_View_Helper_ 'action' => 'index'], null, true)] : []; + $identity = Class_Users::getIdentity(); $menus = [ ['icon' => 'home', 'label' => $this->_('Accueil'), @@ -50,11 +48,11 @@ class ZendAfi_View_Helper_Admin_MenuHorizontalAdmin extends ZendAfi_View_Helper_ 'url' => $this->view->url(['id_profil' => Class_Profil::getCurrentProfil()->getId()], null, true)], ['icon' => 'identity', - 'label' => Class_Users::getIdentity()->getLogin(), + 'label' => $identity->getLogin() . ' (' . $identity->getLibelleRole() . ')', 'url' => $this->view->url(['module' => 'admin', 'controller' => 'users', 'action' => 'edit', - 'id' => Class_Users::getIdentity()->ID_USER], null, true)], + 'id' => $identity->ID_USER], null, true)], $redmine, diff --git a/tests/application/modules/admin/controllers/AdminControllerTest.php b/tests/application/modules/admin/controllers/AdminControllerTest.php index aafff8c8ce1..ec3e1cd28e2 100644 --- a/tests/application/modules/admin/controllers/AdminControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminControllerTest.php @@ -41,10 +41,6 @@ class AdminControllerSitoOKTest extends Admin_AbstractControllerTestCase { } - public function testMenuUtilisateurInfo() { - $this->assertQueryContentContains("div.ligne_info", 'sysadmin'); - } - public function testMenuNewsletterLink() { $this->assertXPathContentContains("//a[@href='" . BASE_URL . "/admin/newsletter']", "Lettres d'information"); @@ -53,9 +49,10 @@ class AdminControllerSitoOKTest extends Admin_AbstractControllerTestCase { /** @test */ public function loginShouldBeInHorizontalMenu() { - $this->assertXPathContentContains("//a[@href='/admin/users/edit/id/777']", "sysadmin"); + $this->assertXPathContentContains("//a[@href='/admin/users/edit/id/777']", 'sysadmin (super administrateur)'); } + /** @test */ function prettyPhotoCssShouldBeInHead() { $this->assertXPath("//head/link[contains(@href, 'css/prettyPhoto.css')]"); diff --git a/tests/application/modules/admin/controllers/UsersControllerTest.php b/tests/application/modules/admin/controllers/UsersControllerTest.php index 0742dd70b71..974b6f3236b 100644 --- a/tests/application/modules/admin/controllers/UsersControllerTest.php +++ b/tests/application/modules/admin/controllers/UsersControllerTest.php @@ -509,7 +509,7 @@ class UsersControllerPostMarcusDataTest extends UsersControllerWithMarcusTestCas } public function testRoleIsAdministrateur() { - $this->assertEquals('admin_bib', $this->marcus->getRole()); + $this->assertEquals('admin_bib', $this->marcus->getNomRole()); } public function testOrdreabonIsTwo() { -- GitLab