X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Faccess_right.pm;h=fc0174602365b1fbd4c603e2f7f2d918f08ee3b4;hb=3bbe0f73c2afbbe182fe8a0a6490ba1700152742;hp=4f8d1e9a081fce134e0306e735eb84285d04ade5;hpb=3e2c08dba947ea254c60cbd621776c0f5dddb2e8;p=freeside.git diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index 4f8d1e9a0..fc0174602 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -145,6 +145,115 @@ sub _upgrade_data { # class method if $error; } + my %migrate = ( + 'Post payment' => [ 'Post check payment', 'Post cash payment' ], + 'Process payment' => [ 'Process credit card payment', 'Process Echeck payment' ], + 'Post refund' => [ 'Post check refund', 'Post cash refund' ], + 'Refund payment' => [ 'Refund credit card payment', 'Refund Echeck payment' ], + ); + + foreach my $oldright (keys %migrate) { + my @old = qsearch('access_right', { 'righttype'=>'FS::access_group', + 'rightname'=>$oldright, + } + ); + + foreach my $old ( @old ) { + + foreach my $newright ( @{ $migrate{$oldright} } ) { + my %hash = ( + 'righttype' => 'FS::access_group', + 'rightobjnum' => $old->rightobjnum, + 'rightname' => $newright, + ); + next if qsearchs('access_right', \%hash); + my $access_right = new FS::access_right \%hash; + my $error = $access_right->insert; + die $error if $error; + } + + #after the WEST stuff is sorted, etc. + #my $error = $old->delete; + #die $error if $error; + + } + + } + + my @all_groups = qsearch('access_group', {}); + + my %onetime = ( + 'List customers' => 'List all customers', + 'List packages' => 'Summarize packages', + 'Post payment' => 'Backdate payment', + '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', + ], + 'List rating data' => [ 'Usage: RADIUS sessions', + 'Usage: Call Detail Records (CDRs)', + 'Usage: Unrateable CDRs', + ], + ); + + 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' => $new_acl, + } ); + my $error = $access_right->insert; + die $error if $error; + } + + FS::upgrade_journal->set_done($journal); + + } + + } + + ### ACL_download_report_data + if ( !FS::upgrade_journal->is_done('ACL_download_report_data') ) { + + # grant to everyone + for my $group (@all_groups) { + my $access_right = FS::access_right->new( { + 'righttype' => 'FS::access_group', + 'rightobjnum' => $group->groupnum, + 'rightname' => 'Download report data', + } ); + my $error = $access_right->insert; + die $error if $error; + } + + FS::upgrade_journal->set_done('ACL_download_report_data'); + } + ''; } @@ -153,8 +262,6 @@ sub _upgrade_data { # class method =head1 BUGS -The author forgot to customize this manpage. - =head1 SEE ALSO L, schema.html from the base documentation.