Mercurial > hgrepos > hgweb.cgi > s4
changeset 213:ca7e27d9224e
Add feature of moving article from personal diary to group board.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 29 Apr 2016 18:15:45 +0859 |
parents | 0001236d6a0c |
children | e4dd3cf443b0 |
files | s4-funcs.sh s4.cgi |
diffstat | 2 files changed, 90 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-funcs.sh Fri Apr 29 09:45:07 2016 +0859 +++ b/s4-funcs.sh Fri Apr 29 18:15:45 2016 +0859 @@ -1954,6 +1954,25 @@ `cgi_hidden grp $grid` EOF } +crview4article() { # $1=rowid of blog, $2(optional)=extra SQL + query<<EOF +CREATE TEMPORARY VIEW writeusers AS + SELECT DISTINCT author FROM article + WHERE id in ( + select id from article where blogid=(select id from blog where rowid=$1) + ); +CREATE TEMPORARY VIEW movablegroups AS +SELECT g.rowid growid , g.gname + FROM (SELECT grp.rowid, grp.gname FROM grp JOIN grp_mem gm + ON grp.gname=gm.gname -- そのユーザが属している + AND user='$user') g -- グループに絞る + WHERE (SELECT author FROM writeusers + EXCEPT + SELECT user FROM grp_mem gm WHERE gm.gname = g.gname) + IS NULL; +$2 +EOF +} editheading() { # $1=rowid-of-heading rowid=${1%%[!A-Z0-9a-z_]*} if [ -z "$rowid" ]; then @@ -1968,6 +1987,76 @@ -D_BLOGS_="" -D_DUMPTABLE_="" \ -D_FORM_="syscmd(\`cat')" \ $layout/html.m4.html $layout/form+dump.m4.html + # Move to group + if isuser "$owner"; then + crview4article $rowid + n=`query "SELECT count(*) FROM writeusers;"` + err N=$n + if [ $((n)) -gt 0 ]; then + err ROWID=$rowid + sql="SELECT growid || ':' || gname FROM movablegroups;" + cat<<-EOF + <div class="fold"> + `cgi_checkbox mv send id="mv"`<label + for="mv">この話題をグループ所有に移動する</label> + <div> + <form action="?mvart" method="POST" enctype="multipart/form-data"> + 移動先グループ: + <select name="mv2grp"> + EOF + query ".mode html" + query<<-EOF | + $sql + .mode list + EOF + sed -e '/<\/TR>/d' -e 's,<TR>,,' -e 's,TD>,option>,g' \ + -e 's,n>\([0-9]*\):\(.*\)<,n value="\1">\2<,' + cat<<-EOF + </select> + <p>`cgi_checkbox cfm yes`<label>確認 + (この操作は元に戻すことができません)</label></p> + `cgi_hidden blogrowid $rowid` + `cgi_submit 移動` + `cgi_reset Reset` + </form> + </div> + </div> + EOF + fi + fi +} +mvart() { + blogrowid=`getpar blogrowid` + mv2grp=`getpar mv2grp` + cfm=`getpar cfm` + ##### echo move blog:$blogrowid to $mv2grp | html p + blogrowid=${blogrowid%%[!A-Z0-9a-z_]*} # Purify + mv2grp=${mv2grp%%[!A-Z0-9a-z_]*} # Purify + . ./s4-blog.sh + if [ -z "$blogrowid" -o -z "$mv2grp" ]; then + echo "無効な指定です(mvart)。" | html p + return + elif [ x"$cfm" != x"yes" ]; then + echo "記事移動の確認にチェックがないので通常表示に戻ります。" | html p + else # OK to go + crview4article $blogrowid + ########## TRANSACTION BEGIN + query "BEGIN;" + n=`query "SELECT count(*) FROM writeusers;"` + err Nwriteuser=$n + if [ $((n)) -gt 0 ]; then + query<<-EOF + UPDATE blog_s SET val=(SELECT gname FROM grp WHERE rowid=$mv2grp) + WHERE key='owner' + AND id=(SELECT id FROM blog WHERE rowid=$blogrowid) + AND $mv2grp IN (SELECT growid FROM movablegroups); + EOF + fi + query "END;" + ########## TRANSACTION END + fi + blog_reply $blogrowid + echo yes | html p } editart() { # $1=article-rowid $2=blogrowid rowid=${1%%[!A-Z0-9a-z_]*}
--- a/s4.cgi Fri Apr 29 09:45:07 2016 +0859 +++ b/s4.cgi Fri Apr 29 18:15:45 2016 +0859 @@ -47,7 +47,7 @@ showattc "$@" exit 0 # Do not output further chunks ;; - invite|groupman|userconf|groupconf|mems|grps|grp|groupupdate|grpaction|joingrpadmit|commission|editheading|editart|showattc|send2mem) + invite|groupman|userconf|groupconf|mems|grps|grp|groupupdate|grpaction|joingrpadmit|commission|editheading|editart|showattc|send2mem|mvart) contenttype; echo [ -n "$1" ] && shift $stage "$@"