[icinga-checkins] icinga.org: icingaweb2/feature/redesign-7144: Add user account menu and move logout and preferences inside it

git at icinga.org git at icinga.org
Thu Nov 13 21:22:56 CET 2014


Module: icingaweb2
Branch: feature/redesign-7144
Commit: 993390941a58049387e5346a0bf31773fe669d3c
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=993390941a58049387e5346a0bf31773fe669d3c

Author: Alexander Fuhr <alexander.fuhr at netways.de>
Date:   Wed Nov 12 13:22:14 2014 +0100

Add user account menu and move logout and preferences inside it

---

 library/Icinga/Web/Menu.php |   76 ++++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 33 deletions(-)

diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php
index 870c2f1..013c8f6 100644
--- a/library/Icinga/Web/Menu.php
+++ b/library/Icinga/Web/Menu.php
@@ -4,6 +4,7 @@
 
 namespace Icinga\Web;
 
+use Icinga\Authentication\Manager;
 use Icinga\Web\Menu\MenuItemRenderer;
 use RecursiveIterator;
 use Zend_Config;
@@ -201,41 +202,50 @@ class Menu implements RecursiveIterator
      */
     protected function addMainMenuItems()
     {
-        $this->add(t('Dashboard'), array(
-            'url'      => 'dashboard',
-            'icon'     => 'img/icons/dashboard.png',
-            'priority' => 10
-        ));
-
-        $section = $this->add(t('System'), array(
-            'icon'     => 'img/icons/configuration.png',
-            'priority' => 200
-        ));
-        $section->add(t('Preferences'), array(
-            'url'      => 'preference',
-            'priority' => 200
-        ));
-        $section->add(t('Configuration'), array(
-            'url'      => 'config',
-            'priority' => 300
-        ));
-        $section->add(t('Modules'), array(
-            'url'      => 'config/modules',
-            'priority' => 400
-        ));
-
-        if (Logger::writesToFile()) {
-            $section->add(t('Application Log'), array(
-                'url'      => 'list/applicationlog',
-                'priority' => 500
+        $auth = Manager::getInstance();
+
+        if ($auth->isAuthenticated()) {
+
+            $this->add(t('Dashboard'), array(
+                'url'      => 'dashboard',
+                'icon'     => 'img/icons/dashboard.png',
+                'priority' => 10
+            ));
+
+            $section = $this->add(t('System'), array(
+                'icon'     => 'img/icons/configuration.png',
+                'priority' => 200
+            ));
+            $section->add(t('Configuration'), array(
+                'url'      => 'config',
+                'priority' => 300
+            ));
+            $section->add(t('Modules'), array(
+                'url'      => 'config/modules',
+                'priority' => 400
             ));
-        }
 
-        $this->add(t('Logout'), array(
-            'url'      => 'authentication/logout',
-            'icon'     => 'img/icons/logout.png',
-            'priority' => 300
-        ));
+            if (Logger::writesToFile()) {
+                $section->add(t('Application Log'), array(
+                    'url'      => 'list/applicationlog',
+                    'priority' => 500
+                ));
+            }
+
+            $section = $this->add($auth->getUser()->getUsername(), array(
+                'icon'     => 'img/icons/user.png',
+                'priority' => 600
+            ));
+            $section->add(t('Preferences'), array(
+                'url'      => 'preference',
+                'priority' => 601
+            ));
+
+            $section->add(t('Logout'), array(
+                'url'      => 'authentication/logout',
+                'priority' => 700
+            ));
+        }
     }
 
     /**



More information about the icinga-checkins mailing list