Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r224 r225 34 34 &getSOA &getRecLine &getDomRecs &getRecCount 35 35 &addRec &updateRec &delRec 36 &getParents 36 &getTypelist 37 &getParents 37 38 &isParent 38 39 &domStatus &importAXFR … … 54 55 &getSOA &getRecLine &getDomRecs &getRecCount 55 56 &addRec &updateRec &delRec 56 &getParents 57 &getTypelist 58 &getParents 57 59 &isParent 58 60 &domStatus &importAXFR … … 132 134 133 135 ## 134 ## util ty functions136 ## utility functions 135 137 # _rectable() 136 138 # Takes default+rdns flags, returns appropriate table name … … 1607 1609 record => 'domain' 1608 1610 ); 1611 1612 1613 ## DNSDB::getTypelist() 1614 # Get a list of record types for various UI dropdowns 1615 # Takes database handle, forward/reverse/lookup flag, and optional "tag as selected" indicator (defaults to A) 1616 # Returns an arrayref to list of hashrefs perfect for HTML::Template 1617 sub getTypelist { 1618 my $dbh = shift; 1619 my $recgroup = shift; 1620 my $type = shift || $reverse_typemap{A}; 1621 1622 # also accepting $webvar{revrec}! 1623 $recgroup = 'f' if $recgroup eq 'n'; 1624 $recgroup = 'r' if $recgroup eq 'y'; 1625 1626 my $sql = "SELECT val,name FROM rectypes WHERE "; 1627 if ($recgroup eq 'r') { 1628 # reverse zone types 1629 $sql .= "stdflag=2 OR stdflag=3"; 1630 } elsif ($recgroup eq 'l') { 1631 # DNS lookup types. Note we avoid our custom types >= 65280, since those are entirely internal. 1632 $sql .= "(stdflag=1 OR stdflag=2 OR stdflag=3) AND val < 65280"; 1633 } else { 1634 # default; forward zone types. technically $type eq 'f' but not worth the error message. 1635 $sql .= "stdflag=1 OR stdflag=2"; 1636 } 1637 $sql .= " ORDER BY listorder"; 1638 1639 my $sth = $dbh->prepare($sql); 1640 $sth->execute; 1641 my @typelist; 1642 while (my ($rval,$rname) = $sth->fetchrow_array()) { 1643 my %row = ( recval => $rval, recname => $rname ); 1644 $row{tselect} = 1 if $rval == $type; 1645 push @typelist, \%row; 1646 } 1647 1648 # Add SOA on lookups since it's not listed in other dropdowns. 1649 if ($recgroup eq 'l') { 1650 my %row = ( recval => $reverse_typemap{SOA}, recname => 'SOA' ); 1651 $row{tselect} = 1 if $reverse_typemap{SOA} == $type; 1652 push @typelist, \%row; 1653 } 1654 1655 return \@typelist; 1656 } # end getTypelist() 1657 1609 1658 1610 1659 ## DNSDB::getParents() -
trunk/dns.cgi
r224 r225 601 601 $page->param(port => $recdata->{port}); 602 602 $page->param(ttl => $recdata->{ttl}); 603 fill_rectypes($recdata->{type});603 $page->param(typelist => getTypelist($dbh, $webvar{revrec}, $webvar{type})); 604 604 605 605 } elsif ($webvar{recact} eq 'update') { … … 1384 1384 1385 1385 $page->param(qfor => $webvar{qfor}) if $webvar{qfor}; 1386 fill_rectypes($webvar{type} ? $webvar{type} : '', 1);1386 $page->param(typelist => getTypelist($dbh, 'l', ($webvar{type} ? $webvar{type} : undef))); 1387 1387 $page->param(nrecurse => $webvar{nrecurse}) if $webvar{nrecurse}; 1388 1388 $page->param(resolver => $webvar{resolver}) if $webvar{resolver}; … … 1778 1778 } 1779 1779 1780 # fill in record type list on add/update/edit record template1781 sub fill_rectypes {1782 my $type = shift || $reverse_typemap{A};1783 my $soaflag = shift || 0;1784 1785 my $sth = $dbh->prepare("SELECT val,name FROM rectypes WHERE stdflag=1 ORDER BY listorder");1786 $sth->execute;1787 my @typelist;1788 while (my ($rval,$rname) = $sth->fetchrow_array()) {1789 my %row = ( recval => $rval, recname => $rname );1790 $row{tselect} = 1 if $rval == $type;1791 push @typelist, \%row;1792 }1793 if ($soaflag) {1794 my %row = ( recval => $reverse_typemap{SOA}, recname => 'SOA' );1795 $row{tselect} = 1 if $reverse_typemap{SOA} == $type;1796 push @typelist, \%row;1797 }1798 $page->param(typelist => \@typelist);1799 } # fill_rectypes1800 1801 1780 sub fill_recdata { 1802 fill_rectypes($webvar{type});1781 $page->param(typelist => getTypelist($dbh, $webvar{revrec}, $webvar{type})); 1803 1782 1804 1783 # le sigh. we may get called with many empty %webvar keys
Note:
See TracChangeset
for help on using the changeset viewer.