rabin 2 роки тому
батько
коміт
417ede628f
5 змінених файлів з 131 додано та 2 видалено
  1. 1 1
      database/menu.php
  2. 91 0
      database/menu_func.php
  3. 27 0
      src/Auth.php
  4. 11 1
      src/Lib/Input.php
  5. 1 0
      src/Menu.php

+ 1 - 1
database/menu.php

@@ -62,7 +62,7 @@ return array
 	# 显示给用户看的名称
 	'lang' => '管理菜单设置',
 	'order' => 2,
-	//'check' => 'key',
+	'check' => 'key',
 	'end' => array
 	(
 		'insert' => 'manage/menu.updateKey',

+ 91 - 0
database/menu_func.php

@@ -0,0 +1,91 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'menu_func',
+	# 显示给用户看的名称
+	'lang' => '菜单子功能',
+	'order' => 2,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '功能ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'desc',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> '功能名称',
+			'default' 	=> '',
+			'desc' 		=> '请输入功能名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'order,fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '功能标识',
+			'default' 	=> '',
+			'desc' 		=> '功能标识',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			'list'		=> true,
+			//'modal'		=> 'test',
+		),
+
+		'menu_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '菜单id',
+			'default' 	=> 1,
+			'desc' 		=> '菜单id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'search'	=> 'select',
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	'manage' => array
+	(
+		
+	),
+	
+	# request 请求接口定义
+	'request' => array
+	(
+		
+	),
+);

+ 27 - 0
src/Auth.php

@@ -44,6 +44,33 @@ class Auth
         ));
     }
 
+    # 检测功能
+    public function checkFunc($key, $func, $name)
+    {
+        $menu = Dever::db('manage/menu')->one(array('key' => $key));
+        if ($menu) {
+            $info = Dever::db('manage/menu_func')->one(array('key' => $func, 'menu_id' => $menu['id']));
+            if (!$info) {
+                $func_id = Dever::db('manage/menu_func')->insert(array('name' => $name, 'key' => $func, 'menu_id' => $menu['id']));
+            } else {
+                if ($info['name'] != $name) {
+                    Dever::db('manage/menu_func')->update(array('name' => $name, 'where_id' => $info['id']));
+                }
+                $func_id = $info['id'];
+            }
+            $data = $this->data();
+            if ($data && isset($data['auth'])) {
+                if ($data['auth'] == 'all') {
+                    return true;
+                } elseif (strstr($data['auth'], 'f_' . $func_id)) {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
     /**
      * 只获取中间的内容部分
      *

+ 11 - 1
src/Lib/Input.php

@@ -697,7 +697,17 @@ class Input
 
                             $input = $input_value = '';
 
-                            if (isset($param['update_input'])) {
+                            if (isset($vi['func']) && $vi['func']) {
+                                $input .= '[';
+                                foreach ($vi['func'] as $vf) {
+                                    $fcheck = '';
+                                    if (isset($param['value']) && in_array('f_' . $vf['id'], $param['value'])) {
+                                        $fcheck = 'checked';
+                                    }
+                                    $input .= '&nbsp;&nbsp;<input update_type="checked" class="update_value checkbox-checkall-' . $param['name'] . '-'. $k . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" data-state="'.$state.'" type="' . $param['update'] . '" name="' . $name . '[]" value="f_' . $vf['id'] . '" ' . $fcheck . '/> ' . $span[0] . $vf['name'] . $span[1] . '&nbsp;&nbsp;';
+                                }
+                                $input .= ']';
+                            } elseif (isset($param['update_input'])) {
                                 if (isset($param['update_input_data']) && isset($param['update_input_data'][$j])) {
                                     $input_value = $param['update_input_data'][$j];
                                     if ($disabled) {

+ 1 - 0
src/Menu.php

@@ -230,6 +230,7 @@ class Menu
                     $menu['child'][$i] = $j;
 
                     $menu['child'][$i] = $this->getChild($menu['child'][$i], $child, $j, $auth, true);
+                    $menu['child'][$i]['func'] = Dever::db('manage/menu_func')->select(array('menu_id' => $menu['child'][$i]['id']));
 
                     if ($j['fast'] == 1) {
                         $this->fast[$i] = $j;