Changeset 481 for trunk/DNSDB.pm


Ignore:
Timestamp:
03/14/13 15:33:42 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Object conversion of DNSDB.pm, 14 of <mumble>. See #11.

  • record manipulation: getSOA(), getRecLine(), getDomRecs(), getRecCount(), addRec(), updateRec(), downconvert(), and delRec() and callers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r480 r481  
    33503350sub getSOA {
    33513351  $errstr = '';
    3352   my $dbh = shift;
     3352  my $self = shift;
     3353  my $dbh = $self->{dbh};
    33533354  my $def = shift;
    33543355  my $rev = shift;
     
    34423443sub getRecLine {
    34433444  $errstr = '';
    3444   my $dbh = shift;
     3445  my $self = shift;
     3446  my $dbh = $self->{dbh};
    34453447  my $defrec = shift;
    34463448  my $revrec = shift;
     
    34863488sub getDomRecs {
    34873489  $errstr = '';
    3488   my $dbh = shift;
     3490  my $self = shift;
     3491  my $dbh = $self->{dbh};
    34893492
    34903493  my %args = @_;
     
    35413544# Returns the count
    35423545sub getRecCount {
    3543   my $dbh = shift;
     3546  my $self = shift;
     3547  my $dbh = $self->{dbh};
    35443548  my $defrec = shift;
    35453549  my $revrec = shift;
     
    35753579sub addRec {
    35763580  $errstr = '';
    3577   my $dbh = shift;
     3581  my $self = shift;
     3582  my $dbh = $self->{dbh};
    35783583  my $defrec = shift;
    35793584  my $revrec = shift;
     
    36263631
    36273632  # Call the validation sub for the type requested.
    3628   ($retcode,$retmsg) = $validators{$$rectype}($dbh, (defrec => $defrec, revrec => $revrec, id => $id,
     3633  ($retcode,$retmsg) = $validators{$$rectype}($self, defrec => $defrec, revrec => $revrec, id => $id,
    36293634        host => $host, rectype => $rectype, val => $val, addr => $addr,
    36303635        dist => \$dist, port => \$port, weight => \$weight,
    3631         fields => \$fields, vallist => \@vallist) );
     3636        fields => \$fields, vallist => \@vallist);
    36323637
    36333638  return ($retcode,$retmsg) if $retcode eq 'FAIL';
    36343639
    36353640  # Set up database fields and bind parameters
    3636   $fields .= "host,type,val,ttl,location,"._recparent($defrec,$revrec);
    3637   push @vallist, ($$host,$$rectype,$$val,$ttl,$location,$id);
     3641  $fields .= "host,type,val,ttl,"._recparent($defrec,$revrec);
     3642  push @vallist, ($$host,$$rectype,$$val,$ttl,$id);
     3643
     3644  # locations are not for default records, silly coder!
     3645  if ($defrec eq 'n') {
     3646    $fields .= ",location";
     3647    push @vallist, $location;
     3648  }
    36383649  my $vallen = '?'.(',?'x$#vallist);
    36393650
     
    37003711  $errstr = '';
    37013712
    3702   my $dbh = shift;
     3713  my $self = shift;
     3714  my $dbh = $self->{dbh};
    37033715  my $defrec = shift;
    37043716  my $revrec = shift;
     
    37543766  # get old record data so we have the right parent ID
    37553767  # and for logging (eventually)
    3756   my $oldrec = getRecLine($dbh, $defrec, $revrec, $id);
     3768  my $oldrec = $self->getRecLine($defrec, $revrec, $id);
    37573769
    37583770  # Call the validation sub for the type requested.
    37593771  # Note the ID to pass here is the *parent*, not the record
    3760   ($retcode,$retmsg) = $validators{$$rectype}($dbh, (defrec => $defrec, revrec => $revrec,
     3772  ($retcode,$retmsg) = $validators{$$rectype}($self, defrec => $defrec, revrec => $revrec,
    37613773        id => ($defrec eq 'y' ? $oldrec->{group_id} : ($revrec eq 'n' ? $oldrec->{domain_id} : $oldrec->{rdns_id})),
    37623774        host => $host, rectype => $rectype, val => $val, addr => $addr,
    37633775        dist => \$dist, port => \$port, weight => \$weight,
    37643776        fields => \$fields, vallist => \@vallist,
    3765         update => $id) );
     3777        update => $id);
    37663778
    37673779  return ($retcode,$retmsg) if $retcode eq 'FAIL';
     
    38773889# Takes the record ID and the new type.  Returns boolean.
    38783890sub downconvert {
    3879   my $dbh = shift;
     3891  my $self = shift;
     3892  my $dbh = $self->{dbh};
    38803893  my $recid = shift;
    38813894  my $newtype = shift;
    38823895
    38833896  # also, only work on live records;  little to no value trying to do this on default records.
    3884   my $rec = getRecLine($dbh, 'n', 'y', $recid);
     3897  my $rec = $self->getRecLine('n', 'y', $recid);
    38853898
    38863899  # hm?
     
    39303943sub delRec {
    39313944  $errstr = '';
    3932   my $dbh = shift;
     3945  my $self = shift;
     3946  my $dbh = $self->{dbh};
    39333947  my $defrec = shift;
    39343948  my $revrec = shift;
    39353949  my $id = shift;
    39363950
    3937   my $oldrec = getRecLine($dbh, $defrec, $revrec, $id);
     3951  my $oldrec = $self->getRecLine($defrec, $revrec, $id);
    39383952
    39393953  # Allow transactions, and raise an exception on errors so we can catch it later.
Note: See TracChangeset for help on using the changeset viewer.