[Rt-commit] r9348 - in rtir/branches/2.3-EXPERIMENTAL: html/RTIR/Incident

ruz at bestpractical.com ruz at bestpractical.com
Thu Oct 18 22:41:29 EDT 2007


Author: ruz
Date: Thu Oct 18 22:41:29 2007
New Revision: 9348

Modified:
   rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html
   rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm

Log:
* add support for handling multiple queues in RT::IR::States

Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html	Thu Oct 18 22:41:29 2007
@@ -107,7 +107,6 @@
 my (@results);
 
 my $IncidentObj = LoadTicket( $id );
-
 $id = $ARGS{'id'} = $IncidentObj->id;
 
 $m->callback(CallbackName => 'Initial', %ARGS, Ticket => $IncidentObj);
@@ -137,18 +136,9 @@
 my @queues = ('Incident Reports', 'Investigations');
 push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
-my $ActiveStatesQuery;
-{
-    my @active_states;
-    foreach my $q( @queues ) {
-        push @active_states, RT::IR::States( Queue => $q );
-    }
-    my %seen;
-    $ActiveStatesQuery = join ' OR ',
-        map "CF.{_RTIR_State} = '$_'",
-        grep !$seen{ $_ }++,
-        @active_states;
-}
+my $ActiveStatesQuery =
+    join ' OR ', map "CF.{_RTIR_State} = '$_'",
+    RT::IR::States( Queue => \@queues );
 
 $Query ||= "( $ActiveStatesQuery )";
 

Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm	Thu Oct 18 22:41:29 2007
@@ -160,6 +160,23 @@
     return undef;
 }
 
+=head2 States
+
+Return sorted list of unique states for one, many or all RTIR queues.
+
+Takes arguments 'Queue', 'Active' and 'Inactive'. By default returns
+only active states. Queue can be an array reference to list several
+queues.
+
+Examples:
+
+    States()
+    States( Queue => 'Blocks' );
+    States( Queue => [ 'Blocks', 'Incident Reports' ] );
+    States( Active => 0, Inactive => 1 );
+
+=cut
+
 my %STATES = (
     'incidents'        => { Active => ['open'], Inactive => ['resolved', 'abandoned'] },
     'incident reports' => { Active => ['new', 'open'], Inactive => ['resolved', 'rejected'] },
@@ -174,8 +191,11 @@
     
     my @states;
     if ( $arg{'Queue'} ) {
-        push @states, @{ $STATES{ lc $arg{'Queue'} }->{'Active'} || [] } if $arg{'Active'};
-        push @states, @{ $STATES{ lc $arg{'Queue'} }->{'Inactive'} || [] } if $arg{'Inactive'};
+        my @queues = ref $arg{'Queue'}? @{ $arg{'Queue'} }: ($arg{'Queue'});
+        foreach ( @queues ) {
+            push @states, @{ $STATES{ lc $_ }->{'Active'} || [] } if $arg{'Active'};
+            push @states, @{ $STATES{ lc $_ }->{'Inactive'} || [] } if $arg{'Inactive'};
+        }
     } else {
         foreach ( values %STATES ) {
             push @states, @{ $_->{'Active'} || [] } if $arg{'Active'};


More information about the Rt-commit mailing list