[Rt-commit] r4216 - in rt/branches/3.4-RELEASE: . html/Search

jesse at bestpractical.com jesse at bestpractical.com
Fri Dec 2 17:02:27 EST 2005


Author: jesse
Date: Fri Dec  2 17:02:21 2005
New Revision: 4216

Modified:
   rt/branches/3.4-RELEASE/   (props changed)
   rt/branches/3.4-RELEASE/html/Search/Build.html
Log:
 r19688 at truegrounds:  jesse | 2005-12-02 17:01:28 -0500
 RT-Ticket: 6962
 RT-Status: resolved
 RT-Update: correspond
 
 * Patch from Rolf Grossmann to fix some bogosity in the query builder
 


Modified: rt/branches/3.4-RELEASE/html/Search/Build.html
==============================================================================
--- rt/branches/3.4-RELEASE/html/Search/Build.html	(original)
+++ rt/branches/3.4-RELEASE/html/Search/Build.html	Fri Dec  2 17:02:21 2005
@@ -462,88 +462,6 @@
 
 my @current_values = grep { defined } @options[@clauses];
 
-# {{{ Try to find if we're adding a clause
-foreach my $arg ( keys %ARGS ) {
-    if (
-        $arg =~ m/^ValueOf(.+)/
-        && ( ref $ARGS{$arg} eq "ARRAY"
-            ? grep { $_ ne "" } @{ $ARGS{$arg} }
-            : $ARGS{$arg} ne "" )
-      )
-    {
-
-        # We're adding a $1 clause
-        my $field = $1;
-        my ( $keyword, $op, $value );
-
-        #figure out if it's a grouping
-        if ( $ARGS{ $field . "Field" } ) {
-            $keyword = $ARGS{ $field . "Field" };
-        }
-        else {
-            $keyword = $field;
-        }
-
-        my ( @ops, @values );
-        if ( ref $ARGS{ 'ValueOf' . $field } eq "ARRAY" ) {
-
-            # we have many keys/values to iterate over, because there is
-            # more than one CF with the same name.
-            @ops    = @{ $ARGS{ $field . 'Op' } };
-            @values = @{ $ARGS{ 'ValueOf' . $field } };
-        }
-        else {
-            @ops    = ( $ARGS{ $field . 'Op' } );
-            @values = ( $ARGS{ 'ValueOf' . $field } );
-        }
-        $RT::Logger->error("Bad Parameters passed into Query Builder")
-          unless @ops == @values;
-
-        for my $i ( 0 .. @ops - 1 ) {
-            my ( $op, $value ) = ( $ops[$i], $values[$i] );
-            next if $value eq "";
-
-            if ( $value eq 'NULL' && $op =~ /=/ ) {
-                if ( $op eq '=' ) {
-                    $op = "IS";
-                }
-                elsif ( $op eq '!=' ) {
-                    $op = "IS NOT";
-                }
-
-                # This isn't "right", but...
-                # It has to be this way until #5182 is fixed
-                $value = "'NULL'";
-            }
-            else {
-                $value = "'$value'";
-            }
-
-            my $clause = {
-                Key   => $keyword,
-                Op    => $op,
-                Value => $value
-            };
-
-            my $newnode = RT::Interface::Web::QueryBuilder::Tree->new($clause);
-            if (@current_values) {
-                foreach my $value (@current_values) {
-                    my $newindex = $value->getIndex() + 1;
-                    $value->insertSibling( $newindex, $newnode );
-                    $value = $newnode;
-                }
-            }
-            else {
-                $tree->getChild(0)->addChild($newnode);
-                @current_values = $newnode;
-            }
-            $newnode->getParent()->setNodeValue( $ARGS{'AndOr'} );
-        }
-    }
-}
-
-# }}}
-
 # {{{ Move things around
 if ( $ARGS{"Up"} ) {
     if (@current_values) {
@@ -637,6 +555,7 @@
 elsif ( $ARGS{"DeleteClause"} ) {
     if (@current_values) {
         $_->getParent()->removeChild($_) for @current_values;
+		@current_values = ();
     }
     else {
         push( @actions, [ loc("error: nothing to delete"), -1 ] );
@@ -661,6 +580,88 @@
     }
 }
 
+# {{{ Try to find if we're adding a clause
+foreach my $arg ( keys %ARGS ) {
+    if (
+        $arg =~ m/^ValueOf(.+)/
+        && ( ref $ARGS{$arg} eq "ARRAY"
+            ? grep { $_ ne "" } @{ $ARGS{$arg} }
+            : $ARGS{$arg} ne "" )
+      )
+    {
+
+        # We're adding a $1 clause
+        my $field = $1;
+        my ( $keyword, $op, $value );
+
+        #figure out if it's a grouping
+        if ( $ARGS{ $field . "Field" } ) {
+            $keyword = $ARGS{ $field . "Field" };
+        }
+        else {
+            $keyword = $field;
+        }
+
+        my ( @ops, @values );
+        if ( ref $ARGS{ 'ValueOf' . $field } eq "ARRAY" ) {
+
+            # we have many keys/values to iterate over, because there is
+            # more than one CF with the same name.
+            @ops    = @{ $ARGS{ $field . 'Op' } };
+            @values = @{ $ARGS{ 'ValueOf' . $field } };
+        }
+        else {
+            @ops    = ( $ARGS{ $field . 'Op' } );
+            @values = ( $ARGS{ 'ValueOf' . $field } );
+        }
+        $RT::Logger->error("Bad Parameters passed into Query Builder")
+          unless @ops == @values;
+
+        for my $i ( 0 .. @ops - 1 ) {
+            my ( $op, $value ) = ( $ops[$i], $values[$i] );
+            next if $value eq "";
+
+            if ( $value eq 'NULL' && $op =~ /=/ ) {
+                if ( $op eq '=' ) {
+                    $op = "IS";
+                }
+                elsif ( $op eq '!=' ) {
+                    $op = "IS NOT";
+                }
+
+                # This isn't "right", but...
+                # It has to be this way until #5182 is fixed
+                $value = "'NULL'";
+            }
+            else {
+                $value = "'$value'";
+            }
+
+            my $clause = {
+                Key   => $keyword,
+                Op    => $op,
+                Value => $value
+            };
+
+            my $newnode = RT::Interface::Web::QueryBuilder::Tree->new($clause);
+            if (@current_values) {
+                foreach my $value (@current_values) {
+                    my $newindex = $value->getIndex() + 1;
+                    $value->insertSibling( $newindex, $newnode );
+                    $value = $newnode;
+                }
+            }
+            else {
+                $tree->getChild(0)->addChild($newnode);
+                @current_values = $newnode;
+            }
+            $newnode->getParent()->setNodeValue( $ARGS{'AndOr'} );
+        }
+    }
+}
+
+# }}}
+
 $tree->PruneChildlessAggregators;
 
 # }}}


More information about the Rt-commit mailing list