Changeset 285 for trunk


Ignore:
Timestamp:
03/22/12 17:23:00 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Move action logging for zone delete (deldom/delrevzone) into delZone()
See #35

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r284 r285  
    13521352  local $dbh->{RaiseError} = 1;
    13531353
     1354  my $msg = '';
    13541355  my $failmsg = '';
     1356  my $zone = ($revrec eq 'n' ? domainName($dbh, $zoneid) : revName($dbh, $zoneid));
     1357
     1358  # Set this up here since we may use if if $config{log_failures} is enabled
     1359  my %loghash;
     1360  $loghash{domain_id} = $zoneid if $revrec eq 'n';
     1361  $loghash{rdns_id} = $zoneid if $revrec eq 'y';
     1362  $loghash{group_id} = parentID($dbh,
     1363        (id => $zoneid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) );
    13551364
    13561365  # Wrap all the SQL in a transaction
     
    13831392    }
    13841393
     1394    $msg = "Deleted ".($revrec eq 'n' ? 'domain' : 'reverse zone')." $zone";
     1395    $loghash{entry} = $msg;
     1396    _log($dbh, %loghash);
     1397
    13851398    # once we get here, we should have suceeded.
    13861399    $dbh->commit;
     
    13881401
    13891402  if ($@) {
    1390     my $msg = $@;
     1403    $msg = $@;
    13911404    eval { $dbh->rollback; };
    1392     return ('FAIL',"$failmsg: $msg");
     1405    $loghash{entry} = "Delete $zone: $failmsg: $msg";
     1406    _log($dbh, %loghash) if $config{log_failures};
     1407    $dbh->commit;       # since we enabled transactions earlier
     1408    return ('FAIL',"Delete $zone: $failmsg: $msg");
    13931409  } else {
    1394     return ('OK','OK');
     1410    return ('OK',$msg);
    13951411  }
    13961412
  • trunk/dns.cgi

    r284 r285  
    415415  } elsif ($webvar{del} eq 'ok') {
    416416    my $pargroup = parentID($dbh, (id => $webvar{id}, type => 'domain', revrec => $webvar{revrec}));
    417     my $dom = domainName($dbh, $webvar{id});
    418417    my ($code,$msg) = delZone($dbh, $webvar{id}, $webvar{revrec});
    419418    if ($code eq 'OK') {
    420       logaction($webvar{id}, $session->param("username"), $pargroup, "Deleted domain $dom");
    421       changepage(page => "domlist", resultmsg => "Deleted domain $dom");
     419      changepage(page => "domlist", resultmsg => $msg);
    422420    } else {
    423       logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $dom ($msg)")
    424         if $config{log_failures};
    425       changepage(page => "domlist", errmsg => "Error deleting domain $dom: $msg");
     421      changepage(page => "domlist", errmsg => $msg);
    426422    }
    427423
     
    528524    my ($code,$msg) = delZone($dbh, $webvar{id}, 'y');
    529525    if ($code eq 'OK') {
    530 ##fixme: logaction needs to take "domid OR revid" and some way to know which it is
    531       logaction($webvar{id}, $session->param("username"), $pargroup, "Deleted reverse zone $zone");
    532       changepage(page => "revzones", resultmsg => "Deleted reverse zone $zone");
     526      changepage(page => "revzones", resultmsg => $msg);
    533527    } else {
    534       logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $zone ($msg)")
    535         if $config{log_failures};
    536 #push @debugbits, "got back $code, $msg\n";
    537       changepage(page => "revzones", errmsg => "Error deleting reverse zone $zone: $msg");
     528      changepage(page => "revzones", errmsg => $msg);
    538529    }
    539530
Note: See TracChangeset for help on using the changeset viewer.