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]); diff --git a/models/searchs/AuthItem.php b/models/searchs/AuthItem.php index d08dd0dc..3811cd81 100644 --- a/models/searchs/AuthItem.php +++ b/models/searchs/AuthItem.php @@ -59,11 +59,18 @@ public function search($params) { /* @var \yii\rbac\Manager $authManager */ $authManager = Configs::authManager(); + $advanced = Configs::instance()->advanced; if ($this->type == Item::TYPE_ROLE) { $items = $authManager->getRoles(); } else { - $items = array_filter($authManager->getPermissions(), function($item) { - return $this->type == Item::TYPE_PERMISSION xor strncmp($item->name, '/', 1) === 0; + $items = array_filter($authManager->getPermissions(), function($item) use ($advanced){ + $isPermission = $this->type == Item::TYPE_PERMISSION; + if ($advanced) { + return $isPermission xor (strncmp($item->name, '/', 1) === 0 or strncmp($item->name, '@', 1) === 0); + } + else { + return $isPermission xor strncmp($item->name, '/', 1) === 0; + } }); } $this->load($params);