X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Faccess_right.pm;h=341055bfc27737f7c5c0e7b359b4fd4a31b9d8c6;hb=eb1652e3e27879dc21fb5de882581b5759a66bee;hp=bc6dd5d841aa6f44f3ffb04f4871e12847efd7d5;hpb=63a268637b2d51a8766412617724b9436439deb6;p=freeside.git diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index bc6dd5d84..341055bfc 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -145,6 +145,86 @@ 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', + ); + + foreach my $old_acl ( keys %onetime ) { + my $new_acl = $onetime{$old_acl}; #support arrayref too? + ( my $journal = 'ACL_'.lc($new_acl) ) =~ s/ /_/g; + next if FS::upgrade_journal->is_done($journal); + + # grant $new_acl to all groups who have $old_acl + for my $group (@all_groups) { + if ( $group->access_right($old_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'); + } + ''; }