[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 00cb3b1291e336dedd28c5326bc210e5e511c337

Ivan ivan at 420.am
Sun Apr 29 13:17:48 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  00cb3b1291e336dedd28c5326bc210e5e511c337 (commit)
      from  22dd966b4dac5e4146424cc7338abcf1264bc87d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 00cb3b1291e336dedd28c5326bc210e5e511c337
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Apr 29 13:17:46 2012 -0700

    support one right to many rights one-time upgrade, RT#17056

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

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/access_right.pm |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)




More information about the freeside-commits mailing list