s4
changeset 56:7fa1ac62dfaf
getgroupadmins()
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 23 Jul 2015 11:08:22 +0900 |
parents | 7f9f7e898986 |
children | 7c61a80051f5 |
files | s4-funcs.sh |
diffstat | 1 files changed, 18 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/s4-funcs.sh Thu Jul 23 11:07:24 2015 +0900 1.2 +++ b/s4-funcs.sh Thu Jul 23 11:08:22 2015 +0900 1.3 @@ -331,13 +331,18 @@ 1.4 err isgrpowner: $sql 1.5 test -n "`query $sql`" 1.6 ) 1.7 -getgroupbyid() ( 1.8 +getgroupadmins() { # $1=group 1.9 + # This function is called in a backquote, so needn't to be subshellized 1.10 + qgrp=`sqlquote "$1"` 1.11 + query "select user from grp_adm where gname=$qgrp;" 1.12 +} 1.13 +getgroupbyid() { 1.14 # $1=id|gname 1.15 sql="select coalesce((select gname from grp where gname=$(sqlquote $1)), 1.16 (select gname from grp where rowid=$(sqlquote $1)));" 1.17 err ggbyid: `echo $sql` 1.18 query $sql 1.19 -) 1.20 +} 1.21 isfilereadable() { # $1=user $2=tbl $3=rowid 1.22 # Return true if user($1) can read attachment files in tbl($2):rowid($3) 1.23 [ -z "$1" -o -z "$2" -o -z "$3" ] && return 1 # invalid argument 1.24 @@ -1014,6 +1019,16 @@ 1.25 ;; 1.26 esac 1.27 } 1.28 +email4group() ( 1.29 + # Get $1=user email address(es) for group $2=group 1.30 + qgrp=`sqlquote "$2"` 1.31 + sql="select coalesce(s.val, g.user) from grp_mem g 1.32 + join grp_mem_s s on g.gname=s.gname and g.user=s.user 1.33 + and s.key='email' and g.user='$1' 1.34 + where g.gname=$qgrp;" 1.35 + err `echo $sql` 1.36 + query "$sql" 1.37 +) 1.38 collectemail() ( 1.39 # Collect email addresses for group $1 1.40 for e; do 1.41 @@ -1030,7 +1045,7 @@ 1.42 # on a.gname=b.gname and a.val=b.user and b.key='email' 1.43 # where a.val in (select name from user) limit 10000;" 1.44 # tmp tmp tmp tmp tmp tmp tmp 1.45 - qgrp=`sqlquote $e` 1.46 + qgrp=`sqlquote "$e"` 1.47 sql="select coalesce(s.val,g.user) from grp_mem g left join grp_mem_s s 1.48 on g.gname=s.gname and g.user=s.user and s.key='email' 1.49 where g.gname=$qgrp;"