Changeset 234 for trunk/dns.cgi


Ignore:
Timestamp:
02/16/12 16:14:36 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Validation for addRec() now functional with %validators hash
Several more tweaks and cleanups in A, AAAA, PTR, and A/AAAA+PTR records
dns.cgi now reports WARN conditions on add record
Minor typos in reclist.tmpl and record.tmpl fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r227 r234  
    486486      $session->clear('resultmsg');
    487487    }
     488    if ($session->param('warnmsg')) {
     489      $page->param(warnmsg => $session->param('warnmsg'));
     490      $session->clear('warnmsg');
     491    }
    488492    if ($session->param('errmsg')) {
    489493      $page->param(errmsg => $session->param('errmsg'));
     
    531535        unless ($permissions{admin} || $permissions{record_create});
    532536
    533 ##fixme: this should probably go in DNSDB::addRec(), need to ponder what to do about PTR and friends
    534     # prevent out-of-domain records from getting added by appending the domain, or DOMAIN for default records
    535 #    my $pname = ($webvar{defrec} eq 'y' ? 'DOMAIN' : domainName($dbh,$webvar{parentid}));
    536 #    $webvar{name} =~ s/\.*$/\.$pname/ if $webvar{name} !~ /$pname$/;
    537 
    538537    my @recargs = ($dbh,$webvar{defrec},$webvar{revrec},$webvar{parentid},
    539         $webvar{name},$webvar{type},$webvar{address},$webvar{ttl});
     538        $webvar{name},\$webvar{type},$webvar{address},$webvar{ttl});
    540539    if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV}) {
    541540      push @recargs, $webvar{distance};
     
    548547    my ($code,$msg) = addRec(@recargs);
    549548
    550     if ($code eq 'OK') {
     549    if ($code eq 'OK' || $code eq 'WARN') {
     550      my $restr;
    551551      if ($webvar{defrec} eq 'y') {
    552         my $restr = "Added default record '$webvar{name} $typemap{$webvar{type}}";
     552        $restr = "Added default record '$webvar{name} $typemap{$webvar{type}}";
    553553        $restr .= " [distance $webvar{distance}]" if $typemap{$webvar{type}} eq 'MX';
    554554        $restr .= " [priority $webvar{distance}] [weight $webvar{weight}] [port $webvar{port}]"
     
    556556        $restr .= " $webvar{address}', TTL $webvar{ttl}";
    557557        logaction(0, $session->param("username"), $webvar{parentid}, $restr);
    558         changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, resultmsg => $restr);
    559558      } else {
    560         my $restr = "Added record '$webvar{name} $typemap{$webvar{type}}";
     559        $restr = "Added record '$webvar{name} $typemap{$webvar{type}}";
    561560        $restr .= " [distance $webvar{distance}]" if $typemap{$webvar{type}} eq 'MX';
    562561        $restr .= " [priority $webvar{distance}] [weight $webvar{weight}] [port $webvar{port}]"
     
    564563        $restr .= " $webvar{address}', TTL $webvar{ttl}";
    565564        logaction($webvar{parentid}, $session->param("username"), parentID($webvar{parentid}, 'dom', 'group'), $restr);
    566         changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, resultmsg => $restr);
    567       }
     565      }
     566      my %pageparams = (page => "reclist", id => $webvar{parentid},
     567        defrec => $webvar{defrec}, revrec => $webvar{revrec});
     568      $pageparams{warnmsg} = $msg."<br><br>\n".$restr if $code eq 'WARN';
     569      $pageparams{resultmsg} = $restr if $code eq 'OK';
     570      changepage(%pageparams);
    568571    } else {
    569572      $page->param(failed       => 1);
     
    574577      $page->param(parentid     => $webvar{parentid});
    575578      $page->param(defrec       => $webvar{defrec});
     579      $page->param(revrec       => $webvar{revrec});
    576580      $page->param(id           => $webvar{id});
     581      $page->param(fwdzone      => $webvar{revrec} eq 'n');
    577582      fill_recdata();   # populate the form... er, mostly.
    578583      $page->param(name => $webvar{name});
Note: See TracChangeset for help on using the changeset viewer.