fix ACL upgrade, RT#17056
authorIvan Kohler <ivan@freeside.biz>
Wed, 2 May 2012 22:47:51 +0000 (15:47 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 2 May 2012 22:47:51 +0000 (15:47 -0700)
FS/FS/AccessRight.pm
FS/FS/access_right.pm
httemplate/elements/menu.html

index a39fb37..a11ad7f 100644 (file)
@@ -288,7 +288,6 @@ tie my %rights, 'Tie::IxHash',
     'Usage: Call Detail Records (CDRs)',
     'Usage: Unrateable CDRs',
     'Usage: Time worked',
-    'Usage: Time worked summary',
 
     #{ rightname => 'List customers of all agents', global=>1 },
   ],
index 719577f..fc01746 100644 (file)
@@ -183,9 +183,28 @@ sub _upgrade_data { # class method
   my @all_groups = qsearch('access_group', {});
 
   my %onetime = (
-    'List customers' => 'List all customers',
-    'List packages'  => 'Summarize packages',
-    'Post payment'   => 'Backdate payment',
+    '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 ) {
@@ -196,20 +215,20 @@ sub _upgrade_data { # class method
 
     foreach my $new_acl ( @new_acl ) {
 
-      ( my $journal = 'ACL_'.lc($new_acl) ) =~ s/ /_/g;
+      ( 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) {
-        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;
-        }
+        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);
index fc8664a..42feb7b 100644 (file)
@@ -254,15 +254,17 @@ tie my %report_inventory, 'Tie::IxHash',
   'Inventory activity' => [ $fsurl.'search/report_h_inventory_item.html', '' ],
 ;
 
-my @report_rating = ();
-push(@report_rating, 'RADIUS sessions' => [ $fsurl.'search/sqlradius.html', '' ]) if $curuser->access_right("Usage: RADIUS sessions");
-push(@report_rating, 'Call Detail Records (CDRs)' => [ $fsurl.'search/report_cdr.html', '' ]) if $curuser->access_right("Usage: Call Detail Records (CDRs)");
-push(@report_rating, 'Unrateable CDRs' => [ $fsurl.'search/cdr.html?freesidestatus=failed'.
-    ';cdrbatchnum=_ALL_' ]) if $curuser->access_right("Usage: Unrateable CDRs");
-push(@report_rating, 'Time worked' => [ $fsurl.'search/report_rt_transaction.html', '' ]) if $curuser->access_right("Usage: Time worked");
-push(@report_rating, 'Time worked summary' => [ $fsurl.'search/report_rt_ticket.html', '' ]) if $curuser->access_right("Usage: Time worked summary");
-
-tie my %report_rating, 'Tie::IxHash', @report_rating;
+tie my %report_rating, 'Tie::IxHash';
+$report_rating{'RADIUS sessions'} = [ $fsurl.'search/sqlradius.html', '' ]
+  if $curuser->access_right("Usage: RADIUS sessions");
+$report_rating{'Call Detail Records (CDRs)'} = [ $fsurl.'search/report_cdr.html', '' ]
+  if $curuser->access_right("Usage: Call Detail Records (CDRs)");
+$report_rating{'Unrateable CDRs'} = [ $fsurl.'search/cdr.html?freesidestatus=failed;cdrbatchnum=_ALL_' ]
+  if $curuser->access_right("Usage: Unrateable CDRs");
+if ( $curuser->access_right("Usage: Time worked") ) {
+  $report_rating{'Time worked'} = [ $fsurl.'search/report_rt_transaction.html', '' ];
+  $report_rating{'Time worked summary'} = [ $fsurl.'search/report_rt_ticket.html', '' ];
+}
 
 tie my %report_ticketing_statistics, 'Tie::IxHash',
   'Tickets per day per Queue'         => [ $fsurl.'rt/RTx/Statistics/CallsQueueDay', 'View the number of tickets created, resolved or deleted in a specific Queue, over the requested period of days' ],