[Rt-commit] r17780 - rt/3.8/trunk/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Fri Jan 16 09:10:23 EST 2009


Author: ruz
Date: Fri Jan 16 09:10:23 2009
New Revision: 17780

Modified:
   rt/3.8/trunk/lib/RT/Config.pm

Log:
* allow caller to avoid sorting by sortorder and falback
  to name based sorting, useful for site configuration screen
  where most options has no defined sort order as they are
  not overridable


Modified: rt/3.8/trunk/lib/RT/Config.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Config.pm	(original)
+++ rt/3.8/trunk/lib/RT/Config.pm	Fri Jan 16 09:10:23 2009
@@ -759,17 +759,27 @@
 
 sub Options {
     my $self = shift;
-    my %args = ( Section => undef, Overridable => 1, @_ );
-    my @res  = sort { ($META{$a}->{SortOrder}||9999) <=> ($META{$b}->{SortOrder}||9999)
-                       || $a cmp $b } keys %META;
+    my %args = ( Section => undef, Overridable => 1, Sorted => 1, @_ );
+    my @res  = keys %META;
+    
     @res = grep( ( $META{$_}->{'Section'} || 'General' ) eq $args{'Section'},
-        @res )
-        if defined $args{'Section'};
+        @res 
+    ) if defined $args{'Section'};
+
     if ( defined $args{'Overridable'} ) {
         @res
             = grep( ( $META{$_}->{'Overridable'} || 0 ) == $args{'Overridable'},
             @res );
     }
+
+    if ( $args{'Sorted'} ) {
+        @res = sort {
+            ($META{$a}->{SortOrder}||9999) <=> ($META{$b}->{SortOrder}||9999)
+            || $a cmp $b 
+        } @res;
+    } else {
+        @res = sort { $a cmp $b } @res;
+    }
     return @res;
 }
 


More information about the Rt-commit mailing list