Add user account menu and move logout and preferences inside it

This commit is contained in:
Alexander Fuhr 2014-11-12 13:22:14 +01:00
parent 2bae33d6ad
commit 993390941a
1 changed files with 41 additions and 31 deletions

View File

@ -4,6 +4,7 @@
namespace Icinga\Web; namespace Icinga\Web;
use Icinga\Authentication\Manager;
use Icinga\Web\Menu\MenuItemRenderer; use Icinga\Web\Menu\MenuItemRenderer;
use RecursiveIterator; use RecursiveIterator;
use Zend_Config; use Zend_Config;
@ -201,6 +202,10 @@ class Menu implements RecursiveIterator
*/ */
protected function addMainMenuItems() protected function addMainMenuItems()
{ {
$auth = Manager::getInstance();
if ($auth->isAuthenticated()) {
$this->add(t('Dashboard'), array( $this->add(t('Dashboard'), array(
'url' => 'dashboard', 'url' => 'dashboard',
'icon' => 'img/icons/dashboard.png', 'icon' => 'img/icons/dashboard.png',
@ -211,10 +216,6 @@ class Menu implements RecursiveIterator
'icon' => 'img/icons/configuration.png', 'icon' => 'img/icons/configuration.png',
'priority' => 200 'priority' => 200
)); ));
$section->add(t('Preferences'), array(
'url' => 'preference',
'priority' => 200
));
$section->add(t('Configuration'), array( $section->add(t('Configuration'), array(
'url' => 'config', 'url' => 'config',
'priority' => 300 'priority' => 300
@ -231,11 +232,20 @@ class Menu implements RecursiveIterator
)); ));
} }
$this->add(t('Logout'), array( $section = $this->add($auth->getUser()->getUsername(), array(
'url' => 'authentication/logout', 'icon' => 'img/icons/user.png',
'icon' => 'img/icons/logout.png', 'priority' => 600
'priority' => 300
)); ));
$section->add(t('Preferences'), array(
'url' => 'preference',
'priority' => 601
));
$section->add(t('Logout'), array(
'url' => 'authentication/logout',
'priority' => 700
));
}
} }
/** /**