[Rt-commit] r3999 - in rtir/branches/1.9-EXPERIMENTAL: .
html/RTIR/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Mon Oct 31 10:49:43 EST 2005
Author: ruz
Date: Mon Oct 31 10:49:43 2005
New Revision: 3999
Modified:
rtir/branches/1.9-EXPERIMENTAL/ (props changed)
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/NewQuery
Log:
r216 at cubic-pc: cubic | 2005-10-31 18:49:24 +0300
r203 at cubic-pc: cubic | 2005-10-29 11:30:31 +0400
* @add_states argument, that allow programmer to add states
to the list of the default states
* if finally list of the states is empty return empty string
user of this component should check empty results, otherwise
he could build wrong query, for example "AND () AND..." or
something similar
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/NewQuery
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/NewQuery (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/NewQuery Mon Oct 31 10:49:43 2005
@@ -1,25 +1,22 @@
<%INIT>
-my ($Type, @basestates) = $m->comp("/RTIR/Elements/Type", Queue => $Queue);
-
- at states = @basestates if !$states[0];
-
-my $Query;
-if ($states[0]) {
- foreach my $state (@states) {
- $Query .= " OR " if $Query;
- $Query .= "'CF.{_RTIR_State}' = '$state'";
- }
+ at states = grep $_, @states;
+unless( @states ) {
+ (undef, @states) = $m->comp("/RTIR/Elements/Type", %ARGS);
}
+push @states, @add_states;
-$Query = "( $Query )" if $Query && (scalar @states) > 1;
+my %seen = ();
+ at states = grep !$seen{$_}++, map lc, @states;
-return $Query;
-
-$RT::Logger->crit($Query);
+my $query = join " OR ",
+ map "'CF.{_RTIR_State}' = '$_'",
+ @states;
+$query = "( $query )" if $query;
+return $query;
</%INIT>
-
<%ARGS>
$Queue => undef
- at states => undef
+ at states => ()
+ at add_states => ()
</%ARGS>
More information about the Rt-commit
mailing list