[Rt-commit] rt branch, 4.0/fix-right-categries-ui, created. rt-4.0.11rc1-1-g1fcfcd5

? sunnavy sunnavy at bestpractical.com
Tue Mar 26 12:51:02 EDT 2013


The branch, 4.0/fix-right-categries-ui has been created
        at  1fcfcd5a9af2dd4ff4a214b02fd79f0a3b03805b (commit)

- Log -----------------------------------------------------------------
commit 1fcfcd5a9af2dd4ff4a214b02fd79f0a3b03805b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Mar 27 00:25:08 2013 +0800

    show customized rights below their _corresponding_ categories
    
    before, if people add new rights(with new categories) by calling
    RT::System::AddRights and RT::System::AddRightCategories, all of them would be
    listed below 'Miscellaneous' tab, which is not right.
    
    new right categories will be listed alphbetically after core categories but
    before 'Miscellaneous'
    
    uninitialized warnings are also fixed.
    
    see also #23158

diff --git a/share/html/Admin/Elements/EditRightsCategoryTabs b/share/html/Admin/Elements/EditRightsCategoryTabs
index 60d0a44..cbf3948 100644
--- a/share/html/Admin/Elements/EditRightsCategoryTabs
+++ b/share/html/Admin/Elements/EditRightsCategoryTabs
@@ -70,7 +70,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,7 +95,12 @@ 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;
@@ -102,7 +108,7 @@ $acldesc ||= join '-', ($Principal ? $Principal->PrincipalId : 'addprincipal'),
     <div class="category-tabs">
       <ul>
 % for my $category (sort { $catsort{$a} <=> $catsort{$b} } keys %categories) {
-        <li><a href="#<% "$id-$category" %>"><% $category_desc{$category} || loc('Miscellaneous') %></a></li>
+        <li><a href="#<% "$id-$category" %>"><% $category_desc{$category} || loc($category) %></a></li>
 % }
       </ul>
 % for my $category (sort { $catsort{$a} <=> $catsort{$b} } keys %categories) {

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


More information about the Rt-commit mailing list