bhikkhu-kosalla-china před 4 roky
rodič
revize
feb1f5adb1
3 změnil soubory, kde provedl 54 přidání a 13 odebrání
  1. 24 3
      app/term/term_edit_dlg.js
  2. 7 2
      app/term/term_get.php
  3. 23 8
      app/term/term_post.php

+ 24 - 3
app/term/term_edit_dlg.js

@@ -117,14 +117,35 @@ function term_edit_dlg_render(word = "") {
 
 	output += "<fieldset>";
 	output += "<legend>" + gLocal.gui.channel + "</legend>";
+
+	let currChannel=null;
+	if(typeof word.channel == "undefined" && typeof word.channal != "undefined"){
+		word.channel = word.channal;
+	}
+	for (const iterator of _my_channal) {
+		if(iterator.id==word.channel){
+			currChannel = iterator;
+		}
+	}
+
 	output += "<select id='term_edit_form_channal' name='channal'>";
-	output += "<option value=''>通用于所有版本</option>";
-	word.channel = word.channal;
+	if(currChannel !== null){
+		if(currChannel.owner == getCookie("user_uid")){
+			//是自己的
+			output += "<option value=''>通用于所有版本</option>";
+			
+		}
+		output += "<option value='"+currChannel.id+"'>仅用于"+currChannel.name+"</option>";
+	}else{
+		output += "<option value=''>通用于所有版本</option>";
+	}
+	/*
 	for (const iterator of _my_channal) {
 		if(word.channel=="" || (word.channel!="" && iterator.id==word.channel)){
-		output += "<option value='"+iterator.id+"'>仅用于"+iterator.name+"</option>";
+			output += "<option value='"+iterator.id+"'>仅用于"+iterator.name+"</option>";
 		}
 	}
+	*/
 	output += "</select>";
 	output += "</fieldset>";
 

+ 7 - 2
app/term/term_get.php

@@ -4,7 +4,7 @@
 输入单词列表
 输出查到的结果
  */
-require_once "../path.php";
+require_once "../config.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
@@ -89,7 +89,12 @@ if (isset($_POST["words"])) {
             $userinfo = new UserInfo();
             foreach ($fetch as $key => $value) {
 				# code...
-				if($value["owner"]==$_COOKIE["userid"]){
+				if(isset($_COOKIE["userid"])){
+					$currUserUid = $_COOKIE["userid"];
+				}else{
+					$currUserUid = "";
+				}
+				if($value["owner"]==$currUserUid){
 					$fetch[$key]["readonly"]=false;
 				}
 				else{

+ 23 - 8
app/term/term_post.php

@@ -2,10 +2,11 @@
 /*
 修改术语
  */
-require_once "../path.php";
+require_once "../config.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once "../redis/function.php";
+require_once "../channal/function.php";
 
 $redis = redis_connect();
 
@@ -26,19 +27,34 @@ PDO_Connect("" . _FILE_DB_TERM_);
 if ($_POST["id"] != "") {
 	#更新
 	#先查询是否有权限
-	$query = "SELECT id from term where guid= ? and owner = ? ";
+	#是否这个术语的作者
+	$query = "SELECT id,channal,owner from term where guid= ? ";
 	$stmt = $PDO->prepare($query);
-	$stmt->execute(array($_POST["id"],$_COOKIE["userid"]));
+	$stmt->execute(array($_POST["id"]));
 	if ($stmt) {
 		$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
-		if(!$Fetch){
+		if($Fetch){
+			if($Fetch['owner']!=$_COOKIE["userid"]){
+				#不是这个术语的作者,查是否是channel的有编辑权限者	
+				$channelInfo = new Channal($redis);
+				$channelPower = $channelInfo->getPower($Fetch['channal']);
+				if($channelPower<20){
+					$respond['status'] = 1;
+					$respond['message'] = "no power";
+					echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+					exit;						
+				}
+			}
+			
+		
+		}else{
 			$respond['status'] = 1;
-			$respond['message'] = "no power";
+			$respond['message'] = "no word";
 			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
-			exit;			
+			exit;				
 		}
 	}
-    $query = "UPDATE term SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? ,  language = ? , note = ? , receive_time= ?, modify_time= ?   where guid= ? and owner = ? ";
+    $query = "UPDATE term SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? ,  language = ? , note = ? , receive_time= ?, modify_time= ?   where guid= ? ";
 	$stmt = @PDO_Execute($query, 
 						array($_POST["mean"],
         					  $_POST["mean2"],
@@ -49,7 +65,6 @@ if ($_POST["id"] != "") {
         					  mTime(),
         					  mTime(),
         					  $_POST["id"],
-        					  $_COOKIE["userid"],
     ));
     if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
         $error = PDO_ErrorInfo();