changeset 122:0681534f9451

When deleting group, remove all blos that belong it.
author HIROSE Yuuji <yuuji@gentei.org>
date Wed, 05 Aug 2015 23:34:40 +0900
parents 34b72806cd22
children 718abe22a5d1
files s4-blog.sh s4-funcs.sh
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/s4-blog.sh	Wed Aug 05 21:50:33 2015 +0900
+++ b/s4-blog.sh	Wed Aug 05 23:34:40 2015 +0900
@@ -411,6 +411,7 @@
   else
     owner=`getpar owner`
   fi
+  err blog-add: \$1=$1 rowid=$rowid owner=$owner
   if isgroup $owner; then
     groupmode=1 listing=$owner guide="[${owner}]" GF_OWNER=$owner
   else
@@ -419,6 +420,7 @@
 
   if [ -n "`getpar title`" ]; then
     if [ "$usermode" ]; then
+      err usermode: user=$user owner=$owner
       if [ x"$user" != x"$owner" ]; then
 	echo "他人の日記は書けません" | html p
 	return 2
--- a/s4-funcs.sh	Wed Aug 05 21:50:33 2015 +0900
+++ b/s4-funcs.sh	Wed Aug 05 23:34:40 2015 +0900
@@ -1241,8 +1241,25 @@
       query "END;"
       return
     fi
+    query "END TRANSACTION;"
     par2table $formdir/grp.def
-    query "END TRANSACTION;"
+    # Remove orphant
+    : <<EOF
+	select a.id,b.val from (select * from blog where id in
+	 (select id from blog_s where key='owner'
+	 and val not in (select name from user union select gname from grp)))
+	a left join blog_s b on a.id=b.id and b.key='owner';
+EOF
+    rm=`getpar rm` cfm=`getpar confirm`
+    err groupupdate:::: after par2tbl rmcfm=$rm$cfm
+    if [ x"$rm$cfm" = x"yesyes" ]; then
+      if [ -z "`query \"select gname from grp where gname=$qgname;\"`" ]; then
+	sql="delete from blog where id in
+	 (select id from blog_s where key='owner' and val=$qgname);"
+	err rm-grp cleaning sql=`echo $sql`
+	query "$sql";
+      fi
+    fi
     [ -z "$parow" ] && joingrp "$gname" "$user" yes "$user" as-admin
   fi
   sql="select rowid from grp where gname=$qgname;"
@@ -2004,7 +2021,7 @@
   ### elink="<a href=\"$myname?edittable+$2+\\2\">EDIT</a>"
   VIEW=${DT_VIEW-replyblog}
   if [ -n "$VIEW" ]; then
-    dvlink=" <a href=\"$myname?$VIEW+\\2\">VIEW</a>"
+    dvlink=" <a href=\"$myname?$VIEW+\\2\">VIE</a><a href=\"$myname?$VIEW+\\2#bottom\">W</a>"
   fi
   # $DT_CHLD=ChildTable:BindColumn
   if [ -n "$DT_CHLD" ]; then

yatex.org