X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FAdmin%2FElements%2FEditRightsCategoryTabs;h=c02ce0476fe1fd92dff1865e6d5674b4a7871c62;hp=786cafdd8c162306b96cd9f0b018fe343fa3b182;hb=de9d037528895f7151a9aead6724ce2df95f9586;hpb=6587f6ba7d047ddc1686c080090afe7d53365bd4 diff --git a/rt/share/html/Admin/Elements/EditRightsCategoryTabs b/rt/share/html/Admin/Elements/EditRightsCategoryTabs index 786cafdd8..c02ce0476 100644 --- a/rt/share/html/Admin/Elements/EditRightsCategoryTabs +++ b/rt/share/html/Admin/Elements/EditRightsCategoryTabs @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -52,15 +52,10 @@ $id $acldesc => '' <%init> -# XXX OPTIMIZATION: Moving the calls to AvailableRights and RightCategories up -# one component to avoid calling them for every principal would be a win, but -# it's cleaner to do it here. The values can really be computed once per -# $Context. - # Find all our available rights... my (%available_rights, %categories); if ( blessed($Context) and $Context->can('AvailableRights') ) { - %available_rights = %{$Context->AvailableRights}; + %available_rights = %{$Context->AvailableRights( $Principal ? $Principal->PrincipalObj : undef )}; } else { %available_rights = ( loc('System Error') => loc("No rights found") ); } @@ -70,7 +65,8 @@ if ( blessed($Context) and $Context->can('RightCategories') ) { my %right_categories = %{$Context->RightCategories}; for my $right (keys %available_rights) { - push @{$categories{$right_categories{$right}}}, $right; + my $category = $right_categories{$right} || 'Miscellaneous'; # loc + push @{$categories{$category}}, $right; } } @@ -94,15 +90,22 @@ my %category_desc = ( 'Status' => loc('Status changes'), ); -my %catsort = ( General => 1, Staff => 2, Admin => 3, Status => 4 ); +my %catsort = ( General => 1, Staff => 2, Admin => 3, Status => 4, Miscellaneous => 999 ); +my $i = 5; +for my $category ( sort keys %categories ) { + next if $catsort{$category}; + $catsort{$category} = $i++; +} $acldesc ||= join '-', ($Principal ? $Principal->PrincipalId : 'addprincipal'), ref($Context), $Context->Id; + +$available_rights{$_} = loc( $available_rights{$_} ) for keys %available_rights;
% for my $category (sort { $catsort{$a} <=> $catsort{$b} } keys %categories) { @@ -115,10 +118,10 @@ $acldesc ||= join '-', ($Principal ? $Principal->PrincipalId : 'addprincipal'), id="SetRights-<% $acldesc %>-<% $right %>" value="<% $right %>" <% $current_rights{$right} ? 'checked' : '' %> /> -