Changeset 500


Ignore:
Timestamp:
05/07/13 10:44:58 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Tweak and fiddle dns-rpc.cgi's getRecList() a little more to handle an
alternate calling convention, and handle passing a zone name instead of
a zone ID.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns-rpc.cgi

    r499 r500  
    4343        'dnsdb.addDomain'       => \&addDomain,
    4444        'dnsdb.delZone'         => \&delZone,
     45        'dnsdb.domainID'        => \&domainID,
    4546        'dnsdb.addRDNS'         => \&addRDNS,
    4647        'dnsdb.addGroup'        => \&addGroup,
     
    173174#sub domainName {}
    174175#sub revName {}
    175 #sub domainID {}
     176
     177sub domainID {
     178  my %args = @_;
     179
     180  _commoncheck(\%args, 'y');
     181
     182  my $domid = $dnsdb->domainID($args{domain});
     183  die $dnsdb->errstr if !$domid;
     184  return $domid;
     185}
     186
    176187#sub revID {}
    177188
     
    346357  _commoncheck(\%args);
    347358
     359  # deal gracefully with alternate calling convention for args{id}
     360  $args{id} = $args{ID} if !$args{id} && $args{ID};
     361  # ... and fail if we don't have one
     362  die "Missing zone ID\n" if !$args{id};
     363
    348364  # set some optional args
    349   $args{nrecs} = 'all' if !$args{nrecs};
    350   $args{nstart} = 0 if !$args{nstart};
     365  $args{offset} = 0 if !$args{offset};
    351366## for order, need to map input to column names
    352367  $args{order} = 'host' if !$args{order};
    353368  $args{direction} = 'ASC' if !$args{direction};
    354 
     369  $args{defrec} = 'n' if !$args{defrec};
     370  $args{revrec} = 'n' if !$args{revrec};
     371
     372  # convert zone name to zone ID, if needed
     373  if ($args{defrec} eq 'n') {
     374    if ($args{revrec} eq 'n') {
     375      $args{id} = $dnsdb->domainID($args{id}) if $args{id} !~ /^\d+$/;
     376    } else {
     377      $args{id} = $dnsdb->revID($args{id}) if $args{id} !~ /^\d+$/
     378    }
     379  }
     380
     381  # and finally retrieve the records.
    355382  my $ret = $dnsdb->getRecList(defrec => $args{defrec}, revrec => $args{revrec}, id => $args{id},
    356         offset => $args{offset}, sortby => $args{sortby}, sortorder => $args{sortorder},
    357         filter => $args{filter});
    358 
     383        offset => $args{offset}, nrecs => $args{nrecs}, sortby => $args{sortby},
     384        sortorder => $args{sortorder}, filter => $args{filter});
     385
     386##fixme:  what to do if domain doesn't exist?
    359387  die $dnsdb->errstr if !$ret;
    360388
Note: See TracChangeset for help on using the changeset viewer.