Changeset 473
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r472 r473 1759 1759 my $entname; 1760 1760 if ($type eq 'domain') { 1761 $entname = domainName($dbh,$id);1761 $entname = $self->domainName($id); 1762 1762 } elsif ($type eq 'revzone') { 1763 $entname = revName($dbh,$id);1763 $entname = $self->revName($id); 1764 1764 } elsif ($type eq 'user') { 1765 $entname = userFullName($dbh,$id, '%u');1765 $entname = $self->userFullName($id, '%u'); 1766 1766 } elsif ($type eq 'group') { 1767 $entname = groupName($dbh,$id);1767 $entname = $self->groupName($id); 1768 1768 } 1769 1769 1770 1770 my ($oldgid) = $dbh->selectrow_array("SELECT group_id FROM $par_tbl{$type} WHERE $id_col{$type}=?", 1771 1771 undef, ($id)); 1772 my $oldgname = groupName($dbh,$oldgid);1773 my $newgname = groupName($dbh,$newgrp);1772 my $oldgname = $self->groupName($oldgid); 1773 my $newgname = $self->groupName($newgrp); 1774 1774 1775 1775 return ('FAIL', "Can't move things into a group that doesn't exist") if !$newgname; … … 1916 1916 my $msg = ''; 1917 1917 my $failmsg = ''; 1918 my $zone = ($revrec eq 'n' ? domainName($dbh, $zoneid) : revName($dbh,$zoneid));1918 my $zone = ($revrec eq 'n' ? $self->domainName($zoneid) : $self->revName($zoneid)); 1919 1919 1920 1920 return ('FAIL', ($revrec eq 'n' ? 'Domain' : 'Reverse zone')." ID $zoneid doesn't exist") if !$zone; … … 1924 1924 $loghash{domain_id} = $zoneid if $revrec eq 'n'; 1925 1925 $loghash{rdns_id} = $zoneid if $revrec eq 'y'; 1926 $loghash{group_id} = parentID($dbh,1927 (id => $zoneid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec));1926 $loghash{group_id} = $self->parentID( 1927 id => $zoneid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec); 1928 1928 1929 1929 # Wrap all the SQL in a transaction … … 1986 1986 sub domainName { 1987 1987 $errstr = ''; 1988 my $dbh = shift; 1988 my $self = shift; 1989 my $dbh = $self->{dbh}; 1989 1990 my $domid = shift; 1990 1991 my ($domname) = $dbh->selectrow_array("SELECT domain FROM domains WHERE domain_id=?", undef, ($domid) ); … … 2000 2001 sub revName { 2001 2002 $errstr = ''; 2002 my $dbh = shift; 2003 my $self = shift; 2004 my $dbh = $self->{dbh}; 2003 2005 my $revid = shift; 2004 2006 my ($revname) = $dbh->selectrow_array("SELECT revnet FROM revzones WHERE rdns_id=?", undef, ($revid) ); … … 2013 2015 sub domainID { 2014 2016 $errstr = ''; 2015 my $dbh = shift; 2017 my $self = shift; 2018 my $dbh = $self->{dbh}; 2016 2019 my $domain = shift; 2017 2020 my ($domid) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE lower(domain) = lower(?)", … … 2027 2030 sub revID { 2028 2031 $errstr = ''; 2029 my $dbh = shift; 2032 my $self = shift; 2033 my $dbh = $self->{dbh}; 2030 2034 my $revzone = shift; 2031 2035 my ($revid) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet=?", undef, ($revzone) ); … … 2439 2443 2440 2444 # collect some pieces for logging and error messages 2441 my $groupname = groupName($dbh,$groupid);2442 my $parid = parentID($dbh, (id => $groupid, type => 'group'));2445 my $groupname = $self->groupName($groupid); 2446 my $parid = $self->parentID(id => $groupid, type => 'group'); 2443 2447 2444 2448 # Wrap all the SQL in a transaction … … 2522 2526 sub groupName { 2523 2527 $errstr = ''; 2524 my $dbh = shift; 2528 my $self = shift; 2529 my $dbh = $self->{dbh}; 2525 2530 my $groupid = shift; 2526 2531 my $sth = $dbh->prepare("SELECT group_name FROM groups WHERE group_id=?"); … … 2625 2630 sub groupID { 2626 2631 $errstr = ''; 2627 my $dbh = shift; 2632 my $self = shift; 2633 my $dbh = $self->{dbh}; 2628 2634 my $group = shift; 2629 2635 my ($grpid) = $dbh->selectrow_array("SELECT group_id FROM groups WHERE group_name=?", undef, ($group) ); … … 2960 2966 sub userFullName { 2961 2967 $errstr = ''; 2962 my $dbh = shift; 2968 my $self = shift; 2969 my $dbh = $self->{dbh}; 2963 2970 my $userid = shift; 2964 2971 my $fullformat = shift || '%f %l (%u)'; … … 3005 3012 3006 3013 my %loghash; 3007 $loghash{group_id} = parentID($dbh, (id => $id, type => 'user'));3014 $loghash{group_id} = $self->parentID(id => $id, type => 'user'); 3008 3015 $loghash{entry} = $resultstr; 3009 3016 _log($dbh, %loghash); … … 3343 3350 # Returns a two-element list with a result code and message 3344 3351 sub updateSOA { 3345 my $dbh = shift; 3352 my $self = shift; 3353 my $dbh = $self->{dbh}; 3346 3354 my $defrec = shift; 3347 3355 my $revrec = shift; … … 3349 3357 my %soa = @_; 3350 3358 3351 my $oldsoa = getSOA($dbh,$defrec, $revrec, $soa{id});3359 my $oldsoa = $self->getSOA($defrec, $revrec, $soa{id}); 3352 3360 3353 3361 my $msg; … … 3356 3364 $logdata{domain_id} = $soa{id} if $revrec eq 'n'; 3357 3365 $logdata{rdns_id} = $soa{id} if $revrec eq 'y'; 3358 $logdata{group_id} = parentID($dbh,(id => $soa{id}, revrec => $revrec,3359 type => ($revrec eq 'n' ? 'domain' : 'revzone') ) );3366 $logdata{group_id} = $self->parentID(id => $soa{id}, revrec => $revrec, 3367 type => ($revrec eq 'n' ? 'domain' : 'revzone') ); 3360 3368 } else { 3361 3369 $logdata{group_id} = $soa{id}; 3362 3370 } 3363 my $parname = ($defrec eq 'y' ? groupName($dbh,$soa{id}) :3364 ($revrec eq 'n' ? domainName($dbh, $soa{id}) : revName($dbh,$soa{id})) );3371 my $parname = ($defrec eq 'y' ? $self->groupName($soa{id}) : 3372 ($revrec eq 'n' ? $self->domainName($soa{id}) : $self->revName($soa{id})) ); 3365 3373 3366 3374 # Allow transactions, and raise an exception on errors so we can catch it later. … … 3612 3620 } 3613 3621 $logdata{group_id} = $id if $defrec eq 'y'; 3614 $logdata{group_id} = parentID($dbh, 3615 (id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) ) 3622 $logdata{group_id} = $self->parentID(id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) 3616 3623 if $defrec eq 'n'; 3617 3624 $logdata{entry} = "Added ".($defrec eq 'y' ? 'default record' : 'record'); … … 3781 3788 } 3782 3789 $logdata{group_id} = $parid if $defrec eq 'y'; 3783 $logdata{group_id} = parentID($dbh, 3784 (id => $parid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) ) 3790 $logdata{group_id} = $self->parentID(id => $parid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) 3785 3791 if $defrec eq 'n'; 3786 3792 $logdata{entry} = "Updated ".($defrec eq 'y' ? 'default record' : 'record')." from\n"; … … 3913 3919 $logdata{rdns_id} = $oldrec->{rdns_id}; 3914 3920 $logdata{group_id} = $oldrec->{group_id} if $defrec eq 'y'; 3915 $logdata{group_id} = parentID($dbh,3916 (id => $oldrec->{domain_id}, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec))3921 $logdata{group_id} = $self->parentID(id => $oldrec->{domain_id}, type => ($revrec eq 'n' ? 'domain' : 'revzone'), 3922 revrec => $revrec) 3917 3923 if $defrec eq 'n'; 3918 3924 $logdata{entry} = "Deleted ".($defrec eq 'y' ? 'default record ' : 'record '). … … 4093 4099 # Returns the ID or undef on failure 4094 4100 sub parentID { 4095 my $dbh = shift; 4101 my $self = shift; 4102 my $dbh = $self->{dbh}; 4096 4103 4097 4104 my %args = @_; … … 4242 4249 4243 4250 ##fixme switch to more consise "Enabled <domain"/"Disabled <domain>" as with users? 4244 $resultstr = "Changed ".($revrec eq 'n' ? domainName($dbh, $id) : revName($dbh,$id)).4251 $resultstr = "Changed ".($revrec eq 'n' ? $self->domainName($id) : $self->revName($id)). 4245 4252 " state to ".($newstatus ? 'active' : 'inactive'); 4246 4253 … … 4248 4255 $loghash{domain_id} = $id if $revrec eq 'n'; 4249 4256 $loghash{rdns_id} = $id if $revrec eq 'y'; 4250 $loghash{group_id} = parentID($dbh, 4251 (id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) ); 4257 $loghash{group_id} = $self->parentID(id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec); 4252 4258 $loghash{entry} = $resultstr; 4253 4259 _log($dbh, %loghash); -
trunk/dns.cgi
r470 r473 392 392 393 393 $page->param(del_getconf => 1); 394 $page->param(domain => domainName($dbh,$webvar{id}));394 $page->param(domain => $dnsdb->domainName($webvar{id})); 395 395 396 396 } elsif ($webvar{del} eq 'ok') { 397 my $pargroup = parentID($dbh, (id => $webvar{id}, type => 'domain', revrec => $webvar{revrec}));397 my $pargroup = $dnsdb->parentID(id => $webvar{id}, type => 'domain', revrec => $webvar{revrec}); 398 398 my ($code,$msg) = delZone($dbh, $webvar{id}, $webvar{revrec}); 399 399 if ($code eq 'OK') { … … 492 492 493 493 $page->param(del_getconf => 1); 494 $page->param(revzone => revName($dbh,$webvar{id}));494 $page->param(revzone => $dnsdb->revName($webvar{id})); 495 495 496 496 } elsif ($webvar{del} eq 'ok') { 497 my $pargroup = parentID($dbh, (id => $webvar{id}, type => 'revzone', revrec => $webvar{revrec}));498 my $zone = revName($dbh,$webvar{id});497 my $pargroup = $dnsdb->parentID(id => $webvar{id}, type => 'revzone', revrec => $webvar{revrec}); 498 my $zone = $dnsdb->revName($webvar{id}); 499 499 my ($code,$msg) = delZone($dbh, $webvar{id}, 'y'); 500 500 if ($code eq 'OK') { … … 569 569 # fill the page-count and first-previous-next-last-all details 570 570 fill_pgcount($count,"records", 571 ($webvar{defrec} eq 'y' ? "group ". groupName($dbh,$webvar{id}) :572 ($webvar{revrec} eq 'y' ? revName($dbh,$webvar{id}) : domainName($dbh,$webvar{id}))571 ($webvar{defrec} eq 'y' ? "group ".$dnsdb->groupName($webvar{id}) : 572 ($webvar{revrec} eq 'y' ? $dnsdb->revName($webvar{id}) : $dnsdb->domainName($webvar{id})) 573 573 )); 574 574 fill_fpnla($count); # should put some params on this sub... … … 724 724 725 725 if ($webvar{defrec} eq 'y') { 726 $page->param(dohere => "default records in group ". groupName($dbh,$webvar{parentid}));726 $page->param(dohere => "default records in group ".$dnsdb->groupName($webvar{parentid})); 727 727 } else { 728 $page->param(dohere => domainName($dbh,$webvar{parentid})) if $webvar{revrec} eq 'n';729 $page->param(dohere => revName($dbh,$webvar{parentid})) if $webvar{revrec} eq 'y';728 $page->param(dohere => $dnsdb->domainName($webvar{parentid})) if $webvar{revrec} eq 'n'; 729 $page->param(dohere => $dnsdb->revName($webvar{parentid})) if $webvar{revrec} eq 'y'; 730 730 } 731 731 … … 929 929 changepage(page => "grpman"); 930 930 } 931 $page->param(delgroupname => groupName($dbh,$webvar{id}));931 $page->param(delgroupname => $dnsdb->groupName($webvar{id})); 932 932 933 933 } elsif ($webvar{page} eq 'edgroup') { … … 968 968 changepage(page => "grpman", warnmsg => 969 969 "You can only grant permissions you hold. Default permissions in group ". 970 groupName($dbh,$webvar{gid})." updated with reduced access");970 $dnsdb->groupName($webvar{gid})." updated with reduced access"); 971 971 } else { 972 972 changepage(page => "grpman", resultmsg => $msg); … … 978 978 } 979 979 $page->param(gid => $webvar{gid}); 980 $page->param(grpmeddle => groupName($dbh,$webvar{gid}));980 $page->param(grpmeddle => $dnsdb->groupName($webvar{gid})); 981 981 my %grpperms; 982 982 getPermissions($dbh, 'group', $webvar{gid}, \%grpperms); … … 996 996 997 997 $page->param(curpage => $webvar{page}); 998 fill_pgcount($count, 'domains',groupName($dbh,$curgroup));998 fill_pgcount($count, 'domains', $dnsdb->groupName($curgroup)); 999 999 fill_fpnla($count); 1000 1000 $page->param(perpage => $perpage); … … 1026 1026 changepage(page => "domlist", errmsg => "You are not permitted to bulk-move domains") 1027 1027 unless ($permissions{admin} || ($permissions{domain_edit} && $permissions{domain_create} && $permissions{domain_delete})); 1028 my $newgname = groupName($dbh,$webvar{destgroup});1028 my $newgname = $dnsdb->groupName($webvar{destgroup}); 1029 1029 $page->param(action => "Move to group $newgname"); 1030 1030 } elsif ($webvar{bulkaction} eq 'deactivate' || $webvar{bulkaction} eq 'activate') { … … 1056 1056 next; 1057 1057 } 1058 $row{domain} = domainName($dbh,$webvar{$_});1058 $row{domain} = $dnsdb->domainName($webvar{$_}); 1059 1059 1060 1060 # Do the $webvar{bulkaction} … … 1317 1317 if (!defined($webvar{del})) { 1318 1318 $page->param(del_getconf => 1); 1319 $page->param(user => userFullName($dbh,$webvar{id}));1319 $page->param(user => $dnsdb->userFullName($webvar{id})); 1320 1320 } elsif ($webvar{del} eq 'ok') { 1321 1321 my ($code,$msg) = delUser($dbh, $webvar{id}); … … 1627 1627 goto DONELOG; 1628 1628 } 1629 $page->param(logfor => 'user '. userFullName($dbh,$id));1629 $page->param(logfor => 'user '.$dnsdb->userFullName($id)); 1630 1630 } elsif ($webvar{ltype} && $webvar{ltype} eq 'dom') { 1631 1631 $id = $webvar{id}; … … 1634 1634 goto DONELOG; 1635 1635 } 1636 $page->param(logfor => 'domain '. domainName($dbh,$id));1636 $page->param(logfor => 'domain '.$dnsdb->domainName($id)); 1637 1637 } elsif ($webvar{ltype} && $webvar{ltype} eq 'rdns') { 1638 1638 $id = $webvar{id}; … … 1641 1641 goto DONELOG; 1642 1642 } 1643 $page->param(logfor => 'reverse zone '. revName($dbh,$id));1643 $page->param(logfor => 'reverse zone '.$dnsdb->revName($id)); 1644 1644 } else { 1645 1645 # Default to listing curgroup log 1646 $page->param(logfor => 'group '. groupName($dbh,$id));1646 $page->param(logfor => 'group '.$dnsdb->groupName($id)); 1647 1647 # note that scope limitations are applied via the change-group check; 1648 1648 # group log is always for the "current" group … … 1699 1699 1700 1700 $page->param(group => $curgroup); 1701 $page->param(groupname => groupName($dbh,$curgroup));1702 $page->param(logingrp => groupName($dbh,$logingroup));1701 $page->param(groupname => $dnsdb->groupName($curgroup)); 1702 $page->param(logingrp => $dnsdb->groupName($logingroup)); 1703 1703 $page->param(logingrp_num => $logingroup); 1704 1704 … … 1771 1771 foreach (@childlist) { 1772 1772 my %row; 1773 $row{grpname} = groupName($dbh,$_);1773 $row{grpname} = $dnsdb->groupName($_); 1774 1774 $row{grpnum} = $_; 1775 1775 $row{whereami} = $uri_self; … … 1847 1847 # $page->param(group => $DNSDB::group); 1848 1848 $page->param(isgrp => 1) if $defrec eq 'y'; 1849 $page->param(parent => ($defrec eq 'y' ? groupName($dbh,$id) :1850 ($revrec eq 'n' ? domainName($dbh, $id) : revName($dbh,$id)) ) );1849 $page->param(parent => ($defrec eq 'y' ? $dnsdb->groupName($id) : 1850 ($revrec eq 'n' ? $dnsdb->domainName($id) : $dnsdb->revName($id)) ) ); 1851 1851 1852 1852 # defaults … … 1926 1926 # prefill <domain> or DOMAIN in "Host" space for new records 1927 1927 if ($webvar{revrec} eq 'n') { 1928 my $domroot = ($webvar{defrec} eq 'y' ? 'DOMAIN' : domainName($dbh,$webvar{parentid}));1928 my $domroot = ($webvar{defrec} eq 'y' ? 'DOMAIN' : $dnsdb->domainName($webvar{parentid})); 1929 1929 $page->param(name => ($webvar{name} ? $webvar{name} : $domroot)); 1930 1930 $page->param(address => $webvar{address}); … … 1936 1936 my $domroot = ($webvar{defrec} eq 'y' ? 'ADMINDOMAIN' : ".$config{domain}"); 1937 1937 $page->param(name => ($webvar{name} ? $webvar{name} : $domroot)); 1938 my $zname = ($webvar{defrec} eq 'y' ? 'ZONE' : revName($dbh,$webvar{parentid}));1938 my $zname = ($webvar{defrec} eq 'y' ? 'ZONE' : $dnsdb->revName($webvar{parentid})); 1939 1939 $zname =~ s|\d*/\d+$||; 1940 1940 $page->param(address => ($webvar{address} ? $webvar{address} : $zname)); … … 2039 2039 2040 2040 # fill page count and first-previous-next-last-all bits 2041 fill_pgcount($count,($webvar{revrec} eq 'n' ? 'domains' : 'revzones'), groupName($dbh,$curgroup));2041 fill_pgcount($count,($webvar{revrec} eq 'n' ? 'domains' : 'revzones'),$dnsdb->groupName($curgroup)); 2042 2042 fill_fpnla($count); 2043 2043 … … 2151 2151 $row{groupval} = $_; 2152 2152 $row{groupactive} = ($_ == $cur); 2153 $row{groupname} = $indent. groupName($dbh,$_);2153 $row{groupname} = $indent.$dnsdb->groupName($_); 2154 2154 push @{$grplist}, \%row; 2155 2155 getgroupdrop($_, $cur, $grplist, $indent.' '); … … 2159 2159 my @grouplist; 2160 2160 push @grouplist, { groupval => $logingroup, groupactive => $logingroup == $curgroup, 2161 groupname => groupName($dbh,$logingroup) };2161 groupname => $dnsdb->groupName($logingroup) }; 2162 2162 getgroupdrop($logingroup, $curgroup, \@grouplist); 2163 2163 -
trunk/textrecs.cgi
r468 r473 58 58 59 59 my $zone; 60 $zone = ($webvar{revrec} eq 'n' ? domainName($dbh, $webvar{id}) : revName($dbh,$webvar{id}))60 $zone = ($webvar{revrec} eq 'n' ? $dnsdb->domainName($webvar{id}) : $dnsdb->revName($webvar{id})) 61 61 if $webvar{defrec} eq 'n'; 62 $zone = "group ". groupName($dbh,$webvar{id}) if $webvar{defrec} eq 'y';62 $zone = "group ".$dnsdb->groupName($webvar{id}) if $webvar{defrec} eq 'y'; 63 63 64 64 ##fixme: do we support both HTML-plain and true plaintext? could be done, with another $webvar{}
Note:
See TracChangeset
for help on using the changeset viewer.