Index: trunk/DNSDB.pm
===================================================================
--- trunk/DNSDB.pm	(revision 472)
+++ trunk/DNSDB.pm	(revision 473)
@@ -1759,17 +1759,17 @@
   my $entname;
   if ($type eq 'domain') {
-    $entname = domainName($dbh, $id);
+    $entname = $self->domainName($id);
   } elsif ($type eq 'revzone') {
-    $entname = revName($dbh, $id);
+    $entname = $self->revName($id);
   } elsif ($type eq 'user') {
-    $entname = userFullName($dbh, $id, '%u');
+    $entname = $self->userFullName($id, '%u');
   } elsif ($type eq 'group') {
-    $entname = groupName($dbh, $id);
+    $entname = $self->groupName($id);
   }
 
   my ($oldgid) = $dbh->selectrow_array("SELECT group_id FROM $par_tbl{$type} WHERE $id_col{$type}=?",
 	undef, ($id));
-  my $oldgname = groupName($dbh, $oldgid);
-  my $newgname = groupName($dbh, $newgrp);
+  my $oldgname = $self->groupName($oldgid);
+  my $newgname = $self->groupName($newgrp);
 
   return ('FAIL', "Can't move things into a group that doesn't exist") if !$newgname;
@@ -1916,5 +1916,5 @@
   my $msg = '';
   my $failmsg = '';
-  my $zone = ($revrec eq 'n' ? domainName($dbh, $zoneid) : revName($dbh, $zoneid));
+  my $zone = ($revrec eq 'n' ? $self->domainName($zoneid) : $self->revName($zoneid));
 
   return ('FAIL', ($revrec eq 'n' ? 'Domain' : 'Reverse zone')." ID $zoneid doesn't exist") if !$zone;
@@ -1924,6 +1924,6 @@
   $loghash{domain_id} = $zoneid if $revrec eq 'n';
   $loghash{rdns_id} = $zoneid if $revrec eq 'y';
-  $loghash{group_id} = parentID($dbh,
-	(id => $zoneid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) );
+  $loghash{group_id} = $self->parentID(
+	id => $zoneid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec);
 
   # Wrap all the SQL in a transaction
