Prechádzať zdrojové kódy

设置channel 显示和隐藏

visuddhinanda 5 rokov pred
rodič
commit
7ac64ee72b

+ 227 - 257
app/article/my_article.js

@@ -1,293 +1,263 @@
 var _display = "para";
 function my_article_init() {
-  my_article_list();
-  article_add_dlg_init("article_add_div");
+	my_article_list();
+	article_add_dlg_init("article_add_div");
 }
 function my_article_list() {
-  $.get(
-    "../article/list.php",
-    {
-      userid: getCookie("userid"),
-      setting: "",
-    },
-    function (data, status) {
-      if (status == "success") {
-        try {
-          let html = "";
-          let result = JSON.parse(data);
-          let key = 1;
-          //表头
-          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:0.5;'>" + key++ + "</div>";
-          html += "<div style='flex:2;'>" + gLocal.gui.title + "</div>";
-          html +=
-            "<div style='flex:2;'>" + gLocal.gui.privacy + "</div>";
-          html += "<div style='flex:1;'>" + gLocal.gui.copy_link + "</div>";
-          html +=
-            "<div style='flex:1;'>" +
-            gLocal.gui.edit +
-            "</a></div>";
-          html +=
-            "<div style='flex:1;'>" +
-            gLocal.gui.preview +
-            "</a></div>";
-          html += "<div style='flex:1;'>15</div>";
-          html += "</div>";
-          //列表
-          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:0.5;'>" + 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_article_edit.php?id=" +
-              iterator.id +
-              "'>" +
-              gLocal.gui.edit +
-              "</a></div>";
-            html +=
-              "<div style='flex:1;'><a href='../article/?id=" +
-              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/list.php",
+		{
+			userid: getCookie("userid"),
+			setting: "",
+		},
+		function (data, status) {
+			if (status == "success") {
+				try {
+					let html = "";
+					let result = JSON.parse(data);
+					let key = 1;
+					//表头
+					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:0.5;'>" + key++ + "</div>";
+					html += "<div style='flex:2;'>" + gLocal.gui.title + "</div>";
+					html += "<div style='flex:2;'>" + gLocal.gui.privacy + "</div>";
+					html += "<div style='flex:1;'>" + gLocal.gui.copy_link + "</div>";
+					html += "<div style='flex:1;'>" + gLocal.gui.edit + "</a></div>";
+					html += "<div style='flex:1;'>" + gLocal.gui.preview + "</a></div>";
+					html += "<div style='flex:1;'>15</div>";
+					html += "</div>";
+					//列表
+					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:0.5;'>" + 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_article_edit.php?id=" +
+							iterator.id +
+							"'>" +
+							gLocal.gui.edit +
+							"</a></div>";
+						html +=
+							"<div style='flex:1;'><a href='../article/?id=" +
+							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");
+			}
+		}
+	);
 }
 
 function render_status(status) {
-  status = parseInt(status);
-  let html = "";
-  let objStatus = [
-    {
-      id: 1,
-      name:
-        "<svg class='icon'><use xlink:href='../studio/svg/icon.svg#ic_lock'></use></svg>" +
-        gLocal.gui.private,
-      tip: gLocal.gui.private_note,
-    },
-    {
-      id: 2,
-      name:
-        "<svg class='icon'><use xlink:href='../studio/svg/icon.svg#eye_disable'></use></svg>" +
-        gLocal.gui.unlisted,
-      tip: gLocal.gui.unlisted_note,
-    },
-    {
-      id: 3,
-      name:
-        "<svg class='icon'><use xlink:href='../studio/svg/icon.svg#eye_enable'></use></svg>" +
-        gLocal.gui.public,
-      tip: gLocal.gui.public_note,
-    },
-  ];
-  html +=
-    '<div class="case_dropdown"  style="flex:7;">';
-  html += '<input type="hidden" name="status"  value ="' + status + '" />';
+	status = parseInt(status);
+	let html = "";
+	let objStatus = [
+		{
+			id: 1,
+			name:
+				"<svg class='icon'><use xlink:href='../studio/svg/icon.svg#ic_lock'></use></svg>" + gLocal.gui.private,
+			tip: gLocal.gui.private_note,
+		},
+		{
+			id: 2,
+			name:
+				"<svg class='icon'><use xlink:href='../studio/svg/icon.svg#eye_disable'></use></svg>" +
+				gLocal.gui.unlisted,
+			tip: gLocal.gui.unlisted_note,
+		},
+		{
+			id: 3,
+			name:
+				"<svg class='icon'><use xlink:href='../studio/svg/icon.svg#eye_enable'></use></svg>" +
+				gLocal.gui.public,
+			tip: gLocal.gui.public_note,
+		},
+	];
+	html += '<div class="case_dropdown"  style="flex:7;">';
+	html += '<input type="hidden" name="status"  value ="' + status + '" />';
 
-  for (const iterator of objStatus) {
-    if (iterator.id == status) {
-      html += "<div >" + iterator.name + "</div>";
-    }
-  }
-  html +=
-    '<div id="privacy_list" class="case_dropdown-content" style="background-color: var(--detail-color); color: var(--btn-color);">';
+	for (const iterator of objStatus) {
+		if (iterator.id == status) {
+			html += "<div >" + iterator.name + "</div>";
+		}
+	}
+	html +=
+		'<div id="privacy_list" class="case_dropdown-content" style="background-color: var(--detail-color); color: var(--btn-color);">';
 
-  for (const iterator of objStatus) {
-    let active = "";
-    if (iterator.id == status) {
-      active = "active";
-    }
-    html += "<a class='" + active + "'  onclick='setStatus(this)'>";
-    html += "<div style='font-size:110%'>" + iterator.name + "</div>";
-    html += "<div style='font-size:80%'>" + iterator.tip + "</div>";
-    html += "</a>";
-  }
-  html += "</div></div>";
-  return html;
+	for (const iterator of objStatus) {
+		let active = "";
+		if (iterator.id == status) {
+			active = "active";
+		}
+		html += "<a class='" + active + "'  onclick='setStatus(this)'>";
+		html += "<div style='font-size:110%'>" + iterator.name + "</div>";
+		html += "<div style='font-size:80%'>" + iterator.tip + "</div>";
+		html += "</a>";
+	}
+	html += "</div></div>";
+	return html;
 }
 
-function setStatus(obj) { }
+function setStatus(obj) {}
 
 function my_article_edit(id) {
-  $.get(
-    "../article/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);
+	$.get(
+		"../article/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 style='display:flex;'>";
-          html += "<div style='flex:4;'>";
+					html += "<div style='display:flex;'>";
+					html += "<div style='flex:4;'>";
 
-          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='tag' value='" + result.tag + "'/>";
-          html +=
-            "<input type='hidden' name='status' value='" +
-            result.status +
-            "'/>";
+					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='tag' value='" + result.tag + "'/>";
+					html += "<input type='hidden' name='status' value='" + result.status + "'/>";
 
-          html +=
-            "<input type='checkbox' name='import' />" +
-            gLocal.gui.import +
-            gLocal.gui.text;
-          html += "<div>";
-          //html += "<div id='article_collect' vui='collect-dlg' ></div>"
-          html += "<div style='display:flex;'>";
-          html +=
-            "<span style='flex:3;margin:auto;'>" + gLocal.gui.title + "</span>";
-          html += '<span id="article_title" style="flex:7;"></span></div>';
-          html +=
-            "<div id='channal_selector' form_name='channal' style='display:flex;'></div>";
-          html +=
-            "<div id='aritcle_status' style='display: flex; '></div>";
-          html +=
-            '<div style="display:flex;width:100%;" ><span style="flex:3;margin: auto;">' +
-            gLocal.gui.language_select +
-            '</span>	<input id="article_lang_select"  style="flex:7;width:100%;" type="input" onchange="article_lang_change()"  placeholder="' +
-            gLocal.gui.input +
-            " & " +
-            gLocal.gui.language_select +
-            "," +
-            gLocal.gui.example +
-            ':Engilish" code="' +
-            result.lang +
-            '" value="' +
-            result.lang +
-            '" > <input id="article_lang" type="hidden" name="lang" value=""></div>';
-          html += "<div style='display:flex;'>";
-          html += "<span style='flex:3;margin:auto;'>" + gLocal.gui.introduction + "</span>"
-          html +=
-            "<textarea style='flex:7;' name='summary' >" + result.summary + "</textarea></div>";
-          html += "</div>";
-          html += "</div>";
+					html += "<input type='checkbox' name='import' />" + gLocal.gui.import + gLocal.gui.text;
+					html += "<div>";
+					//html += "<div id='article_collect' vui='collect-dlg' ></div>"
+					html += "<div style='display:flex;'>";
+					html += "<span style='flex:3;margin:auto;'>" + gLocal.gui.title + "</span>";
+					html += '<span id="article_title" style="flex:7;"></span></div>';
+					html += "<div id='channal_selector' form_name='channal' style='display:flex;'></div>";
+					html += "<div id='aritcle_status' style='display: flex; '></div>";
+					html +=
+						'<div style="display:flex;width:100%;" ><span style="flex:3;margin: auto;">' +
+						gLocal.gui.language_select +
+						'</span>	<input id="article_lang_select"  style="flex:7;width:100%;" type="input" onchange="article_lang_change()"  placeholder="' +
+						gLocal.gui.input +
+						" & " +
+						gLocal.gui.language_select +
+						"," +
+						gLocal.gui.example +
+						':Engilish" code="' +
+						result.lang +
+						'" value="' +
+						result.lang +
+						'" > <input id="article_lang" type="hidden" name="lang" value=""></div>';
+					html += "<div style='display:flex;'>";
+					html += "<span style='flex:3;margin:auto;'>" + gLocal.gui.introduction + "</span>";
+					html += "<textarea style='flex:7;' name='summary' >" + result.summary + "</textarea></div>";
+					html += "</div>";
+					html += "</div>";
 
-          html +=
-            "<textarea id='article_content' name='content' style='height:500px;max-height: 40vh;'>" +
-            result.content +
-            "</textarea>";
-          html += "</div>";
+					html +=
+						"<textarea id='article_content' name='content' style='height:500px;max-height: 40vh;'>" +
+						result.content +
+						"</textarea>";
+					html += "</div>";
 
-          html += "<div id='preview_div'>";
-          html += "<div id='preview_inner' ></div>";
-          html += "</div>";
+					html += "<div id='preview_div'>";
+					html += "<div id='preview_inner' ></div>";
+					html += "</div>";
 
-          html += "</div>";
+					html += "</div>";
 
-          $("#article_list").html(html);
-          channal_select_init("channal_selector");
-          tran_lang_select_init("article_lang_select");
-          $("#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);
-          $("#preview_inner").html(note_init(result.content));
-          note_refresh_new();
+					$("#article_list").html(html);
+					channal_select_init("channal_selector");
+					tran_lang_select_init("article_lang_select");
+					$("#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);
+					$("#preview_inner").html(note_init(result.content));
+					note_refresh_new();
 
-          add_to_collect_dlg_init();
-        } catch (e) {
-          console.error(e);
-        }
-      } else {
-        console.error("ajex error");
-      }
-    }
-  );
+					add_to_collect_dlg_init();
+				} catch (e) {
+					console.error(e);
+				}
+			} else {
+				console.error("ajex error");
+			}
+		}
+	);
 }
 function article_lang_change() {
-  let lang = $("#article_lang_select").val();
-  if (lang.split("-").length == 3) {
-    $("#article_lang").val(lang.split("-")[2]);
-  } else {
-    $("#article_lang").val(lang);
-  }
+	let lang = $("#article_lang_select").val();
+	if (lang.split("-").length == 3) {
+		$("#article_lang").val(lang.split("_")[2]);
+	} else {
+		$("#article_lang").val(lang);
+	}
 }
 function article_preview() {
-  $("#preview_inner").html(note_init($("#article_content").val()));
-  note_refresh_new();
+	$("#preview_inner").html(note_init($("#article_content").val()));
+	note_refresh_new();
 }
 
 function my_article_save() {
-  $.ajax({
-    type: "POST", //方法类型
-    dataType: "json", //预期服务器返回的数据类型
-    url: "../article/my_article_post.php", //url
-    data: $("#article_edit").serialize(),
-    success: function (result) {
-      console.log(result); //打印服务端返回的数据(调试用)
+	$.ajax({
+		type: "POST", //方法类型
+		dataType: "json", //预期服务器返回的数据类型
+		url: "../article/my_article_post.php", //url
+		data: $("#article_edit").serialize(),
+		success: function (result) {
+			console.log(result); //打印服务端返回的数据(调试用)
 
-      if (result.status == 0) {
-        alert(gLocal.gui.saved + gLocal.gui.successful);
-      } 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;
-      }
-    },
-  });
+			if (result.status == 0) {
+				alert(gLocal.gui.saved + gLocal.gui.successful);
+			} 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 course_validate_required(field, alerttxt) {
-  with (field) {
-    if (value == null || value == "") {
-      alert(alerttxt);
-      return false;
-    } else {
-      return true;
-    }
-  }
+	with (field) {
+		if (value == null || value == "") {
+			alert(alerttxt);
+			return false;
+		} else {
+			return true;
+		}
+	}
 }
 
 function course_validate_form(thisform) {
-  with (thisform) {
-    if (
-      course_validate_required(title, gLocal.gui.title_necessary + "!") ==
-      false
-    ) {
-      title.focus();
-      return false;
-    }
-  }
+	with (thisform) {
+		if (course_validate_required(title, gLocal.gui.title_necessary + "!") == false) {
+			title.focus();
+			return false;
+		}
+	}
 }

+ 43 - 9
app/channal/channal.js

@@ -46,10 +46,19 @@ function my_channal_list() {
 						html += "<div style='flex:1;'>" + key++ + "</div>";
 						html += "<div style='flex:2;'>" + iterator.name + "</div>";
 						html += "<div style='flex:2;'>" + iterator.nickname + "</div>";
-						html +=
-							"<div style='flex:2;'>" +
-							//render_status(iterator.status) +
-							"</div>";
+						html += "<div style='flex:2;'>";
+						let arrStatus = [
+							{ id: 0, string: gLocal.gui.disable },
+							{ id: 10, string: gLocal.gui.private },
+							{ id: 30, string: gLocal.gui.public },
+						];
+						for (const status of arrStatus) {
+							if (parseInt(iterator.status) == status.id) {
+								html += status.string;
+							}
+						}
+						//render_status(iterator.status) +
+						html += "</div>";
 						html +=
 							"<div style='flex:1;'><a href='../channal/my_channal_edit.php?id=" +
 							iterator.id +
@@ -94,13 +103,38 @@ function my_channal_edit(id) {
 						result.name +
 						"' maxlength='32' placeholder='📝≤32'/>";
 					html += "<textarea name='summary'>" + result.summary + "</textarea>";
+
+					html += "<div>";
 					html +=
-						'<div>	<input id="channal_lang_select" type="input" onchange="channal_lang_change()"  title="type language name/code" code="' +
+						'<input id="channal_lang_select" type="input"  onchange="channal_lang_change()"  title="type language name/code" code="' +
 						result.lang +
 						'" value="' +
 						result.lang +
-						'" > <input id="channal_lang" type="hidden" name="lang" value=""></div>';
-					html += "<input type='hidden' name='status' value='" + result.status + "'/>";
+						'" > <input id="channal_lang" type="hidden" name="lang" value="' +
+						result.lang +
+						'">';
+					html += "</div>";
+
+					html += '<div style="display:flex;">';
+					html += '<div style="flex:2;">Status</div>';
+					html += '<div style="flex:8;">';
+					let arrStatus = [
+						{ id: 0, string: gLocal.gui.disable },
+						{ id: 10, string: gLocal.gui.private },
+						{ id: 30, string: gLocal.gui.public },
+					];
+					html += "<select id = 'status'  name = 'status'>";
+					for (const iterator of arrStatus) {
+						html += "<option ";
+						if (parseInt(result.status) == iterator.id) {
+							html += " selected ";
+						}
+						html += " value='" + iterator.id + "'>" + iterator.string + "</option>";
+					}
+
+					html += "</select>";
+					html += "</div>";
+					html += "</div>";
 					html += "</div>";
 
 					html += "<div id='preview_div'>";
@@ -126,8 +160,8 @@ function my_channal_edit(id) {
 
 function channal_lang_change() {
 	let lang = $("#channal_lang_select").val();
-	if (lang.split("-").length == 3) {
-		$("#channal_lang").val(lang.split("-")[2]);
+	if (lang.split("_").length == 3) {
+		$("#channal_lang").val(lang.split("_")[2]);
 	} else {
 		$("#channal_lang").val(lang);
 	}

+ 22 - 0
app/channal/my_channal_post.php

@@ -51,6 +51,28 @@ if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$respond['status']=1;
 	$respond['message']=$error[2];
 }
+else{
+    // 设置 句子库和逐词译库可见性
+    PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+    $query="UPDATE sentence SET language = ?  , status = ? where  channal = ?  ";
+    $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
+    if (!$sth || ($sth && $sth->errorCode() != 0)) {
+        $error = PDO_ErrorInfo();
+        $respond['status']=1;
+        $respond['message']=$error[2];
+    }
+    else{
+        // 设置 逐词译库可见性
+        PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
+        $query="UPDATE wbw_block SET lang = ?  , status = ? where  channal = ?  ";
+        $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
+        if (!$sth || ($sth && $sth->errorCode() != 0)) {
+            $error = PDO_ErrorInfo();
+            $respond['status']=1;
+            $respond['message']=$error[2];
+        }
+    }
+}
 
 echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 ?>

+ 16 - 18
app/lang/tran_lang_select.js

@@ -1,21 +1,19 @@
 var _tran_lang_select_div;
 function tran_lang_select_init(div) {
-  _tran_lang_select_div = div;
-  $.getJSON("../lang/lang_list.json", function (result) {
-    let lang_list = new Array();
-    let langCode = $("#" + _tran_lang_select_div).attr("code");
-    let strLang;
-    for (const iterator of result) {
-      if (iterator.code == langCode) {
-        strLang = iterator.english + "-" + iterator.name + "-" + iterator.code;
-      }
-      lang_list.push(
-        iterator.english + "-" + iterator.name + "-" + iterator.code
-      );
-    }
-    $("#" + _tran_lang_select_div).val(strLang);
-    $("#" + _tran_lang_select_div).autocomplete({
-      source: lang_list,
-    });
-  });
+	_tran_lang_select_div = div;
+	$.getJSON("../lang/lang_list.json", function (result) {
+		let lang_list = new Array();
+		let langCode = $("#" + _tran_lang_select_div).attr("code");
+		let strLang;
+		for (const iterator of result) {
+			if (iterator.code == langCode) {
+				strLang = iterator.english + "_" + iterator.name + "_" + iterator.code;
+			}
+			lang_list.push(iterator.english + "_" + iterator.name + "_" + iterator.code);
+		}
+		$("#" + _tran_lang_select_div).val(strLang);
+		$("#" + _tran_lang_select_div).autocomplete({
+			source: lang_list,
+		});
+	});
 }

+ 41 - 2
app/term/channal_list.php

@@ -1,5 +1,7 @@
 <?php
+#输入句子列表查询channel列表 和计算完成度
 require_once "../public/function.php";
+require_once "../public/_pdo.php";
 require_once "../path.php";
 require_once '../channal/function.php';
 require_once '../ucenter/function.php';
@@ -29,6 +31,40 @@ $db_pali_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 $channal = array();
 
+	#查询有阅读权限的channel
+	$channal_list = array();
+	if(isset($_COOKIE["userid"])){
+		PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+		$query = "SELECT id from channal where owner = ?   limit 0,100";
+		$Fetch_my = PDO_FetchAll($query,array($_COOKIE["userid"]));
+		foreach ($Fetch_my as $key => $value) {
+			# code...
+			$channal_list[]=$value["id"];
+		}
+
+		# 找协作的
+		$Fetch_coop = array();
+		$query = "SELECT channal_id FROM cooperation WHERE  user_id = ? ";
+		$coop_channal = PDO_FetchAll($query,array($_COOKIE["userid"]));
+		if(count($coop_channal)>0){
+			foreach ($coop_channal as $key => $value) {
+				# code...
+				$channal_list[]=$value["channal_id"];
+			}
+		}
+		/*  创建一个填充了和params相同数量占位符的字符串 */
+
+	}
+	if(count($channal_list)>0){
+		$channel_place_holders = implode(',', array_fill(0, count($channal_list), '?'));
+		$channel_query = " OR channal IN ($channel_place_holders)";
+	}
+	else{
+		$channel_query = "";
+	}
+
+	# 查询有阅读权限的channel 结束
+
 $final = array();
 $article_len=0;
 foreach ($_data as $key => $value) {
@@ -59,9 +95,12 @@ foreach ($_data as $key => $value) {
 			$pali_letter["len"]=0;
 		}
 
-		$query="SELECT channal FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  group by channal  limit 0 ,20 ";
+		#公开 或 channel有权限的
+		$query="SELECT channal FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0 and (status = 30 {$channel_query} ) group by channal  limit 0 ,20 ";
 		$stmt = $db_trans_sent->prepare($query);
-		$stmt->execute(array($bookId,$para,$begin,$end));
+		$parm = array($bookId,$para,$begin,$end);
+		$parm = array_merge_recursive($parm,$channal_list);
+		$stmt->execute($parm);
 		$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
 		foreach ($Fetch as $key => $value) {
 			# code...

+ 40 - 2
app/term/note.php

@@ -50,6 +50,40 @@ $db_trans_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 $output = array();
 
+	#查询有阅读权限的channel
+	$channal_list = array();
+	if(isset($_COOKIE["userid"])){
+		PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+		$query = "SELECT id from channal where owner = ?   limit 0,100";
+		$Fetch_my = PDO_FetchAll($query,array($_COOKIE["userid"]));
+		foreach ($Fetch_my as $key => $value) {
+			# code...
+			$channal_list[]=$value["id"];
+		}
+
+		# 找协作的
+		$Fetch_coop = array();
+		$query = "SELECT channal_id FROM cooperation WHERE  user_id = ? ";
+		$coop_channal = PDO_FetchAll($query,array($_COOKIE["userid"]));
+		if(count($coop_channal)>0){
+			foreach ($coop_channal as $key => $value) {
+				# code...
+				$channal_list[]=$value["channal_id"];
+			}
+		}
+		/*  创建一个填充了和params相同数量占位符的字符串 */
+
+	}
+	if(count($channal_list)>0){
+		$channel_place_holders = implode(',', array_fill(0, count($channal_list), '?'));
+		$channel_query = " OR channal IN ($channel_place_holders)";
+	}
+	else{
+		$channel_query = "";
+	}
+
+	# 查询有阅读权限的channel 结束
+	
 foreach ($_data as $key => $value) {
 	# code...
 	$id = $value["id"];
@@ -98,13 +132,15 @@ foreach ($_data as $key => $value) {
 		//查询相似句
 
 	//find out translation 查询译文
+
+
 	$tran="";
 	$translation = array();
 	$tran_channal = array();
 	try{
 		if(empty($_setting["channal"])){
 			if($sentChannal==""){
-				$query="SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0   order by modify_time DESC limit 0 ,1 ";
+				$query="SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0 and (status = 30 {$channel_query} )   order by modify_time DESC limit 0 ,1 ";
 				$channal = "";				
 			}
 			else{
@@ -119,7 +155,9 @@ foreach ($_data as $key => $value) {
 		$stmt = $db_trans_sent->prepare($query);
 		if(empty($_setting["channal"])){
 			if($sentChannal==""){
-				$stmt->execute(array($bookId,$para,$begin,$end));
+				$parm = array($bookId,$para,$begin,$end);
+				$parm = array_merge_recursive($parm,$channal_list);
+				$stmt->execute($parm);
 				$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
 				if($Fetch){
 					$tran = $Fetch["text"];