Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r274 r275 48 48 &parentID 49 49 &isParent 50 & domStatus &importAXFR50 &zoneStatus &importAXFR 51 51 &export 52 52 &mailNotify … … 70 70 &parentID 71 71 &isParent 72 & domStatus &importAXFR72 &zoneStatus &importAXFR 73 73 &export 74 74 &mailNotify … … 2722 2722 2723 2723 2724 ## DNSDB:: domStatus()2725 # Sets and/or returns a domain's status2726 # Takes a database handle, domain IDand optionally a status argument2727 # Returns undef on errors.2728 sub domStatus {2724 ## DNSDB::zoneStatus() 2725 # Returns and optionally sets a zone's status 2726 # Takes a database handle, domain/revzone ID, forward/reverse flag, and optionally a status argument 2727 # Returns status, or undef on errors. 2728 sub zoneStatus { 2729 2729 my $dbh = shift; 2730 2730 my $id = shift; 2731 my $newstatus = shift; 2731 my $revrec = shift; 2732 my $newstatus = shift || 'mu'; 2732 2733 2733 2734 return undef if $id !~ /^\d+$/; 2734 2735 2735 my $sth;2736 2737 2736 # ooo, fun! let's see what we were passed for status 2738 if ($newstatus) { 2739 $sth = $dbh->prepare("update domains set status=? where domain_id=?"); 2740 # ass-u-me caller knows what's going on in full 2741 if ($newstatus =~ /^[01]$/) { # only two valid for now. 2742 $sth->execute($newstatus,$id); 2743 } elsif ($newstatus =~ /^domo(?:n|ff)$/) { 2744 $sth->execute(($newstatus eq 'domon' ? 1 : 0),$id); 2745 } 2746 } 2747 2748 $sth = $dbh->prepare("select status from domains where domain_id=?"); 2749 $sth->execute($id); 2750 my ($status) = $sth->fetchrow_array; 2737 if ($newstatus ne 'mu') { 2738 $newstatus = 0 if $newstatus eq 'domoff'; 2739 $newstatus = 1 if $newstatus eq 'domon'; 2740 $dbh->do("UPDATE ".($revrec eq 'n' ? 'domains' : 'revzones')." SET status=? WHERE ". 2741 ($revrec eq 'n' ? 'domain_id' : 'rdns_id')."=?", undef, ($newstatus,$id) ); 2742 } 2743 2744 my ($status) = $dbh->selectrow_array("SELECT status FROM ". 2745 ($revrec eq 'n' ? "domains WHERE domain_id=?" : "revzones WHERE rdns_id=?"), 2746 undef, ($id) ); 2751 2747 return $status; 2752 } # end domStatus()2748 } # end zoneStatus() 2753 2749 2754 2750 -
trunk/dns.cgi
r274 r275 315 315 # hmm. seeing problems in some possibly-not-so-corner cases. 316 316 # this currently only handles "domain on", "domain off" 317 if (defined($webvar{ domstatus})) {317 if (defined($webvar{zonestatus})) { 318 318 # security check - does the user have permission to access this entity? 319 319 my $flag = 0; … … 322 322 } 323 323 if ($flag && ($permissions{admin} || $permissions{domain_edit})) { 324 my $stat = domStatus($dbh,$webvar{id},$webvar{domstatus});324 my $stat = zoneStatus($dbh,$webvar{id},'n',$webvar{zonestatus}); 325 325 ##fixme switch to more consise "Enabled <domain"/"Disabled <domain>" as with users? 326 326 logaction($webvar{id}, $session->param("username"), … … 332 332 $page->param(errmsg => "You are not permitted to view or change the requested domain"); 333 333 } 334 $uri_self =~ s/\& domstatus=[^&]*//g; # clean up URL for stuffing into templates334 $uri_self =~ s/\&zonestatus=[^&]*//g; # clean up URL for stuffing into templates 335 335 } 336 336 … … 434 434 435 435 $webvar{revrec} = 'y'; 436 437 if (defined($webvar{zonestatus})) { 438 # security check - does the user have permission to access this entity? 439 my $flag = 0; 440 foreach (@viewablegroups) { 441 $flag = 1 if isParent($dbh, $_, 'group', $webvar{id}, 'revzone'); 442 } 443 if ($flag && ($permissions{admin} || $permissions{domain_edit})) { 444 my $stat = zoneStatus($dbh,$webvar{id},'y',$webvar{zonestatus}); 445 ##fixme switch to more consise "Enabled <domain"/"Disabled <domain>" as with users? 446 logaction($webvar{id}, $session->param("username"), 447 parentID($dbh, (id => $webvar{id}, type => 'revzone', revrec => $webvar{revrec})), 448 "Changed ".revName($dbh, $webvar{id})." state to ".($stat ? 'active' : 'inactive')); 449 $page->param(resultmsg => "Changed ".revName($dbh, $webvar{id})." state to ". 450 ($stat ? 'active' : 'inactive')); 451 } else { 452 $page->param(errmsg => "You are not permitted to view or change the requested reverse zone"); 453 } 454 $uri_self =~ s/\&zonestatus=[^&]*//g; # clean up URL for stuffing into templates 455 } 436 456 437 457 if ($session->param('resultmsg')) { … … 1222 1242 $row{domain} = domainName($dbh,$webvar{$_}); 1223 1243 ##fixme: error handling on status change 1224 my $stat = domStatus($dbh,$webvar{$_},($webvar{bulkaction} eq 'activate' ? 'domon' : 'domoff'));1244 my $stat = zoneStatus($dbh,$webvar{$_},($webvar{bulkaction} eq 'activate' ? 'domon' : 'domoff')); 1225 1245 logaction($webvar{$_}, $session->param("username"), 1226 1246 parentID($dbh, (id => $webvar{$_}, type => 'domain', revrec => $webvar{revrec})), … … 1637 1657 my %row; 1638 1658 my ($code,$msg) = importAXFR($dbh, $webvar{ifrom}, $domain, $webvar{group}, 1639 $webvar{ domstatus}, $webvar{rwsoa}, $webvar{rwns});1659 $webvar{zonestatus}, $webvar{rwsoa}, $webvar{rwns}); 1640 1660 $row{domok} = $msg if $code eq 'OK'; 1641 1661 if ($code eq 'WARN') { -
trunk/templates/domlist.tmpl
r239 r275 49 49 <td><TMPL_IF status>Active<TMPL_ELSE>Inactive</TMPL_IF></td> 50 50 <td><TMPL_VAR name=group></td> 51 <TMPL_IF domain_edit> <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage><TMPL_IF NAME=offset>&offset=<TMPL_VAR NAME=offset></TMPL_IF>&id=<TMPL_VAR NAME=domainid>& domstatus=<TMPL_IF status>domoff<TMPL_ELSE>domon</TMPL_IF>"><TMPL_IF status>deactivate<TMPL_ELSE>activate</TMPL_IF></a></td></TMPL_IF>51 <TMPL_IF domain_edit> <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage><TMPL_IF NAME=offset>&offset=<TMPL_VAR NAME=offset></TMPL_IF>&id=<TMPL_VAR NAME=domainid>&zonestatus=<TMPL_IF status>domoff<TMPL_ELSE>domon</TMPL_IF>"><TMPL_IF status>deactivate<TMPL_ELSE>activate</TMPL_IF></a></td></TMPL_IF> 52 52 <TMPL_IF domain_delete> <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_IF domlist>deldom<TMPL_ELSE>delrevzone</TMPL_IF>&id=<TMPL_VAR NAME=domainid>"><img src="images/trash2.png" alt="[ Delete ]" /></a></td></TMPL_IF> 53 53 </tr>
Note:
See TracChangeset
for help on using the changeset viewer.