Changeset 283


Ignore:
Timestamp:
03/22/12 16:12:32 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Convert zone status change logging to DNSDB-internal. See #35
Add a global for holding general result messages for subs that
return booleans. This allows us to easily display the same text
as was added to the log.
Fix docucomment on mailNotify(); it (still!) referred to its
copy-paste parent in the IP Database.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r282 r283  
    8080our $group = 1;
    8181our $errstr = '';
     82our $resultstr = '';
    8283
    8384# Halfway sane defaults for SOA, TTL, etc.
     
    28472848  return undef if $id !~ /^\d+$/;
    28482849
    2849 # ooo, fun!  let's see what we were passed for status
     2850  # Allow transactions, and raise an exception on errors so we can catch it later.
     2851  # Use local to make sure these get "reset" properly on exiting this block
     2852  local $dbh->{AutoCommit} = 0;
     2853  local $dbh->{RaiseError} = 1;
     2854
    28502855  if ($newstatus ne 'mu') {
    2851     $newstatus = 0 if $newstatus eq 'domoff';
    2852     $newstatus = 1 if $newstatus eq 'domon';
    2853     $dbh->do("UPDATE ".($revrec eq 'n' ? 'domains' : 'revzones')." SET status=? WHERE ".
     2856    # ooo, fun!  let's see what we were passed for status
     2857    eval {
     2858      $newstatus = 0 if $newstatus eq 'domoff';
     2859      $newstatus = 1 if $newstatus eq 'domon';
     2860      $dbh->do("UPDATE ".($revrec eq 'n' ? 'domains' : 'revzones')." SET status=? WHERE ".
    28542861        ($revrec eq 'n' ? 'domain_id' : 'rdns_id')."=?", undef, ($newstatus,$id) );
     2862
     2863##fixme  switch to more consise "Enabled <domain"/"Disabled <domain>" as with users?
     2864      $resultstr = "Changed ".($revrec eq 'n' ? domainName($dbh, $id) : revName($dbh, $id)).
     2865        " state to ".($newstatus ? 'active' : 'inactive');
     2866
     2867      my %loghash;
     2868      $loghash{domain_id} = $id if $revrec eq 'n';
     2869      $loghash{rdns_id} = $id if $revrec eq 'y';
     2870      $loghash{group_id} = parentID($dbh,
     2871        (id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) );
     2872      $loghash{entry} = $resultstr;
     2873      _log($dbh, %loghash);
     2874
     2875      $dbh->commit;
     2876    };
     2877    if ($@) {
     2878      my $msg = $@;
     2879      eval { $dbh->rollback; };
     2880      $resultstr = '';
     2881      $errstr = $msg;
     2882      return;
     2883    }
    28552884  }
    28562885
     
    32623291
    32633292## DNSDB::mailNotify()
    3264 # Sends notification mail to recipients regarding an IPDB operation
     3293# Sends notification mail to recipients regarding a DNSDB operation
    32653294sub mailNotify {
    32663295  my $dbh = shift;
  • trunk/dns.cgi

    r280 r283  
    330330    if ($flag && ($permissions{admin} || $permissions{domain_edit})) {
    331331      my $stat = zoneStatus($dbh,$webvar{id},'n',$webvar{zonestatus});
    332 ##fixme  switch to more consise "Enabled <domain"/"Disabled <domain>" as with users?
    333       logaction($webvar{id}, $session->param("username"),
    334         parentID($dbh, (id => $webvar{id}, type => 'domain', revrec => $webvar{revrec})),
    335         "Changed ".domainName($dbh, $webvar{id})." state to ".($stat ? 'active' : 'inactive'));
    336       $page->param(resultmsg => "Changed ".domainName($dbh, $webvar{id})." state to ".
    337         ($stat ? 'active' : 'inactive'));
     332      $page->param(resultmsg => $DNSDB::resultstr);
    338333    } else {
    339334      $page->param(errmsg => "You are not permitted to view or change the requested domain");
     
    450445    if ($flag && ($permissions{admin} || $permissions{domain_edit})) {
    451446      my $stat = zoneStatus($dbh,$webvar{id},'y',$webvar{zonestatus});
    452 ##fixme  switch to more consise "Enabled <domain"/"Disabled <domain>" as with users?
    453       logaction($webvar{id}, $session->param("username"),
    454         parentID($dbh, (id => $webvar{id}, type => 'revzone', revrec => $webvar{revrec})),
    455         "Changed ".revName($dbh, $webvar{id})." state to ".($stat ? 'active' : 'inactive'));
    456       $page->param(resultmsg => "Changed ".revName($dbh, $webvar{id})." state to ".
    457         ($stat ? 'active' : 'inactive'));
     447      $page->param(resultmsg => $DNSDB::resultstr);
    458448    } else {
    459449      $page->param(errmsg => "You are not permitted to view or change the requested reverse zone");
Note: See TracChangeset for help on using the changeset viewer.