changeset 860:7cb0edec73bd

Allow users to assign team name to new blog
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 06 Jul 2020 22:40:03 +0900
parents ed9aae18fda9
children 81063a4b220f
files s4-blog.sh s4-funcs.sh
diffstat 2 files changed, 41 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/s4-blog.sh	Thu Jul 02 12:18:50 2020 +0900
+++ b/s4-blog.sh	Mon Jul 06 22:40:03 2020 +0900
@@ -1259,11 +1259,13 @@
     fi
     groupmode=1 listing=$owner GF_OWNER=$owner
     titleguide="[$owner]" guide="[`linkhome $grprowid`]" 
+    GF_ARGS=$(mvteamform "$owner")
   else
     usermode=1 listing=$user guide="[個人]" titleguide=$guide
   fi
 
-  if [ -n "`getpar title`" ]; then
+  title=`getpar title`
+  if [ -n "$title" ]; then
     if [ "$usermode" ]; then
       err usermode: user=$user owner=$owner
       if [ x"$user" != x"$owner" ]; then
@@ -1291,10 +1293,32 @@
       ## err new-Leader: "select rowid from blog where id='$serial';" id=$id
     fi
     if [ -n "$id" ]; then
-      ## If new aritcle is entered, JUMP to blog_reply
+      ## If modifying existing blog, JUMP to blog_reply
       blog_reply $id
       return
     fi
+    # Newly created blog comes here:
+    mv2team=`getpar mv2team`
+    if [ -n "$mv2team" -a -n "$groupmode" ]; then
+      # For newly created BLOG, assign team-name if necessary and correct
+      qmt=`sqlquote "$mv2team"`
+      qowner=`sqlquote "$owner"`
+      team=$(query "SELECT val FROM grp_mem_m
+	            WHERE key='team' AND val=$qmt AND gname=$qowner;")
+      if [ -n "$team" ]; then		# If it is valid team name
+	qtt=`sqlquote "$title"`
+	# We should acquire newly created blog id from title step by step
+	thisblog=$(query \
+		     "SELECT id FROM blog_s
+		      WHERE id IN (SELECT id FROM blog_s
+	      	      WHERE key='owner' AND val=$qowner)
+		      AND key='title' AND val=$qtt;")
+	if [ -n "$thisblog" ]; then
+	  query "REPLACE INTO blog_s(id, key, type, val)
+		 VALUES('$thisblog', 'team', 'string', $qmt);"
+	fi
+      fi
+    fi
   fi
   echo "${titleguide}新規話題作成"	> $tmpd/title.$$
   echo "${guide}新規話題作成"		> $tmpd/h1.$$
--- a/s4-funcs.sh	Thu Jul 02 12:18:50 2020 +0900
+++ b/s4-funcs.sh	Mon Jul 06 22:40:03 2020 +0900
@@ -3251,6 +3251,21 @@
        END;
 EOF
 }
+mvteamform() {
+  owner=$1
+  hexteams=$(hexteams "$owner")
+  test -z "$hexteams" && return
+  none="`echo なし|hexize`"
+  cat<<-EOF
+	<!-- <div class="fold">
+	`cgi_checkbox mv2team send id="mv2team"`<label
+	 for="mv2team">この話題を以下のチームのものにする</label>
+	<div> -->
+	<p>この話題をチーム所有にする:
+	チーム: `cgi_select_h mv2team $none $hexteams`</p>
+	</form></div></div>
+	EOF
+}
 editheading() {	# $1=rowid-of-heading
   rowid=${1%%[!A-Z0-9a-z_]*}
   if [ -z "$rowid" ]; then

yatex.org