diff --git a/application/admin/controller/Auth.php b/application/admin/controller/Auth.php index d15066b..c825b9e 100644 --- a/application/admin/controller/Auth.php +++ b/application/admin/controller/Auth.php @@ -53,7 +53,7 @@ class Auth extends Base { ], 'topButton' => [ [ - 'href' => url('Auth/add'), + 'href' => 'Auth/add', 'class'=> 'btn-success', 'info'=> '新增', 'icon' => 'fa fa-plus', @@ -63,7 +63,7 @@ class Auth extends Base { 'rightButton' => [ [ 'info' => '编辑', - 'href' => url('Auth/edit'), + 'href' => 'Auth/edit', 'class'=> 'btn-info', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-pencil', @@ -72,7 +72,7 @@ class Auth extends Base { ], [ 'info' => '启用', - 'href' => url('Auth/open'), + 'href' => 'Auth/open', 'class'=> 'btn-success ajax-put-url', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-check', @@ -81,7 +81,7 @@ class Auth extends Base { ], [ 'info' => '禁用', - 'href' => url('Auth/close'), + 'href' => 'Auth/close', 'class'=> 'btn-warning ajax-put-url', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-close', @@ -90,7 +90,7 @@ class Auth extends Base { ], [ 'info' => '删除', - 'href' => url('Auth/del'), + 'href' => 'Auth/del', 'class'=> 'btn-danger ajax-delete', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-trash', @@ -145,6 +145,7 @@ class Auth extends Base { ], 'data' => $data ]; + $table = $this->_prepareTemplate($table); $this->result($table, ReturnCode::GET_TEMPLATE_SUCCESS); } diff --git a/application/admin/controller/Base.php b/application/admin/controller/Base.php index 05536b1..0163dd9 100644 --- a/application/admin/controller/Base.php +++ b/application/admin/controller/Base.php @@ -45,6 +45,33 @@ class Base extends Controller { return (new PublicShow())->show_404(); } + protected function _prepareTemplate( $temp ){ + $authList = (new \Permission())->getAuthList($this->uid); + switch ( $temp['tempType'] ){ + case 'table': + foreach ( $temp['topButton'] as $key => $value ){ + if( !isset($authList[$value['href']]) || !$authList[$value['href']] ){ + unset($temp['topButton'][$key]); + }else{ + $temp['topButton'][$key]['href'] = url($value['href']); + } + } + $temp['topButton'] = array_values($temp['topButton']); + foreach ( $temp['rightButton'] as $k => $v ){ + if( !isset($authList[$v['href']]) || !$authList[$v['href']] ){ + unset($temp['rightButton'][$k]); + }else{ + $temp['rightButton'][$k]['href'] = url($v['href']); + } + } + $temp['rightButton'] = array_values($temp['rightButton']); + break; + case 'form': + break; + } + return $temp; + } + /** * 系统初始化函数(登陆状态检测,权限检测,初始化菜单) */ @@ -91,6 +118,9 @@ class Base extends Controller { } } + /** + * 权限检测&权限验证 + */ private function checkRule(){ $check = (new \Permission())->check($this->url, $this->uid); if( !$check && !isAdministrator() ){ diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php index 2b8c01f..088a4de 100644 --- a/application/admin/controller/Menu.php +++ b/application/admin/controller/Menu.php @@ -78,14 +78,14 @@ class Menu extends Base { ], 'topButton' => [ [ - 'href' => url('Menu/add'), + 'href' => 'Menu/add', 'class'=> 'btn-success', 'info'=> '新增', 'icon' => 'fa fa-plus', 'confirm' => 0, ], [ - 'href' => url('Menu/del'), + 'href' => 'Menu/del', 'class'=> 'btn-danger ajax-delete', 'info'=> '删除', 'icon' => 'fa fa-trash', @@ -95,7 +95,7 @@ class Menu extends Base { 'rightButton' => [ [ 'info' => '编辑', - 'href' => url('Menu/edit'), + 'href' => 'Menu/edit', 'class'=> 'btn-warning', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-pencil', @@ -104,7 +104,7 @@ class Menu extends Base { ], [ 'info' => '删除', - 'href' => url('Menu/del'), + 'href' => 'Menu/del', 'class'=> 'btn-danger ajax-delete', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-trash', @@ -190,6 +190,7 @@ class Menu extends Base { ], 'data' => $data ]; + $table = $this->_prepareTemplate($table); $this->result($table, ReturnCode::GET_TEMPLATE_SUCCESS); } diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index 2d7a58f..2efda14 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -61,7 +61,7 @@ class User extends Base { ], 'topButton' => [ [ - 'href' => url('User/add'), + 'href' => 'User/add', 'class'=> 'btn-success', 'info'=> '新增', 'icon' => 'fa fa-plus', @@ -71,7 +71,7 @@ class User extends Base { 'rightButton' => [ [ 'info' => '启用', - 'href' => url('User/open'), + 'href' => 'User/open', 'class'=> 'btn-success ajax-put-url', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-check', @@ -80,7 +80,7 @@ class User extends Base { ], [ 'info' => '禁用', - 'href' => url('User/close'), + 'href' => 'User/close', 'class'=> 'btn-warning ajax-put-url', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-close', @@ -89,7 +89,7 @@ class User extends Base { ], [ 'info' => '授权', - 'href' => url('Auth/group'), + 'href' => 'Auth/group', 'class'=> 'btn-default', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-lock', @@ -97,7 +97,7 @@ class User extends Base { ], [ 'info' => '删除', - 'href' => url('User/del'), + 'href' => 'User/del', 'class'=> 'btn-danger ajax-delete', 'param'=> [$this->primaryKey], 'icon' => 'fa fa-trash', @@ -124,6 +124,7 @@ class User extends Base { ], 'data' => $data ]; + $table = $this->_prepareTemplate($table); $this->result($table, ReturnCode::GET_TEMPLATE_SUCCESS); }