@@ -58,6 +58,7 @@ class MenuBuilder
|
|||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
$isLoggedIn = $this->security->isGranted('IS_AUTHENTICATED_FULLY');
|
$isLoggedIn = $this->security->isGranted('IS_AUTHENTICATED_FULLY');
|
||||||
|
$isTeamlead = $isLoggedIn && $this->security->isGranted('ROLE_TEAMLEAD');
|
||||||
$isAdmin = $isLoggedIn && $this->security->isGranted('ROLE_ADMIN');
|
$isAdmin = $isLoggedIn && $this->security->isGranted('ROLE_ADMIN');
|
||||||
|
|
||||||
$event->addItem(
|
$event->addItem(
|
||||||
@@ -73,12 +74,15 @@ class MenuBuilder
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($isAdmin) {
|
if ($isTeamlead) {
|
||||||
$admin = new MenuItemModel('admin', 'menu.admin', '', [], 'fa fa-wrench');
|
$admin = new MenuItemModel('admin', 'menu.admin', '', [], 'fa fa-wrench');
|
||||||
$event->addItem($admin);
|
$event->addItem($admin);
|
||||||
$admin->addChild(
|
|
||||||
new MenuItemModel('user_admin', 'menu.admin_user', 'admin_user', [], 'fa fa-user')
|
if ($isAdmin) {
|
||||||
);
|
$admin->addChild(
|
||||||
|
new MenuItemModel('user_admin', 'menu.admin_user', 'admin_user', [], 'fa fa-user')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->eventDispatcher->dispatch(
|
$this->eventDispatcher->dispatch(
|
||||||
ConfigureAdminMenuEvent::CONFIGURE,
|
ConfigureAdminMenuEvent::CONFIGURE,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace TimesheetBundle\Controller\Admin;
|
namespace TimesheetBundle\Controller\Admin;
|
||||||
|
|
||||||
|
use Pagerfanta\Pagerfanta;
|
||||||
use TimesheetBundle\Entity\Timesheet;
|
use TimesheetBundle\Entity\Timesheet;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||||
@@ -21,8 +22,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
|
|||||||
/**
|
/**
|
||||||
* Controller used for manage timesheet entries in the admin part of the site.
|
* Controller used for manage timesheet entries in the admin part of the site.
|
||||||
*
|
*
|
||||||
* @Route("/admin/timesheet")
|
* @Route("/team/timesheet")
|
||||||
* @Security("has_role('ROLE_ADMIN')")
|
* @Security("has_role('ROLE_TEAMLEAD')")
|
||||||
*
|
*
|
||||||
* @author Kevin Papst <kevin@kevinpapst.de>
|
* @author Kevin Papst <kevin@kevinpapst.de>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -52,16 +52,23 @@ class Menu
|
|||||||
$menu = $event->getAdminMenu();
|
$menu = $event->getAdminMenu();
|
||||||
$auth = $event->getAuth();
|
$auth = $event->getAuth();
|
||||||
|
|
||||||
$isLoggedIn = $auth->isGranted('IS_AUTHENTICATED_FULLY');
|
if (!$auth->isGranted('IS_AUTHENTICATED_FULLY')) {
|
||||||
$isAdmin = $isLoggedIn && $auth->isGranted('ROLE_ADMIN');
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$isAdmin) {
|
if (!$auth->isGranted('ROLE_TEAMLEAD')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$menu->addChild(
|
$menu->addChild(
|
||||||
new MenuItemModel('timesheet_admin', 'menu.admin_timesheet', 'admin_timesheet', [], 'fa fa-clock-o')
|
new MenuItemModel('timesheet_admin', 'menu.admin_timesheet', 'admin_timesheet', [], 'fa fa-clock-o')
|
||||||
)->addChild(
|
);
|
||||||
|
|
||||||
|
if (!$auth->isGranted('ROLE_ADMIN')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$menu->addChild(
|
||||||
new MenuItemModel('customer_admin', 'menu.admin_customer', 'admin_customer', [], 'fa fa-users')
|
new MenuItemModel('customer_admin', 'menu.admin_customer', 'admin_customer', [], 'fa fa-users')
|
||||||
)->addChild(
|
)->addChild(
|
||||||
new MenuItemModel('project_admin', 'menu.admin_project', 'admin_project', [], 'fa fa-book')
|
new MenuItemModel('project_admin', 'menu.admin_project', 'admin_project', [], 'fa fa-book')
|
||||||
|
|||||||
Reference in New Issue
Block a user