Changeset 237 for trunk/dns.cgi
- Timestamp:
- 02/17/12 17:55:18 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r234 r237 408 408 changepage(page => "domlist"); 409 409 } 410 411 } elsif ($webvar{page} eq 'revzones') { 412 413 $webvar{revrec} = 'y'; 414 $page->param(curpage => $webvar{page}); 415 listzones(); 410 416 411 417 } elsif ($webvar{page} eq 'reclist') { … … 1881 1887 # on a page showing nothing. 1882 1888 # For bonus points, this reverts to the original offset on clicking the "All" link (mostly) 1883 if ($offset ne 'all') { 1889 if ($offset ne 'all') { 1884 1890 $offset-- while ($offset * $perpage) >= $pgcount; 1885 1891 } … … 1895 1901 } # end fill_pgcount() 1896 1902 1897 sub listdomains { 1898 1903 1904 sub listdomains { listzones(); } # temp 1905 1906 sub listzones { 1899 1907 # ACLs 1900 1908 $page->param(domain_create => ($permissions{admin} || $permissions{domain_create}) ); … … 1906 1914 my $childlist = join(',',@childgroups); 1907 1915 1908 my $sql = "SELECT count(*) FROM domains WHERE group_id IN ($curgroup".($childlist ? ",$childlist" : '').")". 1909 ($startwith ? " AND domain ~* ?" : ''). 1910 ($filter ? " AND domain ~* ?" : ''); 1911 my $sth = $dbh->prepare($sql); 1912 $sth->execute(@filterargs); 1913 my ($count) = $sth->fetchrow_array; 1916 my $count = getZoneCount($dbh, (childlist => $childlist, curgroup => $curgroup, revrec => $webvar{revrec}, 1917 filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ) ); 1914 1918 1915 1919 # fill page count and first-previous-next-last-all bits 1916 fill_pgcount($count, "domains",groupName($dbh,$curgroup));1920 fill_pgcount($count,($webvar{revrec} eq 'n' ? 'domains' : 'revzones'),groupName($dbh,$curgroup)); 1917 1921 fill_fpnla($count); 1918 1922 … … 1925 1929 1926 1930 # set up the headers 1927 my @cols = ( 'domain', 'status', 'group');1928 my %colheads = (domain => 'Domain', status => 'Status', group => 'Group');1931 my @cols = (($webvar{revrec} eq 'n' ? 'domain' : 'revnet'), 'status', 'group'); 1932 my %colheads = (domain => 'Domain', revnet => 'Reverse Zone', status => 'Status', group => 'Group'); 1929 1933 fill_colheads($sortby, $sortorder, \@cols, \%colheads); 1930 1934 … … 1934 1938 1935 1939 # waffle, waffle - keep state on these as well as sortby, sortorder? 1940 ##fixme: put this higher so the count doesn't get munched? 1936 1941 $page->param("start$startwith" => 1) if $startwith && $startwith =~ /^(?:[a-z]|0-9)$/; 1937 1942 … … 1939 1944 $page->param(searchsubs => $searchsubs) if $searchsubs; 1940 1945 1941 ##fixme1942 ##fixme push the SQL and direct database fiddling off into a sub in DNSDB.pm1943 ##fixme1944 1945 1946 $page->param(group => $curgroup); 1946 my @domlist; 1947 $sql = "SELECT domain_id,domain,status,groups.group_name AS group FROM domains". 1948 " INNER JOIN groups ON domains.group_id=groups.group_id". 1949 " WHERE domains.group_id IN ($curgroup".($childlist ? ",$childlist" : '').")". 1950 ($startwith ? " AND domain ~* ?" : ''). 1951 ($filter ? " AND domain ~* ?" : ''). 1952 " ORDER BY ".($sortby eq 'group' ? 'groups.group_name' : $sortby). 1953 " $sortorder ".($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage); 1954 $sth = $dbh->prepare($sql); 1955 $sth->execute(@filterargs); 1956 my $rownum = 0; 1957 while (my @data = $sth->fetchrow_array) { 1958 my %row; 1959 $row{domainid} = $data[0]; 1960 $row{domain} = $data[1]; 1961 $row{status} = ($data[2] ? 'Active' : 'Inactive'); 1962 $row{group} = $data[3]; 1963 $row{bg} = ($rownum++)%2; 1964 $row{mkactive} = !$data[2]; 1965 $row{sid} = $sid; 1966 $row{offset} = $offset; 1967 # ACLs 1968 $row{domain_edit} = ($permissions{admin} || $permissions{domain_edit}); 1969 $row{domain_delete} = ($permissions{admin} || $permissions{domain_delete}); 1970 push @domlist, \%row; 1971 } 1972 $page->param(domtable => \@domlist); 1947 1948 my $zonelist = getZoneList($dbh, (childlist => $childlist, curgroup => $curgroup, 1949 revrec => $webvar{revrec}, 1950 filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef), 1951 offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder 1952 ) ); 1953 foreach (@$zonelist) { 1954 $_->{sid} = $sid; 1955 $_->{domain_edit} = ($permissions{admin} || $permissions{domain_edit}); 1956 $_->{domain_delete} = ($permissions{admin} || $permissions{domain_delete}); 1957 } 1958 $page->param(domtable => $zonelist); 1973 1959 } # end listdomains() 1974 1960
Note:
See TracChangeset
for help on using the changeset viewer.