[Rt-commit] rt branch, 4.4/get-referenced-queues-more-search-items, created. rt-4.4.2-133-gd4460613f

? sunnavy sunnavy at bestpractical.com
Tue Apr 10 14:37:52 EDT 2018


The branch, 4.4/get-referenced-queues-more-search-items has been created
        at  d4460613f05bcdc9cfab5f45e05100866767b88b (commit)

- Log -----------------------------------------------------------------
commit d4460613f05bcdc9cfab5f45e05100866767b88b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Apr 10 23:01:52 2018 +0800

    Add support of "Lifecycle =" and "Queue LIKE" to GetReferencedQueues
    
    So queue-level custom fields could show up on pages like query builder
    for queries like "Lifecycle = 'default'" or "Queue LIKE 'General'".

diff --git a/lib/RT/Interface/Web/QueryBuilder/Tree.pm b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
index d63a16d4b..c0a079c2a 100644
--- a/lib/RT/Interface/Web/QueryBuilder/Tree.pm
+++ b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
@@ -99,6 +99,10 @@ will appear as a key whose value is 1.
 
 sub GetReferencedQueues {
     my $self = shift;
+    my %args = (
+        CurrentUser => '',
+        @_
+    );
 
     my $queues = {};
 
@@ -110,10 +114,29 @@ sub GetReferencedQueues {
             return unless $node->isLeaf;
 
             my $clause = $node->getNodeValue();
-            return unless $clause->{Key} eq 'Queue';
-            return unless $clause->{Op} eq '=';
-
-            $queues->{ $clause->{Value} } = 1;
+            if ( $clause->{Key} eq 'Queue' ) {
+                if ( $clause->{Op} eq '=' ) {
+                    $queues->{ $clause->{Value} } ||= 1;
+                }
+                elsif ( $clause->{Op} =~ /^LIKE$/i ) {
+                    my $qs = RT::Queues->new( $args{CurrentUser} || $HTML::Mason::Commands::session{CurrentUser} );
+                    $qs->Limit( FIELD => 'Name', VALUE => $clause->{Value}, OPERATOR => 'LIKE' );
+                    while ( my $q = $qs->Next ) {
+                        next unless $q->id;
+                        $queues->{ $q->id } ||= 1;
+                    }
+                }
+            }
+            elsif ( $clause->{Key} eq 'Lifecycle' ) {
+                if ( $clause->{Op} eq '=' ) {
+                    my $qs = RT::Queues->new( $args{CurrentUser} || $HTML::Mason::Commands::session{CurrentUser} );
+                    $qs->Limit( FIELD => 'Lifecycle', VALUE => $clause->{Value} );
+                    while ( my $q = $qs->Next ) {
+                        next unless $q->id;
+                        $queues->{ $q->id } ||= 1;
+                    }
+                }
+            }
         }
     );
 
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index fdd889044..0c2b0f247 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -160,7 +160,7 @@ our %GROUPINGS_META = (
                 require RT::Interface::Web::QueryBuilder::Tree;
                 my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
                 $tree->ParseSQL( Query => $args->{'Query'}, CurrentUser => $self->CurrentUser );
-                $queues = $args->{'Queues'} = $tree->GetReferencedQueues;
+                $queues = $args->{'Queues'} = $tree->GetReferencedQueues( CurrentUser => $self->CurrentUser );
             }
             return () unless $queues;
 

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


More information about the rt-commit mailing list