Jelajahi Sumber

collection 共享

visuddhinanda 5 tahun lalu
induk
melakukan
44296d4365

+ 25 - 6
app/article/article.js

@@ -4,11 +4,12 @@ var _lang = "";
 var _author = "";
 var _display = "";
 var _collect_id = "";
+var _collection_id = "";
 
 function article_onload() {
 	historay_init();
 }
-function articel_load(id) {
+function articel_load(id, collection_id) {
 	if (id == "") {
 		return;
 	}
@@ -16,6 +17,7 @@ function articel_load(id) {
 		"../article/get.php",
 		{
 			id: id,
+			collection_id: collection_id,
 			setting: "",
 		},
 		function (data, status) {
@@ -64,7 +66,7 @@ function collect_load(id) {
 						$("#contents").html(marked(result.summary));
 
 						let article_list = JSON.parse(result.article_list);
-						render_article_list(article_list);
+						render_article_list(article_list, id);
 					}
 				} catch (e) {
 					console.error(e);
@@ -93,7 +95,7 @@ function articel_load_collect(article_id) {
 						$("#pali_pedia").html(strTitle);
 
 						let article_list = JSON.parse(result[0].article_list);
-						render_article_list(article_list);
+						render_article_list(article_list, result[0].id);
 					}
 				} catch (e) {
 					console.error(e);
@@ -105,7 +107,8 @@ function articel_load_collect(article_id) {
 	);
 }
 
-function render_article_list(article_list) {
+//在collect 中 的article列表
+function render_article_list(article_list, collection_id) {
 	let html = "";
 	html += "<ul>";
 	let display = "";
@@ -114,16 +117,31 @@ function render_article_list(article_list) {
 	}
 	let prevArticle = "无";
 	let nextArticle = "无";
+	let urlCollection = "&collection=" + collection_id;
 	for (let index = 0; index < article_list.length; index++) {
 		const element = article_list[index];
 		if (element.article == _articel_id) {
 			if (index > 0) {
 				const prev = article_list[index - 1];
-				prevArticle = "<a href='../article/index.php?id=" + prev.article + display + "'>" + prev.title + "</a>";
+				prevArticle =
+					"<a href='../article/index.php?id=" +
+					prev.article +
+					display +
+					urlCollection +
+					"'>" +
+					prev.title +
+					"</a>";
 			}
 			if (index < article_list.length - 1) {
 				const next = article_list[index + 1];
-				nextArticle = "<a href='../article/index.php?id=" + next.article + display + "'>" + next.title + "</a>";
+				nextArticle =
+					"<a href='../article/index.php?id=" +
+					next.article +
+					display +
+					urlCollection +
+					"'>" +
+					next.title +
+					"</a>";
 			}
 			$("#contents_nav_left").html(prevArticle);
 			$("#contents_nav_right").html(nextArticle);
@@ -135,6 +153,7 @@ function render_article_list(article_list) {
 			"<a href='../article/index.php?id=" +
 			element.article +
 			display +
+			urlCollection +
 			"'>" +
 			element.title +
 			"</a></li>";

+ 11 - 1
app/article/collect_get.php

@@ -5,9 +5,19 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
+require_once '../collect/function.php';
+require_once '../redis/function.php';
 
-
+$redis = redis_connect();
 if(isset($_GET["id"])){
+	//查询权限
+
+	$collection = new CollectInfo($redis); 
+	$power = $collection->getPower($_GET["id"]);
+	if($power<10){
+		echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+        exit;
+	}
     PDO_Connect(_FILE_DB_USER_ARTICLE_);
     $id=$_GET["id"];
     $query = "select * from collect  where id = ? ";

+ 10 - 1
app/article/function.php

@@ -72,7 +72,7 @@ class Article
             return false;
         }
 	}
-	public function getPower($id){
+	public function getPower($id,$collectionId=""){
 		#查询用户对此是否有权限	
 		if(isset($_COOKIE["userid"])){
 			$userId = $_COOKIE["userid"];
@@ -116,9 +116,18 @@ class Article
 		}
 		#查询共享权限,如果共享权限更大,覆盖上面的的
 		$sharePower = share_get_res_power($_COOKIE["userid"],$id);
+		if($collectionId!=""){
+			$sharePowerCollection = share_get_res_power($_COOKIE["userid"],$collectionId);
+		}
+		else{
+			$sharePowerCollection =0;
+		}
 		if($sharePower>$iPower){
 			$iPower=$sharePower;
 		}
+		if($sharePowerCollection>$iPower){
+			$iPower=$sharePowerCollection;
+		}
 		$this->_redis->hSet("power://article/".$id,$_COOKIE["userid"],$iPower);
 		return $iPower;
 	}

+ 3 - 2
app/article/get.php

@@ -1,5 +1,5 @@
 <?php
-//查询term字典
+//获取article内容
 
 require_once "../path.php";
 require_once "../public/_pdo.php";
@@ -12,9 +12,10 @@ require_once "../article/function.php";
 
 if(isset($_GET["id"])){
 	//查询权限
+	$collectionId = $_GET["collection_id"];
 	$redis = redis_connect();
 	$article = new Article($redis); 
-	$power = $article->getPower($_GET["id"]);
+	$power = $article->getPower($_GET["id"],$collectionId);
 	if($power<10){
 		$output = array();
 		$output["title"]="error";

+ 4 - 3
app/article/index.php

@@ -24,6 +24,9 @@ require_once "../pcdl/html_head.php";
 	if(isset($_GET["collect"])){
 		echo "_collect_id='".$_GET["collect"]."';";
 	}
+	if(isset($_GET["collection"])){
+		echo "_collection_id='".$_GET["collection"]."';";
+	}
 	if(isset($_GET["display"])){
 		echo "_display='".$_GET["display"]."';";
 	}
@@ -161,7 +164,7 @@ require_once "../pcdl/html_head.php";
 	note_create();
 	historay_init();
 	if(_collect_id==""){
-		articel_load(_articel_id);
+		articel_load(_articel_id,_collection_id);
 		articel_load_collect(_articel_id);
 	}
 	else{
@@ -169,8 +172,6 @@ require_once "../pcdl/html_head.php";
 	}
 	});
 
-
-
 	 window.addEventListener('scroll',winScroll);
 	function winScroll(e){ 
 		if(GetPageScroll().y>220){

+ 2 - 0
app/article/my_article.js

@@ -49,9 +49,11 @@ function my_article_list() {
 							"' target='_blank'>" +
 							gLocal.gui.preview +
 							"</a></div>";
+
 						html += "<div style='flex:1;'>";
 						html += "<a onclick=\"article_share('" + iterator.id + "')\">share</a>";
 						html += "</div>";
+
 						html += "</div>";
 					}
 					$("#article_list").html(html);

+ 221 - 212
app/article/my_collect.js

@@ -1,229 +1,238 @@
+var share_win;
+
 function my_collect_init() {
-  my_collect_list();
-  collect_add_dlg_init("collect_add_div");
+	my_collect_list();
+	share_win = iframe_win_init({ container: "share_win", name: "share", width: "500px" });
+	collect_add_dlg_init("collect_add_div");
 }
 function my_collect_list() {
-  $.get(
-    "../article/collect_list.php",
-    {
-      userid: getCookie("userid"),
-      setting: "",
-    },
-    function (data, status) {
-      if (status == "success") {
-        try {
-          let html = "";
-          let result = JSON.parse(data);
-          let key = 1;
-          for (const iterator of result) {
-            html += '<div class="file_list_row" style="padding:5px;">';
-            html +=
-              '<div style="max-width:2em;flex:1;"><input type="checkbox" /></div>';
-            html += "<div style='flex:1;'>" + key++ + "</div>";
-            html += "<div style='flex:2;'>" + iterator.title + "</div>";
-            html +=
-              "<div style='flex:2;'>" +
-              render_status(iterator.status) +
-              "</div>";
-            html += "<div style='flex:1;'>"+gLocal.gui.copy_link+"</div>";
-            html +=
-              "<div style='flex:1;'><a href='../article/my_collect_edit.php?id=" +
-              iterator.id +
-              "'>"+gLocal.gui.edit+"</a></div>";
-            html +=
-              "<div style='flex:1;'><a href='../article/?collect=" +
-              iterator.id +
-              "' target='_blank'>"+gLocal.gui.preview+"</a></div>";
-            html += "<div style='flex:1;'>15</div>";
-            html += "</div>";
-          }
-          $("#article_list").html(html);
-        } catch (e) {
-          console.error(e);
-        }
-      } else {
-        console.error("ajex error");
-      }
-    }
-  );
+	$.get(
+		"../article/collect_list.php",
+		{
+			userid: getCookie("userid"),
+			setting: "",
+		},
+		function (data, status) {
+			if (status == "success") {
+				try {
+					let html = "";
+					let result = JSON.parse(data);
+					let key = 1;
+					for (const iterator of result) {
+						html += '<div class="file_list_row" style="padding:5px;">';
+						html += '<div style="max-width:2em;flex:1;"><input type="checkbox" /></div>';
+						html += "<div style='flex:1;'>" + key++ + "</div>";
+						html += "<div style='flex:2;'>" + iterator.title + "</div>";
+						html += "<div style='flex:2;'>" + render_status(iterator.status) + "</div>";
+						html += "<div style='flex:1;'>" + gLocal.gui.copy_link + "</div>";
+						html +=
+							"<div style='flex:1;'><a href='../article/my_collect_edit.php?id=" +
+							iterator.id +
+							"'>" +
+							gLocal.gui.edit +
+							"</a></div>";
+						html +=
+							"<div style='flex:1;'><a href='../article/?collect=" +
+							iterator.id +
+							"' target='_blank'>" +
+							gLocal.gui.preview +
+							"</a></div>";
+						html += "<div style='flex:1;'>";
+						html += "<a onclick=\"collection_share('" + iterator.id + "')\">share</a>";
+						html += "</div>";
+						html += "</div>";
+					}
+					$("#article_list").html(html);
+				} catch (e) {
+					console.error(e);
+				}
+			} else {
+				console.error("ajex error");
+			}
+		}
+	);
 }
 var _arrArticleList;
 var _arrArticleOrder = new Array();
 function my_collect_edit(id) {
-  $.get(
-    "../article/collect_get.php",
-    {
-      id: id,
-      setting: "",
-    },
-    function (data, status) {
-      if (status == "success") {
-        try {
-          let html = "";
-          let result = JSON.parse(data);
-          $("#article_collect").attr("a_id", result.id);
-          html += '<div class="" style="padding:5px;">';
-          html += '<div style="max-width:2em;flex:1;"></div>';
-          html += "<input type='hidden' name='id' value='" + result.id + "'/>";
-          html +=
-            "<input type='hidden' name='subtitle' value='" +
-            result.subtitle +
-            "'/>";
-          html +=
-            "<input type='hidden' name='summary' value='" +
-            result.summary +
-            "'/>";
-          html +=
-            "<input type='hidden' name='status' value='" +
-            result.status +
-            "'/>";
-          html +=
-            "<input type='hidden' name='lang' value='" + result.lang + "'/>";
-          html +=
-            "<input id='form_article_list' type='hidden' name='article_list' value='" +
-            result.article_list +
-            "'/>";
-          html += "</div>";
-          html += "<div style='display:flex;'>";
-          html += "<div style='flex:4;'>";
-
-          _arrArticleList = JSON.parse(result.article_list);
-          html += "<ul id='ul_article_list'>";
-          for (let index = 0; index < _arrArticleList.length; index++) {
-            const element = _arrArticleList[index];
-            html += my_collect_render_article(index, element);
-            _arrArticleOrder.push(index);
-          }
-
-          html += "</ul>";
-
-          html += "</div>";
-
-          html += "<div id='preview_div'>";
-          html += "<div id='preview_inner' ></div>";
-          html += "</div>";
-
-          html += "</div>";
-
-          $("#article_list").html(html);
-          $("#collect_title").val(result.title);
-
-          $("#ul_article_list").sortable({
-            update: function (event, ui) {
-              let sortedIDs = $("#ul_article_list").sortable("toArray");
-              _arrArticleOrder = new Array();
-              for (const iSorted of sortedIDs) {
-                let newindex = parseInt($("#" + iSorted).attr("article_index"));
-                _arrArticleOrder.push(_arrArticleList[newindex]);
-              }
-              $("#form_article_list").val(JSON.stringify(_arrArticleOrder));
-            },
-          });
-
-          $("#aritcle_status").html(render_status(result.status));
-          let html_title =
-            "<input id='input_article_title' type='input' name='title' value='" +
-            result.title +
-            "' />";
-          $("#article_title").html(html_title);
-        } catch (e) {
-          console.error(e);
-        }
-      } else {
-        console.error("ajex error");
-      }
-    }
-  );
+	$.get(
+		"../article/collect_get.php",
+		{
+			id: id,
+			setting: "",
+		},
+		function (data, status) {
+			if (status == "success") {
+				try {
+					let html = "";
+					let result = JSON.parse(data);
+					$("#article_collect").attr("a_id", result.id);
+					html += '<div class="" style="padding:5px;">';
+					html += '<div style="max-width:2em;flex:1;"></div>';
+					html += "<input type='hidden' name='id' value='" + result.id + "'/>";
+
+					html += "<div style='display:flex;'>";
+					html += "<div style='flex:2;'>" + gLocal.gui.title + "</div>";
+					html += "<div style='flex:8;'>";
+					html += "<input type='input' name='title' value='" + result.title + "'/>";
+					html += "</div></div>";
+
+					html += "<div style='display:flex;'>";
+					html += "<div style='flex:2;'>" + gLocal.gui.sub_title + "</div>";
+					html += "<div style='flex:8;'>";
+					html += "<input type='input' name='subtitle' value='" + result.subtitle + "'/>";
+					html += "</div></div>";
+
+					html += "<div style='display:flex;'>";
+					html += "<div style='flex:2;'>" + gLocal.gui.summary + "</div>";
+					html += "<div style='flex:8;'>";
+					html += "<input type='input' name='summary' value='" + result.summary + "'/>";
+					html += "</div></div>";
+
+					html += "<div style='display:flex;'>";
+					html += "<div style='flex:2;'>" + gLocal.gui.status + "</div>";
+					html += "<div style='flex:8;'>";
+					html += render_status(result.status, false);
+					html += "</div></div>";
+
+					html += "<div style='display:flex;'>";
+					html += "<div style='flex:2;'>" + gLocal.gui.language + "</div>";
+					html += "<div style='flex:8;'>";
+					html += "<input type='input' name='lang' value='" + result.lang + "'/>";
+					html += "</div></div>";
+
+					html +=
+						"<input id='form_article_list' type='hidden' name='article_list' value='" +
+						result.article_list +
+						"'/>";
+					html += "</div>";
+					html += "<div style='display:flex;'>";
+					html += "<div style='flex:4;'>";
+
+					_arrArticleList = JSON.parse(result.article_list);
+					html += "<ul id='ul_article_list'>";
+					for (let index = 0; index < _arrArticleList.length; index++) {
+						const element = _arrArticleList[index];
+						html += my_collect_render_article(index, element);
+						_arrArticleOrder.push(index);
+					}
+
+					html += "</ul>";
+
+					html += "</div>";
+
+					html += "<div id='preview_div'>";
+					html += "<div id='preview_inner' ></div>";
+					html += "</div>";
+
+					html += "</div>";
+
+					$("#article_list").html(html);
+					$("#collection_title").html(result.title);
+
+					$("#ul_article_list").sortable({
+						update: function (event, ui) {
+							let sortedIDs = $("#ul_article_list").sortable("toArray");
+							_arrArticleOrder = new Array();
+							for (const iSorted of sortedIDs) {
+								let newindex = parseInt($("#" + iSorted).attr("article_index"));
+								_arrArticleOrder.push(_arrArticleList[newindex]);
+							}
+							$("#form_article_list").val(JSON.stringify(_arrArticleOrder));
+						},
+					});
+				} catch (e) {
+					console.error(e);
+				}
+			} else {
+				console.error("ajex error");
+			}
+		}
+	);
 }
 
 function my_collect_render_article(index, article) {
-  let html = "";
-  html +=
-    "<li id='article_item_" +
-    index +
-    "' article_index='" +
-    index +
-    "' class='file_list_row'>";
-  html += "<span style='flex:1;'>";
-  html += "<select>";
-  let selected = "";
-  for (let i = 1; i < 9; i++) {
-    if (parseInt(article.level) == i) {
-      selected = "selected";
-    } else {
-      selected = "";
-    }
-    html += "<option " + selected + " value='" + i + "' >H " + i + "</option>";
-  }
-  html += "</select>";
-  html += "</span>";
-  html += "<span style='flex:3;'>";
-  html +=
-    "<a href='../article/my_article_edit.php?id=" + article.article + "'>";
-  html += article.title;
-  html += "</a>";
-  html += "</span>";
-  html +=
-    "<span style='flex:1;' onclick=\"article_preview('" +
-    article.article +
-    "')\">";
-  html += "Preview";
-  html += "</span>";
-  html += "</li>";
-  return html;
+	let html = "";
+	html += "<li id='article_item_" + index + "' article_index='" + index + "' class='file_list_row'>";
+	html += "<span style='flex:1;'>";
+	html += "<select>";
+	let selected = "";
+	for (let i = 1; i < 9; i++) {
+		if (parseInt(article.level) == i) {
+			selected = "selected";
+		} else {
+			selected = "";
+		}
+		html += "<option " + selected + " value='" + i + "' >H " + i + "</option>";
+	}
+	html += "</select>";
+	html += "</span>";
+	html += "<span style='flex:3;'>";
+	html += "<a href='../article/my_article_edit.php?id=" + article.article + "'>";
+	html += article.title;
+	html += "</a>";
+	html += "</span>";
+	html += "<span style='flex:1;' onclick=\"article_preview('" + article.article + "')\">";
+	html += "Preview";
+	html += "</span>";
+	html += "</li>";
+	return html;
 }
 
 function article_preview(id) {
-  $.get(
-    "../article/get.php",
-    {
-      id: id,
-      setting: "",
-    },
-    function (data, status) {
-      if (status == "success") {
-        try {
-          let html = "";
-          let result = JSON.parse(data);
-          $("#preview_inner").html(note_init(result.content));
-          note_refresh_new();
-        } catch (e) {
-          console.error(e.message);
-        }
-      }
-    }
-  );
+	$.get(
+		"../article/get.php",
+		{
+			id: id,
+			setting: "",
+		},
+		function (data, status) {
+			if (status == "success") {
+				try {
+					let html = "";
+					let result = JSON.parse(data);
+					$("#preview_inner").html(note_init(result.content));
+					note_refresh_new();
+				} catch (e) {
+					console.error(e.message);
+				}
+			}
+		}
+	);
 }
 
 function my_collect_save() {
-  $.ajax({
-    type: "POST", //方法类型
-    dataType: "json", //预期服务器返回的数据类型
-    url: "../article/my_collect_post.php", //url
-    data: $("#collect_edit").serialize(),
-    success: function (result) {
-      console.log(result); //打印服务端返回的数据(调试用)
-
-      if (result.status == 0) {
-        alert("保存成功");
-      } else {
-        alert("error:" + result.message);
-      }
-    },
-    error: function (data, status) {
-      alert("异常!" + data.responseText);
-      switch (status) {
-        case "timeout":
-          break;
-        case "error":
-          break;
-        case "notmodified":
-          break;
-        case "parsererror":
-          break;
-        default:
-          break;
-      }
-    },
-  });
+	$.ajax({
+		type: "POST", //方法类型
+		dataType: "json", //预期服务器返回的数据类型
+		url: "../article/my_collect_post.php", //url
+		data: $("#collect_edit").serialize(),
+		success: function (result) {
+			console.log(result); //打印服务端返回的数据(调试用)
+
+			if (result.status == 0) {
+				alert("保存成功");
+			} else {
+				alert("error:" + result.message);
+			}
+		},
+		error: function (data, status) {
+			alert("异常!" + data.responseText);
+			switch (status) {
+				case "timeout":
+					break;
+				case "error":
+					break;
+				case "notmodified":
+					break;
+				case "parsererror":
+					break;
+				default:
+					break;
+			}
+		},
+	});
+}
+function collection_share(id) {
+	share_win.show("../share/share.php?id=" + id + "&type=4");
 }

+ 5 - 2
app/article/my_collect_edit.php

@@ -3,6 +3,7 @@ require_once '../studio/index_head.php';
 ?>
 <body id="file_list_body" >
 
+	<script language="javascript" src="../article/my_article.js"></script>
 	<script language="javascript" src="../article/my_collect.js"></script>
 	<script language="javascript" src="../term/note.js"></script>
 	<script language="javascript" src="../term/term.js"></script>
@@ -17,7 +18,6 @@ require_once '../studio/index_head.php';
 	<style>
 	#collect {
 		background-color: var(--btn-border-color);
-		
 	}
 	#collect:hover{
 		background-color: var(--btn-border-color);
@@ -59,7 +59,7 @@ require_once '../studio/index_head.php';
 		<div class="tool_bar">
 			<div style="display:flex;">
 				<a href="../article/my_collect_index.php">返回</a>
-				<span><input  id="collect_title" type='input' name='title' value="" /></span>
+				<span id='collection_title'></span>
 			</div>
 			<div style="display:flex;">
 				<div id="aritcle_status"></div>
@@ -83,6 +83,9 @@ require_once '../studio/index_head.php';
 			</div>
 		</div>
 
+		<div id="collection_info"  class="file_list_block" style="">
+
+		</div>
 		<div id="article_list"  class="file_list_block" style="">
 
 		</div>

+ 2 - 1
app/article/my_collect_index.php

@@ -57,7 +57,8 @@ require_once '../studio/index_tool_bar.php';
 			</div>
 		</div>
 	</div>
-	
+	<div class="modal_win_bg">
+	<div id="share_win" class="iframe_container"></div>
 <?php
 require_once '../studio/index_foot.php';
 ?>

+ 22 - 1
app/article/my_collect_post.php

@@ -2,8 +2,10 @@
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
-require_once '../hostsetting/function.php';
+require_once '../collect/function.php';
 require_once "../ucenter/active.php";
+require_once "../redis/function.php";
+
 
 $respond=array("status"=>0,"message"=>"");
 if(!isset($_COOKIE["userid"])){
@@ -13,6 +15,17 @@ if(!isset($_COOKIE["userid"])){
 	echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 	exit;
 }
+# 检查当前用户是否有修改权限
+$redis = redis_connect();
+$collection = new CollectInfo($redis); 
+$power = $collection->getPower($_POST["id"]);
+if($power<20){
+	$respond["status"]=1;
+    $respond["message"]="No Power For Edit";
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+
 
 add_edit_event(_COLLECTION_EDIT_,$_POST["id"]);
 
@@ -28,6 +41,10 @@ if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$respond['message']=$error[2];
 }
 else{
+	if($redis){
+		$redis->del("collection://".$_POST["id"]);
+		$redis->del("power://collection/".$_POST["id"]);
+	}
     # 更新 article_list 表
     $query = "DELETE FROM article_list WHERE collect_id = ? ";
      PDO_Execute($query,array($_POST["id"]));
@@ -39,6 +56,10 @@ else{
         $sth = $PDO->prepare($query);
         foreach ($arrList as $row) {
             $sth->execute(array($_POST["id"],$row->article,$row->level,$row->title));
+			if($redis){
+				#删除article权限缓存
+				$redis->del("power://article/".$row->article);
+			}
         }
         $PDO->commit();
         if (!$sth || ($sth && $sth->errorCode() != 0)) {

+ 79 - 2
app/collect/function.php

@@ -1,14 +1,19 @@
 <?php
 require_once '../path.php';
+require_once "../share/function.php";
+
 
 class CollectInfo
 {
     private $dbh;
     private $buffer;
-    public function __construct() {
+	private $_redis;
+
+    public function __construct($redis=false) {
         $dns = ""._FILE_DB_USER_ARTICLE_;
         $this->dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+		$this->_redis=$redis;
         $buffer = array();
     }
 
@@ -20,7 +25,7 @@ class CollectInfo
             return $buffer[$id];
         }
         if($this->dbh){
-            $query = "SELECT id,title FROM collect WHERE id= ? limit 0,10";
+            $query = "SELECT id,title,owner,status,lang FROM collect WHERE id= ?";
             $stmt = $this->dbh->prepare($query);
             $stmt->execute(array($id));
 			$collect = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -38,5 +43,77 @@ class CollectInfo
             return $buffer[$id];
         }
     }
+
+	public function getArticleList($id){
+        if(empty($id)){
+            return array();
+        }
+        if($this->dbh){
+            $query = "SELECT article_id FROM article_list WHERE collect_id= ? limit 0,1000";
+            $stmt = $this->dbh->prepare($query);
+            $stmt->execute(array($id));
+			$article_list = $stmt->fetchAll(PDO::FETCH_ASSOC);
+			$output=array();
+			foreach ($article_list as $key => $value) {
+				# code...
+				$output[]=$value["article_id"];
+			}
+			return $output;
+        }
+        else{
+            return array();
+        }
+    }
+
+	public function getPower($id){
+		#查询用户对此是否有权限	
+		if(isset($_COOKIE["userid"])){
+			$userId = $_COOKIE["userid"];
+		}
+		else{
+			$userId='0';
+		}
+		if($this->_redis!==false){
+			$power = $this->_redis->hGet("power://collection/".$id,$userId);
+			if($power!==FALSE){
+				return $power;
+			}
+		}
+		$iPower = 0;
+		$query = "SELECT owner,status FROM collect WHERE id=?  ";
+		$stmt = $this->dbh->prepare($query);
+		$stmt->execute(array($id));
+		$result = $stmt->fetch(PDO::FETCH_ASSOC);
+		if($result){
+			if(!isset($_COOKIE["userid"])){
+				#未登录用户
+				if($result["status"]==30){
+					#全网公开有读取和建议权限
+					return 10;
+				}
+				else{
+					#其他状态没有任何权限
+					return 0;
+				}
+			}
+			else{
+				if($result["owner"]==$_COOKIE["userid"]){
+					#自己的
+					return 30;
+				}
+				else if($result["status"]>=30){
+					#全网公开的 可以提交pr
+					$iPower = 10;
+				}			
+			}
+			#查询共享权限,如果共享权限更大,覆盖上面的的
+			$sharePower = share_get_res_power($userId,$id);
+			if($sharePower>$iPower){
+				$iPower=$sharePower;
+			}
+			$this->_redis->hSet("power://collection/".$id,$userId,$iPower);			
+		}
+		return $iPower;
+	}
 }
 ?>

+ 2 - 2
app/collect/list.php

@@ -23,8 +23,8 @@ require_once '../ucenter/function.php';
     else{
         $begin = 0;
     }
-    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
-    $query = "SELECT * FROM collect  where  1 ";
+    PDO_Connect(_FILE_DB_USER_ARTICLE_);
+    $query = "SELECT * FROM collect  where  status>=30 ";
     if(isset($_GET["orderby"])){
         switch ($_GET["orderby"]) {
             case 'like':

+ 10 - 0
app/group/group.js

@@ -210,6 +210,16 @@ function group_list(id, list) {
 										"' target='_blank'>编辑</a>";
 									break;
 								case 4: //collection
+									html += "<use xlink:href='../studio/svg/icon.svg#collection'></use>";
+									cardUrl = "../collect/card.php";
+									doing +=
+										"<a href='../article/?collect=" +
+										iterator.res_id +
+										"' target='_blank'>查看</a>";
+									doing +=
+										"|<a href='../article/my_collect_edit.php?id=" +
+										iterator.res_id +
+										"' target='_blank'>编辑</a>";
 									break;
 								case 5: //channel片段
 									break;

+ 35 - 1
app/share/coop_del.php

@@ -6,12 +6,15 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
 require_once '../group/function.php';
+require_once "../redis/function.php";
+require_once "../collect/function.php";
 
 $respond['status']=0;
 $respond['message']="成功";
 if(isset($_POST["res_id"])){
-	PDO_Connect(_FILE_DB_USER_SHARE_);
+	$redis = redis_connect();
 
+	PDO_Connect(_FILE_DB_USER_SHARE_);
     $query = "DELETE FROM share_cooperator WHERE res_id=? and cooperator_id = ? ";
 	$sth = $PDO->prepare($query);
 	if($sth)
@@ -31,6 +34,37 @@ if(isset($_POST["res_id"])){
 		else{
 			$respond['status']=0;
 			$respond['message']="成功";
+			if($redis){
+				switch ((int)$_POST["res_type"]) {
+					case 1:
+						# pcs
+						$redis->del("power://pcs/".$_POST["res_id"]);
+						break;
+					case 2:
+						# channel
+						$redis->del("power://channel/".$_POST["res_id"]);
+						break;
+					case 3:
+						# code...
+						$redis->del("power://article/".$_POST["res_id"]);
+						break;
+					case 4:
+						# 文集
+						$redis->del("power://collection/".$_POST["res_id"]);
+						# 删除文章列表权限缓存
+						$collection = new CollectInfo($redis);
+						$articleList = $collection->getArticleList($_POST["res_id"]);
+						foreach ($articleList as $key => $value) {
+							# code...
+							$redis->del("power://article/".$value);
+						}
+						
+						break;											
+					default:
+						# code...
+						break;
+				}
+			}
 		}							
 	}
 

+ 33 - 1
app/share/coop_post.php

@@ -6,12 +6,14 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
 require_once '../group/function.php';
+require_once "../redis/function.php";
+require_once "../collect/function.php";
 
 $respond['status']=0;
 $respond['message']="成功";
 if(isset($_POST["res_id"])){
+	$redis = redis_connect();
 	PDO_Connect(_FILE_DB_USER_SHARE_);
-
     $query = "UPDATE share_cooperator set power = ? WHERE res_id=? and cooperator_id = ? ";
 	$sth = $PDO->prepare($query);
 	if($sth)
@@ -32,6 +34,36 @@ if(isset($_POST["res_id"])){
 		else{
 			$respond['status']=0;
 			$respond['message']="成功";
+			if($redis){
+				switch ((int)$_POST["res_type"]) {
+					case 1:
+						# pcs
+						$redis->del("power://pcs/".$_POST["res_id"]);
+						break;
+					case 2:
+						# channel
+						$redis->del("power://channel/".$_POST["res_id"]);
+						break;
+					case 3:
+						# code...
+						$redis->del("power://article/".$_POST["res_id"]);
+						break;
+					case 4:
+						# 文集
+						$redis->del("power://collection/".$_POST["res_id"]);
+						# 删除文章列表权限缓存
+						$collection = new CollectInfo($redis);
+						$articleList = $collection->getArticleList($_POST["res_id"]);
+						foreach ($articleList as $key => $value) {
+							# code...
+							$redis->del("power://article/".$value);
+						}
+						break;											
+					default:
+						# code...
+						break;
+				}
+			}
 		}							
 	}
 

+ 33 - 0
app/share/coop_put.php

@@ -6,10 +6,13 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
 require_once '../group/function.php';
+require_once "../redis/function.php";
+require_once "../collect/function.php";
 
 $respond['status']=0;
 $respond['message']="成功";
 if(isset($_POST["res_id"])){
+	$redis = redis_connect();
 	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,?,?,?,?,?,?,?,?) ";
@@ -41,6 +44,36 @@ if(isset($_POST["res_id"])){
 	else{
 		$respond['status']=0;
 		$respond['message']="成功";
+		if($redis){
+			switch ((int)$_POST["res_type"]) {
+				case 1:
+					# pcs
+					$redis->del("power://pcs/".$_POST["res_id"]);
+					break;
+				case 2:
+					# channel
+					$redis->del("power://channel/".$_POST["res_id"]);
+					break;
+				case 3:
+					# code...
+					$redis->del("power://article/".$_POST["res_id"]);
+					break;
+				case 4:
+					# 文集
+					$redis->del("power://collection/".$_POST["res_id"]);
+					# 删除文章列表权限缓存
+					$collection = new CollectInfo($redis);
+					$articleList = $collection->getArticleList($_POST["res_id"]);
+					foreach ($articleList as $key => $value) {
+						# code...
+						$redis->del("power://article/".$value);
+					}					
+					break;											
+				default:
+					# code...
+					break;
+			}
+		}
 	}	
     echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 }

+ 19 - 0
app/share/function.php

@@ -5,6 +5,7 @@ require_once '../public/function.php';
 require_once '../ucenter/function.php';
 require_once '../channal/function.php';
 require_once '../article/function.php';
+require_once '../collect/function.php';
 require_once '../redis/function.php';
 require_once '../doc/function.php';
 /*
@@ -66,6 +67,7 @@ function share_res_list_get($userid,$res_type=-1){
 	}
 	$channel = new Channal(); 
 	$article = new Article($redis); 
+	$collection = new CollectInfo($redis); 
 	foreach ($resList as $key => $res) {
 		# 获取资源标题 和所有者 
 		switch ($res["res_type"]) {
@@ -107,6 +109,19 @@ function share_res_list_get($userid,$res_type=-1){
 				break;
 			case 4:
 				# 4 Collection 文集
+				$aInfo = $collection->get($res["res_id"]);
+				if($aInfo){
+					$resList[$key]["res_title"]=$aInfo["title"];
+					$resList[$key]["res_owner_id"]=$aInfo["owner"];
+					$resList[$key]["status"]=$aInfo["status"];
+					$resList[$key]["lang"]=$aInfo["lang"];
+				}
+				else{
+					$resList[$key]["res_title"]="_unkown_";
+					$resList[$key]["res_owner_id"]="_unkown_";
+					$resList[$key]["status"]="0";
+					$resList[$key]["lang"]="unkow";
+				}
 				break;
 			case 5:
 				# code...
@@ -124,6 +139,10 @@ function share_res_list_get($userid,$res_type=-1){
 
 //获取对某个共享资源的权限
 function share_get_res_power($userid,$res_id){
+		if($userid==='0'){
+			#未登录用户 没有共享资源
+			return 0;
+		}
 		# 找我加入的群
 		$dbhGroup = new PDO(_FILE_DB_GROUP_, "", "");
 		$dbhGroup->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);

File diff ditekan karena terlalu besar
+ 1 - 2
app/studio/index_tool_bar.php


File diff ditekan karena terlalu besar
+ 1 - 0
app/studio/svg/icon.svg


+ 0 - 1
app/term/note.php

@@ -272,7 +272,6 @@ foreach ($_data as $key => $value) {
         } else {
             $translation[$key]["channalinfo"] = false;
         }
-
     }
 
     //查询路径

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini