Changeset 66 for trunk/dns.cgi
- Timestamp:
- 11/26/10 17:43:34 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r65 r66 476 476 if ($webvar{action} && $webvar{action} eq 'add') { 477 477 # not gonna provide the 4th param: template-or-clone flag, just yet 478 my ($code,$msg) = addGroup($dbh, $webvar{newgroup}, $webvar{pargroup}); 478 my %newperms; 479 foreach (@permtypes) { 480 $newperms{$_} = 0; 481 $newperms{$_} = 1 if $webvar{$_} eq 'on'; 482 } 483 my ($code,$msg) = addGroup($dbh, $webvar{newgroup}, $webvar{pargroup}, \%newperms); 479 484 if ($code eq 'OK') { 480 485 logaction(0, $session->param("username"), $webvar{pargroup}, "Added group $webvar{newgroup}"); 481 486 changepage(page => "grpman"); 482 487 } 488 # no point in doing extra work 489 fill_permissions($page, \%newperms); 483 490 $page->param(add_failed => 1); 484 491 $page->param(errmsg => $msg); 485 492 $page->param(newgroup => $webvar{newgroup}); 486 493 fill_grouplist('pargroup',$webvar{pargroup}); 487 494 } else { 488 495 # $page->param 489 fill_grouplist('pargroup',$curgroup); 490 496 fill_grouplist('pargroup',$curgroup); 497 # fill default permissions with immediate parent's current ones 498 my %parperms; 499 getPermissions($dbh, 'group', $curgroup, \%parperms); 500 fill_permissions($page, \%parperms); 491 501 } 492 502 … … 530 540 my %curperms; 531 541 getPermissions($dbh, 'group', $webvar{gid}, \%curperms); 532 foreach (('group_edit','group_create','group_delete', 533 'user_edit','user_create','user_delete', 534 'domain_edit','domain_create','domain_delete', 535 'record_edit','record_create','record_delete', 536 'self_edit') 537 ) { 542 my %chperms; 543 foreach (@permtypes) { 538 544 $webvar{$_} = 0 if !defined($webvar{$_}); 539 545 $webvar{$_} = 1 if $webvar{$_} eq 'on'; 540 push @debugbits, "$_ has changed: '$curperms{$_}' => '$webvar{$_}'<br>\n" if $curperms{$_} ne $webvar{$_}; 541 if ($permissions{admin} || $permissions{$_}) { 542 if (($webvar{$_} eq 'on' && !$curperms{$_}) or 543 (!$webvar{$_} && $curperms{$_})) { 544 push @debugbits, ' '."may update $_<br>\n"; 545 } 546 } 547 } 546 $chperms{$_} = $webvar{$_} if $curperms{$_} ne $webvar{$_}; 547 } 548 my ($code,$msg) = changePermissions($dbh, 'group', $webvar{gid}, \%chperms); 549 if ($code eq 'OK') { 550 logaction(0, $session->param("username"), $webvar{gid}, "Changed default permissions in group $webvar{gid}"); 551 changepage(page => "grpman"); 552 } 553 # no point in doing extra work 554 fill_permissions($page, \%chperms); 555 $page->param(errmsg => $msg); 548 556 } 549 557 $page->param(gid => $webvar{gid}); … … 551 559 my %grpperms; 552 560 getPermissions($dbh, 'group', $webvar{gid}, \%grpperms); 553 # unless (0) { 554 foreach (('group_edit','group_create','group_delete', 555 'user_edit','user_create','user_delete', 556 'domain_edit','domain_create','domain_delete', 557 'record_edit','record_create','record_delete', 558 'self_edit') 559 ) { 560 #push @debugbits, "$_ => admin? '$permissions{admin}' may_$_? '$permissions{$_}' group? '$grpperms{$_}'<br>\n"; 561 $page->param("may_$_" => ($permissions{admin} || $permissions{$_})); 562 $page->param($_ => $grpperms{$_}); 563 } 564 # } 565 # my %grpperms = getPermissions('group',$webvar{group}); 561 fill_permissions($page, \%grpperms); 566 562 567 563 } elsif ($webvar{page} eq 'useradmin') { … … 1450 1446 ##fixme: really need to do a little more error handling, I think 1451 1447 } # end parentID() 1448 1449 # we have to do this in a variety of places; let's make it consistent 1450 sub fill_permissions { 1451 my $template = shift; # may need to do several sets on a single page 1452 my $permset = shift; # hashref to permissions on object 1453 1454 foreach (@permtypes) { 1455 $template->param("may_$_" => ($permissions{admin} || $permissions{$_})); 1456 $template->param($_ => $permset->{$_}); 1457 } 1458 }
Note:
See TracChangeset
for help on using the changeset viewer.