Changeset 480


Ignore:
Timestamp:
03/13/13 17:57:03 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

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

  • location add/update/delete/retrieve in addLoc(), updateLoc(), delLoc(), getLoc(), getLocCount(), getLocList(), and getLocDropdown() and callers
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r479 r480  
    21602160      } else {
    21612161        my $logentry = "[new $zone] Added record '$host $typemap{$type} $val', TTL $ttl";
    2162         $logentry .= ", default location ".getLoc($dbh, $defloc)->{description} if $defloc;
     2162        $logentry .= ", default location ".$self->getLoc($defloc)->{description} if $defloc;
    21632163        _log($dbh, (rdns_id => $rdns_id, domain_id => $domid, group_id => $group, entry => $logentry) );
    21642164      }
     
    30733073# Returns ('OK',<location>) on success, ('FAIL',<failmsg>) on failure
    30743074sub addLoc {
    3075   my $dbh = shift;
     3075  my $self = shift;
     3076  my $dbh = $self->{dbh};
    30763077  my $grp = shift;
    30773078  my $shdesc = shift;
     
    31533154# Returns a result code and message
    31543155sub updateLoc {
    3155   my $dbh = shift;
     3156  my $self = shift;
     3157  my $dbh = $self->{dbh};
    31563158  my $loc = shift;
    31573159  my $grp = shift;
     
    31693171  local $dbh->{RaiseError} = 1;
    31703172
    3171   my $oldloc = getLoc($dbh, $loc);
     3173  my $oldloc = $self->getLoc($loc);
    31723174  my $okmsg = "Updated location (".$oldloc->{description}.", '".$oldloc->{iplist}."') to ($shdesc, '$iplist')";
    31733175
     
    31953197## DNSDB::delLoc()
    31963198sub delLoc {
    3197   my $dbh = shift;
     3199  my $self = shift;
     3200  my $dbh = $self->{dbh};
    31983201  my $loc = shift;
    31993202
     
    32033206  local $dbh->{RaiseError} = 1;
    32043207
    3205   my $oldloc = getLoc($dbh, $loc);
     3208  my $oldloc = $self->getLoc($loc);
    32063209  my $olddesc = ($oldloc->{description} ? $oldloc->{description} : $loc);
    32073210  my $okmsg = "Deleted location ($olddesc, '".$oldloc->{iplist}."')";
     
    32353238# Returns a reference to a hash containing the group ID, IP list, description, and comments/notes
    32363239sub getLoc {
    3237   my $dbh = shift;
     3240  my $self = shift;
     3241  my $dbh = $self->{dbh};
    32383242  my $loc = shift;
    32393243
     
    32513255# - a "Starts with" string
    32523256sub getLocCount {
    3253   my $dbh = shift;
     3257  my $self = shift;
     3258  my $dbh = $self->{dbh};
    32543259
    32553260  my %args = @_;
     
    32743279## DNSDB::getLocList()
    32753280sub getLocList {
    3276   my $dbh = shift;
     3281  my $self = shift;
     3282  my $dbh = $self->{dbh};
    32773283
    32783284  my %args = @_;
     
    33133319# Returns a reference to a list of hashrefs suitable to feeding to HTML::Template
    33143320sub getLocDropdown {
    3315   my $dbh = shift;
     3321  my $self = shift;
     3322  my $dbh = $self->{dbh};
    33163323  my $grp = shift;
    33173324  my $sel = shift || '';
     
    36553662        if $typemap{$$rectype} eq 'SRV';
    36563663  $logdata{entry} .= "', TTL $ttl";
    3657   $logdata{entry} .= ", location ".getLoc($dbh, $location)->{description} if $location;
     3664  $logdata{entry} .= ", location ".$self->getLoc($location)->{description} if $location;
    36583665
    36593666  # Allow transactions, and raise an exception on errors so we can catch it later.
     
    38223829        if $typemap{$oldrec->{type}} eq 'SRV';
    38233830  $logdata{entry} .= "', TTL $oldrec->{ttl}";
    3824   $logdata{entry} .= ", location ".getLoc($dbh, $oldrec->{location})->{description} if $oldrec->{location};
     3831  $logdata{entry} .= ", location ".$self->getLoc($oldrec->{location})->{description} if $oldrec->{location};
    38253832  $logdata{entry} .= "\nto\n";
    38263833  # More NS special
     
    38333840  $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$$rectype} eq 'SRV';
    38343841  $logdata{entry} .= "', TTL $ttl";
    3835   $logdata{entry} .= ", location ".getLoc($dbh, $location)->{description} if $location;
     3842  $logdata{entry} .= ", location ".$self->getLoc($location)->{description} if $location;
    38363843
    38373844  local $dbh->{AutoCommit} = 0;
     
    39493956        if $typemap{$oldrec->{type}} eq 'SRV';
    39503957  $logdata{entry} .= "', TTL $oldrec->{ttl}";
    3951   $logdata{entry} .= ", location ".getLoc($dbh, $oldrec->{location})->{description} if $oldrec->{location};
     3958  $logdata{entry} .= ", location ".$self->getLoc($oldrec->{location})->{description} if $oldrec->{location};
    39523959
    39533960  eval {
  • trunk/dns-rpc.cgi

    r479 r480  
    304304  $args{defloc} = '' if !$args{defloc};
    305305
    306   my $ret = DNSDB::getLocDropdown($dbh, $args{group}, $args{defloc});
     306  my $ret = $dnsdb->getLocDropdown($args{group}, $args{defloc});
    307307  return $ret;
    308308}
  • trunk/dns.cgi

    r479 r480  
    439439
    440440  fill_grouplist("grouplist");
    441   my $loclist = getLocDropdown($dbh, $curgroup);
     441  my $loclist = $dnsdb->getLocDropdown($curgroup);
    442442  $page->param(loclist => $loclist);
    443443
     
    13631363        unless ($permissions{admin} || $permissions{location_create});
    13641364
    1365     my ($code,$msg) = addLoc($dbh, $curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
     1365    my ($code,$msg) = $dnsdb->addLoc($curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
    13661366
    13671367    if ($code eq 'OK' || $code eq 'WARN') {
     
    13871387        unless ($permissions{admin} || $permissions{location_edit});
    13881388
    1389     my $loc = getLoc($dbh, $webvar{loc});
     1389    my $loc = $dnsdb->getLoc($webvar{loc});
    13901390    $page->param(wastrying      => "editing");
    13911391    $page->param(todo           => "Edit location/view");
     
    14001400        unless ($permissions{admin} || $permissions{location_edit});
    14011401
    1402     my ($code,$msg) = updateLoc($dbh, $webvar{id}, $curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
     1402    my ($code,$msg) = $dnsdb->updateLoc($webvar{id}, $curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist});
    14031403
    14041404    if ($code eq 'OK') {
     
    14381438
    14391439  $page->param(locid => $webvar{locid});
    1440   my $locdata = getLoc($dbh, $webvar{locid});
     1440  my $locdata = $dnsdb->getLoc($webvar{locid});
    14411441  $locdata->{description} = $webvar{locid} if !$locdata->{description};
    14421442  # first pass = confirm y/n (sorta)
     
    14451445    $page->param(location => $locdata->{description});
    14461446  } elsif ($webvar{del} eq 'ok') {
    1447     my ($code,$msg) = delLoc($dbh, $webvar{locid});
     1447    my ($code,$msg) = $dnsdb->delLoc($webvar{locid});
    14481448    if ($code eq 'OK') {
    14491449      # success.  go back to the user list, do not pass "GO"
     
    21742174
    21752175  if ($permissions{admin} || $permissions{record_locchg}) {
    2176     my $loclist = getLocDropdown($dbh, $cur, $defloc);
     2176    my $loclist = $dnsdb->getLocDropdown($cur, $defloc);
    21772177    $page->param(record_locchg => 1);
    21782178    $page->param(loclist => $loclist);
    21792179  } else {
    2180     my $loc = getLoc($dbh, $defloc);
     2180    my $loc = $dnsdb->getLoc($defloc);
    21812181    $page->param(loc_name => $loc->{description});
    21822182  }
     
    22372237  my $childlist = join(',',@childgroups);
    22382238
    2239   my $count = getLocCount($dbh, (childlist => $childlist, curgroup => $curgroup,
    2240         filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ) );
     2239  my $count = $dnsdb->getLocCount(childlist => $childlist, curgroup => $curgroup,
     2240        filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) );
    22412241
    22422242# fill page count and first-previous-next-last-all bits
     
    22632263  $page->param(searchsubs => $searchsubs) if $searchsubs;
    22642264
    2265   my $loclist = getLocList($dbh, (childlist => $childlist, curgroup => $curgroup,
     2265  my $loclist = $dnsdb->getLocList(childlist => $childlist, curgroup => $curgroup,
    22662266        filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef),
    2267         offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder) );
     2267        offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder);
    22682268  # Some UI things need to be done to the list
    22692269  foreach my $l (@{$loclist}) {
Note: See TracChangeset for help on using the changeset viewer.