Changeset 640


Ignore:
Timestamp:
06/05/14 14:00:13 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Finish duplicating "Bulk Domain Operations" to "Bulk Reverse Zone
Operations" by adding a confirmation page for bulk operations.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r638 r640  
    10791079} 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.
    1081 ##fixme:  do we care about bulk operations on revzones?  Move-to-group, activate, deactivate,
    1082 # and delete should all be much rarer for revzones than for domains.
    10831081
    10841082  changepage(page => "domlist", errmsg => "You are not permitted to make bulk zone changes")
     
    11121110  $page->param(maydelete => $permissions{admin} || $permissions{domain_delete});
    11131111
     1112#} elsif ($webvar{page} eq 'confirmbulkdom' || $webvar{page} eq 'confirmbulkrev') {
     1113} elsif ($webvar{page} eq 'confirmbulk') {
     1114
     1115  changepage(page => "domlist", errmsg => "You are not permitted to make bulk zone changes")
     1116        unless ($permissions{admin} || $permissions{domain_edit} || $permissions{domain_create} || $permissions{domain_delete});
     1117
     1118  $page->param(bulkaction => $webvar{bulkaction});
     1119  $page->param(destgroup => $webvar{destgroup});
     1120  my @zlist;
     1121  my $rownum = 0;
     1122
     1123##fixme: this could probably be made more efficient, since this looks up 2 zone names for
     1124# each comparison during sort rather than slurping them in bulk once before doing the sort
     1125  # sort zones by zone name, not ID
     1126  sub zsort {
     1127    my $tmpa = ($a =~ /^dom/ ? $dnsdb->domainName($webvar{$a}) : $dnsdb->revName($webvar{$a}) );
     1128    my $tmpb = ($b =~ /^dom/ ? $dnsdb->domainName($webvar{$b}) : $dnsdb->revName($webvar{$b}) );
     1129    return $tmpa cmp $tmpb;
     1130  }
     1131  # eugh.  can't see a handy way to sort this mess by zone name the way it is on the submitting page.  :(
     1132  foreach my $input (sort zsort grep(/^(?:dom|rev)_/, keys %webvar) ) {
     1133    next unless $input =~ /^(dom|rev)_\d+$/;
     1134    my $fr = $1;
     1135    my %row = (zoneid => $webvar{$input},
     1136        zone => ($fr eq 'dom' ? $dnsdb->domainName($webvar{$input}) : $dnsdb->revName($webvar{$input}) ),
     1137        zvarname => $input,
     1138        newrow => ( (++$rownum) % 5 == 0 && $rownum != $perpage),
     1139        );
     1140    push @zlist, \%row;
     1141  }
     1142  $page->param(domtable => \@zlist);
     1143
    11141144} elsif ($webvar{page} eq 'bulkchange') {
    11151145
     
    11201150  }
    11211151
     1152  # skip the changes if user did not confirm
     1153  my $wasrev = grep /^rev_/, keys %webvar;
     1154  changepage(page => ($wasrev ? "bulkrev" : "bulkdomain")) unless $webvar{okdel} eq 'y';
     1155
     1156  changepage(page => "domlist", errmsg => "You are not permitted to make bulk zone changes")
     1157        unless ($permissions{admin} || $permissions{domain_edit} || $permissions{domain_create} || $permissions{domain_delete});
     1158
    11221159  # per-action scope checks
    11231160  if ($webvar{bulkaction} eq 'move') {
    1124     changepage(page => "domlist", errmsg => "You are not permitted to bulk-move domains")
     1161    changepage(page => "domlist", errmsg => "You are not permitted to bulk-move zones")
    11251162        unless ($permissions{admin} || ($permissions{domain_edit} && $permissions{domain_create} && $permissions{domain_delete}));
    11261163    my $newgname = $dnsdb->groupName($webvar{destgroup});
    11271164    $page->param(action => "Move to group $newgname");
    11281165  } elsif ($webvar{bulkaction} eq 'deactivate' || $webvar{bulkaction} eq 'activate') {
    1129     changepage(page => "domlist", errmsg => "You are not permitted to bulk-$webvar{bulkaction} domains")
     1166    changepage(page => "domlist", errmsg => "You are not permitted to bulk-$webvar{bulkaction} zones")
    11301167        unless ($permissions{admin} || $permissions{domain_edit});
    1131     $page->param(action => "$webvar{bulkaction} domains");
     1168    $page->param(action => "$webvar{bulkaction} zones");
    11321169  } elsif ($webvar{bulkaction} eq 'delete') {
    1133     changepage(page => "domlist", errmsg => "You are not permitted to bulk-delete domains")
     1170    changepage(page => "domlist", errmsg => "You are not permitted to bulk-delete zones")
    11341171        unless ($permissions{admin} || $permissions{domain_delete});
    1135     $page->param(action => "$webvar{bulkaction} domains");
     1172    $page->param(action => "$webvar{bulkaction} zones");
    11361173  } else {
    11371174    # unknown action, bypass actually doing anything.  it should not be possible in
  • trunk/templates/bulkdomain.tmpl

    r638 r640  
    1010<fieldset>
    1111
    12 <input type="hidden" name="page" value="bulkchange" />
     12<input type="hidden" name="page" value="confirmbulk" />
    1313<input type="hidden" name="offset" value="<TMPL_VAR NAME=offset>" />
    1414<input type="hidden" name="perpage" value="<TMPL_VAR NAME=perpage>" />
     
    4444<tr>
    4545<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>
    46 <TMPL_IF newrow></tr>
     46<TMPL_IF newrow><TMPL_UNLESS __last__></tr>
    4747<tr>
    48 </TMPL_IF></TMPL_LOOP>
     48</TMPL_UNLESS></TMPL_IF></TMPL_LOOP>
    4949</tr>
    5050</table>
Note: See TracChangeset for help on using the changeset viewer.