Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r111 r112 27 27 &initGlobals 28 28 &initPermissions &getPermissions &changePermissions &comparePermissions 29 &changeGroup 29 30 &connectDB &finish 30 31 &addDomain &delDomain &domainName &domainID … … 43 44 &initGlobals 44 45 &initPermissions &getPermissions &changePermissions &comparePermissions 46 &changeGroup 45 47 &connectDB &finish 46 48 &addDomain &delDomain &domainName &domainID … … 348 350 return $retval; 349 351 } # end comparePermissions() 352 353 354 ## DNSDB::changeGroup() 355 # Change group ID of an entity 356 # Takes a database handle, entity type, entity ID, and new group ID 357 sub changeGroup { 358 my $dbh = shift; 359 my $type = shift; 360 my $id = shift; 361 my $newgrp = shift; 362 363 ##fixme: fail on not enough args 364 #return ('FAIL', "Missing 365 366 if ($type eq 'domain') { 367 $dbh->do("UPDATE domains SET group_id=? WHERE domain_id=?", undef, ($newgrp, $id)) 368 or return ('FAIL','Group change failed: '.$dbh->errstr); 369 } elsif ($type eq 'user') { 370 $dbh->do("UPDATE users SET group_id=? WHERE user_id=?", undef, ($newgrp, $id)) 371 or return ('FAIL','Group change failed: '.$dbh->errstr); 372 } elsif ($type eq 'group') { 373 $dbh->do("UPDATE groups SET parent_group_id=? WHERE group_id=?", undef, ($newgrp, $id)) 374 or return ('FAIL','Group change failed: '.$dbh->errstr); 375 } 376 return ('OK','OK'); 377 } # end changeGroup() 350 378 351 379 -
trunk/dns.cgi
r111 r112 37 37 38 38 my @debugbits; # temp, to be spit out near the end of processing 39 my $debugenv = 0;39 my $debugenv = 1; 40 40 41 41 # Let's do these templates right... … … 108 108 my $sortorder = "ASC"; 109 109 110 my ($dbh,$msg) = connectDB("dnsdb","dnsdb","secret","newdbhost"); 110 #my ($dbh,$msg) = connectDB("dnsdb","dnsdb","secret","newdbhost"); 111 # dbname, user, pass, host (optional) 112 my ($dbh,$msg) = connectDB("dnsdb", "dnsdb", "secret", "dnsdbhost"); 111 113 #my $dbh = DBI->connect("DBI:mysql:database=vegadns","vegadns","secret", 112 114 # { AutoCommit => 0 }) or die $DBI::errstr; … … 587 589 if ($code ne 'OK') { 588 590 # need to find failure mode 591 logaction(0, $session->param("username"), $webvar{curgroup}, "Failure deleting group $deleteme: $msg"); 589 592 changepage(page => "grpman", del_failed => 1, errmsg => $msg); 590 ##fixme: log591 593 } else { 592 594 ##fixme: need to clean up log when deleting a major container … … 642 644 643 645 ##fixme: un-hardcode the limit? 644 $perpage = 50;646 # $perpage = 50; 645 647 646 648 my $sth = $dbh->prepare("SELECT count(*) FROM domains WHERE group_id=?"); … … 651 653 fill_pgcount($count,'domains',groupName($dbh,$curgroup)); 652 654 fill_fpnla($count); 655 $page->param(offset => $offset); # since apparently this isn't set explicitly elsewhere. Who knew? 656 $page->param(perpage => $perpage); 653 657 654 658 my @domlist; … … 669 673 } 670 674 $page->param(domtable => \@domlist); 671 # ACLs675 # ACLs 672 676 $page->param(maymove => ($permissions{admin} || ($permissions{domain_edit} && $permissions{domain_create} && $permissions{domain_delete}))); 673 677 $page->param(maystatus => $permissions{admin} || $permissions{domain_edit}); 674 678 $page->param(maydelete => $permissions{admin} || $permissions{domain_delete}); 675 679 676 ##fixme: need to clean up status indicator/usage/inversion 680 } elsif ($webvar{page} eq 'bulkchange') { 681 682 if ($webvar{action} eq 'move') { 683 changepage(page => "domlist", errmsg => "You are not permitted to bulk-move domains") 684 unless ($permissions{admin} || ($permissions{domain_edit} && $permissions{domain_create} && $permissions{domain_delete})); 685 $page->param(action => $webvar{action}); 686 my $tmpstr = 'tmpstr: '; 687 my @bulkresults; 688 # nngh. due to alpha-sorting on the previous page, we can't use domid-numeric 689 # order here, and since we don't have the domain names until we go around this 690 # loop, we can't alpha-sort them here. :( 691 foreach (keys %webvar) { 692 my %row; 693 next unless $_ =~ /^dom_\d+$/; 694 $row{domain} = domainName($dbh,$webvar{$_}); 695 my ($code, $msg) = changeGroup($dbh, 'domain', $webvar{$_}, $webvar{destgroup}); 696 $row{domok} = ($code eq 'OK'); 697 $row{domerr} = $msg; 698 push @bulkresults, \%row; 699 } 700 $page->param(bulkresults => \@bulkresults); 701 702 } elsif ($webvar{action} eq 'deactivate') { 703 changepage(page => "domlist", errmsg => "You are not permitted to bulk-deactivate domains") 704 unless ($permissions{admin} || $permissions{domain_edit}); 705 } elsif ($webvar{action} eq 'activate') { 706 changepage(page => "domlist", errmsg => "You are not permitted to bulk-activate domains") 707 unless ($permissions{admin} || $permissions{domain_edit}); 708 } elsif ($webvar{action} eq 'delete') { 709 changepage(page => "domlist", errmsg => "You are not permitted to bulk-delete domains") 710 unless ($permissions{admin} || $permissions{domain_delete}); 711 } 712 # not going to handle the unknown $webvar{action} else; it should not be possible in normal 713 # operations, and anyone who meddles with the URL gets what they deserve. 677 714 678 715 } elsif ($webvar{page} eq 'useradmin') { -
trunk/templates/bulkdomain.tmpl
r110 r112 9 9 10 10 <input type="hidden" name="sid" value="<TMPL_VAR NAME=sid>" /> 11 <input type="hidden" name="page" value="bulkdomain" /> 11 <input type="hidden" name="page" value="bulkchange" /> 12 <input type="hidden" name="offset" value="<TMPL_VAR NAME=offset>" /> 13 <input type="hidden" name="perpage" value="<TMPL_VAR NAME=perpage>" /> 12 14 13 15 <table class="container"> 14 16 <tr><td> 15 17 <table border="0" cellspacing="2" cellpadding="2" width="100%"> 16 <TMPL_IF add_failed> <tr><td class="errhead" colspan="2">Error adding domain <TMPL_VAR NAME=domain>: <TMPL_VAR NAME=errmsg></td></tr></TMPL_IF>17 18 <tr class="darkrowheader"><td colspan="2" align="center">Bulk Domain Changes</td></tr> 18 19 … … 20 21 <td>Action:</td> 21 22 <td align="left"> 22 <TMPL_IF maymove> <input type="radio" name="action" value="move" /> Move to group: <select name="group">23 <TMPL_IF maymove> <input type="radio" name="action" value="move" checked="checked" /> Move to group: <select name="destgroup"> 23 24 <TMPL_LOOP name=grouplist> <option value="<TMPL_VAR NAME=groupval>"<TMPL_IF groupactive> selected="selected"</TMPL_IF>><TMPL_VAR name=groupname></option> 24 25 </TMPL_LOOP> 25 26 </select><br /></TMPL_IF> 26 <TMPL_IF maystatus> <input type="radio" name="action" value="deactivate" /> Deactivate<br />27 <input type="radio" name="action" value="activate" /> Activate<br /></TMPL_IF>28 <TMPL_IF maydelete> <input type="radio" name="action" value="delete" /> Delete<br /></TMPL_IF>29 </td>27 <TMPL_IF maystatus> <input type="radio" name="action" value="deactivate" /> Deactivate<br /> 28 <input type="radio" name="action" value="activate" /> Activate<br /></TMPL_IF> 29 <TMPL_IF maydelete> <input type="radio" name="action" value="delete" /> Delete<br /></TMPL_IF> 30 </td> 30 31 </tr> 31 32 <tr class="darkrowheader"> … … 46 47 </table> 47 48 </td> 48 </tr> 49 </td> 50 </tr> 51 <tr class="darkrowheader"><td colspan="2" align="center"><input type="submit" value="Make changes" /></td></tr> 49 52 </table> 50 53 </td>
Note:
See TracChangeset
for help on using the changeset viewer.