Legend:
- Unmodified
- Added
- Removed
-
trunk/TODO
r50 r52 30 30 - would let users create plugin code to support arbitrary types 31 31 - Push DB name, host, username, password into config file 32 33 2009/12/17 34 - "complete rewrite" target: one table of objects, one set of functions; hooks 35 to manipulate "special" data for given types of objects? (even merging 36 domain/group/user objects would reduce a lot of code almost-duplication) -
trunk/dns.cgi
r51 r52 726 726 # le sigh. and we need to strip any previous action 727 727 $tmp_ruri =~ s/\&action=[^&]+//g; 728 729 ##fixme: need to sort out how to propagate these without dragging them along too far, and <n>plicating them 728 730 # and any bits from the "starts with" letter block - (ab)using this widget 729 731 # to fill the bulk of the URI so various templates don't grow to insanity 730 732 $tmp_ruri =~ s/\&startwith=[a-z09-]+//g; 733 # search box webvars 734 $tmp_ruri =~ s/\&searchsubs=[a-z09-]+//g; 735 $tmp_ruri =~ s/\&filter=[a-z09-]+//g; 736 731 737 # $page->param(whereami => $ENV{REQUEST_URI}); 732 738 $page->param(whereami => $tmp_ruri); … … 968 974 sub listdomains { 969 975 970 ##fixme: account for searches and starts-with filters 971 my $sth = $dbh->prepare("SELECT count(*) FROM domains WHERE group_id=?"); 972 $sth->execute($curgroup); 976 ##fixme: $logingroup or$curgroup? 977 my @childgroups; 978 getChildren($dbh, $logingroup, \@childgroups, 'all'); 979 my $childlist = join(',',@childgroups); 980 981 my $sql = "SELECT count(*) FROM domains WHERE group_id IN ($logingroup".($childlist ? ",$childlist" : '').")". 982 (defined($webvar{startwith}) ? " AND domain ~* '^[$webvar{startwith}]'" : ''). 983 (defined($webvar{filter}) ? " AND domain ~* '$webvar{filter}'" : ''); 984 my $sth = $dbh->prepare($sql); 985 $sth->execute; 973 986 my ($count) = $sth->fetchrow_array; 974 987 … … 1006 1019 $page->param(group => $curgroup); 1007 1020 my @domlist; 1008 my$sql = "SELECT domain_id,domain,status,groups.group_name AS group FROM domains".1021 $sql = "SELECT domain_id,domain,status,groups.group_name AS group FROM domains". 1009 1022 " INNER JOIN groups ON domains.group_id=groups.group_id". 1010 " WHERE domains.group_id =?".1023 " WHERE domains.group_id IN ($logingroup".($childlist ? ",$childlist" : '').")". 1011 1024 ##fixme: don't do variable subs in SQL, use placeholders and params in ->execute() 1012 1025 (defined($webvar{startwith}) ? " AND domain ~* '^[$webvar{startwith}]'" : ''). … … 1015 1028 " $sortorder ".($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage); 1016 1029 $sth = $dbh->prepare($sql); 1017 $sth->execute ($curgroup);1030 $sth->execute; 1018 1031 my $rownum = 0; 1019 1032 while (my @data = $sth->fetchrow_array) { … … 1040 1053 my $childlist = join(',',@childgroups); 1041 1054 1042 my $sql = "SELECT count(*) FROM groups WHERE group_id IN ($logingroup".($childlist ? ",$childlist" : '').")"; 1055 my $sql = "SELECT count(*) FROM groups WHERE group_id IN ($logingroup".($childlist ? ",$childlist" : '').")". 1056 (defined($webvar{startwith}) ? " AND group_name ~* '^[$webvar{startwith}]'" : ''). 1057 (defined($webvar{filter}) ? " AND group_name ~* '$webvar{filter}'" : ''); 1043 1058 my $sth = $dbh->prepare($sql); 1044 1059 … … 1088 1103 $sth->execute; 1089 1104 1090 push @debugbits, $sth->errstr;1091 1105 my $rownum = 0; 1092 1106 while (my @data = $sth->fetchrow_array) { … … 1135 1149 1136 1150 sub list_users { 1137 my $sth = $dbh->prepare("select count(*) from users where group_id=?"); 1138 $sth->execute($curgroup); 1151 1152 my @childgroups; 1153 getChildren($dbh, $curgroup, \@childgroups, 'all') if $webvar{searchsubs}; 1154 my $childlist = join(',',@childgroups); 1155 1156 my $sql = "SELECT count(*) FROM users WHERE group_id IN ($curgroup".($childlist ? ",$childlist" : '').")". 1157 (defined($webvar{startwith}) ? " AND username ~* '^[$webvar{startwith}]'" : ''). 1158 (defined($webvar{filter}) ? " AND username ~* '$webvar{filter}'" : ''); 1159 my $sth = $dbh->prepare($sql); 1160 $sth->execute; 1139 1161 my ($count) = ($sth->fetchrow_array); 1140 1162 … … 1161 1183 1162 1184 $page->param(filter => $webvar{filter}) if $webvar{filter}; 1185 $page->param(searchsubs => $webvar{searchsubs}) if $webvar{searchsubs}; 1163 1186 1164 1187 # munge sortby for columns in database … … 1169 1192 1170 1193 my @userlist; 1171 $s th = $dbh->prepare("SELECT u.user_id, u.username, u.firstname || ' ' || u.lastname AS fname, u.type, g.group_name, u.status ".1194 $sql = "SELECT u.user_id, u.username, u.firstname || ' ' || u.lastname AS fname, u.type, g.group_name, u.status ". 1172 1195 "FROM users u ". 1173 1196 "INNER JOIN groups g ON u.group_id=g.group_id ". 1174 "WHERE u.group_id =?".1197 "WHERE u.group_id IN ($curgroup".($childlist ? ",$childlist" : '').")". 1175 1198 ##fixme: don't do variable subs in SQL, use placeholders and params in ->execute() 1176 1199 (defined($webvar{startwith}) ? " AND u.username ~* '^[$webvar{startwith}]'" : ''). 1177 1200 (defined($webvar{filter}) ? " AND u.username ~* '$webvar{filter}'" : ''). 1178 1201 " ORDER BY $sortby $sortorder ". 1179 ($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage) );1202 ($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage); 1180 1203 1181 1204 # " GROUP BY g.group_id, g.group_name, g2.group_name ". 1182 1205 # ($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage)); 1183 1206 1184 $sth->execute($curgroup); 1207 $sth = $dbh->prepare($sql); 1208 $sth->execute; 1185 1209 1186 1210 my $rownum = 0; -
trunk/templates/sbox.tmpl
r46 r52 1 1 <form action="<TMPL_VAR NAME=whereami>" method="post"> 2 2 <fieldset> 3 Search subgroups: <input type="checkbox" <TMPL_IF searchsubs>checked="checked"</TMPL_IF> name="searchsubs" /> 3 Search subgroups: <input type="checkbox"<TMPL_IF searchsubs> checked="checked"</TMPL_IF> name="searchsubs" /> 4 <input type="hidden" name="searchsubs" value="<TMPL_VAR NAME=searchsubs>"> 4 5 <input name="filter" value="<TMPL_VAR NAME=filter>" /> 5 6 <input type="submit" value="Search" />
Note:
See TracChangeset
for help on using the changeset viewer.