Changeset 243
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r242 r243 1822 1822 ## DNSDB::getRecLine() 1823 1823 # Return all data fields for a zone record in separate elements of a hash 1824 # Takes a database handle, default/live flag, and record ID1824 # Takes a database handle, default/live flag, forward/reverse flag, and record ID 1825 1825 sub getRecLine { 1826 1826 $errstr = ''; 1827 1827 my $dbh = shift; 1828 my $def = shift; 1828 my $defrec = shift; 1829 my $revrec = shift; 1829 1830 my $id = shift; 1830 1831 1831 my $sql = "SELECT record_id,host,type,val, distance,weight,port,ttl".1832 (($def eq 'def' or $def eq 'y') ? ',group_id FROM default_' : ',domain_id FROM ').1833 "recordsWHERE record_id=?";1832 my $sql = "SELECT record_id,host,type,val,ttl".($revrec eq 'n' ? ',distance,weight,port' : ''). 1833 (($defrec eq 'y') ? ',group_id FROM ' : ',domain_id,rdns_id FROM '). 1834 _rectable($defrec,$revrec)." WHERE record_id=?"; 1834 1835 my $ret = $dbh->selectrow_hashref($sql, undef, ($id) ); 1835 1836 … … 1844 1845 } 1845 1846 1846 $ret->{parid} = (($def eq 'def' or $def eq 'y') ? $ret->{group_id} : $ret->{domain_id}); 1847 # explicitly set a parent id 1848 if ($defrec eq 'y') { 1849 $ret->{parid} = $ret->{group_id}; 1850 } else { 1851 $ret->{parid} = (($revrec eq 'n') ? $ret->{domain_id} : $ret->{rdns_id}); 1852 # and a secondary if we have a custom type that lives in both a forward and reverse zone 1853 $ret->{secid} = (($revrec eq 'y') ? $ret->{domain_id} : $ret->{rdns_id}) if $ret->{type} > 65279; 1854 } 1847 1855 1848 1856 return $ret; … … 2097 2105 my $dbh = shift; 2098 2106 my $defrec = shift; 2107 my $revrec = shift; 2099 2108 my $id = shift; 2100 2109 2101 my $sth = $dbh->prepare("DELETE FROM ". ($defrec eq 'y' ? 'default_' : '')."recordsWHERE record_id=?");2110 my $sth = $dbh->prepare("DELETE FROM "._rectable($defrec,$revrec)." WHERE record_id=?"); 2102 2111 $sth->execute($id); 2103 2112 -
trunk/dns.cgi
r242 r243 619 619 $page->param(id => $webvar{id}); 620 620 $page->param(defrec => $webvar{defrec}); 621 my $recdata = getRecLine($dbh, $webvar{defrec}, $webvar{id}); 621 $page->param(revrec => $webvar{revrec}); 622 my $recdata = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id}); 622 623 $page->param(name => $recdata->{host}); 623 624 $page->param(address => $recdata->{val}); … … 638 639 639 640 # get current/previous record info so we can log "updated 'foo A 1.2.3.4' to 'foo A 2.3.4.5'" 640 my $oldrec = getRecLine($dbh, $webvar{defrec}, $webvar{ id});641 my $oldrec = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id}); 641 642 642 643 my ($code,$msg) = updateRec($dbh,$webvar{defrec},$webvar{id}, … … 694 695 # This is a complete separate segment since it uses a different template from add/edit records above 695 696 696 changepage(page => "reclist", errmsg => "You are not permitted to delete records", id => $webvar{parentid}) 697 changepage(page => "reclist", errmsg => "You are not permitted to delete records", id => $webvar{parentid}, 698 revrec => $webvar{revrec}) 697 699 unless ($permissions{admin} || $permissions{record_delete}); 698 700 … … 704 706 $page->param(id => $webvar{id}); 705 707 $page->param(defrec => $webvar{defrec}); 708 $page->param(revrec => $webvar{revrec}); 706 709 $page->param(parentid => $webvar{parentid}); 707 710 # first pass = confirm y/n (sorta) 708 711 if (!defined($webvar{del})) { 709 712 $page->param(del_getconf => 1); 710 my $rec = getRecLine($dbh, $webvar{defrec},$webvar{id});713 my $rec = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id}); 711 714 $page->param(host => $rec->{host}); 712 715 $page->param(ftype => $typemap{$rec->{type}}); … … 714 717 } elsif ($webvar{del} eq 'ok') { 715 718 # get rec data before we try to delete it 716 my $rec = getRecLine($dbh, $webvar{defrec},$webvar{id});717 my ($code,$msg) = delRec($dbh, $webvar{defrec},$webvar{id});719 my $rec = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id}); 720 my ($code,$msg) = delRec($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id}); 718 721 if ($code eq 'OK') { 719 722 if ($webvar{defrec} eq 'y') { … … 725 728 my $restr = "Deleted record '$rec->{host} $typemap{$rec->{type}} $rec->{val}', TTL $rec->{ttl}"; 726 729 logaction($rec->{parid}, $session->param("username"), parentID($rec->{parid}, 'dom', 'group'), $restr); 727 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, resultmsg => $restr); 730 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, 731 revrec => $webvar{revrec}, resultmsg => $restr); 728 732 } 729 733 } else { … … 740 744 } 741 745 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, 742 errmsg => "Error deleting record: $msg");746 revrec => $webvar{revrec}, errmsg => "Error deleting record: $msg"); 743 747 } 744 748 } else { -
trunk/templates/delrec.tmpl
r100 r243 6 6 <h3>Are you really sure you want to delete record:<br /> 7 7 <TMPL_VAR NAME=host> <TMPL_VAR NAME=ftype> <TMPL_VAR NAME=recval></h3> 8 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrec&del=cancel&id=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&parentid=<TMPL_VAR NAME=parentid>">cancel</a> | <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrec&del=ok&id=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&parentid=<TMPL_VAR NAME=parentid>">confirm</a> 8 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrec&del=cancel&id=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&revrec=<TMPL_VAR NAME=revrec>&parentid=<TMPL_VAR NAME=parentid>">cancel</a> 9 | 10 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrec&del=ok&id=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&revrec=<TMPL_VAR NAME=revrec>&parentid=<TMPL_VAR NAME=parentid>">confirm</a> 9 11 </td></tr></table> 10 12
Note:
See TracChangeset
for help on using the changeset viewer.