[Rt-commit] rtir branch, 2.5-trunk, updated. 4a802b0d8db51df163d26c7eea1b8d3123958c50

Ruslan Zakirov ruz at bestpractical.com
Thu Jul 23 23:47:29 EDT 2009


The branch, 2.5-trunk has been updated
       via  4a802b0d8db51df163d26c7eea1b8d3123958c50 (commit)
      from  fba3ace1720994ade5922a9feaa0e7831dd92d1b (commit)

Summary of changes:
 html/RTIR/Elements/ChildSummary    |   15 +++++++++++++--
 html/RTIR/Elements/IncidentSummary |   15 +++++++++++++--
 html/RTIR/Tools/Lookup.html        |    4 ++--
 3 files changed, 28 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 4a802b0d8db51df163d26c7eea1b8d3123958c50
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri Jul 24 07:46:42 2009 +0400

    allow to use any custom field for lookup, not only IP

diff --git a/html/RTIR/Elements/ChildSummary b/html/RTIR/Elements/ChildSummary
index 58b210b..ac06fa9 100644
--- a/html/RTIR/Elements/ChildSummary
+++ b/html/RTIR/Elements/ChildSummary
@@ -33,6 +33,10 @@
 <th align="right"><b><&|/l&>Actions<b></&></th>
 </tr>
 
+% if ( $lookup_cf_not_applies ) {
+<tr><td colspan="5"><% loc("Custom field '[_1]' doesn't applies to this queue", loc($lookuptype) ) %></td></tr>
+% }
+
 % my $i=0;
 % while (my $Ticket = $session{'tickets'}->Next) {
 % next unless ($Ticket->QueueObj->Name eq $Queue);
@@ -79,9 +83,16 @@
 <%INIT>
 my $Query = $m->comp('/RTIR/Elements/NewQuery', Queue => $Queue);
 my @conditions = ();
+my $lookup_cf_not_applies = 0;
 if ( defined $q && length $q ) {
-    if ( lc( $lookuptype || '' ) eq 'ip' ) {
-        push @conditions, "CF.{IP} = '$q'";
+    if ( $lookuptype && RT::IR->CustomFields( Field => $lookuptype ) ) {
+        my @this = RT::IR->CustomFields( Field => $lookuptype, Queue => $Queue );
+        if ( @this ) {
+            push @conditions, "'CF.{$lookuptype}' = '$q'";
+        } else {
+            $lookup_cf_not_applies = 1;
+            push @conditions, "id = 0";
+        }
     } else {
         push @conditions, "Content LIKE '$q'";
     }
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index 5057ae3..2136345 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -32,6 +32,10 @@
 <td align="right"><b><&|/l&>Actions<b></&></td>
 </tr>
 
+% if ( $lookup_cf_not_applies ) {
+<tr><td colspan="5"><% loc("Custom field '[_1]' doesn't applies to this queue", loc($lookuptype) ) %></td></tr>
+% }
+
 % my $i=0;
 % foreach my $incident (sort keys %{$incidents}) {
 % my $Ticket = $incidents->{$incident}->{'Ticket'};
@@ -89,9 +93,16 @@ while ( my $Ticket = $session{'tickets'}->Next ) {
 
 my $Query = $m->comp('/RTIR/Elements/NewQuery', Queue => 'Incidents');
 my @conditions = ();
+my $lookup_cf_not_applies = 0;
 if ( defined $q && length $q ) {
-    if ( lc( $lookuptype || '' ) eq 'ip' ) {
-        push @conditions, "CF.{IP} = '$q'";
+    if ( $lookuptype && RT::IR->CustomFields( Field => $lookuptype ) ) {
+        my @this = RT::IR->CustomFields( Field => $lookuptype, Queue => 'Incidents' );
+        if ( @this ) {
+            push @conditions, "'CF.{$lookuptype}' = '$q'";
+        } else {
+            $lookup_cf_not_applies = 1;
+            push @conditions, "id = 0";
+        }
     } else {
         push @conditions, "Content LIKE '$q'";
     }
diff --git a/html/RTIR/Tools/Lookup.html b/html/RTIR/Tools/Lookup.html
index 694ba76..2e349c6 100644
--- a/html/RTIR/Tools/Lookup.html
+++ b/html/RTIR/Tools/Lookup.html
@@ -247,8 +247,8 @@ if ( $q ) {
     $current_subtab .= '?'. $m->comp('/Elements/QueryString', q => $q, server => $server );
 
     my $query;
-    if ( $type eq 'ip' ) {
-        $query = "CF.{IP} = '$q'"
+    if ( $type && RT::IR->CustomFields( Field => $type ) ) {
+        $query = "'CF.{$type}' = '$q'"
     } else {
         $query = "( ContentType = 'text/plain' "
             . "OR ContentType = 'text' "

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


More information about the Rt-commit mailing list