Browse Source

:sparkles: channel 支持 type 修改

visuddhinanda@gmail.com 4 years ago
parent
commit
e60194d400

+ 33 - 42
public/app/channal/channal.js

@@ -1,6 +1,12 @@
 var _my_channal = null;
 var gChannelId;
 var get_channel_list_callback = null;
+var enumChannelType = [
+    {id:'translation',title:'translation',icon:''},    
+    {id:'original',title:'original',icon:''},
+    {id:'nissaya',title:'nissaya',icon:''},
+    {id:'commentary',title:'commentary',icon:''},
+]
 channal_list();
 var share_win;
 function channal_list_init() {
@@ -47,6 +53,7 @@ function my_channal_list() {
 					html += '<div style="max-width:2em;flex:1;"><input type="checkbox" /></div>';
 					html += "<div style='flex:0.5;'>No.</div>";
 					html += "<div style='flex:2;'>" + gLocal.gui.title + "</div>";
+					html += "<div style='flex:1;'>" + gLocal.gui.type + "</a></div>";                    
 					html += "<div style='flex:2;'>" + gLocal.gui.owner + "</div>";
 					html += "<div style='flex:1;'>" + gLocal.gui.privacy + "</div>";
 					html += "<div style='flex:1;'>" + gLocal.gui.permission + "</a></div>";
@@ -59,11 +66,17 @@ function my_channal_list() {
 						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>";
+                        //title
 						html += "<div style='flex:2;'>";
 						html += "<guide url='../channal/card.php' gid='" + iterator.uid + "'>";
 						html += iterator.name;
 						html += "</guide>";
 						html += "</div>";
+                        //type
+						html += "<div style='flex:1;'>";
+						html += iterator.type;
+						html += "</div>";
+                        //owner
 						html += "<div style='flex:2;'>";
 						if (parseInt(iterator.power) == 30) {
 							html += gLocal.gui.your;
@@ -74,6 +87,7 @@ function my_channal_list() {
 						}
 
 						html += "</div>";
+                        //privacy
 						html += "<div style='flex:1;'>";
 						let arrStatus = [
 							{ id: 0, string: gLocal.gui.disable },
@@ -205,6 +219,21 @@ function my_channal_edit(id) {
 					html += "</div>";
 					html += "</div>";
 
+					html += '<div style="display:flex;line-height:32px;">';
+					html += '<div style="flex:2;">' + gLocal.gui.privacy + "</div>";
+					html += '<div style="flex:8;">';
+                    html += "<select id = 'type'  name = 'type'>";
+					for (const iterator of enumChannelType) {
+						html += "<option ";
+						if (result.type == iterator.id) {
+							html += " selected ";
+						}
+						html += " value='" + iterator.id + "'>" + iterator.title + "</option>";
+					}
+					html += "</select>";
+                    html += "</div>";
+                    html += "</div>";
+
 					html += '<div style="display:flex;line-height:32px;">';
 					html += '<div style="flex:2;">' + gLocal.gui.privacy + "</div>";
 					html += '<div style="flex:8;">';
@@ -223,60 +252,22 @@ function my_channal_edit(id) {
 						}
 						html += " value='" + iterator.id + "'>" + iterator.string + "</option>";
 					}
-
 					html += "</select>";
 					html +=
 						"<span id = 'status_help' style='margin: 0 1em;'>" +
 						status_note +
-						"</span><a href='#' target='_blank'>[" +
+						"</span>"+
+                        "<a href='#' target='_blank'>[" +
 						gLocal.gui.infomation +
-						"]</a></li>";
+						"]</a>"+
+                        "</li>";
 					html += "</div>";
 					html += "</div>";
 					html += "</div>";
-					/*
-					旧的channel分享方式 删除
-					html += "<div id='coop_div' style='padding:5px;position: relative;'>";
-					html += "<h2>" + gLocal.gui.cooperators + "</h2>";
-
-					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 += "<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) {
-						html += gLocal.gui.empty_null_mark;
-					} 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;">' + gLocal.gui.personal + "</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>" + gLocal.gui.remove + "</button>";
-							html += "</div>";
-							html += "</div>";
-						}
-					}
-					html += "</div>";
-					html += "</div>";
-*/
 					$("#channal_info").html(html);
 					user_select_dlg_init("add_coop_user_dlg");
 					tran_lang_select_init("channal_lang_select");
-					//$("#aritcle_status").html(render_status(result.status));
 					$("#channal_title").html(result.name);
 					$("#preview_inner").html();
 				} catch (e) {

+ 19 - 3
public/app/channal/get.php

@@ -28,13 +28,21 @@ $channelList = array();
 
 //找自己的
 PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
-$query = "SELECT uid,owner_uid,name,status,lang FROM "._TABLE_CHANNEL_." WHERE owner_uid = ?  LIMIT 100";
+$query = "SELECT uid,owner_uid,name,status,lang,type FROM "._TABLE_CHANNEL_." WHERE owner_uid = ? order by updated_at DESC LIMIT 200";
 $Fetch_my = PDO_FetchAll($query,array($_COOKIE["user_uid"]));
 
 #去掉重复的
 foreach ($Fetch_my as $key => $value) {
 	# code...
-	$channelList[$value["uid"]]=array("uid"=>$value["uid"],"owner_uid"=>$value["owner_uid"],"name"=>$value["name"],"power"=>30,"status"=>$value["status"],"lang"=>$value["lang"]);
+	$channelList[$value["uid"]]=array(
+        "uid"=>$value["uid"],
+        "owner_uid"=>$value["owner_uid"],
+        "name"=>$value["name"],
+        "power"=>30,
+        "type"=>$value["type"],
+        "status"=>$value["status"],
+        "lang"=>$value["lang"]
+        );
 }
 
 # 找协作的
@@ -47,7 +55,15 @@ foreach ($coop_channal as $key => $value) {
 		}
 	}
 	else{
-		$channelList[$value["res_id"]]=array("uid"=>$value["res_id"],"owner_uid"=>$value["res_owner_id"],"name"=>$value["res_title"],"power"=>(int)$value["power"],"status"=>(int)$value["status"],"lang"=>(int)$value["lang"]);
+		$channelList[$value["res_id"]]=array(
+            "uid"=>$value["res_id"],
+            "owner_uid"=>$value["res_owner_id"],
+            "name"=>$value["res_title"],
+            "power"=>(int)$value["power"],
+            "type"=>(int)$value["type"],
+            "status"=>(int)$value["status"],
+            "lang"=>(int)$value["lang"]
+            );
 	}
 }
 

+ 9 - 2
public/app/channal/my_channal_post.php

@@ -31,11 +31,18 @@ if($channelPower<30){
     exit;
 }
 
+if(!isset($_POST["type"])){
+    $respond["status"] = 1;
+    $respond["message"] = 'Error: no [type]  ';
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+
 $channelOldInfo = $channel->getChannal($_POST["id"]);
 
-$query="UPDATE "._TABLE_CHANNEL_." SET editor_id=?, name = ? ,  summary = ?,  status = ? , lang = ? , updated_at = now()  , modify_time= ?   where uid = ?  ";
+$query="UPDATE "._TABLE_CHANNEL_." SET editor_id=?, name = ? ,  summary = ?, type = ?, status = ? , lang = ? , updated_at = now()  , modify_time= ?   where uid = ?  ";
 $sth = $PDO->prepare($query);
-$sth->execute(array($_COOKIE["user_id"],$_POST["name"] , $_POST["summary"], $_POST["status"] , $_POST["lang"] ,  mTime() , $_POST["id"]));
+$sth->execute(array($_COOKIE["user_id"],$_POST["name"] , $_POST["summary"], $_POST["type"], $_POST["status"] , $_POST["lang"] ,  mTime() , $_POST["id"]));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();

+ 2 - 0
public/app/share/function.php

@@ -81,12 +81,14 @@ function share_res_list_get($userid,$res_type=-1){
 				if($channelInfo){
 					$resList[$key]["res_title"]=$channelInfo["name"];
 					$resList[$key]["res_owner_id"]=$channelInfo["owner_uid"];
+					$resList[$key]["type"]=$channelInfo["type"];
 					$resList[$key]["status"]=$channelInfo["status"];
 					$resList[$key]["lang"]=$channelInfo["lang"];
 				}
 				else{
 					$resList[$key]["res_title"]="_unkown_";
 					$resList[$key]["res_owner_id"]="_unkown_";
+					$resList[$key]["type"]=$channelInfo["type"];
 					$resList[$key]["status"]="0";
 					$resList[$key]["lang"]="unkow";
 				}