add admin menu
This commit is contained in:
parent
f0e52f59c3
commit
328d02be03
@ -1,19 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace backend\components;
|
||||
|
||||
use Yii;
|
||||
use common\components\RoleDefinition;
|
||||
|
||||
class AdminMenuStructure{
|
||||
class AdminMenuStructure
|
||||
{
|
||||
|
||||
public $menuItems;
|
||||
public $emptyUrl = '#';//maybe null
|
||||
|
||||
public function __construct(){
|
||||
public function __construct()
|
||||
{
|
||||
$this->menuItems = [];
|
||||
}
|
||||
|
||||
protected function can($authItem){
|
||||
protected function can($authItem)
|
||||
{
|
||||
$result = false;
|
||||
if (\Yii::$app->user->can($authItem)) {
|
||||
$result = true;
|
||||
@ -25,7 +29,8 @@ class AdminMenuStructure{
|
||||
/**
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
*/
|
||||
protected function addUserMainMenu(){
|
||||
protected function addUserMainMenu()
|
||||
{
|
||||
|
||||
$userMainMenu = null;
|
||||
$items = [];
|
||||
@ -50,6 +55,8 @@ class AdminMenuStructure{
|
||||
];
|
||||
}
|
||||
|
||||
if (RoleDefinition::isAdmin() || RoleDefinition::isEmployee()
|
||||
|| RoleDefinition::isReception()) {
|
||||
/////////////////////////////
|
||||
// Törszadatok
|
||||
/////////////////////////////
|
||||
@ -160,11 +167,12 @@ class AdminMenuStructure{
|
||||
$this->menuItems[] = ['label' => 'Koronavírus', 'url' => $this->emptyUrl,
|
||||
'items' => $items
|
||||
];
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// Group Training
|
||||
/////////////////////////////
|
||||
if ( Yii::$app->user ){
|
||||
if (RoleDefinition::isLoggedUser()) {
|
||||
$items = [];
|
||||
$items[] = ['label' => 'Felszerelés', 'url' => ['/event-equipment-type']];
|
||||
$items[] = ['label' => 'Edzők', 'url' => ['/trainer']];
|
||||
@ -181,7 +189,7 @@ class AdminMenuStructure{
|
||||
/////////////////////////////
|
||||
// Development
|
||||
/////////////////////////////
|
||||
if ( Yii::$app->user ){
|
||||
if (RoleDefinition::isAdmin()) {
|
||||
$items = [];
|
||||
$items[] = ['label' => 'Kapu Ki', 'url' => ['/door-log/out']];
|
||||
$items[] = ['label' => 'Kapu Be', 'url' => ['/door-log/in']];
|
||||
@ -194,7 +202,8 @@ class AdminMenuStructure{
|
||||
|
||||
}
|
||||
|
||||
protected function addLoginMainMenu(){
|
||||
protected function addLoginMainMenu()
|
||||
{
|
||||
if (Yii::$app->user->isGuest) {
|
||||
$mainMenuItem = ['label' => Yii::t('common/site', 'Login'), 'url' => ['/site/login']];
|
||||
} else {
|
||||
@ -213,7 +222,8 @@ class AdminMenuStructure{
|
||||
* @return array
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
*/
|
||||
public function run(){
|
||||
public function run()
|
||||
{
|
||||
$this->addUserMainMenu();
|
||||
// $this->addLoginMainMenu();
|
||||
return $this->menuItems;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user