X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Faccess_right.pm;h=e6266b49b1bcadca5952797c6ee37e3e0aebca69;hb=81978af92ecdaaefeff5156d9ab3b4f99586df1c;hp=d2a39aac862d1a1f10f11af9640108263c54c36c;hpb=3de7385d0a6ad25fa300f50929473f33998ea858;p=freeside.git diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index d2a39aac8..e6266b49b 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -2,7 +2,9 @@ package FS::access_right; use strict; use vars qw( @ISA ); +use Tie::IxHash; use FS::Record qw( qsearch qsearchs ); +use FS::upgrade_journal; @ISA = qw(FS::Record); @@ -182,23 +184,70 @@ sub _upgrade_data { # class method my @all_groups = qsearch('access_group', {}); - ### ACL_list_all_customers - if ( !FS::upgrade_journal->is_done('ACL_list_all_customers') ) { + tie my %onetime, 'Tie::IxHash', + 'List customers' => 'List all customers', + 'List all customers' => 'Advanced customer search', + 'List packages' => 'Summarize packages', + 'Post payment' => 'Backdate payment', + 'Cancel customer package immediately' => 'Un-cancel customer package', + 'Suspend customer package' => 'Suspend customer', + 'Unsuspend customer package' => 'Unsuspend customer', + 'New prospect' => 'Generate quotation', + + 'List services' => [ 'Services: Accounts', + 'Services: Domains', + 'Services: Certificates', + 'Services: Mail forwards', + 'Services: Virtual hosting services', + 'Services: Wireless broadband services', + 'Services: DSLs', + 'Services: Dish services', + 'Services: Hardware', + 'Services: Phone numbers', + 'Services: PBXs', + 'Services: Ports', + 'Services: Mailing lists', + 'Services: External services', + ], + + 'Services: Accounts' => 'Services: Accounts: Advanced search', + 'Services: Wireless broadband services' => 'Services: Wireless broadband services: Advanced search', + 'Services: Hardware' => 'Services: Hardware: Advanced search', + + 'List rating data' => [ 'Usage: RADIUS sessions', + 'Usage: Call Detail Records (CDRs)', + 'Usage: Unrateable CDRs', + ], + ; - # grant "List all customers" to all users who have "List customers" - for my $group (@all_groups) { - if ( $group->access_right('List customers') ) { + foreach my $old_acl ( keys %onetime ) { + + my @new_acl = ref($onetime{$old_acl}) + ? @{ $onetime{$old_acl} } + : ( $onetime{$old_acl} ); + + foreach my $new_acl ( @new_acl ) { + + ( my $journal = 'ACL_'.lc($new_acl) ) =~ s/\W/_/g; + next if FS::upgrade_journal->is_done($journal); + + # grant $new_acl to all groups who have $old_acl + for my $group (@all_groups) { + next unless $group->access_right($old_acl); + next if $group->access_right($new_acl); my $access_right = FS::access_right->new( { 'righttype' => 'FS::access_group', 'rightobjnum' => $group->groupnum, - 'rightname' => 'List all customers', + 'rightname' => $new_acl, } ); my $error = $access_right->insert; die $error if $error; } - } - FS::upgrade_journal->set_done('ACL_list_all_customers'); + FS::upgrade_journal->set_done($journal); + + } + } ### ACL_download_report_data