Changeset 920 for branches


Ignore:
Timestamp:
08/14/25 13:35:51 (18 hours ago)
Author:
Kris Deugau
Message:

/branches/secondaryzones

Complete secondary zone update section

Location:
branches/secondaryzones
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/secondaryzones/DNSDB.pm

    r918 r920  
    46134613
    46144614
     4615## DNSDB::updateSecondaryDetails()
     4616# Update primary server and/or location/view of a secondary zone
     4617# Takes a hash with the zone ID, primary server string, and location
     4618# Returns a two-element list with a result code and message
     4619sub updateSecondaryDetails {
     4620  $errstr = '';
     4621  my $self = shift;
     4622  my $dbh = $self->{dbh};
     4623
     4624  my %secondary = @_;
     4625
     4626  my $oldsecondary = $self->getSecondaryDetails($secondary{id});
     4627
     4628  my $msg;
     4629  my %logdata;
     4630  $logdata{secondary_id} = $secondary{id};
     4631  $logdata{group_id} = $self->parentID(id => $secondary{id}, type => 'secondaryzone');
     4632  my $zone = $self->secondaryName($secondary{id});
     4633
     4634  # Allow transactions, and raise an exception on errors so we can catch it later.
     4635  # Use local to make sure these get "reset" properly on exiting this block
     4636  local $dbh->{AutoCommit} = 0;
     4637  local $dbh->{RaiseError} = 1;
     4638
     4639  eval {
     4640    my $sql = "UPDATE secondaryzones SET primaryserver=?, default_location=? WHERE secondary_id=?";
     4641    $dbh->do($sql, undef, ($secondary{primary}, $secondary{location}, $secondary{id}));
     4642    $msg = "Updated secondary zone $zone from (primary $oldsecondary->{primaryserver}, location ".
     4643        $self->getLoc($oldsecondary->{default_location})->{description}.") to (primary $secondary{primary}, ".
     4644        "location ".$self->getLoc($secondary{location})->{description}.")";
     4645    $logdata{entry} = $msg;
     4646    $self->_log(%logdata);
     4647    $dbh->commit;
     4648  };
     4649  if ($@) {
     4650    $msg = $@;
     4651    eval { $dbh->rollback; };
     4652    $logdata{entry} = "Error updating secondary zone settings: $msg";
     4653    if ($self->{log_failures}) {
     4654      $self->_log(%logdata);
     4655      $dbh->commit;
     4656    }
     4657    return ('FAIL', $msg);
     4658  } else {
     4659    return ('OK', $msg);
     4660  }
     4661
     4662} # end updateSecondaryDetails
     4663
     4664
    46154665## DNSDB::getRecLine()
    46164666# Return all data fields for a zone record in separate elements of a hash
  • branches/secondaryzones/dns.cgi

    r919 r920  
    651651  $page->param(prins => $zoneinfo->{primaryserver});
    652652  fill_loclist($curgroup, $zoneinfo->{default_location});
     653
     654} elsif ($webvar{page} eq 'updatesecondary') {
     655
     656  # security check - does the user have permission to view this entity?
     657  # pass 1, record ID
     658  # id is zone id
     659  if (!check_scope(id => $webvar{id}, type => 'secondaryzone')) {
     660    changepage(page => 'secondaryzones',
     661        errmsg => "You do not have permission to edit the requested secondary zone");
     662  }
     663
     664  changepage(page => "secondaryzones", errmsg => "You are not permitted to edit secondary zones", id => $webvar{id})
     665        unless ($permissions{admin} || $permissions{domain_edit});
     666
     667  my ($code, $msg) = $dnsdb->updateSecondaryDetails(
     668        id => $webvar{id}, primary => $webvar{prins}, location => $webvar{defloc});
     669  if ($code eq 'OK') {
     670    my $zone = $dnsdb->secondaryName($webvar{id});
     671    changepage(page => "secondaryzones", resultmsg => "Secondary zone $zone updated");
     672  } else {
     673    $page->param(update_failed => 1);
     674    $page->param(msg => $msg);
     675
     676    $page->param(id => $webvar{id});
     677    $page->param(prins => $webvar{prins});
     678    fill_loclist($curgroup, $webvar{defloc});
     679  }
    653680
    654681} elsif ($webvar{page} eq 'reclist') {
Note: See TracChangeset for help on using the changeset viewer.