Index: /trunk/DNSDB.pm
===================================================================
--- /trunk/DNSDB.pm	(revision 479)
+++ /trunk/DNSDB.pm	(revision 480)
@@ -2160,5 +2160,5 @@
       } else {
 	my $logentry = "[new $zone] Added record '$host $typemap{$type} $val', TTL $ttl";
-	$logentry .= ", default location ".getLoc($dbh, $defloc)->{description} if $defloc;
+	$logentry .= ", default location ".$self->getLoc($defloc)->{description} if $defloc;
 	_log($dbh, (rdns_id => $rdns_id, domain_id => $domid, group_id => $group, entry => $logentry) );
       }
@@ -3073,5 +3073,6 @@
 # Returns ('OK',<location>) on success, ('FAIL',<failmsg>) on failure
 sub addLoc {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $grp = shift;
   my $shdesc = shift;
@@ -3153,5 +3154,6 @@
 # Returns a result code and message
 sub updateLoc {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $loc = shift;
   my $grp = shift;
@@ -3169,5 +3171,5 @@
   local $dbh->{RaiseError} = 1;
 
-  my $oldloc = getLoc($dbh, $loc);
+  my $oldloc = $self->getLoc($loc);
   my $okmsg = "Updated location (".$oldloc->{description}.", '".$oldloc->{iplist}."') to ($shdesc, '$iplist')";
 
@@ -3195,5 +3197,6 @@
 ## DNSDB::delLoc()
 sub delLoc {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $loc = shift;
 
@@ -3203,5 +3206,5 @@
   local $dbh->{RaiseError} = 1;
 
-  my $oldloc = getLoc($dbh, $loc);
+  my $oldloc = $self->getLoc($loc);
   my $olddesc = ($oldloc->{description} ? $oldloc->{description} : $loc);
   my $okmsg = "Deleted location ($olddesc, '".$oldloc->{iplist}."')";
@@ -3235,5 +3238,6 @@
 # Returns a reference to a hash containing the group ID, IP list, description, and comments/notes
 sub getLoc {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $loc = shift;
 
@@ -3251,5 +3255,6 @@
 # - a "Starts with" string
 sub getLocCount {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
 
   my %args = @_;
@@ -3274,5 +3279,6 @@
 ## DNSDB::getLocList()
 sub getLocList {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
 
   my %args = @_;
@@ -3313,5 +3319,6 @@
 # Returns a reference to a list of hashrefs suitable to feeding to HTML::Template
 sub getLocDropdown {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $grp = shift;
   my $sel = shift || '';
@@ -3655,5 +3662,5 @@
 	if $typemap{$$rectype} eq 'SRV';
   $logdata{entry} .= "', TTL $ttl";
-  $logdata{entry} .= ", location ".getLoc($dbh, $location)->{description} if $location;
+  $logdata{entry} .= ", location ".$self->getLoc($location)->{description} if $location;
 
   # Allow transactions, and raise an exception on errors so we can catch it later.
@@ -3822,5 +3829,5 @@
 	if $typemap{$oldrec->{type}} eq 'SRV';
   $logdata{entry} .= "', TTL $oldrec->{ttl}";
-  $logdata{entry} .= ", location ".getLoc($dbh, $oldrec->{location})->{description} if $oldrec->{location};
+  $logdata{entry} .= ", location ".$self->getLoc($oldrec->{location})->{description} if $oldrec->{location};
   $logdata{entry} .= "\nto\n";
   # More NS special
@@ -3833,5 +3840,5 @@
   $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$$rectype} eq 'SRV';
   $logdata{entry} .= "', TTL $ttl";
-  $logdata{entry} .= ", location ".getLoc($dbh, $location)->{description} if $location;
+  $logdata{entry} .= ", location ".$self->getLoc($location)->{description} if $location;
 
   local $dbh->{AutoCommit} = 0;
@@ -3949,5 +3956,5 @@
 	if $typemap{$oldrec->{type}} eq 'SRV';
   $logdata{entry} .= "', TTL $oldrec->{ttl}";
-  $logdata{entry} .= ", location ".getLoc($dbh, $oldrec->{location})->{description} if $oldrec->{location};
+  $logdata{entry} .= ", location ".$self->getLoc($oldrec->{location})->{description} if $oldrec->{location};
 
   eval {
Index: /trunk/dns-rpc.cgi
===================================================================
--- /trunk/dns-rpc.cgi	(revision 479)
+++ /trunk/dns-rpc.cgi	(revision 480)
@@ -304,5 +304,5 @@
   $args{defloc} = '' if !$args{defloc};
 
-  my $ret = DNSDB::getLocDropdown($dbh, $args{group}, $args{defloc});
+  my $ret = $dnsdb->getLocDropdown($args{group}, $args{defloc});
   return $ret;
 }
Index: /trunk/dns.cgi
===================================================================
--- /trunk/dns.cgi	(revision 479)
+++ /trunk/dns.cgi	(revision 480)
@@ -439,5 +439,5 @@
 
   fill_grouplist("grouplist");
-  my $loclist = getLocDropdown($dbh, $curgroup);
+  my $loclist = $dnsdb->getLocDropdown($curgroup);
   $page->param(loclist => $loclist);
 
@@ -1363,5 +1363,5 @@
 	unless ($permissions{admin} || $permissions{location_create});
 
-    my ($code,$msg) = addLoc($dbh, $curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
+    my ($code,$msg) = $dnsdb->addLoc($curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
 
     if ($code eq 'OK' || $code eq 'WARN') {
@@ -1387,5 +1387,5 @@
 	unless ($permissions{admin} || $permissions{location_edit});
 
-    my $loc = getLoc($dbh, $webvar{loc});
+    my $loc = $dnsdb->getLoc($webvar{loc});
     $page->param(wastrying	=> "editing");
     $page->param(todo		=> "Edit location/view");
@@ -1400,5 +1400,5 @@
 	unless ($permissions{admin} || $permissions{location_edit});
 
-    my ($code,$msg) = updateLoc($dbh, $webvar{id}, $curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
+    my ($code,$msg) = $dnsdb->updateLoc($webvar{id}, $curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
 
     if ($code eq 'OK') {
@@ -1438,5 +1438,5 @@
 
   $page->param(locid => $webvar{locid});
-  my $locdata = getLoc($dbh, $webvar{locid});
+  my $locdata = $dnsdb->getLoc($webvar{locid});
   $locdata->{description} = $webvar{locid} if !$locdata->{description};
   # first pass = confirm y/n (sorta)
@@ -1445,5 +1445,5 @@
     $page->param(location => $locdata->{description});
   } elsif ($webvar{del} eq 'ok') {
-    my ($code,$msg) = delLoc($dbh, $webvar{locid});
+    my ($code,$msg) = $dnsdb->delLoc($webvar{locid});
     if ($code eq 'OK') {
       # success.  go back to the user list, do not pass "GO"
@@ -2174,9 +2174,9 @@
 
   if ($permissions{admin} || $permissions{record_locchg}) {
-    my $loclist = getLocDropdown($dbh, $cur, $defloc);
+    my $loclist = $dnsdb->getLocDropdown($cur, $defloc);
     $page->param(record_locchg => 1);
     $page->param(loclist => $loclist);
   } else {
-    my $loc = getLoc($dbh, $defloc);
+    my $loc = $dnsdb->getLoc($defloc);
     $page->param(loc_name => $loc->{description});
   }
@@ -2237,6 +2237,6 @@
   my $childlist = join(',',@childgroups);
 
-  my $count = getLocCount($dbh, (childlist => $childlist, curgroup => $curgroup,
-	filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ) );
+  my $count = $dnsdb->getLocCount(childlist => $childlist, curgroup => $curgroup,
+	filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) );
 
 # fill page count and first-previous-next-last-all bits
@@ -2263,7 +2263,7 @@
   $page->param(searchsubs => $searchsubs) if $searchsubs;
 
-  my $loclist = getLocList($dbh, (childlist => $childlist, curgroup => $curgroup,
+  my $loclist = $dnsdb->getLocList(childlist => $childlist, curgroup => $curgroup,
 	filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef),
-	offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder) );
+	offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder);
   # Some UI things need to be done to the list
   foreach my $l (@{$loclist}) {
