dever 6 gadi atpakaļ
vecāks
revīzija
33136be787
4 mainītis faili ar 124 papildinājumiem un 16 dzēšanām
  1. 18 0
      database/inbox.php
  2. 18 0
      database/outbox.php
  3. 76 0
      database/project.php
  4. 12 16
      lib/Data.php

+ 18 - 0
database/inbox.php

@@ -18,6 +18,11 @@ $type = function()
 	return Dever::load('message/type-state');
 };
 
+$project = function()
+{
+	return Dever::load('message/project-state');
+};
+
 return array
 (
 	# 表名
@@ -96,6 +101,19 @@ return array
 			'list'		=> true,
 		),
 
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属项目',
+			'default' 	=> '1',
+			'desc' 		=> '所属项目',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $project,
+			'update'	=> 'select',
+			//'search'	=> 'select',
+			'list'		=> true,
+		),
+
 		'type'		=> array
 		(
 			'type' 		=> 'int-11',

+ 18 - 0
database/outbox.php

@@ -19,6 +19,11 @@ $type = array
 	2 => '系统通知',
 );
 
+$project = function()
+{
+	return Dever::load('message/project-state');
+};
+
 return array
 (
 	# 表名
@@ -77,6 +82,19 @@ return array
 			'list'		=> true,
 		),
 
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属项目',
+			'default' 	=> '1',
+			'desc' 		=> '所属项目',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $project,
+			'update'	=> 'select',
+			//'search'	=> 'select',
+			'list'		=> true,
+		),
+
 		'type'		=> array
 		(
 			'type' 		=> 'int-11',

+ 76 - 0
database/project.php

@@ -0,0 +1,76 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'project',
+	# 显示给用户看的名称
+	'lang' => '项目管理',
+	'order' => 30,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'fulltext',
+			'order'		=> 'desc',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-30',
+			'name' 		=> '项目名称',
+			'default' 	=> '',
+			'desc' 		=> '项目名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'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
+	(
+		
+	),
+
+	'default' => array
+	(
+		'col' => 'id,name,state,cdate',
+		'value' => array
+		(
+			'1, "默认项目", 1,' . DEVER_TIME,
+		),
+	),
+	
+	# request 请求接口定义
+	'request' => array
+	(
+		
+	),
+);

+ 12 - 16
lib/Data.php

@@ -20,7 +20,7 @@ class Data
      * 
      * @return mixed
      */
-	public function read($uid, $type = false, $update = false, $status = false)
+	public function read($uid, $type = false, $update = false, $status = false, $project = 1)
 	{
         if (!$uid) {
             Dever::alert('错误的用户信息');
@@ -29,10 +29,10 @@ class Data
 		$outbox = $prefix . 'message_outbox';
 		$inbox = $prefix . 'message_inbox';
 
-		$where = ' and a.state = 1';
+		$where = ' and a.state = 1 and a.project_id = ' . $project;
         $where .= ' and a.type <= 10';
 		# 读取outbox里的数据
-		$sql = 'select a.name,a.content,a.id,a.type,a.uid from '.$outbox.' as a where not exists(select oid from '.$inbox.' where a.id = oid and uid = '.$uid.')' . $where . ' ';
+		$sql = 'select a.name,a.content,a.id,a.type,a.uid,a.project_id from '.$outbox.' as a where not exists(select oid from '.$inbox.' where a.id = oid and uid = '.$uid.')' . $where . ' ';
 
         $state = Dever::db('message/inbox')->query($sql);
 		$outbox = $state->fetchAll();
@@ -42,6 +42,7 @@ class Data
                 $insert['add_uid'] = $uid;
                 $insert['add_oid'] = $v['id'];
                 $insert['add_status'] = 1;
+                $insert['add_project_id'] = $v['project_id'];
                 $insert['add_type'] = $v['type'];
 				//$insert['add_site'] = $v['site'];
 				$insert['add_from_uid'] = $v['uid'];
@@ -50,6 +51,9 @@ class Data
                 Dever::load('message/inbox-insert', $insert);
             }
 		}
+        if ($project) {
+            $param['option_project_id'] = $project;
+        }
         if ($type) {
             $param['option_type'] = $type;
         }
@@ -74,9 +78,9 @@ class Data
      * 
      * @return mixed
      */
-    public function num($uid)
+    public function num($uid, $project = 1)
     {
-        return $this->read($uid, false, false, 1);
+        return $this->read($uid, false, false, 1, $project);
     }
 
 	/**
@@ -105,19 +109,11 @@ class Data
      * 
      * @return mixed
      */
-	public function push($uid, $to_uid, $name, $content, $type = 11)
+	public function push($uid, $to_uid, $name, $content, $type = 11, $project = 1)
 	{
-        //$site 	    = intval(Dever::input('site', -1));
-
         if (!is_numeric($type)) {
             Dever::alert('错误的消息类型');
         }
-        /*
-        if(!is_numeric($site))
-        {
-            Dever::alert('错误的站点ID');
-        }
-        */
         if ($type > 10 && !$uid) {
             Dever::alert('错误的发件人id');
         }
@@ -137,7 +133,7 @@ class Data
             $data['add_name'] = $name;
             $data['add_content'] = $content;
             $data['add_type'] = $type;
-            //$data['add_site'] = $site;
+            $data['add_project_id'] = $project;
             $id = Dever::load('message/outbox-insert', $data);
 
             if ($id > 0) {
@@ -148,7 +144,7 @@ class Data
                         $insert['add_oid'] = $id;
                         $insert['add_status'] = 1;
                         $insert['add_type'] = $data['add_type'];
-                        //$insert['add_site'] = $site;
+                        $insert['add_project_id'] = $project;
                         $insert['add_from_uid'] = $data['add_uid'];
                         $insert['add_name'] = $data['add_name'];
                         $insert['add_content'] = $data['add_content'];