Index: /trunk/dns.cgi
===================================================================
--- /trunk/dns.cgi	(revision 53)
+++ /trunk/dns.cgi	(revision 54)
@@ -52,5 +52,5 @@
   $session->param('domlistsortby','domain');
   $session->param('domlistorder','ASC');
-  $session->param('useradminsortby','username');
+  $session->param('useradminsortby','user');
   $session->param('useradminorder','ASC');
   $session->param('grpmansortby','group');
@@ -67,4 +67,17 @@
 my $group = ($webvar{group} ? $webvar{group} : 1);
 
+# per-page startwith, filter, searchsubs
+$session->param($webvar{page}.'startwith', $webvar{startwith}) if $webvar{startwith};
+$session->param($webvar{page}.'filter', $webvar{filter}) if $webvar{filter};
+$webvar{searchsubs} =~ s/^n ?// if $webvar{searchsubs};
+$session->param($webvar{page}.'searchsubs', $webvar{searchsubs}) if $webvar{searchsubs};
+
+my $startwith = $session->param($webvar{page}.'startwith');
+my $filter = $session->param($webvar{page}.'filter');
+my $searchsubs = $session->param($webvar{page}.'searchsubs');
+
+
+
+if (0) {
 # filter, starts with, search subgroups
 $session->param('filter', "$webvar{page}:filter$webvar{filter}") if defined($webvar{filter});
@@ -80,4 +93,7 @@
 my $searchsubs = $session->param('searchsubs');
 $searchsubs = ($searchsubs =~ /^$webvar{page}:searchsubs(.+)$/ ? $1 : '');
+}
+
+
 
 # nrgh, can't handle login here because we don't have a database handle to check the user/pass with yet
@@ -1022,5 +1038,5 @@
   my @cols = ('domain', 'status', 'group');
   my %colheads = (domain => 'Domain', status => 'Status', group => 'Group');
-  fill_colheads(\@cols, \%colheads);
+  fill_colheads($sortby, $sortorder, \@cols, \%colheads);
 
 #  $page->param(sortorder => $sortorder);
@@ -1076,5 +1092,5 @@
   my $childlist = join(',',@childgroups);
 
-  my $sql = "SELECT count(*) FROM groups WHERE group_id IN ($logingroup".($childlist ? ",$childlist" : '').")".
+  my $sql = "SELECT count(*) FROM groups WHERE parent_group_id IN ($logingroup".($childlist ? ",$childlist" : '').")".
 	($startwith ? " AND group_name ~* '^[$startwith]'" : '').
 	($filter ? " AND group_name ~* '$filter'" : '');
@@ -1099,5 +1115,5 @@
   my @cols = ('group','parent','nusers','ndomains');
   my %colnames = (group => 'Group', parent => 'Parent Group', nusers => 'Users', ndomains => 'Domains');
-  fill_colheads(\@cols, \%colnames);
+  fill_colheads($sortby, $sortorder, \@cols, \%colnames);
 
 # waffle, waffle - keep state on these as well as sortby, sortorder?
@@ -1118,5 +1134,5 @@
 	"LEFT OUTER JOIN users u ON u.group_id=g.group_id ".
 	"LEFT OUTER JOIN domains d ON d.group_id=g.group_id ".
-	"WHERE g.group_id IN ($logingroup".($childlist ? ",$childlist" : '').") ".
+	"WHERE g.parent_group_id IN ($logingroup".($childlist ? ",$childlist" : '').") ".
 ##fixme:  don't do variable subs in SQL, use placeholders and params in ->execute()
 	($startwith ? " AND g.group_name ~* '^[$startwith]'" : '').
@@ -1201,5 +1217,5 @@
   my @cols = ('user','fname','type','group','status');
   my %colnames = (user => 'Username', fname => 'Full Name', type => 'Type', group => 'Group', status => 'Status');
-  fill_colheads(\@cols, \%colnames);
+  fill_colheads($sortby, $sortorder, \@cols, \%colnames);
 
 # waffle, waffle - keep state on these as well as sortby, sortorder?
@@ -1250,4 +1266,6 @@
 # Takes an array ref and hash ref
 sub fill_colheads {
+  my $sortby = shift;
+  my $sortorder = shift;
   my $cols = shift;
   my $colnames = shift;
@@ -1274,3 +1292,3 @@
   $page->param(colheads => \@headings);
 
-} # end gentableheadings
+} # end fill_colheads()
