s4

changeset 890:bc52f605f41d

Log message for blog_setfrozen more informative
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 24 Dec 2020 20:04:51 +0900
parents 5843755e3b30
children 45771085d097
files s4-blog.sh
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Thu Dec 24 19:42:58 2020 +0900
     1.2 +++ b/s4-blog.sh	Thu Dec 24 20:04:51 2020 +0900
     1.3 @@ -1301,10 +1301,12 @@
     1.4    rid=`numericalize $1`
     1.5    blogowner=`getvalbyid blog owner "$rid"`
     1.6    contenttype "application/json; charset=utf-8"; echo
     1.7 -  if ! isgroup "$blogowner"; then
     1.8 -    msg="グループのみの操作です";	code=1
     1.9 +  if [ -z "$blogowner" ]; then
    1.10 +    msg="不当な掲示板です";		code=1
    1.11 +  elif ! isgroup "$blogowner"; then
    1.12 +    msg="グループのみの操作です";	code=2
    1.13    elif ! isgrpowner "$user" "$blogowner"; then
    1.14 -    msg="グループ管理者のみの操作です";	code=2
    1.15 +    msg="グループ管理者のみの操作です";	code=3
    1.16    else	# With full permission
    1.17      blogid=`query "SELECT id FROM blog WHERE rowid=$rid;"`
    1.18      dbsetbyid blog "$blogid" "$2" "$3"
    1.19 @@ -1313,19 +1315,18 @@
    1.20    # echo "{\"code\": $code, \"message\": \"foo\"}"; exit
    1.21    newval=`getvalbyid blog "$2" "$1"`
    1.22    alert="${msg:+, \"alert\": \"$msg\"}"
    1.23 -  cat <<-EOF
    1.24 +  json=$(cat <<-EOF
    1.25  	{"code": $code, "$2": "`echo "$newval"|sed 's/"/\\\\"/g'`"$alert}
    1.26  	EOF
    1.27 +      )
    1.28 +  err blog_setval: returning JSON: "$json"
    1.29 +  echo "$json"
    1.30    exit
    1.31  }
    1.32  
    1.33  blog_setfrozen() {
    1.34    # $1=GRProwID $2=val={ "frozen" | "" }
    1.35 -  case "$2" in
    1.36 -    [Ff])	state="frozen" ;;
    1.37 -    *)		state="" ;;
    1.38 -  esac
    1.39 -  err getvalbyid-blog-$1= `getvalbyid blog state "$1"`
    1.40 +  err blog_setfrozen: getvalbyid-blog-$1=`getvalbyid blog state "$1"`
    1.41    case `getvalbyid blog state "$1"` in
    1.42      [Ff][Rr]*)	newval="" ;;
    1.43      *)		newval="frozen" ;;