visuddhinanda 5 лет назад
Родитель
Сommit
8627291cc3

+ 34 - 0
app/article/card.php

@@ -0,0 +1,34 @@
+<?php
+//
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../ucenter/function.php';
+
+
+if (isset($_GET["id"])) {
+	$output["id"]=$_GET["id"];
+	PDO_Connect( _FILE_DB_USER_ARTICLE_);
+	$query = "SELECT title,create_time,owner,summary FROM article  WHERE id = ? ";
+	$result = PDO_FetchRow($query, array($_GET["id"]));
+	$strData="";
+	if ($result) {
+		
+		$_userinfo = new UserInfo();
+		$name = $_userinfo->getName($result["owner"]);
+
+		$strData .= "<div>标题:".$result["title"]."</div>";
+		$strData .=  "<div>创建人:".$name["nickname"]."</div>";
+		$strData .=  "<div>创建时间:".date("Y/m/d",$result["create_time"]/1000)."</div>";
+		$strData .=  "<div>简介:".$result["summary"]."</div>";
+	} else {
+		$strData .=  "unkow";
+	}
+	$output["data"] = $strData;
+} else {
+	$output["id"]=0;
+	$output["data"] = "unkow";
+}
+echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
+?>

+ 34 - 0
app/channal/card.php

@@ -0,0 +1,34 @@
+<?php
+//
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../ucenter/function.php';
+
+
+if (isset($_GET["id"])) {
+	$output["id"]=$_GET["id"];
+	PDO_Connect( _FILE_DB_CHANNAL_);
+	$query = "SELECT name,create_time,owner,summary FROM channal  WHERE id = ? ";
+	$channel = PDO_FetchRow($query, array($_GET["id"]));
+	$strData="";
+	if ($channel) {
+		
+		$_userinfo = new UserInfo();
+		$name = $_userinfo->getName($channel["owner"]);
+
+		$strData .= "<div>名称:".$channel["name"]."</div>";
+		$strData .=  "<div>创建人:".$name["nickname"]."</div>";
+		$strData .=  "<div>创建时间:".date("Y/m/d",$channel["create_time"]/1000)."</div>";
+		$strData .=  "<div>简介:".$channel["summary"]."</div>";
+	} else {
+		$strData .=  "unkow";
+	}
+	$output["data"] = $strData;
+} else {
+	$output["id"]=0;
+	$output["data"] = "unkow";
+}
+echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
+?>

+ 57 - 14
app/channal/channal.js

@@ -2,9 +2,10 @@ var _my_channal = null;
 var gChannelId;
 var get_channel_list_callback = null;
 channal_list();
