dever há 3 anos atrás
pai
commit
e765ed0124
5 ficheiros alterados com 25 adições e 11 exclusões
  1. 1 0
      database/menu.php
  2. 4 3
      database/role.php
  3. 2 2
      src/Auth.php
  4. 3 3
      src/Database.php
  5. 15 3
      src/Menu.php

+ 1 - 0
database/menu.php

@@ -65,6 +65,7 @@ return array
 	//'check' => 'key',
 	'end' => array
 	(
+		'insert' => 'manage/menu.updateKey',
 		'update' => 'manage/menu.updateKey',
 	),
 	# 数据结构

+ 4 - 3
database/role.php

@@ -22,11 +22,12 @@ $top = function()
 # 操作权限控制
 $oper = array
 (
-	1 => '浏览',
-	2 => '索',
-	3 => '更新',
+	1 => '列表',
+	2 => '索',
+	3 => '编辑',
 	4 => '新增',
 	5 => '删除',
+	6 => '其他',
 );
 
 # 是否只能管理自己发布的内容

+ 2 - 2
src/Auth.php

@@ -453,7 +453,7 @@ class Auth
                 Dever::alert('没有该权限');
             }
 
-            if ($menu['key']) {
+            if ($menu) {
                 if (isset($admin['auth']) && $admin['auth']) {
                     if ($admin['auth'] == 'all' || $admin['auth'] == '') {
                         return;
@@ -461,7 +461,7 @@ class Auth
 
                     $admin['auth'] = explode(',', $admin['auth']);
 
-                    if (!in_array($menu['key'], $admin['auth'])) {
+                    if (!in_array($menu['id'], $admin['auth'])) {
                         Dever::alert('您没有操作权限');
                     }
                 } else {

+ 3 - 3
src/Database.php

@@ -986,7 +986,7 @@ class Database
             $config['manage']['button'][$name] = 'onclick="jump(\''.$this->url('excel').'\', \'#form1\')"';
         }
         # 增加回收站
-        if (isset($config['struct']['state']) && (!isset($config['manage']['delete']) || (isset($config['manage']['delete']) && $config['manage']['delete'] && isset($config['manage']['_list']['value']['delete'])))) {
+        if (Dever::load('manage/auth.oper', 5) != false && isset($config['struct']['state']) && (!isset($config['manage']['delete']) || (isset($config['manage']['delete']) && $config['manage']['delete'] && isset($config['manage']['_list']['value']['delete'])))) {
             if ($config['state'] == 2) {
                 $config['manage']['button']['返回数据列表'] = $this->url('list', 0, false, '&search_option_state=1', $this->project);
             } else {
@@ -995,7 +995,7 @@ class Database
         }
 
         # 列表页按钮
-        if (isset($config['manage']['button'])) {
+        if (Dever::load('manage/auth.oper', 6) != false && isset($config['manage']['button'])) {
             $result .= $this->button_list($config['manage']['button']);
         }
 
@@ -2331,7 +2331,7 @@ class Database
     private function list_tbody_button($config, $data, $type = 'td')
     {
         $result = '';
-        if (isset($config['manage']['_list']['value'])) {
+        if ((Dever::load('manage/auth.oper', 3) != false || Dever::load('manage/auth.oper', 5) != false) && isset($config['manage']['_list']['value'])) {
             $result = '<'.$type.'>';
             if ($config['state'] == 2) {
                 if (isset($config['manage']['_list']['value']['update'])) {

+ 15 - 3
src/Menu.php

@@ -167,23 +167,30 @@ class Menu
             $child = Dever::db('manage/menu')->child();
 
             if ($auth && is_array($auth)) {
-                $auth = implode(',', $auth);
+                //$auth = implode(',', $auth);
             }
             
             $console = false;
             if (layadmin()) {
                 $console = true;
             }
+
             foreach ($menu as $k => $v) {
 
                 if (!$console && $k == 'console') {
                     unset($menu[$k]);
                     continue;
                 }
+                if ($auth && !in_array($v['id'], $auth)) {
+                    //unset($menu[$k]);
+                    //continue;
+                }
+                /*
                 if ($auth && strpos($auth . '.', $k . '.') === false) {
                     unset($menu[$k]);
                     continue;
                 }
+                */
 
                 $path = Dever::load('manage/project.path', $v['key']);
                 if ($path && strpos($path, 'http://') === 0) {
@@ -212,7 +219,8 @@ class Menu
     {
         if (isset($child[$v['id']])) {
             foreach ($child[$v['id']] as $i => $j) {
-                if ($state == false && $auth && $i && strpos($auth . '.', $i) === false) {
+                //if ($state == false && $auth && $i && strpos($auth . '.', $i) === false) {
+                if ($state == false && $auth && !in_array($j['id'], $auth)) {
                     //unset($child[$parent][$i]);
                     //continue;
                 } else {
@@ -658,7 +666,11 @@ class Menu
         if (isset($v['child']) && $v['child']) {
             $html .= '<dl class="layui-nav-child">';
             foreach ($v['child'] as $k1 => $v1) {
-                $html .= '<dd data-name="'.$v1['key'].'">';
+                $active = '';
+                if ($v1['key'] == 'console.index') {
+                    $active = 'layui-this';
+                }
+                $html .= '<dd data-name="'.$v1['key'].'" class="'.$active.'">';
                 if (isset($v1['child']) && $v1['child']) {
                     $html .= '<a href="javascript:;">'.$v1['name'].'</a><dl class="layui-nav-child">';
                     foreach ($v1['child'] as $k2 => $v2) {