s4

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 diff
     1.1 --- a/s4-blog.sh	Thu Jul 02 12:18:50 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.$$
     2.1 --- a/s4-funcs.sh	Thu Jul 02 12:18:50 2020 +0900
     2.2 +++ b/s4-funcs.sh	Mon Jul 06 22:40:03 2020 +0900
     2.3 @@ -3251,6 +3251,21 @@
     2.4         END;
     2.5  EOF
     2.6  }
     2.7 +mvteamform() {
     2.8 +  owner=$1
     2.9 +  hexteams=$(hexteams "$owner")
    2.10 +  test -z "$hexteams" && return
    2.11 +  none="`echo なし|hexize`"
    2.12 +  cat<<-EOF
    2.13 +	<!-- <div class="fold">
    2.14 +	`cgi_checkbox mv2team send id="mv2team"`<label
    2.15 +	 for="mv2team">この話題を以下のチームのものにする</label>
    2.16 +	<div> -->
    2.17 +	<p>この話題をチーム所有にする:
    2.18 +	チーム: `cgi_select_h mv2team $none $hexteams`</p>
    2.19 +	</form></div></div>
    2.20 +	EOF
    2.21 +}
    2.22  editheading() {	# $1=rowid-of-heading
    2.23    rowid=${1%%[!A-Z0-9a-z_]*}
    2.24    if [ -z "$rowid" ]; then