s4

diff s4-blog.sh @ 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 c86c04920f84
children ee91a512b63a
line diff
     1.1 --- a/s4-blog.sh	Thu Jul 02 08:07:45 2020 +0900
     1.2 +++ b/s4-blog.sh	Mon Jul 06 22:40:03 2020 +0900
     1.3 @@ -1259,11 +1259,13 @@
     1.4      fi
     1.5      groupmode=1 listing=$owner GF_OWNER=$owner
     1.6      titleguide="[$owner]" guide="[`linkhome $grprowid`]" 
     1.7 +    GF_ARGS=$(mvteamform "$owner")
     1.8    else
     1.9      usermode=1 listing=$user guide="[個人]" titleguide=$guide
    1.10    fi
    1.11  
    1.12 -  if [ -n "`getpar title`" ]; then
    1.13 +  title=`getpar title`
    1.14 +  if [ -n "$title" ]; then
    1.15      if [ "$usermode" ]; then
    1.16        err usermode: user=$user owner=$owner
    1.17        if [ x"$user" != x"$owner" ]; then
    1.18 @@ -1291,10 +1293,32 @@
    1.19        ## err new-Leader: "select rowid from blog where id='$serial';" id=$id
    1.20      fi
    1.21      if [ -n "$id" ]; then
    1.22 -      ## If new aritcle is entered, JUMP to blog_reply
    1.23 +      ## If modifying existing blog, JUMP to blog_reply
    1.24        blog_reply $id
    1.25        return
    1.26      fi
    1.27 +    # Newly created blog comes here:
    1.28 +    mv2team=`getpar mv2team`
    1.29 +    if [ -n "$mv2team" -a -n "$groupmode" ]; then
    1.30 +      # For newly created BLOG, assign team-name if necessary and correct
    1.31 +      qmt=`sqlquote "$mv2team"`
    1.32 +      qowner=`sqlquote "$owner"`
    1.33 +      team=$(query "SELECT val FROM grp_mem_m
    1.34 +	            WHERE key='team' AND val=$qmt AND gname=$qowner;")
    1.35 +      if [ -n "$team" ]; then		# If it is valid team name
    1.36 +	qtt=`sqlquote "$title"`
    1.37 +	# We should acquire newly created blog id from title step by step
    1.38 +	thisblog=$(query \
    1.39 +		     "SELECT id FROM blog_s
    1.40 +		      WHERE id IN (SELECT id FROM blog_s
    1.41 +	      	      WHERE key='owner' AND val=$qowner)
    1.42 +		      AND key='title' AND val=$qtt;")
    1.43 +	if [ -n "$thisblog" ]; then
    1.44 +	  query "REPLACE INTO blog_s(id, key, type, val)
    1.45 +		 VALUES('$thisblog', 'team', 'string', $qmt);"
    1.46 +	fi
    1.47 +      fi
    1.48 +    fi
    1.49    fi
    1.50    echo "${titleguide}新規話題作成"	> $tmpd/title.$$
    1.51    echo "${guide}新規話題作成"		> $tmpd/h1.$$