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