diff s4-funcs.sh @ 825:e9817a71f332

List groups in other worlds
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 21 Jun 2020 09:50:32 +0900
parents d2c4c473e08e
children 97be0474f268
line wrap: on
line diff
--- a/s4-funcs.sh	Sat Jun 20 18:18:17 2020 +0900
+++ b/s4-funcs.sh	Sun Jun 21 09:50:32 2020 +0900
@@ -32,7 +32,8 @@
 tmpfiles=""
 querylog=${QUERYLOG:-$logdir/query.log}
 searchlog=${SEARCHLOG:-$logdir/search.log}
-db=${DB:-$dbdir/cgi.sq3}
+defaultdb=$dbdir/cgi.sq3
+db=${DB:-$defaultdb}
 sessdb=${SESSDB:-$dbdir/sess.sq3}
 userupdateflag=$dbdir/userupdate
 sesstb=tmp.sess
@@ -2334,7 +2335,7 @@
   fi
   ) > $hometail &		# Is background call safe to m4??
   #
-  listgroupbytable $formdir/grp.def $cond |
+  listgroupbytable $formdir/grp.def "$cond" $uname |
       _m4 -D_BODYCLASS_=home -D_TITLE_="spaste(\`$tf')" \
 	  -D_PROFILE_="spaste(\`$pf')$usermenu" \
 	  -D_PROFIMG_="spaste(\`$imf')" \
@@ -2361,16 +2362,12 @@
   fi
 }
 listgroupbytable() {
-  # $1=deffile $2...=condition
-  tagline=`grep :tag: $1`; shift
-  and="${1:+and }" where=${1:+where }
+  # $1=deffile $2...=condition $3(optional)=uname
+  tagline=`grep :tag: $1`;
+  and="${2:+and }" where=${2:+where }
   href="<a href=\"$myname?grp+"
   echo '<div class="listgroup">'
-  NGsql="select distinct tag from\
-	(select gname, max(case key when 'tag' then val end) as tag, \
-	  max(case key when 'ctime' then val end) as ctime\
-	 from grp_s group by gname order by ctime);"
-  sql="select val from grp_s where key='tag' $and$* group by val;"
+  sql="select val from grp_s where key='tag' $and$2 group by val;"
 ## err ListGRP: query sql="$sql"
   for tag in `query "$sql"`
   do
@@ -2384,7 +2381,7 @@
 	 max(case key when 'gecos' then val end) as '説明',
 	 max(case key when 'tag' then val end) as 'tag',
 	 max(case key when 'mtime' then val end) as mtime from grp_s
-	 $where$* group by gname having tag='$tag' order by mtime desc);"
+	 $where$2 group by gname having tag='$tag' order by mtime desc);"
 ## err PersonalGroupList= `echo $sql`
     echo "<h2>$tn</h2>"
     echo '<table class="b listgroup">'
@@ -2392,6 +2389,9 @@
       | sed "s,\(<TR><TD>\)\([0-9]*\):\([^<]*\)</TD>,\1$href\2\">\3</a>,"
     echo '</table>'
   done
+  if [ -n "$S4WORLDLIST" -a -n "$3" ]; then
+    peekgrpworlds mem="$3"
+  fi
   echo '</div>'
 }
 iconhref() (
@@ -2550,7 +2550,7 @@
     # limit=3
     hiddens=$hiddens" "`cgi_hidden tag2 "$tag"`
   fi
-  if [ $total -gt $limit ]; then
+  if [ $total -gt $limit -o \( -n "$S4WORLDLIST" -a x"$tbl" = x"grp" \) ]; then
     echo '<div>'
     METHOD=GET cgi_form $stage <<EOF
 $form
@@ -2633,6 +2633,9 @@
   done
   echo "</div>"					# End of List-entry div
   echo ${pnbtn:+"<hr>$nextbtn$prevbtn"}
+  if [ -n "$kwd" -a x"$tbl" = x"grp" -a -n "$S4WORLDS" ]; then
+    peekgrpworlds kwd="$kwd"
+  fi
 )
 listmember() {
   listentry user "$@"

yatex.org