# HG changeset patch # User HIROSE Yuuji # Date 1594042803 -32400 # Node ID 7cb0edec73bd14c3692a474c8e1d36c5fe0a3b6d # Parent ed9aae18fda92e4b9171003adc2456a1e42a4035 Allow users to assign team name to new blog diff -r ed9aae18fda9 -r 7cb0edec73bd s4-blog.sh --- 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.$$ diff -r ed9aae18fda9 -r 7cb0edec73bd s4-funcs.sh --- 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 + +

この話題をチーム所有にする: + チーム: `cgi_select_h mv2team $none $hexteams`

+ + EOF +} editheading() { # $1=rowid-of-heading rowid=${1%%[!A-Z0-9a-z_]*} if [ -z "$rowid" ]; then