diff s4-funcs.sh @ 58:ccd0c6736215

Argument order reversed on email4group
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 23 Jul 2015 11:35:05 +0900
parents 7fa1ac62dfaf
children 916d81b9c4fc
line wrap: on
line diff
--- a/s4-funcs.sh	Thu Jul 23 11:09:09 2015 +0900
+++ b/s4-funcs.sh	Thu Jul 23 11:35:05 2015 +0900
@@ -1019,16 +1019,18 @@
       ;;
   esac
 }
-email4group() (
-  # Get $1=user email address(es) for group $2=group
-  qgrp=`sqlquote "$2"`
+email4group() {
+  # Get for-$1=group email address(es) for $2=user
+  qgrp=`sqlquote "$1"`; shift
+  users=`for i; do sqlquote "$i"; done`
+  users=`echo $users|tr ' ' ','`
   sql="select coalesce(s.val, g.user) from grp_mem g
-	join grp_mem_s s on g.gname=s.gname and g.user=s.user
-	and s.key='email' and g.user='$1'
-	where g.gname=$qgrp;"
+	left join grp_mem_s s on g.gname=s.gname and g.user=s.user
+	and s.key='email'
+	where g.gname=$qgrp and g.user in ($users);"
   err `echo $sql`
   query "$sql"
-)
+}
 collectemail() (
   # Collect email addresses for group $1
   for e; do

yatex.org