Index: trunk/DNSDB.pm
===================================================================
--- trunk/DNSDB.pm	(revision 483)
+++ trunk/DNSDB.pm	(revision 484)
@@ -4340,24 +4340,25 @@
 # Import a domain via AXFR
 # Takes AXFR host, domain to transfer, group to put the domain in,
-# and optionally:
-#  - active/inactive state flag (defaults to active)
-#  - overwrite-SOA flag (defaults to off)
-#  - overwrite-NS flag (defaults to off, doesn't affect subdomain NS records)
+# and an optional hash containing:
+#  status - active/inactive state flag (defaults to active)
+#  rwsoa - overwrite-SOA flag (defaults to off)
+#  rwns - overwrite-NS flag (defaults to off, doesn't affect subdomain NS records)
+#  merge - flag to automerge A or AAAA records with matching PTR records
 # Returns a status code (OK, WARN, or FAIL) and message - message should be blank
 # if status is OK, but WARN includes conditions that are not fatal but should
 # really be reported.
 sub importAXFR {
-  my $dbh = shift;
+  my $self = shift;
+  my $dbh = $self->{dbh};
   my $ifrom_in = shift;
   my $zone = shift;
   my $group = shift;
-  my $status = shift;
-  $status = (defined($status) ? $status : 0);	# force sane semantics, and allow passing "null" (inactive) status
-  my $rwsoa = shift || 0;
-  my $rwns = shift || 0;
-  my $newttl = shift;
-  my $merge = shift || 0;	# do we attempt to merge A/AAAA and PTR records whenever possible?
-				# do we overload this with the fixme below?
+
+  my %args = @_;
+
 ##fixme:  add mode to delete&replace, merge+overwrite, merge new?
+
+  $args{status} = (defined($args{status}) ? $args{status} : 0);
+  $args{status} = 1 if $args{status} eq 'on'; 
 
   my $nrecs = 0;
@@ -4465,5 +4466,6 @@
     if ($rev eq 'n') {
 ##fixme:  serial
-      $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef, ($zone,$group,$status) );
+      $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef,
+        ($zone, $group, $args{status}) );
       # get domain id so we can do the records
       ($zone_id) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')");
@@ -4473,5 +4475,6 @@
     } else {
 ##fixme:  serial
-      $dbh->do("INSERT INTO revzones (revnet,group_id,status) VALUES (?,?,?)", undef, ($cidr,$group,$status) );
+      $dbh->do("INSERT INTO revzones (revnet,group_id,status) VALUES (?,?,?)", undef,
+        ($cidr,$group,$args{status}) );
       # get revzone id so we can do the records
       ($zone_id) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')");
@@ -4512,5 +4515,5 @@
       my $type = $rr->type;
       my $host = $rr->name;
-      my $ttl = ($newttl ? $newttl : $rr->ttl);	# allow force-override TTLs
+      my $ttl = ($args{newttl} ? $args{newttl} : $rr->ttl);	# allow force-override TTLs
 
       $soaflag = 1 if $type eq 'SOA';
@@ -4542,5 +4545,5 @@
       } elsif ($type eq 'NS') {
 # hmm.  should we warn here if subdomain NS'es are left alone?
-	next if ($rwns && ($rr->name eq $zone));
+	next if ($args{rwns} && ($rr->name eq $zone));
 	if ($rev eq 'y') {
 	  # revzones have records more or less reversed from forward zones.
@@ -4578,5 +4581,5 @@
 	}
       } elsif ($type eq 'SOA') {
-	next if $rwsoa;
+	next if $args{rwsoa};
 	$host = $rr->rname.":".$rr->mname;
 	$val = $rr->refresh.":".$rr->retry.":".$rr->expire.":".$rr->minimum;
@@ -4626,5 +4629,5 @@
       my $logentry = "[AXFR ".($rev eq 'n' ? $zone : $cidr)."] ";
 
-      if ($merge) {
+      if ($args{merge}) {
 	if ($rev eq 'n') {
 	  # importing a domain;  we have A and AAAA records that could be merged with matching PTR records
@@ -4672,5 +4675,5 @@
 	  }
 	} # $rev eq 'y'
-      } # if $merge
+      } # if $args{merge}
 
       # Insert the new record
@@ -4681,5 +4684,5 @@
 
       if ($type eq 'SOA') {
-	# also !$rwsoa, but if that's set, it should be impossible to get here.
+	# also !$args{rwsoa}, but if that's set, it should be impossible to get here.
 	my @tmp1 = split /:/, $host;
 	my @tmp2 = split /:/, $val;
@@ -4707,5 +4710,5 @@
 
     # Overwrite SOA record
-    if ($rwsoa) {
+    if ($args{rwsoa}) {
       $soaflag = 1;
       my $sthgetsoa = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?");
@@ -4720,5 +4723,5 @@
 
     # Overwrite NS records
-    if ($rwns) {
+    if ($args{rwns}) {
       $nsflag = 1;
       my $sthgetns = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?");
