summaryrefslogtreecommitdiff
path: root/FS/FS/access_right.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-04-29 13:17:44 -0700
committerIvan Kohler <ivan@freeside.biz>2012-04-29 13:17:44 -0700
commitd9fd5e2d14e21482069db1ab3f97f547f6534cec (patch)
treedf63e98f7070c12151617a411c6858d095f54985 /FS/FS/access_right.pm
parent0198166784e8291e1b5a083ce3c89607ffef721e (diff)
support one right to many rights one-time upgrade, RT#17056
Diffstat (limited to 'FS/FS/access_right.pm')
-rw-r--r--FS/FS/access_right.pm39
1 files changed, 24 insertions, 15 deletions
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index 341055b..815c6d9 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -188,24 +188,33 @@ sub _upgrade_data { # class method
);
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;
+ 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/ /_/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);
+ FS::upgrade_journal->set_done($journal);
+
+ }
+
}
### ACL_download_report_data