-
+var share_win;
 function channal_list_init() {
 	my_channal_list();
+	share_win = iframe_win_init({ container: "share_win", name: "share", width: "500px" });
 	channal_add_dlg_init("channal_add_div");
 }
 function channal_list() {
@@ -47,7 +48,7 @@ function my_channal_list() {
 						html += "<div style='flex:1;'>" + key++ + "</div>";
 						html += "<div style='flex:2;'>" + iterator.name + "</div>";
 						html += "<div style='flex:2;'>";
-						if (iterator.username == getCookie("username")) {
+						if (iterator.username == "_you_") {
 							html += gLocal.gui.your;
 						} else {
 							html += iterator.nickname;
@@ -67,13 +68,47 @@ function my_channal_list() {
 						}
 						//render_status(iterator.status) +
 						html += "</div>";
-						html +=
-							"<div style='flex:1;'><a href='../channal/my_channal_edit.php?id=" +
-							iterator.id +
-							"'>" +
-							gLocal.gui.edit +
-							"</a></div>";
-						html += "<div style='flex:1;'></div>";
+
+						switch (parseInt(iterator.power)) {
+							case 10:
+								html += "<div style='flex:1;'>";
+								html += gLocal.gui.read_only;
+								html += "</div>";
+								html += "<div style='flex:1;'>";
+								html += "</div>";
+								break;
+							case 20:
+								html += "<div style='flex:1;'>";
+								html += gLocal.gui.write;
+								html += "</div>";
+								html += "<div style='flex:1;'>";
+								html +=
+									"<a href='../channal/my_channal_edit.php?id=" +
+									iterator.id +
+									"'>" +
+									gLocal.gui.edit +
+									"</a>";
+								html += "</div>";
+								break;
+							case 30:
+								html += "<div style='flex:1;'>";
+								html += gLocal.gui.owner;
+								html += "</div>";
+								html += "<div style='flex:1;'>";
+								html +=
+									"<a href='../channal/my_channal_edit.php?id=" +
+									iterator.id +
+									"'>" +
+									gLocal.gui.edit +
+									"</a>";
+								html += " <a onclick=\"channel_share('" + iterator.id + "')\">Share</a>";
+								html += "</div>";
+
+								break;
+							default:
+								break;
+						}
+
 						html += "</div>";
 					}
 					$("#my_channal_list").html(html);
@@ -87,6 +122,9 @@ function my_channal_list() {
 	);
 }
 
+function channel_share(id) {
+	share_win.show("../share/share.php?id=" + id + "&type=2");
+}
 /*
 编辑channel信息
 */
@@ -177,12 +215,17 @@ function my_channal_edit(id) {
 					html += "</div>";
 
 					html += "<div id='coop_div' style='padding:5px;position: relative;'>";
-					html += "<h2>"+gLocal.gui.cooperators+"</h2>";
+					html += "<h2>" + gLocal.gui.cooperators + "</h2>";
 
-					html += "<button onclick='add_coop_user()'>"+gLocal.gui.add+gLocal.gui.cooperators+"</button>";
+					html +=
+						"<button onclick='add_coop_user()'>" + gLocal.gui.add + gLocal.gui.cooperators + "</button>";
 					html += "<div id='add_coop_user_dlg' class='float_dlg' style='left: 0;'></div>";
 
-					html += "<button onclick='add_coop_group()' >"+gLocal.gui.add+gLocal.gui.cooperate_group+"</button>";
+					html +=
+						"<button onclick='add_coop_group()' >" +
+						gLocal.gui.add +
+						gLocal.gui.cooperate_group +
+						"</button>";
 					html += "<div id='add_coop_group_dlg' class='float_dlg' style='left: 0;'></div>";
 					html += "<div id='coop_inner' >";
 					if (typeof result.coop == "undefined" || result.coop.length == 0) {
@@ -191,7 +234,7 @@ function my_channal_edit(id) {
 						for (const coop of result.coop) {
 							html += '<div class="file_list_row" style="padding:5px;">';
 							if (coop.type == 0) {
-								html += '<div style="flex:1;">'+gLocal.gui.personal+'</div>';
+								html += '<div style="flex:1;">' + gLocal.gui.personal + "</div>";
 								html += "<div style='flex:3;'>" + coop.user_name.nickname + "</div>";
 							} else {
 								html += '<div style="flex:1;">' + gLocal.gui.group + "</div>";
@@ -200,7 +243,7 @@ function my_channal_edit(id) {
 
 							html += "<div style='flex:3;'>" + coop.power + "</div>";
 							html += "<div class='hover_button' style='flex:3;'>";
-							html += "<button>"+gLocal.gui.remove+"</button>";
+							html += "<button>" + gLocal.gui.remove + "</button>";
 							html += "</div>";
 							html += "</div>";
 						}

+ 17 - 0
app/channal/function.php

@@ -1,5 +1,22 @@
 <?php
 require_once "../path.php";
+
+function channel_get_title($id)
+{
+    if (isset($id)) {
+		PDO_Connect( _FILE_DB_CHANNAL_);
+		$query = "SELECT name FROM channal  WHERE id = ? ";
+		$channel = PDO_FetchRow($query, array($id));
+		if ($channel) {
+			return $channel["name"];
+		} else {
+			return "";
+		}
+    } else {
+        return "";
+    }
+}
+
 class Channal
 {
     public $dbh;

+ 33 - 10
app/channal/get.php

@@ -4,12 +4,14 @@
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../ucenter/function.php';
+require_once '../share/function.php';
 
 if(!isset($_COOKIE["userid"])){
 	echo json_encode(array(), JSON_UNESCAPED_UNICODE);
 	exit;
 }
 
+/*
 # 找我加入的群
 PDO_Connect(""._FILE_DB_GROUP_);
 $query = "SELECT group_id from group_member where user_id = ?  limit 0,100";
@@ -20,15 +22,28 @@ foreach ($my_group as $key => $value) {
 	# code...
 	$userList[]=$value["group_id"];
 }
-
+*/
 //找自己的
 PDO_Connect(""._FILE_DB_CHANNAL_);
-$query = "SELECT * from channal where owner = ?  limit 0,100";
+$query = "SELECT id,owner,name FROM channal WHERE owner = ?  LIMIT 0,100";
 $Fetch_my = PDO_FetchAll($query,array($_COOKIE["userid"]));
 
-$place_holders = implode(',', array_fill(0, count($userList), '?'));
+
 # 找协作的
+$coop_channal =  share_res_list_get($_COOKIE["userid"],2);
 $Fetch_coop = array();
+foreach ($coop_channal as $key => $value) {
+	# return res_id,res_type,power res_title  res_owner_id
+	$res["id"]=$value["res_id"];
+	$res["owner"]=$value["res_owner_id"];
+	$res["name"]=$value["res_title"];
+	$res["power"]=$value["power"];
+	$Fetch_coop[]=$res;
+}
+/*
+
+$place_holders = implode(',', array_fill(0, count($userList), '?'));
+
 $query = "SELECT channal_id FROM cooperation WHERE  user_id IN ($place_holders) ";
 $coop_channal = PDO_FetchAll($query,$userList);
 if(count($coop_channal)>0){
@@ -36,24 +51,32 @@ if(count($coop_channal)>0){
         # code...
         $channal[]=$value["channal_id"];
     }
-    /*  创建一个填充了和params相同数量占位符的字符串 */
+    // 创建一个填充了和params相同数量占位符的字符串 
     $place_holders = implode(',', array_fill(0, count($channal), '?'));
     $query = "SELECT * FROM channal WHERE id IN ($place_holders) order by owner";
     $Fetch_coop = PDO_FetchAll($query,$channal);
 }
+*/
 $all = array_merge_recursive($Fetch_my,$Fetch_coop);
 
-
-
 $_userinfo = new UserInfo();
 
 $output = array();
 foreach ($all as $key => $value) {
     # code...
-    $new = $value;
-    $name = $_userinfo->getName($value["owner"]);
-    $new["username"] = $name["username"];
-	$new["nickname"] = $name["nickname"];
+	$new = $value;
+	$name = $_userinfo->getName($value["owner"]);	
+	if($value["owner"]===$_COOKIE["userid"]){
+		$new["username"] = "_you_";
+		$new["nickname"] = "_you_";
+		$new["power"] = 30;
+	}
+	else{
+		$new["username"] = $name["username"];
+		$new["nickname"] = $name["nickname"];		
+		$new["power"] = $value["power"];		
+	}
+
 	$new["count"] = 0;
     $new["all"] = 1;
     $output[]=$new;

+ 3 - 0
app/channal/my_channal_index.php

@@ -66,6 +66,9 @@ require_once '../studio/index_head.php';
 		
 	</div>
 	
+<div class="modal_win_bg">
+	<div id="share_win" class="iframe_container"></div>
+</div>
 
 <?php
 require_once '../studio/index_foot.php';

+ 34 - 0
app/collect/card.php

@@ -0,0 +1,34 @@
+<?php
+//
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../ucenter/function.php';
+
+
+if (isset($_GET["id"])) {
+	$output["id"]=$_GET["id"];
+	PDO_Connect( _FILE_DB_USER_ARTICLE_);
+	$query = "SELECT title,create_time,owner,summary FROM collect  WHERE id = ? ";
+	$result = PDO_FetchRow($query, array($_GET["id"]));
+	$strData="";
+	if ($result) {
+		
+		$_userinfo = new UserInfo();
+		$name = $_userinfo->getName($result["owner"]);
+
+		$strData .= "<div>标题:".$result["title"]."</div>";
+		$strData .=  "<div>创建人:".$name["nickname"]."</div>";
+		$strData .=  "<div>创建时间:".date("Y/m/d",$result["create_time"]/1000)."</div>";
+		$strData .=  "<div>简介:".$result["summary"]."</div>";
+	} else {
+		$strData .=  "unkow";
+	}
+	$output["data"] = $strData;
+} else {
+	$output["id"]=0;
+	$output["data"] = "unkow";
+}
+echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
+?>

+ 0 - 1
app/dict/css/style.css

@@ -305,7 +305,6 @@ input[type="submit"] {
 	margin: 2px 0;
 	line-height: 160%;
 	font-weight: 400;
-	display: inline-block;
 	font-style: normal;
 }
 

+ 33 - 0
app/doc/card.php

@@ -0,0 +1,33 @@
+<?php
+//
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../ucenter/function.php';
+
+
+if (isset($_GET["id"])) {
+	$output["id"]=$_GET["id"];
+	PDO_Connect( _FILE_DB_FILEINDEX_);
+	$query = "SELECT title,create_time,user_id as owner FROM fileindex  WHERE id = ? ";
+	$result = PDO_FetchRow($query, array($_GET["id"]));
+	$strData="";
+	if ($result) {
+		
+		$_userinfo = new UserInfo();
+		$name = $_userinfo->getName($result["owner"]);
+
+		$strData .= "<div>标题:".$result["title"]."</div>";
+		$strData .=  "<div>创建人:".$name["nickname"]."</div>";
+		$strData .=  "<div>创建时间:".date("Y/m/d",$result["create_time"]/1000)."</div>";
+	} else {
+		$strData .=  "unkow";
+	}
+	$output["data"] = $strData;
+} else {
+	$output["id"]=0;
+	$output["data"] = "unkow";
+}
+echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
+?>

+ 1 - 1
app/doc/coop.php

@@ -49,7 +49,7 @@ $powerlist["10"] = "仅阅读";
 $powerlist["30"] = "可修改";
 //$powerlist["40"] = "管理员";
 
-PDO_Connect("" . _FILE_DB_FILEINDEX_);
+PDO_Connect(_FILE_DB_FILEINDEX_);
 
 echo "<input id='doc_coop_docid' type='hidden' value='{$_doc_id}' />";
 $query = "SELECT * from fileindex where id = ? ";

+ 20 - 0
app/doc/function.php

@@ -0,0 +1,20 @@
+<?php
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+
+function pcs_get_title($id)
+{
+    if (isset($id)) {
+		PDO_Connect("" . _FILE_DB_FILEINDEX_);
+		$query = "SELECT title FROM fileindex  WHERE id = ? ";
+		$file = PDO_FetchRow($query, array($id));
+		if ($file) {
+			return $file["title"];
+		} else {
+			return "";
+		}
+    } else {
+        return "";
+    }
+}

+ 27 - 0
app/group/function.php

@@ -31,6 +31,7 @@ class GroupInfo
         $this->dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
         $buffer = array();
+        $parentId = array();
     }
 
     public function getName($id)
@@ -57,5 +58,31 @@ class GroupInfo
             $buffer[$id] = "";
             return $buffer[$id];
         }
+	}
+	
+	public function getParentId($id)
+    {
+        if (empty($id)) {
+            return "";
+        }
+        if (isset($parentId[$id])) {
+            return $parentId[$id];
+        }
+        if ($this->dbh) {
+            $query = "SELECT parent FROM group_info WHERE id= ? ";
+            $stmt = $this->dbh->prepare($query);
+            $stmt->execute(array($id));
+            $user = $stmt->fetch(PDO::FETCH_ASSOC);
+            if ($user) {
+                $parentId[$id] = $user["parent"];
+                return $parentId[$id];
+            } else {
+                $parentId[$id] = "";
+                return $parentId[$id];
+            }
+        } else {
+            $parentId[$id] = "";
+            return $parentId[$id];
+        }
     }
 }

+ 8 - 3
app/group/get.php

@@ -5,6 +5,7 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
+require_once '../share/function.php';
 
 $output = array();
 if (isset($_GET["id"])) {
@@ -25,8 +26,9 @@ if (isset($_GET["id"])) {
             $parent_group = PDO_FetchRow($query, array($Fetch["parent"]));
             $output["parent"] = $parent_group;
         }
-        #列出组文件
+        #列出组共享资源
         {
+			/*
             PDO_Connect("" . _FILE_DB_FILEINDEX_);
             $query = "SELECT * FROM power  WHERE user = ? ";
             $fileList = PDO_FetchAll($query, array($id));
@@ -39,8 +41,11 @@ if (isset($_GET["id"])) {
                 } else {
                     $fileList[$key]["title"] = "";
                 }
-            }
-            $output["file"] = $fileList;
+			}
+			
+			$output["file"] = $fileList;
+			*/
+			$output["file"] =share_res_list_get($id);
         }
     }
 }

+ 36 - 5
app/group/group.js

@@ -73,7 +73,7 @@ function my_group_list() {
 							"</a></div>";
 						html += "<div style='flex:1;'><div class='hover_button'>";
 						if (parseInt(iterator.power) == 0) {
-							//管理员可以删除group
+							//只有管理员可以删除group
 							html +=
 								"<button onclick=\"group_del('" +
 								iterator.group_id +
@@ -118,7 +118,7 @@ function group_list(id, list) {
 					$("#curr_group").html("/" + result.info.name);
 
 					if (result.parent) {
-						//如果是project 显示 group名
+						//如果是project 显示 group名
 						$("#parent_group").html(
 							" / <a href='../group/index.php?id=" +
 								result.parent.id +
@@ -175,16 +175,46 @@ function group_list(id, list) {
 						for (const iterator of result.file) {
 							html += '<div class="file_list_row" style="padding:5px;">';
 							html += "<div style='flex:1;'>" + key++ + "</div>";
-							html += "<div style='flex:2;'>" + iterator.title + "</div>";
+							html += "<div style='flex:1;'>";
+							//资源类型
+							html += "<svg class='icon'>";
+							let cardUrl = "";
+							switch (parseInt(iterator.res_type)) {
+								case 1: //pcs
+									html += "<use xlink:href='../studio/svg/icon.svg#ic_person'></use>";
+									cardUrl = "../doc/card.php";
+									break;
+								case 2: //channel
+									html += "<use xlink:href='../studio/svg/icon.svg#channel_leaves'></use>";
+									cardUrl = "../channal/card.php";
+									break;
+								case 3: //article
+									html += "<use xlink:href='../studio/svg/icon.svg#channel_leaves'></use>";
+									cardUrl = "../article/card.php";
+									break;
+								case 4: //collection
+									break;
+								case 5: //channel片段
+									break;
+								default:
+									html += "<use xlink:href='../studio/svg/icon.svg#ic_person'></use>";
+									break;
+							}
+
+							html += "</svg>";
+							html += "</div>";
 							html += "<div style='flex:2;'>";
-							switch (iterator.power) {
+							html += "<guide url='" + cardUrl + "' gid='" + iterator.res_id + "'>";
+							html += iterator.res_title + "</guide></div>";
+							html += "<div style='flex:2;'>";
+							switch (parseInt(iterator.power)) {
 								case 10:
 									html += gLocal.gui.read_only;
 									break;
 								case 20:
+									html += gLocal.gui.write;
 									break;
 								case 30:
-									html += gLocal.gui.write;
 									break;
 								default:
 									break;
@@ -203,6 +233,7 @@ function group_list(id, list) {
 					html += "</div>";
 
 					$("#my_group_list").html(html);
+					guide_init();
 				} catch (e) {
 					console.error(e);
 				}

+ 12 - 2
app/group/list.php

@@ -6,9 +6,19 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
 
-//没有id 列出 我的群组
+//列出 我j参与的群组
 PDO_Connect("" . _FILE_DB_GROUP_);
 $query = "SELECT group_name,group_id,power FROM group_member  WHERE level = 0 and user_id=?";
 $Fetch = PDO_FetchAll($query, array($_COOKIE["userid"]));
-
+foreach ($Fetch as $key => $value) {
+	# code...
+	$query = "SELECT name FROM group_info  WHERE id=?";
+	$groupInfo = PDO_FetchRow($query, array($value["group_id"]));
+	if($groupInfo){
+		$Fetch[$key]["group_name"]=$groupInfo["name"];
+	}
+	else{
+		$Fetch[$key]["group_name"]="";
+	}
+}
 echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);

+ 5 - 1
app/guide/guide.js

@@ -20,8 +20,12 @@ function guide_init() {
 			return;
 		}
 		let gid = $(this).attr("gid");
+		let url = $(this).attr("url");
+		if (typeof url == "undefined" || url == "") {
+			url = "../guide/get.php";
+		}
 		$.get(
-			"../guide/get.php",
+			url,
 			{
 				id: gid,
 			},

+ 1 - 0
app/path.php

@@ -120,3 +120,4 @@ define("_FILE_DB_HOSTSETTING_", "sqlite:" . __DIR__ . "/../tmp/user/hostsetting.
 define("_FILE_DB_USER_SENTENCE_HISTORAY_", "sqlite:" . __DIR__ . "/../tmp/user/usent_historay.db3");
 define("_FILE_DB_USER_ACTIVE_", "sqlite:" . __DIR__ . "/../tmp/user/user_active.db3");
 define("_FILE_DB_USER_ACTIVE_LOG_", "sqlite:" . __DIR__ . "/../tmp/user/user_active_log.db3");
+define("_FILE_DB_USER_SHARE_", "sqlite:" . __DIR__ . "/../tmp/user/share.db3");

+ 44 - 0
app/share/coop_del.php

@@ -0,0 +1,44 @@
+<?php
+//查询term字典
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../public/function.php';
+require_once '../ucenter/function.php';
+require_once '../group/function.php';
+
+$respond['status']=0;
+$respond['message']="成功";
+if(isset($_POST["res_id"])){
+	PDO_Connect(_FILE_DB_USER_SHARE_);
+
+    $query = "DELETE FROM share_cooperator WHERE res_id=? and cooperator_id = ? ";
+	$sth = $PDO->prepare($query);
+	if($sth)
+	{
+		# code...
+		$sth->execute(array($_POST["res_id"],
+							$_POST["user_id"]
+						));
+		if (!$sth || ($sth && $sth->errorCode() != 0)) {
+			/*  识别错误  */
+			$error = PDO_ErrorInfo();
+			$respond['status']=1;
+			$respond['message']=$error[2];
+			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+			exit;
+		}
+		else{
+			$respond['status']=0;
+			$respond['message']="成功";
+		}							
+	}
+
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+}
+else{
+	$respond['status']=1;
+	$respond['message']="no res id";
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+}
+?>

+ 43 - 0
app/share/coop_get.php

@@ -0,0 +1,43 @@
+<?php
+//查询term字典
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../public/function.php';
+require_once '../ucenter/function.php';
+require_once '../group/function.php';
+
+if(isset($_GET["res_id"])){
+    PDO_Connect(_FILE_DB_USER_SHARE_);
+    $id=$_GET["res_id"];
+    $query = "SELECT * FROM share_cooperator  WHERE res_id = ? ";
+	$Fetch = PDO_FetchAll($query,array($id));
+
+	#获取协作者
+	if(count($Fetch)>0){
+		$user_info = new UserInfo();
+		$group_info = new GroupInfo();
+		foreach ($Fetch as $key => $value) {
+			# code...
+			switch ($value["cooperator_type"]) {
+				case 0:
+					$Fetch[$key]["user"] = $user_info->getName($value["cooperator_id"]);
+					break;
+				case 1:
+					# 小组写作者
+					$Fetch[$key]["user"] = $group_info->getName($value["cooperator_id"]);
+					$Fetch[$key]["parent_name"] = $group_info->getName($group_info->getParentId($value["cooperator_id"]));
+					break;
+				default:
+					# 未知类型
+					$Fetch[$key]["user"] ="unkow";
+					break;
+			}
+		}
+	}
+    echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
+}
+else{
+    echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+}
+?>

+ 45 - 0
app/share/coop_post.php

@@ -0,0 +1,45 @@
+<?php
+//查询term字典
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../public/function.php';
+require_once '../ucenter/function.php';
+require_once '../group/function.php';
+
+$respond['status']=0;
+$respond['message']="成功";
+if(isset($_POST["res_id"])){
+	PDO_Connect(_FILE_DB_USER_SHARE_);
+
+    $query = "UPDATE share_cooperator set power = ? WHERE res_id=? and cooperator_id = ? ";
+	$sth = $PDO->prepare($query);
+	if($sth)
+	{
+		# code...
+		$sth->execute(array($_POST["power"],
+							$_POST["res_id"],
+							$_POST["user_id"]
+						));
+		if (!$sth || ($sth && $sth->errorCode() != 0)) {
+			/*  识别错误  */
+			$error = PDO_ErrorInfo();
+			$respond['status']=1;
+			$respond['message']=$error[2];
+			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+			exit;
+		}
+		else{
+			$respond['status']=0;
+			$respond['message']="成功";
+		}							
+	}
+
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+}
+else{
+	$respond['status']=1;
+	$respond['message']="no res id";
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+}
+?>

+ 52 - 0
app/share/coop_put.php

@@ -0,0 +1,52 @@
+<?php
+//查询term字典
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../public/function.php';
+require_once '../ucenter/function.php';
+require_once '../group/function.php';
+
+$respond['status']=0;
+$respond['message']="成功";
+if(isset($_POST["res_id"])){
+	PDO_Connect(_FILE_DB_USER_SHARE_);
+	$PDO->beginTransaction();
+    $query = "INSERT  INTO share_cooperator ('id','res_id','res_type','cooperator_id','cooperator_type','power','create_time','modify_time','is_deleted') VALUES (null,?,?,?,?,?,?,?,?) ";
+	$sth = $PDO->prepare($query);
+	$data = json_decode($_POST["user_info"]);
+	foreach ($data as $key => $user) {
+		# code...
+		$sth->execute(array($_POST["res_id"],
+							$_POST["res_type"],
+							$user->id,
+							$user->type,
+							$_POST["power"],
+							mTime(),
+							mTime(),
+							0
+						));
+	}
+	$PDO->commit();
+        
+	if (!$sth || ($sth && $sth->errorCode() != 0)) {
+		/*  识别错误且回滚更改  */
+		$PDO->rollBack();
+		$error = PDO_ErrorInfo();
+		$respond['status']=1;
+		$respond['message']=$error[2];
+		echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+		exit;
+	}
+	else{
+		$respond['status']=0;
+		$respond['message']="成功";
+	}	
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+}
+else{
+	$respond['status']=1;
+	$respond['message']="no res id";
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+}
+?>

+ 121 - 0
app/share/function.php

@@ -0,0 +1,121 @@
+<?php 
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../public/function.php';
+require_once '../ucenter/function.php';
+require_once '../channal/function.php';
+require_once '../doc/function.php';
+/*
+获取某用户的可见的协作资源
+$res_type 见readme.md#资源类型 -1全部类型资源
+*/
+function share_res_list_get($userid,$res_type=-1){
+	# 找我加入的群
+	$dbhGroup = new PDO(_FILE_DB_GROUP_, "", "");
+    $dbhGroup->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+	$query = "SELECT group_id from group_member where user_id = ?  limit 0,100";
+	$stmtGroup = $dbhGroup->prepare($query);
+	$stmtGroup->execute(array($userid));
+	$my_group = $stmtGroup->fetchAll(PDO::FETCH_ASSOC);
+	$userList = array();
+	$userList[] = $userid;
+	foreach ($my_group as $key => $value) {
+		# code...
+		$userList[]=$value["group_id"];
+	}
+	
+	$place_holders = implode(',', array_fill(0, count($userList), '?'));
+	$Fetch=array();
+	$PDO = new PDO(_FILE_DB_USER_SHARE_, "", "");
+    $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+	if($res_type==-1){
+		$query = "SELECT res_id,res_type,power FROM share_cooperator  WHERE is_deleted=0 AND cooperator_id IN ($place_holders) group by res_id ";
+		$stmt = $PDO->prepare($query);
+		$stmt->execute($userList);
+		$Fetch =$stmt->fetchAll(PDO::FETCH_ASSOC);
+	}
+	else{
+		$userList[]=$res_type;
+		$query = "SELECT res_id,res_type,power FROM share_cooperator  WHERE is_deleted=0 AND  cooperator_id IN ($place_holders) AND res_type = ? group by res_id";
+		$stmt = $PDO->prepare($query);
+		$stmt->execute($userList);
+		$Fetch =$stmt->fetchAll(PDO::FETCH_ASSOC);
+	}
+
+	$channel = new Channal(); 
+	foreach ($Fetch as $key => $res) {
+		# 获取资源标题 和所有者 
+		switch ($res["res_type"]) {
+			case 1:
+				# pcs 文档
+				$Fetch[$key]["res_title"]=pcs_get_title($res["res_id"]);
+				break;
+			case 2:
+				# channel
+				$channelInfo = $channel->getChannal($res["res_id"]);
+				if($channelInfo){
+					$Fetch[$key]["res_title"]=$channelInfo["name"];
+					$Fetch[$key]["res_owner_id"]=$channelInfo["owner"];
+				}
+				else{
+					$Fetch[$key]["res_title"]="_unkown_";
+					$Fetch[$key]["res_owner_id"]="_unkown_";
+				}
+				
+				break;
+			case 3:
+				# code...
+				break;
+			case 4:
+				# code...
+				break;
+			case 5:
+				# code...
+				break;
+																		
+			default:
+				# code...
+				break;
+		}
+	}
+
+	return $Fetch;
+
+}
+
+//对某个共享资源的权限
+function share_get_res_power($userid,$res_id){
+		# 找我加入的群
+		$dbhGroup = new PDO(_FILE_DB_GROUP_, "", "");
+		$dbhGroup->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+		$query = "SELECT group_id from group_member where user_id = ?  limit 0,100";
+		$stmtGroup = $dbhGroup->prepare($query);
+		$stmtGroup->execute(array($userid));
+		$my_group = $stmtGroup->fetchAll(PDO::FETCH_ASSOC);
+		$userList = array();
+		$userList[] = $userid;
+		foreach ($my_group as $key => $value) {
+			# code...
+			$userList[]=$value["group_id"];
+		}
+		
+		$place_holders = implode(',', array_fill(0, count($userList), '?'));
+		$Fetch=array();
+		$PDO = new PDO(_FILE_DB_USER_SHARE_, "", "");
+		$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+			$userList[]=$res_id;
+			$query = "SELECT power FROM share_cooperator  WHERE is_deleted=0 AND  cooperator_id IN ($place_holders) AND res_id = ? ";
+			$stmt = $PDO->prepare($query);
+			$stmt->execute($userList);
+			$Fetch =$stmt->fetchAll(PDO::FETCH_ASSOC);
+		$power=0;
+		foreach ($Fetch as $key => $value) {
+			# code...
+			if((int)$value["power"]>$power){
+				$power = $value["power"];
+			}
+		}
+		return $power;
+}
+?>

+ 15 - 0
app/share/readme.md

@@ -0,0 +1,15 @@
+# 共享与协作
+
+## 资源类型
+
+-   1 PCS 文档
+-   2 Channel 版本
+-   3 Article 文章
+-   4 Collection 文集
+-   5 版本片段
+
+## 权限
+
+-   10 只读
+-   20 写入
+-   30 拥有者

+ 338 - 0
app/share/share.js

@@ -0,0 +1,338 @@
+var _res_id;
+var _res_type;
+var gUserList = new Array();
+
+function share_load(id, type) {
+	refresh_coop_list(id);
+}
+
+function refresh_coop_list(id) {
+	$.get(
+		"../share/coop_get.php",
+		{
+			res_id: id,
+		},
+		function (data, status) {
+			if (status == "success") {
+				let result = JSON.parse(data);
+				$("#coop_list").html(render_coop_list(result));
+			}
+		}
+	);
+}
+
+function render_coop_list(cooplist) {
+	let html = "";
+	if (typeof cooplist == "undefined" || cooplist.length == 0) {
+		html += gLocal.gui.empty_null_mark;
+	} else {
+		for (const coop of cooplist) {
+			html += '<div class="file_list_row" style="padding:5px;">';
+			let username;
+			if (coop.cooperator_type == 0) {
+				username = coop.user.nickname;
+				html += '<div style="flex:1;" title="' + gLocal.gui.personal + '">';
+				html += "<svg class='icon'>";
+				html += "	<use xlink:href='../studio/svg/icon.svg#ic_person'></use>";
+				html += "</svg>";
+				html += "</div>";
+				html += "<div style='flex:3;'>" + username + "</div>";
+			} else {
+				username = coop.user;
+				html += '<div style="flex:1;" title="' + gLocal.gui.group + '">';
+				html += "<svg class='icon'>";
+				html += "	<use xlink:href='../studio/svg/icon.svg#ic_two_person'></use>";
+				html += "</svg>";
+				html += "</div>";
+				html += "<div style='flex:3;'>";
+				if (coop.parent_name != "") {
+					html += coop.parent_name + "/";
+				}
+				html += username + "</div>";
+			}
+
+			html += "<div style='flex:3;'>";
+			let power = [
+				{ id: 10, string: "查看者" },
+				{ id: 20, string: "编辑者" },
+			];
+			html += "<select onchange=\"coop_set_power('" + coop.cooperator_id + "',this)\">";
+			for (const iterator of power) {
+				html += "<option value='" + iterator.id + "' ";
+				if (iterator.id == coop.power) {
+					html += " selected ";
+				}
+				html += ">" + iterator.string + "</option>";
+			}
+			html += "</select>";
+
+			html += "</div>";
+			html += "<div class='hover_button' style='flex:3;'>";
+			html +=
+				"<button onclick=\"coop_remove('" +
+				coop.cooperator_id +
+				"','" +
+				username +
+				"')\">" +
+				gLocal.gui.remove +
+				"</button>";
+			html += "</div>";
+			html += "</div>";
+		}
+	}
+	return html;
+}
+
+function username_search_keyup(e, obj) {
+	var keynum;
+	if (window.event) {
+		// IE
+		keynum = e.keyCode;
+	} else if (e.which) {
+		// Netscape/Firefox/Opera
+		keynum = e.which;
+	}
+	var keychar = String.fromCharCode(keynum);
+	if (keynum == 13) {
+	} else {
+		if (obj.value.length > 0) {
+			let type = $("#user_type").val();
+			username_search(obj.value, type);
+		} else {
+			$("#user_search").html("");
+		}
+	}
+}
+
+function user_selected(id, name, type) {
+	if (parseInt(type) == 0) {
+		gUserList.push({ id: id, name: name, type: type });
+		$("#user_list").html(render_user_list());
+		$("#user_search").html("");
+	} else {
+		$.get("../group/get.php", { id: id }, function (data, status) {
+			if (status == "success") {
+				try {
+					let result = JSON.parse(data);
+					gUserList.push({ id: id, name: name, type: type, project: result.children });
+					$("#user_list").html(render_user_list());
+					$("#user_search").html("");
+				} catch (e) {}
+			}
+		});
+	}
+}
+function render_user_list() {
+	let html = "<ul>";
+	let arrIndex = 0;
+	for (const iterator of gUserList) {
+		html += "<li>" + iterator.name + ' <a onclick="userlist_del(' + arrIndex + ')">删除</a>';
+		if (iterator.type == 1) {
+			//如果是小组,显示项目列表
+			html += "<div>";
+			html += "<div><input id='prj_" + iterator.id + "' checked type='checkbox' />全组可用</div>";
+			if (typeof iterator.project != "undefined") {
+				for (const project of iterator.project) {
+					html += "<div><input id='prj_" + project.id + "' type='checkbox' />" + project.name + "</div>";
+				}
+			}
+			html += "</div>";
+		}
+		html += "</li>";
+		arrIndex++;
+	}
+	html += "</ul>";
+	return html;
+}
+
+//从候选列表中删除一个元素
+function userlist_del(index) {
+	let deleted = gUserList.splice(index, 1);
+	$("#user_list").html(render_user_list());
+	if (gUserList.length == 0) {
+		$("#coop_new_tools").hide();
+	}
+}
+function username_search(keyword, type) {
+	//let obj = document.querySelector("#cooperator_type_user");
+	if (type == 1) {
+		$.get(
+			"../ucenter/get.php",
+			{
+				username: keyword,
+			},
+			function (data, status) {
+				let result;
+				try {
+					result = JSON.parse(data);
+				} catch (error) {
+					console(error);
+				}
+				let html = "<ul id='user_search_list'>";
+				if (result.length > 0) {
+					$("#coop_new_tools").show();
+					for (const iterator of result) {
+						html +=
+							"<li onclick=\"user_selected('" +
+							iterator.id +
+							"','" +
+							iterator.username +
+							"',0)\">" +
+							iterator.nickname +
+							"@" +
+							iterator.username +
+							"</li>";
+					}
+				} else {
+					$("#coop_new_tools").hide();
+				}
+				html += "</ul>";
+				$("#user_search").html(html);
+			}
+		);
+	} else {
+		$.get(
+			"../group/get_name.php",
+			{
+				name: keyword,
+			},
+			function (data, status) {
+				let result;
+				try {
+					result = JSON.parse(data);
+				} catch (error) {
+					console(error);
+				}
+				let html = "<ul id='user_search_list'>";
+				if (result.length > 0) {
+					$("#coop_new_tools").show();
+					for (const iterator of result) {
+						html +=
+							"<li onclick=\"user_selected('" +
+							iterator.id +
+							"','" +
+							iterator.name +
+							"',1)\">" +
+							iterator.name +
+							"</li>";
+					}
+				} else {
+					$("#coop_new_tools").hide();
+				}
+				html += "</ul>";
+				$("#user_search").html(html);
+			}
+		);
+	}
+}
+
+function add_coop() {
+	let coopList = new Array();
+	for (const itUser of gUserList) {
+		if (itUser.type == 0) {
+			coopList.push({ id: itUser.id, type: itUser.type });
+		} else if (itUser.type == 1) {
+			let obj = document.querySelector("#prj_" + itUser.id);
+			if (obj.checked) {
+				coopList.push({ id: itUser.id, type: itUser.type });
+			}
+			if (typeof itUser.project != "undefined") {
+				for (const project of itUser.project) {
+					obj = document.querySelector("#prj_" + project.id);
+					if (obj.checked) {
+						coopList.push({ id: project.id, type: itUser.type });
+					}
+				}
+			}
+		}
+	}
+	$.post(
+		"../share/coop_put.php",
+		{
+			res_id: _res_id,
+			res_type: _res_type,
+			user_info: JSON.stringify(coopList),
+			power: $("#coop_new_power").val(),
+		},
+		function (data, status) {
+			cancel_coop();
+			let result = JSON.parse(data);
+			if (parseInt(result.status) == 0) {
+				refresh_coop_list(_res_id);
+			} else {
+				alert(result.message);
+			}
+		}
+	);
+}
+
+function cancel_coop() {
+	$("#user_list").html("");
+	$("#user_search").html("");
+	$("#coop_new_tools").hide();
+	$("#search_user").val("");
+	gUserList = new Array();
+}
+
+function coop_remove(userid, username) {
+	let strMsg = "要删除%name%吗?";
+	if (confirm(strMsg.replace("%name%", username))) {
+		$.post(
+			"../share/coop_del.php",
+			{
+				res_id: _res_id,
+				res_type: _res_type,
+				user_id: userid,
+			},
+			function (data, status) {
+				cancel_coop();
+				let result = JSON.parse(data);
+				if (parseInt(result.status) == 0) {
+					refresh_coop_list(_res_id);
+				} else {
+					alert(result.message);
+				}
+			}
+		);
+	}
+}
+
+function coop_set_power(userid, power) {
+	{
+		$.post(
+			"../share/coop_post.php",
+			{
+				res_id: _res_id,
+				res_type: _res_type,
+				user_id: userid,
+				power: $(power).val(),
+			},
+			function (data, status) {
+				cancel_coop();
+				let result = JSON.parse(data);
+				if (parseInt(result.status) == 0) {
+					refresh_coop_list(_res_id);
+				} else {
+					alert(result.message);
+				}
+			}
+		);
+	}
+}
+
+function get_group_project(id) {
+	$.get(
+		"../group/get.php",
+		{
+			id: id,
+		},
+		function (data, status) {
+			let result = JSON.parse(data);
+			if (parseInt(result.status) == 0) {
+				refresh_coop_list(_res_id);
+			} else {
+				alert(result.message);
+			}
+		}
+	);
+}

+ 117 - 0
app/share/share.php

@@ -0,0 +1,117 @@
+<?php
+require_once '../studio/index_head.php';
+?>
+
+<body>
+<script language="javascript" src="../share/share.js"></script>
+<style>
+.item_block{
+	border-top: 1px solid var(--border-line-color);
+    padding: 0 0 2em 0;
+}
+#coop_new_tools{
+	display:none;
+}
+select{
+	background-color:unset;
+}
+input[type="text"], input[type="input"], input[type="password"], textarea{
+	background-color:unset;
+	color:unset;
+}
+#user_search {
+    border: 1px solid var(--border-line-color);
+    display: inline-block;
+    position: absolute;
+    background-color: var(--drop-bg-color);
+}
+#user_search_list li{
+	padding:5px;
+}
+#user_search_list li:hover{
+	background-color: var(--link-color);
+    color: var(--tool-color);
+}
+.file_list_row:hover {
+    background-color: var(--link-color);
+}
+.icon{
+	fill: var(--main-color);
+	height: 28px;
+    width: 28px;
+}
+</style>
+<div class=" " >
+	<div class="item_block">
+		<h2>隐私设置</h2>
+		<ul>
+		<li><input type="radio" name="list" checked />私有</li>
+		<li><input type="radio" name="list" />公开列出</li>
+		<li><input type="radio" name="list" />公开编辑</li>
+		</ul>
+	</div>
+	<div class="item_block">
+		<h2>分享链接</h2>
+		<div><button>创建分享链接</button></div>
+		<div id="share_link">
+			<button>关闭分享链接</button>
+			<div style="display:flex;"><span style="max-width:200px;"><input type="input" name="" /></span><button>复制分享链接</button></div>
+			<select>
+					<option value="10">查看者</option>
+					<option value="20">编辑者</option>
+			</select>
+		</div>
+	</div>	
+	<div class="item_block">
+		<h2>协作</h2>
+		<div>
+			<div style="display:flex;">
+			<span>
+				<svg class="icon">
+					<use xlink:href="../studio/svg/icon.svg#ic_add_person"></use>
+				</svg>
+			</span>
+			<span style="max-width:200px;">
+			<input id="search_user" type="input" name="" placeholder="输入用户名或组名" onkeyup="username_search_keyup(event,this)" />
+			</span>
+			<select id="user_type" >
+				<option value="1">用户</option>
+				<option value="2">工作组</option>
+				<option value="3">项目</option>
+			</select>
+			</div>
+			<div id="user_search">
+			</div>
+			<div id="user_list_shell">
+				<div id="user_list">
+				</div>
+				<div id="coop_new_tools">
+					<select id="coop_new_power">
+						<option value="10">查看者</option>
+						<option value="20">编辑者</option>
+					</select>
+					<button onclick="add_coop()">添加</button>
+					<button onclick="cancel_coop()">取消</button>
+				</div>
+			</div>
+		</div>
+		<div>
+		<h3>有权使用的人</h3>
+		<div id="coop_list">
+		</div>
+		</div>
+	</div>	
+</div>
+<script>
+$(document).ready(function(){
+	<?php
+	if(isset($_GET["id"]) && isset($_GET["type"])){
+		echo "_res_id = '{$_GET["id"]}'; \n";
+		echo "_res_type = '{$_GET["type"]}'; \n";
+		echo "share_load('{$_GET["id"]}','{$_GET["type"]}');";
+	}
+	?>
+});
+</script>
+</body>
+</html>

+ 10 - 0
app/studio/index_head.php

@@ -64,6 +64,16 @@ require_once '../public/load_lang.php';
 	<script src="../term/term_popup.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
 
+	<script language="javascript" src="../guide/guide.js"></script>
+	<link type="text/css" rel="stylesheet" href="../guide/guide.css"/>
+
+	<script src="../public/js/marked.js"></script>
+	<script src="../public/js/mermaid.min.js"></script>
+
+	<script src="../widget/iframe_modal_win.js"></script>
+	<link type="text/css" rel="stylesheet" href="../widget/iframe_modal_win.css"/>
+
+
 	<script type="text/javascript">
 	<?php require_once '../public/load_lang_js.php';//加载js语言包?>
 		

+ 16 - 3
app/term/note.js

@@ -326,7 +326,12 @@ function render_channal_list(channalinfo) {
 		'<div class="channel_select"><input type="checkbox" ' + checked + " channal_id='" + channalinfo.id + "'></div>";
 	output += "<div class='head'>";
 	output += "<span class='head_img'>";
-	output += channalinfo.nickname.slice(0, 2);
+	if (channalinfo.nickname == "_you_") {
+		output += gLocal.gui.your.slice(0, 1);
+	} else {
+		output += channalinfo.nickname.slice(0, 1);
+	}
+
 	output += "</span>";
 	output += "</div>";
 
@@ -341,7 +346,11 @@ function render_channal_list(channalinfo) {
 	output += channalinfo["name"];
 
 	output += "</a>";
-	output += "@" + channalinfo["nickname"];
+	if (channalinfo.nickname == "_you_") {
+		output += "@" + gLocal.gui.your;
+	} else {
+		output += "@" + channalinfo["nickname"];
+	}
 	output += "</div>";
 
 	output += "<div class='userinfo_channal'>";
@@ -666,7 +675,11 @@ function add_new_tran_button_click(obj) {
 				"' ,'" +
 				iterator.id +
 				"',this)";
-			html += '">' + iterator.name + "</li>";
+			html += '">' + iterator.name;
+			if (parseInt(iterator.power) < 20) {
+				html += "(建议)";
+			}
+			html += "</li>";
 		}
 	}
 	html += "</ul>";

+ 144 - 31
app/usent/sent_post.php

@@ -5,6 +5,7 @@ require_once "../public/_pdo.php";
 require_once "../public/function.php";
 require_once "../usent/function.php";
 require_once "../ucenter/active.php";
+require_once "../share/function.php";
 
 #检查是否登陆
 if (!isset($_COOKIE["userid"])) {
@@ -28,6 +29,8 @@ $respond['channal'] = $_POST["channal"];
 $respond['text'] = $_POST["text"];
 $respond['editor'] = $_COOKIE["userid"];
 
+add_edit_event(_SENT_EDIT_, "{$_POST["book"]}-{$_POST["para"]}-{$_POST["begin"]}-{$_POST["end"]}@{$_POST["channal"]}");
+
 #先查询对此channal是否有权限修改
 $cooperation = 0;
 $text_lang = "en";
@@ -44,8 +47,11 @@ if (isset($_POST["channal"])) {
     $respond['lang'] = $text_lang;
     if ($fetch && $fetch["owner"] == $_COOKIE["userid"]) {
         #自己的channal
-        $cooperation = 1;
+        $cooperation = 30;
     } else {
+		$sharePower = share_get_res_power($_COOKIE["userid"],$_POST["channal"]);
+		$cooperation = $sharePower;
+		/*
         $query = "SELECT count(*) FROM cooperation WHERE channal_id= ? and user_id=? ";
         $fetch = PDO_FetchOne($query, array($_POST["channal"], $_COOKIE["userid"]));
         if ($fetch > 0) {
@@ -54,7 +60,8 @@ if (isset($_POST["channal"])) {
         } else {
             #无协作权限
             $cooperation = 0;
-        }
+		}
+		*/
     }
 } else {
     $respond["status"] = 1;
@@ -63,7 +70,12 @@ if (isset($_POST["channal"])) {
     exit;
 }
 
-add_edit_event(_SENT_EDIT_, "{$_POST["book"]}-{$_POST["para"]}-{$_POST["begin"]}-{$_POST["end"]}@{$_POST["channal"]}");
+if($cooperation==0){
+	$respond['message'] = "no power";
+	$respond['status'] = 1;
+	echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+    exit;
+}
 
 PDO_Connect("" . _FILE_DB_SENTENCE_);
 
@@ -79,27 +91,27 @@ if ((isset($_POST["id"]) && empty($_POST["id"])) || !isset($_POST["id"])) {
 
 if ($_id == false) {
     # 没有id新建
-    if ($cooperation == 1) {
-        #有权限
+    if ($cooperation >=20) {
+        #有写入权限
         $query = "INSERT INTO sentence (id,
-                                            parent,
-                                            book,
-                                            paragraph,
-                                            begin,
-                                            end,
-                                            channal,
-                                            tag,
-                                            author,
-                                            editor,
-                                            text,
-                                            language,
-                                            ver,
-                                            status,
-                                            strlen,
-                                            modify_time,
-                                            receive_time,
-                                            create_time
-                                            )
+                                        parent,
+                                        book,
+                                        paragraph,
+                                        begin,
+                                        end,
+                                        channal,
+                                        tag,
+                                        author,
+                                        editor,
+                                        text,
+                                        language,
+                                        ver,
+                                        status,
+                                        strlen,
+                                        modify_time,
+                                        receive_time,
+                                        create_time
+                                        )
 										VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
         $stmt = $PDO->prepare($query);
         $newId = UUID::v4();
@@ -141,15 +153,65 @@ if ($_id == false) {
             }
         }
     } else {
-        #TO DO没权限 插入建议数据
-        $respond['message'] = "没有权限";
-        $respond['status'] = 1;
+		#没写入权限 插入pr数据
+		$query = "INSERT INTO sent_pr (id,
+										book,
+										paragraph,
+										begin,
+										end,
+										channel,
+										tag,
+										author,
+										editor,
+										text,
+										language,
+										ver,
+										status,
+										strlen,
+										modify_time,
+										receive_time,
+										create_time
+										)
+										VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+		$stmt = $PDO->prepare($query);
+		$newId = UUID::v4();
+		# 初始状态 1 未处理
+		$stmt->execute(array($newId,
+							$_POST["book"],
+							$_POST["para"],
+							$_POST["begin"],
+							$_POST["end"],
+							$_POST["channal"],
+							"",
+							"[]",
+							$_COOKIE["userid"],
+							$_POST["text"],
+							$text_lang,
+							1,
+							1,
+							mb_strlen($_POST["text"], "UTF-8"),
+							mTime(),
+							mTime(),
+							mTime(),
+							));
+		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+			/*  识别错误  */
+			$error = PDO_ErrorInfo();
+			$respond['message'] = $error[2];
+			$respond['status'] = 1;
+			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+			exit;
+		} else {
+		# 没错误
+			$respond['message'] = "已经提交修改建议";
+			$respond['status'] = 0;
+		}
     }
 } else {
     /* 修改现有数据 */
     #判断是否有修改权限
-    if ($cooperation == 1) {
-        #有权限
+    if ($cooperation >=20) {
+        #有写入权限
         $query = "UPDATE sentence SET text= ?  , strlen = ? , editor = ? , receive_time= ?  , modify_time= ?   where  id= ?  ";
         $stmt = PDO_Execute($query,
             array($_POST["text"],
@@ -176,9 +238,60 @@ if ($_id == false) {
             }
         }
     } else {
-        #TO DO没权限 插入建议数据
-        $respond['message'] = "没有权限";
-        $respond['status'] = 1;
+        #TO DO没权限 插入pr数据
+		#没写入权限 插入pr数据
+		$query = "INSERT INTO sent_pr (id,
+										book,
+										paragraph,
+										begin,
+										end,
+										channel,
+										tag,
+										author,
+										editor,
+										text,
+										language,
+										ver,
+										status,
+										strlen,
+										modify_time,
+										receive_time,
+										create_time
+										)
+										VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+		$stmt = $PDO->prepare($query);
+		$newId = UUID::v4();
+		# 初始状态 1 未处理
+		$stmt->execute(array($newId,
+							$_POST["book"],
+							$_POST["para"],
+							$_POST["begin"],
+							$_POST["end"],
+							$_POST["channal"],
+							"",
+							"[]",
+							$_COOKIE["userid"],
+							$_POST["text"],
+							$text_lang,
+							1,
+							1,
+							mb_strlen($_POST["text"], "UTF-8"),
+							mTime(),
+							mTime(),
+							mTime(),
+							));
+		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+			/*  识别错误  */
+			$error = PDO_ErrorInfo();
+			$respond['message'] = $error[2];
+			$respond['status'] = 1;
+			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+			exit;
+		} else {
+		# 没错误
+			$respond['message'] = "已经提交修改建议";
+			$respond['status'] = 0;
+		}
     }
 }
 

+ 33 - 0
app/widget/iframe_modal_win.css

@@ -0,0 +1,33 @@
+.modal_win_bg {
+	background-color: rgba(0, 0, 0, 0.8);
+	position: fixed;
+	top: 0;
+	left: 0;
+	width: 100%;
+	height: 100%;
+	display: none;
+	z-index: 99;
+}
+.iframe_container {
+	display: none;
+	z-index: 100;
+	background-color: var(--bg-color);
+	border-radius: 20px;
+	width: 75%;
+	height: 80%;
+	margin: auto;
+	position: absolute;
+	top: 0;
+	left: 0;
+	right: 0;
+	bottom: 0;
+	/*
+版权声明:本文为CSDN博主「_吟游诗人」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
+原文链接:https://blog.csdn.net/qq_32623363/article/details/77101971
+*/
+}
+.iframe_container iframe {
+	width: 100%;
+	height: 100%;
+	border: 0;
+}

+ 40 - 0
app/widget/iframe_modal_win.js

@@ -0,0 +1,40 @@
+/*
+container 容器id
+name=iframe name
+width
+height
+*/
+function iframe_win_init(param) {
+	let iframeWin = new Object();
+	iframeWin.container = param.container;
+	iframeWin.name = param.name;
+	iframeWin.show = function (url) {
+		$(".modal_win_bg").show();
+		$("#" + iframeWin.container).show();
+		window.open(url, this.name);
+	};
+	if (typeof param.onclose != "undefined") {
+		iframeWin.onclose = onclose;
+	} else {
+		iframeWin.onclose = function () {
+			return 1;
+		};
+	}
+	$("#" + iframeWin.container).addClass("iframe_container");
+	if (typeof param.width != "undefined") {
+		$("#" + iframeWin.container).css("width", param.width);
+	}
+	if (typeof param.height != "undefined") {
+		$("#" + iframeWin.container).css("height", param.height);
+	}
+	let iframe = $("#" + iframeWin.container).children("iframe");
+	if (iframe.length == 0) {
+		$("#" + iframeWin.container).append("<iframe name='" + param.name + "'></iframe>");
+	}
+	$(".modal_win_bg").click(function () {
+		$(".modal_win_bg").hide();
+		$(".iframe_container").hide();
+		this.onclose();
+	});
+	return iframeWin;
+}