Index: /branches/secondaryzones/DNSDB.pm
===================================================================
--- /branches/secondaryzones/DNSDB.pm	(revision 919)
+++ /branches/secondaryzones/DNSDB.pm	(revision 920)
@@ -4613,4 +4613,54 @@
 
 
+## DNSDB::updateSecondaryDetails()
+# Update primary server and/or location/view of a secondary zone
+# Takes a hash with the zone ID, primary server string, and location
+# Returns a two-element list with a result code and message
+sub updateSecondaryDetails {
+  $errstr = '';
+  my $self = shift;
+  my $dbh = $self->{dbh};
+
+  my %secondary = @_;
+
+  my $oldsecondary = $self->getSecondaryDetails($secondary{id});
+
+  my $msg;
+  my %logdata;
+  $logdata{secondary_id} = $secondary{id};
+  $logdata{group_id} = $self->parentID(id => $secondary{id}, type => 'secondaryzone');
+  my $zone = $self->secondaryName($secondary{id});
+
+  # Allow transactions, and raise an exception on errors so we can catch it later.
+  # Use local to make sure these get "reset" properly on exiting this block
+  local $dbh->{AutoCommit} = 0;
+  local $dbh->{RaiseError} = 1;
+
+  eval {
+    my $sql = "UPDATE secondaryzones SET primaryserver=?, default_location=? WHERE secondary_id=?";
+    $dbh->do($sql, undef, ($secondary{primary}, $secondary{location}, $secondary{id}));
+    $msg = "Updated secondary zone $zone from (primary $oldsecondary->{primaryserver}, location ".
+	$self->getLoc($oldsecondary->{default_location})->{description}.") to (primary $secondary{primary}, ".
+	"location ".$self->getLoc($secondary{location})->{description}.")";
+    $logdata{entry} = $msg;
+    $self->_log(%logdata);
+    $dbh->commit;
+  };
+  if ($@) {
+    $msg = $@;
+    eval { $dbh->rollback; };
+    $logdata{entry} = "Error updating secondary zone settings: $msg";
+    if ($self->{log_failures}) {
+      $self->_log(%logdata);
+      $dbh->commit;
+    }
+    return ('FAIL', $msg);
+  } else {
+    return ('OK', $msg);
+  }
+
+} # end updateSecondaryDetails
+
+
 ## DNSDB::getRecLine()
 # Return all data fields for a zone record in separate elements of a hash
Index: /branches/secondaryzones/dns.cgi
===================================================================
--- /branches/secondaryzones/dns.cgi	(revision 919)
+++ /branches/secondaryzones/dns.cgi	(revision 920)
@@ -651,4 +651,31 @@
   $page->param(prins => $zoneinfo->{primaryserver});
   fill_loclist($curgroup, $zoneinfo->{default_location});
+
+} elsif ($webvar{page} eq 'updatesecondary') {
+
+  # security check - does the user have permission to view this entity?
+  # pass 1, record ID
+  # id is zone id
+  if (!check_scope(id => $webvar{id}, type => 'secondaryzone')) {
+    changepage(page => 'secondaryzones',
+	errmsg => "You do not have permission to edit the requested secondary zone");
+  }
+
+  changepage(page => "secondaryzones", errmsg => "You are not permitted to edit secondary zones", id => $webvar{id})
+	unless ($permissions{admin} || $permissions{domain_edit});
+
+  my ($code, $msg) = $dnsdb->updateSecondaryDetails(
+	id => $webvar{id}, primary => $webvar{prins}, location => $webvar{defloc});
+  if ($code eq 'OK') {
+    my $zone = $dnsdb->secondaryName($webvar{id});
+    changepage(page => "secondaryzones", resultmsg => "Secondary zone $zone updated");
+  } else {
+    $page->param(update_failed => 1);
+    $page->param(msg => $msg);
+
+    $page->param(id => $webvar{id});
+    $page->param(prins => $webvar{prins});
+    fill_loclist($curgroup, $webvar{defloc});
+  }
 
 } elsif ($webvar{page} eq 'reclist') {
Index: /branches/secondaryzones/templates/updatesecondary.tmpl
===================================================================
--- /branches/secondaryzones/templates/updatesecondary.tmpl	(revision 920)
+++ /branches/secondaryzones/templates/updatesecondary.tmpl	(revision 920)
@@ -0,0 +1,1 @@
+<TMPL_INCLUDE NAME="editsecondary.tmpl">
