Changeset 275 for trunk/DNSDB.pm


Ignore:
Timestamp:
03/15/12 15:34:38 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Convert domStatus() and caller to zoneStatus() for reverse DNS
Add status change to revzones page handling
See #26

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r274 r275  
    4848        &parentID
    4949        &isParent
    50         &domStatus &importAXFR
     50        &zoneStatus &importAXFR
    5151        &export
    5252        &mailNotify
     
    7070                &parentID
    7171                &isParent
    72                 &domStatus &importAXFR
     72                &zoneStatus &importAXFR
    7373                &export
    7474                &mailNotify
     
    27222722
    27232723
    2724 ## DNSDB::domStatus()
    2725 # Sets and/or returns a domain's status
    2726 # Takes a database handle, domain ID and optionally a status argument
    2727 # Returns undef on errors.
    2728 sub domStatus {
     2724## DNSDB::zoneStatus()
     2725# Returns and optionally sets a zone's status
     2726# Takes a database handle, domain/revzone ID, forward/reverse flag, and optionally a status argument
     2727# Returns status, or undef on errors.
     2728sub zoneStatus {
    27292729  my $dbh = shift;
    27302730  my $id = shift;
    2731   my $newstatus = shift;
     2731  my $revrec = shift;
     2732  my $newstatus = shift || 'mu';
    27322733
    27332734  return undef if $id !~ /^\d+$/;
    27342735
    2735   my $sth;
    2736 
    27372736# ooo, fun!  let's see what we were passed for status
    2738   if ($newstatus) {
    2739     $sth = $dbh->prepare("update domains set status=? where domain_id=?");
    2740     # ass-u-me caller knows what's going on in full
    2741     if ($newstatus =~ /^[01]$/) {       # only two valid for now.
    2742       $sth->execute($newstatus,$id);
    2743     } elsif ($newstatus =~ /^domo(?:n|ff)$/) {
    2744       $sth->execute(($newstatus eq 'domon' ? 1 : 0),$id);
    2745     }
    2746   }
    2747 
    2748   $sth = $dbh->prepare("select status from domains where domain_id=?");
    2749   $sth->execute($id);
    2750   my ($status) = $sth->fetchrow_array;
     2737  if ($newstatus ne 'mu') {
     2738    $newstatus = 0 if $newstatus eq 'domoff';
     2739    $newstatus = 1 if $newstatus eq 'domon';
     2740    $dbh->do("UPDATE ".($revrec eq 'n' ? 'domains' : 'revzones')." SET status=? WHERE ".
     2741        ($revrec eq 'n' ? 'domain_id' : 'rdns_id')."=?", undef, ($newstatus,$id) );
     2742  }
     2743
     2744  my ($status) = $dbh->selectrow_array("SELECT status FROM ".
     2745        ($revrec eq 'n' ? "domains WHERE domain_id=?" : "revzones WHERE rdns_id=?"),
     2746        undef, ($id) );
    27512747  return $status;
    2752 } # end domStatus()
     2748} # end zoneStatus()
    27532749
    27542750
Note: See TracChangeset for help on using the changeset viewer.