From f554f7effd49de5f7c0b46863e955eb17cb23492 Mon Sep 17 00:00:00 2001 From: alexey_u Date: Sat, 20 Oct 2018 00:24:42 +0400 Subject: [PATCH] Do not show routes on Permissions list when advanced config is enabled. Fix AuthItem::getItems() method too. --- models/AuthItem.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/AuthItem.php b/models/AuthItem.php index 79813675..2c22929d 100644 --- a/models/AuthItem.php +++ b/models/AuthItem.php @@ -246,6 +246,7 @@ public function removeChildren($items) public function getItems() { $manager = Configs::authManager(); + $advanced = Configs::instance()->advanced; $available = []; if ($this->type == Item::TYPE_ROLE) { foreach (array_keys($manager->getRoles()) as $name) { @@ -253,12 +254,12 @@ public function getItems() } } foreach (array_keys($manager->getPermissions()) as $name) { - $available[$name] = $name[0] == '/' ? 'route' : 'permission'; + $available[$name] = $name[0] == '/' || $advanced && $name[0] == '@' ? 'route' : 'permission'; } $assigned = []; foreach ($manager->getChildren($this->_item->name) as $item) { - $assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' ? 'route' : 'permission'); + $assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' || $advanced && $item->name[0] == '@' ? 'route' : 'permission'); unset($available[$item->name]); } unset($available[$this->name]);