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 wrap: on
line diff
--- a/s4-blog.sh	Thu Dec 24 19:42:58 2020 +0900
+++ b/s4-blog.sh	Thu Dec 24 20:04:51 2020 +0900
@@ -1301,10 +1301,12 @@
   rid=`numericalize $1`
   blogowner=`getvalbyid blog owner "$rid"`
   contenttype "application/json; charset=utf-8"; echo
-  if ! isgroup "$blogowner"; then
-    msg="グループのみの操作です";	code=1
+  if [ -z "$blogowner" ]; then
+    msg="不当な掲示板です";		code=1
+  elif ! isgroup "$blogowner"; then
+    msg="グループのみの操作です";	code=2
   elif ! isgrpowner "$user" "$blogowner"; then
-    msg="グループ管理者のみの操作です";	code=2
+    msg="グループ管理者のみの操作です";	code=3
   else	# With full permission
     blogid=`query "SELECT id FROM blog WHERE rowid=$rid;"`
     dbsetbyid blog "$blogid" "$2" "$3"
@@ -1313,19 +1315,18 @@
   # echo "{\"code\": $code, \"message\": \"foo\"}"; exit
   newval=`getvalbyid blog "$2" "$1"`
   alert="${msg:+, \"alert\": \"$msg\"}"
-  cat <<-EOF
+  json=$(cat <<-EOF
 	{"code": $code, "$2": "`echo "$newval"|sed 's/"/\\\\"/g'`"$alert}
 	EOF
+      )
+  err blog_setval: returning JSON: "$json"
+  echo "$json"
   exit
 }
 
 blog_setfrozen() {
   # $1=GRProwID $2=val={ "frozen" | "" }
-  case "$2" in
-    [Ff])	state="frozen" ;;
-    *)		state="" ;;
-  esac
-  err getvalbyid-blog-$1= `getvalbyid blog state "$1"`
+  err blog_setfrozen: getvalbyid-blog-$1=`getvalbyid blog state "$1"`
   case `getvalbyid blog state "$1"` in
     [Ff][Rr]*)	newval="" ;;
     *)		newval="frozen" ;;

yatex.org