@@ -1986,5 +1986,6 @@
 sub domainName {
   $errstr = '';
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $domid = shift;
   my ($domname) = $dbh->selectrow_array("SELECT domain FROM domains WHERE domain_id=?", undef, ($domid) );
@@ -2000,5 +2001,6 @@
 sub revName {
   $errstr = '';
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $revid = shift;
   my ($revname) = $dbh->selectrow_array("SELECT revnet FROM revzones WHERE rdns_id=?", undef, ($revid) );
@@ -2013,5 +2015,6 @@
 sub domainID {
   $errstr = '';
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $domain = shift;
   my ($domid) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE lower(domain) = lower(?)",
@@ -2027,5 +2030,6 @@
 sub revID {
   $errstr = '';
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $revzone = shift;
   my ($revid) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet=?", undef, ($revzone) );
@@ -2439,6 +2443,6 @@
 
   # collect some pieces for logging and error messages
-  my $groupname = groupName($dbh,$groupid);
-  my $parid = parentID($dbh, (id => $groupid, type => 'group'));
+  my $groupname = $self->groupName($groupid);
+  my $parid = $self->parentID(id => $groupid, type => 'group');
 
   # Wrap all the SQL in a transaction
@@ -2522,5 +2526,6 @@
 sub groupName {
   $errstr = '';
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $groupid = shift;
   my $sth = $dbh->prepare("SELECT group_name FROM groups WHERE group_id=?");
@@ -2625,5 +2630,6 @@
 sub groupID {
   $errstr = '';
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $group = shift;
   my ($grpid) = $dbh->selectrow_array("SELECT group_id FROM groups WHERE group_name=?", undef, ($group) );
@@ -2960,5 +2966,6 @@
 sub userFullName {
   $errstr = '';
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $userid = shift;
   my $fullformat = shift || '%f %l (%u)';
@@ -3005,5 +3012,5 @@
 
       my %loghash;
-      $loghash{group_id} = parentID($dbh, (id => $id, type => 'user'));
+      $loghash{group_id} = $self->parentID(id => $id, type => 'user');
       $loghash{entry} = $resultstr;
       _log($dbh, %loghash);
@@ -3343,5 +3350,6 @@
 # Returns a two-element list with a result code and message
 sub updateSOA {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $defrec = shift;
   my $revrec = shift;
@@ -3349,5 +3357,5 @@
   my %soa = @_;
 
-  my $oldsoa = getSOA($dbh, $defrec, $revrec, $soa{id});
+  my $oldsoa = $self->getSOA($defrec, $revrec, $soa{id});
 
   my $msg;
@@ -3356,11 +3364,11 @@
     $logdata{domain_id} = $soa{id} if $revrec eq 'n';
     $logdata{rdns_id} = $soa{id} if $revrec eq 'y';
-    $logdata{group_id} = parentID($dbh, (id => $soa{id}, revrec => $revrec,
-	type => ($revrec eq 'n' ? 'domain' : 'revzone') ) );
+    $logdata{group_id} = $self->parentID(id => $soa{id}, revrec => $revrec,
+	type => ($revrec eq 'n' ? 'domain' : 'revzone') );
   } else {
     $logdata{group_id} = $soa{id};
   }
-  my $parname = ($defrec eq 'y' ? groupName($dbh, $soa{id}) :
-		($revrec eq 'n' ? domainName($dbh, $soa{id}) : revName($dbh, $soa{id})) );
+  my $parname = ($defrec eq 'y' ? $self->groupName($soa{id}) :
+		($revrec eq 'n' ? $self->domainName($soa{id}) : $self->revName($soa{id})) );
 
   # Allow transactions, and raise an exception on errors so we can catch it later.
@@ -3612,6 +3620,5 @@
   }
   $logdata{group_id} = $id if $defrec eq 'y';
-  $logdata{group_id} = parentID($dbh,
-		(id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) )
+  $logdata{group_id} = $self->parentID(id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec)
 	if $defrec eq 'n';
   $logdata{entry} = "Added ".($defrec eq 'y' ? 'default record' : 'record');
@@ -3781,6 +3788,5 @@
   }
   $logdata{group_id} = $parid if $defrec eq 'y';
-  $logdata{group_id} = parentID($dbh,
-		(id => $parid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) )
+  $logdata{group_id} = $self->parentID(id => $parid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec)
 	if $defrec eq 'n';
   $logdata{entry} = "Updated ".($defrec eq 'y' ? 'default record' : 'record')." from\n";
@@ -3913,6 +3919,6 @@
   $logdata{rdns_id} = $oldrec->{rdns_id};
   $logdata{group_id} = $oldrec->{group_id} if $defrec eq 'y';
-  $logdata{group_id} = parentID($dbh,
-		(id => $oldrec->{domain_id}, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) )
+  $logdata{group_id} = $self->parentID(id => $oldrec->{domain_id}, type => ($revrec eq 'n' ? 'domain' : 'revzone'),
+	revrec => $revrec)
 	if $defrec eq 'n';
   $logdata{entry} = "Deleted ".($defrec eq 'y' ? 'default record ' : 'record ').
@@ -4093,5 +4099,6 @@
 # Returns the ID or undef on failure
 sub parentID {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
 
   my %args = @_;
@@ -4242,5 +4249,5 @@
 
 ##fixme  switch to more consise "Enabled <domain"/"Disabled <domain>" as with users?
-      $resultstr = "Changed ".($revrec eq 'n' ? domainName($dbh, $id) : revName($dbh, $id)).
+      $resultstr = "Changed ".($revrec eq 'n' ? $self->domainName($id) : $self->revName($id)).
 	" state to ".($newstatus ? 'active' : 'inactive');
 
@@ -4248,6 +4255,5 @@
       $loghash{domain_id} = $id if $revrec eq 'n';
       $loghash{rdns_id} = $id if $revrec eq 'y';
-      $loghash{group_id} = parentID($dbh,
-	(id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) );
+      $loghash{group_id} = $self->parentID(id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec);
       $loghash{entry} = $resultstr;
       _log($dbh, %loghash);
