Changeset 638


Ignore:
Timestamp:
06/03/14 17:18:10 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Add "Bulk Reverse Zone Operations" as an overlay on "Bulk Domain Operations"
Add "Select all" widget to bulk operations page

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r628 r638  
    10771077  fill_permissions($page, \%grpperms);
    10781078
    1079 } elsif ($webvar{page} eq 'bulkdomain') {
     1079} elsif ($webvar{page} eq 'bulkdomain' || $webvar{page} eq 'bulkrev') {
    10801080  # Bulk operations on domains.  Note all but group move are available on the domain list.
    10811081##fixme:  do we care about bulk operations on revzones?  Move-to-group, activate, deactivate,
    10821082# and delete should all be much rarer for revzones than for domains.
    10831083
    1084   changepage(page => "domlist", errmsg => "You are not permitted to make bulk domain changes")
     1084  changepage(page => "domlist", errmsg => "You are not permitted to make bulk zone changes")
    10851085        unless ($permissions{admin} || $permissions{domain_edit} || $permissions{domain_create} || $permissions{domain_delete});
    10861086
    10871087  fill_grouplist("grouplist");
    10881088
    1089   my $count = $dnsdb->getZoneCount(revrec => 'n', curgroup => $curgroup);
     1089  $page->param(fwdzone => $webvar{page} eq 'bulkdomain');
     1090
     1091  my $count = $dnsdb->getZoneCount(revrec => ($webvar{page} eq 'bulkdomain' ? 'n' : 'y'),
     1092        curgroup => $curgroup);
    10901093
    10911094  $page->param(curpage => $webvar{page});
     
    10941097  $page->param(perpage => $perpage);
    10951098
    1096   my $domlist = $dnsdb->getZoneList(revrec => 'n', curgroup => $curgroup, offset => $offset);
     1099  my $domlist = $dnsdb->getZoneList(revrec => ($webvar{page} eq 'bulkdomain' ? 'n' : 'y'),
     1100        curgroup => $curgroup, offset => $offset);
    10971101  my $rownum = 0;
    10981102  foreach my $dom (@{$domlist}) {
    10991103    delete $dom->{status};
    11001104    delete $dom->{group};
    1101     $dom->{newrow} = (++$rownum) % 5 == 0;
     1105    $dom->{newrow} = (++$rownum) % 5 == 0 && $rownum != $perpage;
    11021106  }
    11031107
     
    11401144  # order here, and since we don't have the domain names until we go around this
    11411145  # loop, we can't alpha-sort them here.  :(
    1142   foreach (keys %webvar) {
     1146  foreach my $input (keys %webvar) {
    11431147    my %row;
    1144     next unless $_ =~ /^dom_\d+$/;
     1148    next unless $input =~ /^(dom|rev)_\d+$/;
     1149    my $fr = $1;
    11451150    # second security check - does the user have permission to meddle with this domain?
    1146     if (!check_scope(id => $webvar{$_}, type => 'domain')) {
    1147       $row{domerr} = "You are not permitted to make changes to the requested domain";
    1148       $row{domain} = $webvar{$_};
     1151    if (!check_scope(id => $webvar{$input}, type => ($fr eq 'dom' ? 'domain' : 'revzone'))) {
     1152      $row{domerr} = "You are not permitted to make changes to the requested zone";
     1153      $row{domain} = $webvar{$input};
    11491154      push @bulkresults, \%row;
    11501155      next;
    11511156    }
    1152     $row{domain} = $dnsdb->domainName($webvar{$_});
     1157    $row{domain} = ($fr eq 'dom' ? $dnsdb->domainName($webvar{$input}) : $dnsdb->revName($webvar{$input}));
    11531158
    11541159    # Do the $webvar{bulkaction}
    11551160    my ($code, $msg);
    1156     ($code, $msg) = $dnsdb->changeGroup('domain', $webvar{$_}, $webvar{destgroup})
     1161    ($code, $msg) = $dnsdb->changeGroup(($fr eq 'dom' ? 'domain' : 'revzone'), $webvar{$input}, $webvar{destgroup})
    11571162        if $webvar{bulkaction} eq 'move';
    11581163    if ($webvar{bulkaction} eq 'deactivate' || $webvar{bulkaction} eq 'activate') {
    1159       my $stat = $dnsdb->zoneStatus($webvar{$_}, 'n', ($webvar{bulkaction} eq 'activate' ? 'domon' : 'domoff'));
     1164      my $stat = $dnsdb->zoneStatus($webvar{$input}, ($fr eq 'dom' ? 'n' : 'y'),
     1165        ($webvar{bulkaction} eq 'activate' ? 'domon' : 'domoff'));
    11601166      $code = (defined($stat) ? 'OK' : 'FAIL');
    11611167      $msg = (defined($stat) ? $DNSDB::resultstr : $DNSDB::errstr);
    11621168    }
    1163     ($code, $msg) = $dnsdb->delZone($webvar{$_}, 'n')
     1169    ($code, $msg) = $dnsdb->delZone($webvar{$input}, ($fr eq 'dom' ? 'n' : 'y'))
    11641170        if $webvar{bulkaction} eq 'delete';
    11651171
  • trunk/templates/bulkdomain.tmpl

    r590 r638  
    1717<tr><td>
    1818    <table border="0" cellspacing="2" cellpadding="2" width="100%">
    19         <tr class="darkrowheader"><td colspan="2" align="center">Bulk Domain Changes</td></tr>
     19        <tr class="darkrowheader"><td colspan="2" align="center">Bulk Zone Changes</td></tr>
    2020
    2121        <tr class="datalinelight">
     
    3232        </tr>
    3333        <tr class="darkrowheader">
    34                 <td colspan="2" align="center">Domains to change:</td>
     34                <td colspan="2" align="center">Zones to change:</td>
    3535        </tr>
    3636        <tr class="datalinelight">
     
    3838<div class="center"><TMPL_INCLUDE NAME="pgcount.tmpl"></div>
    3939<div class="center"><TMPL_INCLUDE NAME="fpnla.tmpl"></div>
    40 <div class="center hidden" id="selall"><input type="checkbox" name="selall" id="master" onclick="bulk_selall();" /> Select all domains on this page</div>
     40<div class="center hidden" id="selall"><input type="checkbox" name="selall" id="master" onclick="bulk_selall();"
     41/> Select all zones on this page</div>
    4142
    4243<table>
    4344<tr>
    44 <TMPL_LOOP NAME=domtable><td><input type="checkbox" name="dom_<TMPL_VAR NAME=zoneid>" value="<TMPL_VAR NAME=zoneid>" /> <TMPL_VAR NAME=zone></td>
     45<TMPL_LOOP NAME=domtable><td><input type="checkbox" name="<TMPL_IF fwdzone>dom<TMPL_ELSE>rev</TMPL_IF>_<TMPL_VAR NAME=zoneid>" value="<TMPL_VAR NAME=zoneid>" /> <TMPL_VAR NAME=zone></td>
    4546<TMPL_IF newrow></tr>
    4647<tr>
  • trunk/templates/menu.tmpl

    r493 r638  
    1212<TMPL_IF mayimport><a href="<TMPL_VAR NAME=script_self>&amp;page=axfr">AXFR Import</a><br /></TMPL_IF>
    1313<TMPL_IF maybulk><a href="<TMPL_VAR NAME=script_self>&amp;page=bulkdomain">Bulk Domain Operations</a><br /></TMPL_IF>
     14<TMPL_IF maybulk><a href="<TMPL_VAR NAME=script_self>&amp;page=bulkrev">Bulk Reverse Zone Operations</a><br /></TMPL_IF>
    1415<br />
    1516<a href="<TMPL_VAR NAME=script_self>&amp;page=grpman"><TMPL_IF chggrps>Manage<TMPL_ELSE>View</TMPL_IF> groups</a><br />
  • trunk/templates/widgets.js

    r590 r638  
    1414  var newstate = document.getElementById("master").checked;
    1515  for (var i=0; i<y.length; i++) {
    16     // only monkey with the dom_nnnn checkboxes
    17     if (y[i].name.substring(0,4) == 'dom_') {
     16    // only monkey with the dom/rev_nnnn checkboxes
     17    if (y[i].name.substring(0,4) == 'dom_' || y[i].name.substring(0,4) == 'rev_') {
    1818      if (newstate == true) {
    1919        // if the master gets checkmarked, save the original state of
    20         // the dom_nnn checkbox, and force it to "true"
     20        // the dom/rev_nnn checkbox, and force it to "true"
    2121        bulk_selstate[i] = y[i].checked;
    2222        y[i].checked = true;
Note: See TracChangeset for help on using the changeset viewer.