ソースを参照

channel 显示协作列表

visuddhinanda 5 年 前
コミット
24e7385485

+ 27 - 3
app/channal/channal.js

@@ -169,13 +169,37 @@ function my_channal_edit(id) {
 						status_note +
 						"</span><a href='#' target='_blank'>[" +
 						gLocal.gui.infomation +
-						"]</li>";
+						"]</a></li>";
 					html += "</div>";
 					html += "</div>";
 					html += "</div>";
 
-					html += "<div id='preview_div'>";
-					html += "<div id='preview_inner' ></div>";
+					html += "<div id='coop_div' style='padding:5px;'>";
+					html += "<h2>协作者</h2>";
+					html += "<button disabled>添加协作者</button>";
+					html += "<button disabled>添加协作群</button>";
+					html += "<div id='coop_inner' >";
+					if (typeof result.coop == "undefined" || result.coop.length == 0) {
+						html += "这里很安静";
+					} else {
+						for (const coop of result.coop) {
+							html += '<div class="file_list_row" style="padding:5px;">';
+							if (coop.type == 0) {
+								html += '<div style="flex:1;">个人</div>';
+								html += "<div style='flex:3;'>" + coop.user_name.nickname + "</div>";
+							} else {
+								html += '<div style="flex:1;">' + gLocal.gui.group + "</div>";
+								html += "<div style='flex:3;'>" + coop.user_name.name + "</div>";
+							}
+
+							html += "<div style='flex:3;'>" + coop.power + "</div>";
+							html += "<div class='hover_button' style='flex:3;'>";
+							html += "<button>移除</button>";
+							html += "</div>";
+							html += "</div>";
+						}
+					}
+					html += "</div>";
 					html += "</div>";
 
 					$("#channal_info").html(html);

+ 3 - 5
app/channal/my_channal_edit.php

@@ -23,9 +23,7 @@ require_once '../studio/index_head.php';
 		color: var(--btn-color);
 		cursor:auto;
 	}
-	.file_list_block{
-		width:unset;
-	}
+
 	.case_dropdown-content>a {
 		display:block;
 	}
@@ -33,8 +31,8 @@ require_once '../studio/index_head.php';
 		background-color:gray;
 	}
 	.file_list_block {
-    max-width: 100%;
-    margin-right: 1em;
+    	max-width: 65em;
+    	margin-right: 1em;
 	}
 	.index_inner {
     margin-left: 16em;

+ 20 - 1
app/channal/my_channal_get.php

@@ -5,13 +5,32 @@ 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["id"])){
     PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
     $id=$_GET["id"];
     $query = "SELECT * FROM channal  WHERE id = ? ";
-    $Fetch = PDO_FetchRow($query,array($id));
+	$Fetch = PDO_FetchRow($query,array($id));
+
+	#获取协作者
+	if($Fetch){
+		$user_info = new UserInfo();
+		$group_info = new GroupInfo();
+		$query = "SELECT * FROM cooperation  WHERE channal_id = ? ";
+		$coop = PDO_FetchAll($query,array($id));
+		foreach ($coop as $key => $value) {
+			# code...
+			if($value["type"]==0){
+				$coop[$key]["user_name"] = $user_info->getName($value["user_id"]);
+			}
+			else if($value["type"]==1){
+				$coop[$key]["user_name"] = $group_info->getName($value["user_id"]);
+			}
+		}
+		$Fetch["coop"]=$coop;
+	}
     echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
 }
 else{

+ 38 - 0
app/group/function.php

@@ -23,5 +23,43 @@ function group_get_name($id){
 	}
 }
 
+class GroupInfo
+{
+    private $dbh;
+    private $buffer;
+    public function __construct() {
+        $dns = "sqlite:"._FILE_DB_GROUP_;
+        $this->dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+        $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+        $buffer = array();
+    }
+
+    public function getName($id){
+        if(empty($id)){
+            return "";
+        }
+        if(isset($buffer[$id])){
+            return $buffer[$id];
+        }
+        if($this->dbh){
+            $query = "SELECT name FROM group_info WHERE id= ? ";
+            $stmt = $this->dbh->prepare($query);
+            $stmt->execute(array($id));
+            $user = $stmt->fetch(PDO::FETCH_ASSOC);
+            if($user){
+                $buffer[$id] = $user["name"];
+                return $buffer[$id];
+            }
+            else{
+                $buffer[$id] ="";
+                return $buffer[$id];
+            }            
+        }
+        else{
+            $buffer[$id] ="";
+            return $buffer[$id];
+        }
+    }
+}
 
 ?>

+ 0 - 1
app/public/lang/default.json

@@ -358,7 +358,6 @@
 		"year_1": "- ",
 		"years": "&nbsp;year(s) ",
 		"yes_string": "can ",
-		"": "",
 		"continue": "continue",
 		"account": "Username",
 		"new_to_wikipali": "New to Wikipāḷi",

+ 6 - 0
app/studio/css/style.css

@@ -4718,6 +4718,12 @@ note {
 .file_list_row:hover {
 	background-color: gray;
 }
+.file_list_row .hover_button {
+	visibility: hidden;
+}
+.file_list_row:hover .hover_button {
+	visibility: visible;
+}
 
 #file_list_head {
 	border-bottom: 2px solid var(--btn-hover-bg-color);