[Rt-commit] [svn] r1346 - in rtir/branches/1.1/html/RTIR: .
Elements Incident Report/Elements Search Search/Elements Tools
leira at pallas.eruditorum.org
leira at pallas.eruditorum.org
Wed Aug 18 00:47:22 EDT 2004
Author: leira
Date: Wed Aug 18 00:47:21 2004
New Revision: 1346
Added:
rtir/branches/1.1/html/RTIR/Elements/BaseQuery
rtir/branches/1.1/html/RTIR/Elements/NewQuery
rtir/branches/1.1/html/RTIR/Search/
rtir/branches/1.1/html/RTIR/Search/Build.html
rtir/branches/1.1/html/RTIR/Search/Elements/
rtir/branches/1.1/html/RTIR/Search/Elements/BuildQuery
rtir/branches/1.1/html/RTIR/Search/Elements/ClearQuery
rtir/branches/1.1/html/RTIR/Search/Elements/PickBasics
rtir/branches/1.1/html/RTIR/Search/Elements/PickCriteria
rtir/branches/1.1/html/RTIR/Search/Elements/ProcessQuery
rtir/branches/1.1/html/RTIR/Search/Elements/ShowResults
rtir/branches/1.1/html/RTIR/Search/Results.html
Modified:
rtir/branches/1.1/html/RTIR/Display.html
rtir/branches/1.1/html/RTIR/Edit.html
rtir/branches/1.1/html/RTIR/Elements/ChildSummary
rtir/branches/1.1/html/RTIR/Elements/IncidentSummary
rtir/branches/1.1/html/RTIR/Elements/SearchFields
rtir/branches/1.1/html/RTIR/Elements/Tabs
rtir/branches/1.1/html/RTIR/Elements/Type
rtir/branches/1.1/html/RTIR/Incident/Create.html
rtir/branches/1.1/html/RTIR/Incident/Display.html
rtir/branches/1.1/html/RTIR/Listing.html
rtir/branches/1.1/html/RTIR/Merge.html
rtir/branches/1.1/html/RTIR/Report/Elements/Tabs
rtir/branches/1.1/html/RTIR/Split.html
rtir/branches/1.1/html/RTIR/Tools/Lookup.html
rtir/branches/1.1/html/RTIR/Update.html
Log:
Latest RTIR files (still need some more things).
Modified: rtir/branches/1.1/html/RTIR/Display.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Display.html (original)
+++ rtir/branches/1.1/html/RTIR/Display.html Wed Aug 18 00:47:21 2004
@@ -265,8 +265,7 @@
Abort('No incident specified');
}
-$Type = $m->scomp('Elements/Type', Ticket => $Ticket->Id);
-$Type =~ s/\s+$//;
+($Type, undef) = $m->comp('Elements/Type', Ticket => $Ticket->Id);
if ($Type eq 'Report') {
$name = "Incident Report";
Modified: rtir/branches/1.1/html/RTIR/Edit.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Edit.html (original)
+++ rtir/branches/1.1/html/RTIR/Edit.html Wed Aug 18 00:47:21 2004
@@ -187,8 +187,7 @@
<%INIT>
my $Ticket = LoadTicket($id);
-my $Type = $m->scomp('Elements/Type', Ticket => $Ticket->Id);
-$Type =~ s/\s+$//;
+($Type, undef) = $m->comp('Elements/Type', Ticket => $Ticket->Id);
my $name;
if ($Type eq 'Report') {
Added: rtir/branches/1.1/html/RTIR/Elements/BaseQuery
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Elements/BaseQuery Wed Aug 18 00:47:21 2004
@@ -0,0 +1,12 @@
+<%INIT>
+
+my ($Type, @states) = $m->comp("/RTIR/Elements/Type", Queue => $Queue);
+
+my $BaseQuery = "Queue = '$Queue'";
+
+return $BaseQuery;
+</%INIT>
+
+<%ARGS>
+$Queue => undef
+</%ARGS>
Modified: rtir/branches/1.1/html/RTIR/Elements/ChildSummary
==============================================================================
--- rtir/branches/1.1/html/RTIR/Elements/ChildSummary (original)
+++ rtir/branches/1.1/html/RTIR/Elements/ChildSummary Wed Aug 18 00:47:21 2004
@@ -34,8 +34,7 @@
%while (my $Ticket = $session{'tickets'}->Next) {
% next unless ($Ticket->QueueObj->Name eq $Queue);
% $i++;
-% my $t = $m->scomp("/RTIR/Elements/Type", Ticket => $Ticket->Id);
-% $t =~ s/\s*$//;
+% my ($t, undef) = $m->comp("/RTIR/Elements/Type", Ticket => $Ticket->Id);
<TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td><b><A HREF="<%$RT::WebPath%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id%></a></b></td>
<td><b><A HREF="<%$RT::WebPath%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Subject%></a></b></td>
Modified: rtir/branches/1.1/html/RTIR/Elements/IncidentSummary
==============================================================================
--- rtir/branches/1.1/html/RTIR/Elements/IncidentSummary (original)
+++ rtir/branches/1.1/html/RTIR/Elements/IncidentSummary Wed Aug 18 00:47:21 2004
@@ -34,8 +34,7 @@
% foreach my $incident (sort keys %{$incidents}) {
% my $Ticket = $incidents->{$incident}->{'Ticket'};
% $i++;
-% my $t = $m->scomp("/RTIR/Elements/Type", Ticket => $Ticket->Id);
-% $t =~ s/\s*$//;
+% my ($t, undef) = $m->comp("/RTIR/Elements/Type", Ticket => $Ticket->Id);
<TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td><b><A HREF="<%$RT::WebPath%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id%></a></b></td>
<td><b><A HREF="<%$RT::WebPath%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Subject%></a></b></td>
Added: rtir/branches/1.1/html/RTIR/Elements/NewQuery
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Elements/NewQuery Wed Aug 18 00:47:21 2004
@@ -0,0 +1,18 @@
+<%INIT>
+my ($Type, @states) = $m->comp("/RTIR/Elements/Type", Queue => $Queue);
+
+my $Query;
+if ($states[0]) {
+ foreach my $state (@states) {
+ $Query .= " OR " if $Query;
+ $Query .= "'CF.$Queue.{_RTIR_State}' = '$state'";
+ }
+}
+
+return $Query;
+
+</%INIT>
+
+<%ARGS>
+$Queue => undef
+</%ARGS>
Modified: rtir/branches/1.1/html/RTIR/Elements/SearchFields
==============================================================================
--- rtir/branches/1.1/html/RTIR/Elements/SearchFields (original)
+++ rtir/branches/1.1/html/RTIR/Elements/SearchFields Wed Aug 18 00:47:21 2004
@@ -40,7 +40,7 @@
% } else {
% if ($field =~ m/(.*)MemberOf by (.*)/) {
% my $tid = $2;
-% my $type = $m->scomp('/RTIR/Elements/Type', Ticket => $tid);
+% my ($type, undef) = $m->comp('/RTIR/Elements/Type', Ticket => $tid);
% if (($type =~ s/^\s*(.*?)\s*$/$1/) && $type eq 'Incident') {
Child of Incident <%$tid%>
% } else {
Modified: rtir/branches/1.1/html/RTIR/Elements/Tabs
==============================================================================
--- rtir/branches/1.1/html/RTIR/Elements/Tabs (original)
+++ rtir/branches/1.1/html/RTIR/Elements/Tabs Wed Aug 18 00:47:21 2004
@@ -41,16 +41,15 @@
path => 'RTIR/index.html',
},
C => { title => loc('Incidents'),
- path => 'RTIR/Listing.html?NewSearch=1&Queue=Incidents',
+ path => 'RTIR/Search/Results.html?Queue=Incidents',
},
D => { title => loc('Incident Reports'),
- path => 'RTIR/Listing.html?NewSearch=1&Queue=Incident Reports',
- },
+ path => 'RTIR/Search/Results.html?Queue=Incident Reports' . $QueryString },
E => { title => loc('Investigations'),
- path => 'RTIR/Listing.html?NewSearch=1&Queue=Investigations',
+ path => 'RTIR/Search/Results.html?Queue=Investigations',
},
F => { title => loc('Blocks'),
- path => 'RTIR/Listing.html?NewSearch=1&Queue=Blocks',
+ path => 'RTIR/Search/Results.html?Queue=Blocks',
},
G => { title => loc('Tools'),
path => 'RTIR/Tools/Lookup.html',
@@ -69,4 +68,11 @@
$tabs => undef
$actions => undef
$Title => undef
+$QueryString => undef
+$Query => undef
+$Format => undef
+$Rows => undef
+$OrderBy => undef
+$Order => undef
+$Page => undef
</%ARGS>
Modified: rtir/branches/1.1/html/RTIR/Elements/Type
==============================================================================
--- rtir/branches/1.1/html/RTIR/Elements/Type (original)
+++ rtir/branches/1.1/html/RTIR/Elements/Type Wed Aug 18 00:47:21 2004
@@ -34,16 +34,16 @@
}
my ($Type, @states);
-if ($Queue eq "Incidents") {
+if ($name eq "Incidents") {
$Type = 'Incident';
@states = ('new', 'open');
-} elsif ($Queue eq "Incident Reports") {
+} elsif ($name eq "Incident Reports") {
$Type = 'Report';
@states = ('new', 'open');
-} elsif ($Queue eq "Investigations") {
+} elsif ($name eq "Investigations") {
$Type = 'Investigation';
@states = ('open');
-} if ($Queue eq "Blocks") {
+} if ($name eq "Blocks") {
$Type = 'Block';
@states = ('pending activation', 'active', 'pending removal');
}
Modified: rtir/branches/1.1/html/RTIR/Incident/Create.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Incident/Create.html (original)
+++ rtir/branches/1.1/html/RTIR/Incident/Create.html Wed Aug 18 00:47:21 2004
@@ -51,7 +51,7 @@
<& /Elements/TitleBoxStart, contentbg => "#cccccc", title => $Title &>
<TABLE border=0 cellpadding=0 cellspacing=2>
% if ($link) {
-% my $Type = $m->scomp("/RTIR/Elements/Type", Ticket => $link->Id);
+% my ($Type, undef) = $m->comp("/RTIR/Elements/Type", Ticket => $link->Id);
% $Type =~ s/\s*$//;
<TR>
<TD class="label"><%$label%>:</TD>
Modified: rtir/branches/1.1/html/RTIR/Incident/Display.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Incident/Display.html (original)
+++ rtir/branches/1.1/html/RTIR/Incident/Display.html Wed Aug 18 00:47:21 2004
@@ -223,7 +223,7 @@
my $Target = shift;
my @linkresults;
- my $Type = $m->scomp("/RTIR/Elements/Type", Ticket => $Ticket->Id);
+ my ($Type, undef) = $m->comp("/RTIR/Elements/Type", Ticket => $Ticket->Id);
$ARGS{$Ticket->Id.'-MemberOf'} = $Target->Id;
# Blocks can have multiple incidents
Modified: rtir/branches/1.1/html/RTIR/Listing.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Listing.html (original)
+++ rtir/branches/1.1/html/RTIR/Listing.html Wed Aug 18 00:47:21 2004
@@ -79,6 +79,20 @@
}
}
+my $Query= "Queue = '$Queue'";
+
+my $statequery;
+if (!$setstate) {
+ foreach my $state (@states) {
+ $statequery .= " OR " if $statequery;
+ $statequery .= " CF.{$Queue}.State = '$state'";
+ }
+}
+
+$Query .= " AND ( $statequery )" if $statequery;
+
+$m->print("Query: $Query");
+
ProcessSearchQuery(ARGS=>\%ARGS);
$session{'tickets'}->RedoSearch();
if ( $session{'tickets'}->DescribeRestrictions()) {
Modified: rtir/branches/1.1/html/RTIR/Merge.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Merge.html (original)
+++ rtir/branches/1.1/html/RTIR/Merge.html Wed Aug 18 00:47:21 2004
@@ -54,8 +54,7 @@
<%INIT>
my $Ticket = LoadTicket($id);
-my $Type = $m->scomp('Elements/Type', Ticket => $Ticket->Id);
-$Type =~ s/\s+$//;
+my ($Type, undef) = $m->comp('Elements/Type', Ticket => $Ticket->Id);
my @states;
my $name = $Type;
Modified: rtir/branches/1.1/html/RTIR/Report/Elements/Tabs
==============================================================================
--- rtir/branches/1.1/html/RTIR/Report/Elements/Tabs (original)
+++ rtir/branches/1.1/html/RTIR/Report/Elements/Tabs Wed Aug 18 00:47:21 2004
@@ -29,11 +29,18 @@
current_toptab => $current_toptab,
current_tab => $mytab,
current_subtab => $current_subtab,
- Title => $Title &>
+ Title => $Title,
+ QueryString => $QueryString,
+&>
+
+current_toptab: <%$current_toptab%><br>
+current_subtab: <%$current_subtab%><br>
+my tab: <%$mytab%><br>
<%INIT>
+
my $tabs = {};
-my $current_toptab = 'RTIR/Listing.html?NewSearch=1&Queue=Incident Reports',
+my $current_toptab = 'RTIR/Search/Results.html?Queue=Incident Reports' . $QueryString,
my ($actions, $mytab);
my $searchtabs = { } ;
@@ -159,8 +166,15 @@
$tabs->{"A"} = { path => 'RTIR/Create.html?Queue=Incident Reports',
title => loc('New Incident Report') };
-$tabs->{"g"} = { path => 'RTIR/Listing.html?NewSearch=1&Queue=Incident Reports',
- title => loc('Search'),
+$tabs->{"e"} = { path => 'RTIR/Search/Build.html?Queue=Incident Reports&NewQuery=1',
+ title => loc('New Query'),
+ subtabs => $searchtabs };
+$tabs->{"f"} = { path => 'RTIR/Search/Build.html?Queue=Incident Reports' . $QueryString . '&NewQuery=1',
+ title => loc('Query Builder'),
+ separator => 1,
+ subtabs => $searchtabs };
+$tabs->{"g"} = { path => 'RTIR/Search/Results.html?Queue=Incident Reports' . $QueryString,
+ title => loc('Results'),
separator => 1,
subtabs => $searchtabs };
$tabs->{"h"} = { path => 'RTIR/Report/BulkReject.html?ClearRestrictions=1',
@@ -175,4 +189,5 @@
$current_tab => undef
$current_subtab => undef
$Title => undef
+$QueryString =>undef
</%ARGS>
Added: rtir/branches/1.1/html/RTIR/Search/Build.html
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Build.html Wed Aug 18 00:47:21 2004
@@ -0,0 +1,138 @@
+%# {{{ BEGIN BPS TAGGED BLOCK
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# }}} END BPS TAGGED BLOCK
+<& /Elements/Header, Title => $title &>
+<& '/RTIR/'.$Type.'/Elements/Tabs',
+ current_tab => "RTIR/Search/Build.html?Queue=$Queue$QueryString",
+ current_subtab => "RTIR/Search/Build.html?Queue=$Queue$QueryString",
+ QueryString => $QueryString,
+&>
+
+<& Elements/BuildQuery,
+ queues => \%queues,
+ actions => $results,
+ optionlist => $optionlist,
+ search_hash => $search_hash,
+ dirty => $dirty,
+ AvailableColumns => $AvailableColumns,
+ CurrentFormat => $CurrentFormat,
+ BaseQuery => $BaseQuery,
+ %ARGS &>
+
+<%INIT>
+$m->print("Build query: |$Query|<br>");
+my $title = loc("Query Builder");
+
+my %queues = ();
+my $results;
+my $optionlist;
+my $search_hash;
+my $dirty;
+my $AvailableColumns;
+my $CurrentFormat;
+my ( $Format, $Order, $OrderBy, $RowsPerPage );
+
+my $BaseQuery = $m->comp('/RTIR/Elements/BaseQuery', Queue => $Queue);
+
+my $QueryString;
+if ($NewQuery) {
+ # If it's a new query, wipe it ourselves...
+
+ # Wipe all data-carrying variables clear if we want a new
+ # search, or we're deleting an old one..
+
+ $Query = '';
+ $Format = '';
+ $Order = '';
+ $OrderBy = '';
+ $RowsPerPage = '';
+ # ($search hasn't been set yet; no need to clear)
+
+ $m->comp('Elements/ClearQuery', %ARGS);
+
+ # and replace it with our standard new query...
+
+ $ARGS{'Query'} = $m->comp('/RTIR/Elements/NewQuery', Queue => $Queue);
+ $Query = $ARGS{'Query'};
+
+ # and claim it isn't a new query any more
+
+ $ARGS{'NewQuery'} = 0;
+}
+
+( $Query, $Format, $Order, $OrderBy, $RowsPerPage ) =
+ $m->comp('Elements/ProcessQuery',
+ queues => \%queues,
+ results => \$results,
+ optionlist => \$optionlist,
+ search_hash => \$search_hash,
+ dirty => \$dirty,
+ AvailableColumns => \$AvailableColumns,
+ CurrentFormat => \$CurrentFormat,
+ BaseQuery => $BaseQuery,
+ Query => "foo bar",
+ %ARGS);
+
+my ($Type, @states) = $m->comp("/RTIR/Elements/Type", Queue => $Queue);
+
+# {{{ Build a querystring for the tabs
+
+ $QueryString = '&' . $m->comp('/Elements/QueryString',
+ Query => $Query,
+ Format => $Format,
+ Order => $Order,
+ OrderBy => $OrderBy,
+ Rows => $RowsPerPage) if ($Query);
+# }}}
+
+$ARGS{'Query'} = $Query;
+
+</%INIT>
+
+<%ARGS>
+$NewQuery => 0
+$Queue => undef
+$Query=> undef
+</%ARGS>
Added: rtir/branches/1.1/html/RTIR/Search/Elements/BuildQuery
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Elements/BuildQuery Wed Aug 18 00:47:21 2004
@@ -0,0 +1,115 @@
+%# {{{ BEGIN BPS TAGGED BLOCK
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# }}} END BPS TAGGED BLOCK
+
+<FORM METHOD="POST" ACTION="Build.html" NAME="BuildQuery">
+<input type=hidden name=SearchId value="<%$SearchId%>">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
+<input type=hidden name=BaseQuery value="<%$BaseQuery%>">
+<table width=100%>
+<tr>
+<td valign=top class="boxcontainer">
+<& /Search/Elements/PickCriteria, query => $Query, cfqueues => \%queues &>
+<& /Elements/Submit, Caption => loc('Add additional criteria'), Label => loc('Add'), Name => 'AddClause'&>
+
+</td>
+<td valign=top class="boxcontainer">
+<& /Elements/TitleBoxStart, title => loc("Query") . ": " .$Description &>
+<& /Search/Elements/NewListActions, actions => \@actions &>
+<select size="10" name="clauses" style="width: 100%">
+<%$optionlist|n%>
+</select>
+</td></tr><tr><td bgcolor="#dddddd" colspan="2">
+<center>
+<input type=submit name="Up" value="^">
+<input type=submit name="Down" value="v">
+<input type=submit name="Left" value="<">
+<input type=submit name="Right" value=">">
+<input type=submit name="DeleteClause" value="Delete">
+<br />
+<input type=submit name="Clear" value="Clear">
+<input type=submit name="Toggle" value="And/Or">
+%#<input type=submit name="EditQuery" value="Advanced">
+</center>
+<& /Elements/TitleBoxEnd &>
+<br>
+<& /Search/Elements/EditSearches, CurrentSearch => $search_hash, Dirty => $dirty, SearchId => $SearchId &>
+</td>
+</tr>
+<tr>
+<td colspan=2 class="boxcontainer">
+
+<& /Search/Elements/DisplayOptions, %ARGS,
+ Format=> $Format,
+ AvailableColumns => $AvailableColumns,
+ CurrentFormat => $CurrentFormat,
+ RowsPerPage => $RowsPerPage,
+ OrderBy => $OrderBy,
+ Order => $Order &>
+</td>
+</tr>
+</table>
+</FORM>
+
+<%ARGS>
+$NewQuery => 0
+$SearchId => undef
+$BaseQuery => undef
+$Query => undef
+$Format => undef
+$Description => undef
+$Order => undef
+$OrderBy => undef
+$RowsPerPage => undef
+$HideResults => 0
+%queues => ()
+ at actions => ()
+$optionlist => undef
+$search_hash => undef
+$dirty => undef
+$AvailableColumns => undef
+$CurrentFormat => undef
+</%ARGS>
Added: rtir/branches/1.1/html/RTIR/Search/Elements/ClearQuery
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Elements/ClearQuery Wed Aug 18 00:47:21 2004
@@ -0,0 +1,9 @@
+<%INIT>
+# ..then wipe the session out..
+undef $session{'CurrentSearchHash'};
+
+# ..and the search results.
+$session{'tickets'}->CleanSlate() if defined $session{'tickets'};
+
+</%INIT>
+
Added: rtir/branches/1.1/html/RTIR/Search/Elements/PickBasics
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Elements/PickBasics Wed Aug 18 00:47:21 2004
@@ -0,0 +1,161 @@
+%# {{{ BEGIN BPS TAGGED BLOCK
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# }}} END BPS TAGGED BLOCK
+<tr><td>
+% foreach my $field (@fields) {
+<tr><td align=right>
+% if ($field eq "Attachment") {
+<& /Elements/SelectAttachmentField, Name => 'AttachmentField' &>
+</td><td>
+<& /Elements/SelectBoolean, Name => "AttachmentOp",
+ True => loc("matches"),
+ False => loc("does not match"),
+ TrueVal => 'LIKE',
+ FalseVal => 'NOT LIKE'
+&>
+</td><td>
+<Input Name="ValueOfAttachment" Size=20>
+% } elsif ($field eq "Dates") {
+<& /Elements/SelectDateType, Name=>"DateField" &>
+</td><td>
+<& /Elements/SelectDateRelation, Name=>"DateOp" &>
+</td><td>
+<& /Elements/SelectDate, Name => "ValueOfDate", ShowTime => 0, Default => '' &>
+% } elsif ($field eq "Links") {
+<& SelectLinks, Name=>"LinksField" &>
+</td><td>
+<& /Elements/SelectBoolean, Name => "LinksOp",
+ True => loc("is"),
+ False => loc("isn't"),
+ TrueVal=> '=',
+ FalseVal => '!='
+&>
+</td><td>
+<INPUT Name="ValueOfLinks" value="" SIZE=5>
+%} elsif ($field eq "Priority") {
+<SELECT NAME="PriorityField">
+<OPTION VALUE="Priority"><&|/l&>Priority</&></OPTION>
+<OPTION VALUE="InitialPriority"><&|/l&>Initial Priority</&></OPTION>
+<OPTION VALUE="FinalPriority"><&|/l&>Final Priority</&></OPTION>
+</SELECT>
+</td><td>
+<& /Elements/SelectEqualityOperator, Name => "PriorityOp" &>
+</td><td>
+<INPUT Name="ValueOfPriority" SIZE=5>
+%} elsif ($field =~ m/Time.*/) {
+<SELECT NAME="TimeField">
+<OPTION VALUE="TimeWorked"><&|/l&>Time Worked</&></OPTION>
+<OPTION VALUE="TimeEstimated"><&|/l&>Time Estimated</&></OPTION>
+<OPTION VALUE="TimeLeft"><&|/l&>Time Left</&></OPTION>
+</SELECT>
+</td><td>
+<& /Elements/SelectEqualityOperator, Name => "TimeOp" &>
+</td><td>
+<INPUT Name="ValueOfTime" SIZE=5>
+%} elsif ($field =~ m/.*Priority/ || $field =~ m/Time.*/) {
+<&|/l&><%$field%></&>
+</td><td>
+<& /Elements/SelectEqualityOperator, Name => $field . "Op" &>
+</td><td>
+<INPUT Name="<%"ValueOf" . $field%>" SIZE=5>
+% } elsif ($field eq "id") {
+<&|/l&>Id</&>
+</td><td>
+<& /Elements/SelectEqualityOperator, Name => "idOp" &>
+</td><td>
+<INPUT Name="ValueOfid" SIZE=5>
+% } elsif ($field eq "People") {
+% foreach my $field (@people) {
+<tr><td class="label">
+% if ($field eq "Actor") {
+<SELECT NAME="ActorField">
+<OPTION VALUE="Owner"><&|/l&>Owner</&></OPTION>
+<OPTION VALUE="Creator"><&|/l&>Creator</&></OPTION>
+<OPTION VALUE="LastUpdatedBy"><&|/l&>LastUpdatedBy</&></OPTION>
+</SELECT>
+</td><td>
+<& /Elements/SelectBoolean, Name => "ActorOp",
+ TrueVal=> '=',
+ FalseVal => '!='
+&>
+</td><td>
+<& /Elements/SelectOwner, Name => "ValueOfActor" &>
+% } elsif ($field eq 'Watcher') {
+<& SelectPersonType, Name => 'WatcherField', Default => 'Requestor' &>
+</td><td>
+<& /Elements/SelectMatch, Name => "WatcherOp" &>
+</td><td>
+<Input Name="ValueOfWatcher" Size=20>
+% } else {
+<&|/l&><%$field%></&>
+<& /Elements/SelectMatch, Name => "$field" . "Op" &>
+<INPUT Name="<%"ValueOf" . $field%>" value=""SIZE=20>
+% }
+</td></tr>
+% }
+% } else {
+<&|/l&><%$field%></&>
+</td><td>
+<& /Elements/SelectMatch, Name => "$field" . "Op" &>
+</td><td>
+<INPUT Name="<%"ValueOf" . $field%>" value="" SIZE=20>
+% }
+</td></tr>
+% }
+
+<%INIT>
+my @fields = ('Attachment',
+ 'People',
+ 'Dates',
+ 'Time',
+ 'Priority',
+ 'Links',
+ 'id',
+ );
+
+my @people = ('Actor',
+ 'Watcher',
+ );
+</%INIT>
Added: rtir/branches/1.1/html/RTIR/Search/Elements/PickCriteria
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Elements/PickCriteria Wed Aug 18 00:47:21 2004
@@ -0,0 +1,74 @@
+%# {{{ BEGIN BPS TAGGED BLOCK
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# }}} END BPS TAGGED BLOCK
+<& /Elements/TitleBoxStart, title => loc('Add Criteria')&>
+<table width=100% cellspacing=0 cellpadding=0 border=0>
+ <tr>
+ <td>
+ <table cellspacing=0 border=0>
+ <tr><td class=label>
+ Aggregator:
+ </td>
+ <td><& /Search/Elements/SelectAndOr, Name => "AndOr" &>
+ </td></tr>
+ </table>
+ </td></tr>
+ <tr>
+ <td colspan=3>
+ <hr>
+ </td>
+ </tr>
+ <& PickBasics &>
+ <& PickCFs, cfqueues => \%cfqueues &>
+ <tr><td> </td></tr>
+</table>
+
+<& /Elements/TitleBoxEnd &>
+
+<%ARGS>
+$addquery => 0
+$query => undef
+%cfqueues => undef
+</%ARGS>
Added: rtir/branches/1.1/html/RTIR/Search/Elements/ProcessQuery
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Elements/ProcessQuery Wed Aug 18 00:47:21 2004
@@ -0,0 +1,691 @@
+<%INIT>
+use Tree::Simple;
+
+my $search;
+my $title = loc("Query Builder");
+
+# {{{ Clear out unwanted data
+if ($NewQuery or $ARGS{'Delete'}) {
+ # Wipe all data-carrying variables clear if we want a new
+ # search, or we're deleting an old one..
+
+ $Query = '';
+ $Format = '';
+ $Description = '';
+ $SearchId = '';
+ $Order = '';
+ $OrderBy = '';
+ $RowsPerPage = '';
+ # ($search hasn't been set yet; no need to clear)
+
+ $m->comp('ClearQuery', %ARGS);
+}
+# }}}
+
+
+# {{{ Attempt to load what we can from the session, set defaults
+
+# We don't read or write to the session again until the end
+$search_hash = $session{'CurrentSearchHash'};
+
+# These variables are what define a search_hash; this is also
+# where we give sane defaults.
+$Query ||= $search_hash->{'Query'};
+$Format ||= $search_hash->{'Format'};
+$Description ||= $search_hash->{'Description'};
+$SearchId ||= $search_hash->{'SearchId'} || 'new';
+$Order ||= $search_hash->{'Order'} || 'ASC';
+$OrderBy ||= $search_hash->{'OrderBy'} || 'id';
+$RowsPerPage = ($search_hash->{'RowsPerPage'} || 50) unless defined ($RowsPerPage);
+$search ||= $search_hash->{'Object'};
+# }}}
+
+# Clean unwanted junk from the format
+$Format = $m->comp('/Elements/ScrubHTML', Content => $Format) if ($Format);
+
+# {{{ If we're asked to delete the current search, make it go away and reset the search parameters
+if ( $ARGS{'Delete'} ) {
+ # We set $SearchId to 'new' above already, so peek into the %ARGS
+ if ( $ARGS{'SearchId'} =~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) {
+ my $obj_type = $1;
+ my $obj_id = $2;
+ my $search_id = $3;
+
+ my $container_object;
+ if ( $obj_type eq 'RT::User' && $obj_id == $session{'CurrentUser'}->Id) {
+ $container_object = $session{'CurrentUser'}->UserObj;
+ }
+ elsif ($obj_type eq 'RT::Group') {
+ $container_object = RT::Group->new($session{'CurrentUser'});
+ $container_object->Load($obj_id);
+ }
+
+ if ($container_object->id ) {
+ # We have the object the entry is an attribute on; delete
+ # the entry..
+ $container_object->Attributes->DeleteEntry( Name => 'SavedSearch', id => $search_id);
+ }
+
+ }
+}
+# }}}
+
+# {{{ If the user wants to copy a search, uncouple from the one that this was based on, but don't erase the $Query or $Format
+if ( $ARGS{'CopySearch'} ) {
+ $SearchId = 'new';
+ $search = undef;
+ $Description = loc("[_1] copy", $Description);
+}
+# }}}
+
+# {{{ if we're asked to revert the current search, we just want to load it
+if ( $ARGS{'Revert'} ) {
+ $ARGS{'LoadSavedSearch'} = $SearchId;
+}
+# }}}
+
+# {{{ if we're asked to load a search, load it.
+
+if ( $ARGS{'LoadSavedSearch'} =~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) {
+ my $obj_type = $1;
+ my $obj_id = $2;
+ my $search_id = $3;
+
+ # We explicitly list out the available types (user and group) and
+ # don't trust user input here
+ if ( ( $obj_type eq 'RT::User' ) && ( $obj_id == $session{'CurrentUser'}->id ) ) {
+ $search = $session{'CurrentUser'}->UserObj->Attributes->WithId($search_id);
+
+ }
+ elsif ($obj_type eq 'RT::Group') {
+ my $group = RT::Group->new($session{'CurrentUser'});
+ $group->Load($obj_id);
+ $search = $group->Attributes->WithId($search_id);
+ }
+
+ # We have a $search and now; import the others
+ $SearchId = $ARGS{'LoadSavedSearch'};
+ $Description = $search->Description;
+ $Format = $search->SubValue('Format');
+ $Query = $search->SubValue('Query');
+ $Order = $search->SubValue('Order');
+ $OrderBy = $search->SubValue('OrderBy');
+ $RowsPerPage = $search->SubValue('RowsPerPage');
+}
+
+# }}}
+
+# {{{ Parse the query
+my $tree;
+my @actions;
+ParseQuery( $Query, \$tree, \@actions );
+
+# if parsing went poorly, send them to the edit page to fix it
+if ( $actions[0] ) {
+ $m->comp( "Edit.html", Query => $Query, actions => \@actions );
+ $m->abort();
+}
+
+my @options;
+$Query = "";
+%queues = ();
+
+# Build the optionlist from the tree, so we can do additions and movements based on it
+$$optionlist = build_array( \$Query, $ARGS{clauses}, $tree, \@options, \%queues );
+
+my $currentkey;
+$currentkey = $options[$ARGS{clauses}] if defined $ARGS{clauses};
+
+# {{{ Try to find if we're adding a clause
+foreach my $arg ( keys %ARGS ) {
+ if ( $arg =~ m/ValueOf(.+)/ && $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;
+ }
+
+ $value = $ARGS{'ValueOf' . $field};
+ $op = $ARGS{ $field . 'Op' };
+ 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 = Tree::Simple->new($clause);
+ if ($currentkey) {
+ my $newindex = $currentkey->getIndex() + 1;
+ if (!$currentkey->getParent->getParent()->isRoot()) {
+ }
+ $currentkey->insertSibling($newindex, $newnode);
+ $currentkey = $newnode;
+ }
+ else {
+ $tree->getChild(0)->addChild($newnode);
+ $currentkey = $newnode;
+ }
+ $newnode->getParent()->setNodeValue($ARGS{'AndOr'});
+ }
+}
+# }}}
+
+# {{{ Move things around
+if ( $ARGS{"Up"} ) {
+ if ($currentkey) {
+ my $index = $currentkey->getIndex();
+ if ( $currentkey->getIndex() > 0 ) {
+ my $parent = $currentkey->getParent();
+ $parent->removeChild($index);
+ $parent->insertChild($index - 1, $currentkey);
+ $currentkey = $parent->getChild($index - 1);
+ }
+ else {
+ push( @actions, [ "error: can't move up", -1 ] );
+ }
+ }
+ else {
+ push( @actions, [ "error: nothing to move", -1 ] );
+ }
+}
+elsif ( $ARGS{"Down"} ) {
+ if ($currentkey) {
+ my $index = $currentkey->getIndex();
+ my $parent = $currentkey->getParent();
+ if ( $currentkey->getIndex() < ($parent->getChildCount - 1) ) {
+ $parent->removeChild($index);
+ $parent->insertChild($index + 1, $currentkey);
+ $currentkey = $parent->getChild($index + 1);
+ }
+ else {
+ push( @actions, [ "error: can't move down", -1 ] );
+ }
+ }
+ else {
+ push( @actions, [ "error: nothing to move", -1 ] );
+ }
+}
+elsif ( $ARGS{"Left"} ) {
+ if ($currentkey) {
+ my $parent = $currentkey->getParent();
+ my $grandparent = $parent->getParent();
+ if (!$grandparent->isRoot) {
+ my $index = $parent->getIndex();
+ $parent->removeChild($currentkey);
+ $grandparent->insertChild($index, $currentkey);
+ if ($parent->isLeaf()) {
+ $grandparent->removeChild($parent);
+ }
+ }
+ else {
+ push( @actions, [ "error: can't move left", -1 ] );
+ }
+ }
+ else {
+ push( @actions, [ "error: nothing to move", -1 ] );
+ }
+}
+elsif ( $ARGS{"Right"} ) {
+ if ($currentkey) {
+ my $parent = $currentkey->getParent();
+ my $index = $currentkey->getIndex();
+ my $newparent;
+ if ($index > 0 ) {
+ my $sibling = $parent->getChild($index - 1);
+ if (ref($sibling->getNodeValue)) {
+ $parent->removeChild($currentkey);
+ my $newtree = Tree::Simple->new('AND', $parent);
+ $newtree->addChild($currentkey);
+ } else {
+ $parent->removeChild($index);
+ $sibling->addChild($currentkey);
+ }
+ }
+ else {
+ $parent->removeChild($currentkey);
+ $newparent = Tree::Simple->new('AND', $parent);
+ $newparent->addChild($currentkey);
+ }
+ } else {
+ push( @actions, [ "error: nothing to move", -1 ] );
+ }
+}
+elsif ( $ARGS{"DeleteClause"} ) {
+ if ($currentkey) {
+ $currentkey->getParent()->removeChild($currentkey);
+ }
+ else {
+ push( @actions, [ "error: nothing to delete", -1 ] );
+ }
+}
+elsif ( $ARGS{"Toggle"} ) {
+ my $ea;
+ if ($currentkey) {
+ my $value = $currentkey->getNodeValue();
+ my $parent = $currentkey->getParent();
+ my $parentvalue = $parent->getNodeValue();
+
+ if ( $parentvalue eq 'AND') {
+ $parent->setNodeValue('OR');
+ }
+ else {
+ $parent->setNodeValue('AND');
+ }
+ }
+ else {
+ push( @actions, [ "error: nothing to toggle", -1 ] );
+ }
+}
+elsif ( $ARGS{"Clear"} ) {
+ $tree = Tree::Simple->new(Tree::Simple->ROOT);
+}
+# }}}
+
+# {{{ Rebuild $Query based on the additions / movements
+$Query = "";
+ at options = ();
+%queues = ();
+$$optionlist = build_array( \$Query, $currentkey, $tree, \@options, \%queues );
+
+sub build_array {
+ my $Query = shift;
+ my $currentkey = shift;
+ my $tree = shift;
+ my ($keys, $queues) = @_;
+ my $i = 0;
+ my $optionlist;
+ my $depth = 0;
+ my %parens;
+
+ $tree->traverse( sub {
+ my ($_tree) = @_;
+
+ return if $_tree->getParent->isRoot();
+
+ push @$keys, $_tree;
+ my $clause = $_tree->getNodeValue();
+ my $str;
+ my $ea = $_tree->getParent()->getNodeValue();
+ if (ref($clause)) {
+ $str .= $ea . " " if $_tree->getIndex() > 0;
+ $str .= $clause->{Key} . " " . $clause->{Op} . " " . $clause->{Value};
+
+ if ( $clause->{Key} eq "Queue" ) {
+ $queues->{ $clause->{Value} } = 1;
+ }
+ } else {
+ $str = $ea if $_tree->getIndex() > 0;
+ }
+
+ my $selected;
+ if ($_tree == $currentkey) {
+ $selected = "SELECTED";
+ }
+ else {
+ $selected = "";
+ }
+
+ foreach my $p (keys %parens) {
+ if ($p > $_tree->getDepth) {
+ $$Query .= ')' x $parens{$p};
+ $parens{$p}--;
+ }
+ }
+
+ $optionlist .= "<option value=$i $selected>" .
+ (" " x 5 x ($_tree->getDepth() - 1)) . "$str</option>\n";
+ my $parent = $_tree->getParent();
+ if (!($parent->isRoot || $parent->getParent()->isRoot) &&
+ !ref($parent->getNodeValue())) {
+ if ( $_tree->getIndex() == 0) {
+ $$Query .= '(';
+ $parens{$_tree->getDepth}++;
+ }
+ }
+ $$Query .= " " . $str . " ";
+
+ if ($_tree->getDepth < $depth) {
+ $$Query .= ')';
+ $parens{$depth}--;
+ }
+
+ $i++;
+ });
+
+ foreach my $p (keys %parens) {
+ $$Query .= ") " x $parens{$p};
+ }
+
+ return $optionlist;
+
+}
+
+use Regexp::Common qw /delimited/;
+
+# States
+use constant VALUE => 1;
+use constant AGGREG => 2;
+use constant OP => 4;
+use constant PAREN => 8;
+use constant KEYWORD => 16;
+
+sub ParseQuery {
+ my $string = shift;
+ my $tree = shift;
+ my @actions = shift;
+ my $want = KEYWORD | PAREN;
+ my $last = undef;
+
+ my $depth = 1;
+
+ # make a tree root
+ $$tree = Tree::Simple->new(Tree::Simple->ROOT);
+ my $root = Tree::Simple->new('AND', $$tree);
+ my $lastnode = $root;
+ my $parentnode = $root;
+
+ # get the FIELDS from Tickets_Overlay
+ my $tickets = new RT::Tickets( $session{'CurrentUser'} );
+ my %FIELDS = %{ $tickets->FIELDS };
+
+ # Lower Case version of FIELDS, for case insensitivity
+ my %lcfields = map { ( lc($_) => $_ ) } ( keys %FIELDS );
+
+ my @tokens = qw[VALUE AGGREG OP PAREN KEYWORD];
+ my $re_aggreg = qr[(?i:AND|OR)];
+ my $re_value = qr[$RE{delimited}{-delim=>qq{\'\"}}|\d+];
+ my $re_keyword = qr[$RE{delimited}{-delim=>qq{\'\"}}|(?:\{|\}|\w|\.)+];
+ my $re_op = qr[=|!=|>=|<=|>|<|(?i:IS NOT)|(?i:IS)|(?i:NOT LIKE)|(?i:LIKE)] ; # long to short
+ my $re_paren = qr'\(|\)';
+
+ # assume that $ea is AND if it's not set
+ my ( $ea, $key, $op, $value ) = ( "AND", "", "", "" );
+
+ # order of matches in the RE is important.. op should come early,
+ # because it has spaces in it. otherwise "NOT LIKE" might be parsed
+ # as a keyword or value.
+
+ while ( $string =~ /(
+ $re_aggreg
+ |$re_op
+ |$re_keyword
+ |$re_value
+ |$re_paren
+ )/igx
+ )
+ {
+ my $val = $1;
+ my $current = 0;
+
+ # Highest priority is last
+ $current = OP if _match( $re_op, $val );
+ $current = VALUE if _match( $re_value, $val );
+ $current = KEYWORD
+ if _match( $re_keyword, $val ) && ( $want & KEYWORD );
+ $current = AGGREG if _match( $re_aggreg, $val );
+ $current = PAREN if _match( $re_paren, $val );
+
+ unless ( $current && $want & $current ) {
+
+ # Error
+ # FIXME: I will only print out the highest $want value
+ my $token = $tokens[ ( ( log $want ) / ( log 2 ) ) ];
+ push @actions, [ "current: $current, want $want, Error near ->$val<- expecting a " . $token . " in '$string'\n", -1 ];
+ }
+
+ # State Machine:
+ my $parentdepth = $depth;
+
+ # Parens are highest priority
+ if ( $current & PAREN ) {
+ if ( $val eq "(" ) {
+ $depth++;
+ # make a new node that the clauses can be children of
+ $parentnode = Tree::Simple->new($ea, $parentnode);
+ }
+ else {
+ $depth--;
+ $parentnode = $parentnode->getParent();
+ $lastnode = $parentnode;
+ }
+
+ $want = KEYWORD | PAREN | AGGREG;
+ }
+ elsif ( $current & AGGREG ) {
+ $ea = $val;
+ $want = KEYWORD | PAREN;
+ }
+ elsif ( $current & KEYWORD ) {
+ $key = $val;
+ $want = OP;
+ }
+ elsif ( $current & OP ) {
+ $op = $val;
+ $want = VALUE;
+ }
+ elsif ( $current & VALUE ) {
+ $value = $val;
+
+ # Remove surrounding quotes from $key, $val
+ # (in future, simplify as for($key,$val) { action on $_ })
+ if ( $key =~ /$RE{delimited}{-delim=>qq{\'\"}}/ ) {
+ substr( $key, 0, 1 ) = "";
+ substr( $key, -1, 1 ) = "";
+ }
+ if ( $val =~ /$RE{delimited}{-delim=>qq{\'\"}}/ ) {
+ substr( $val, 0, 1 ) = "";
+ substr( $val, -1, 1 ) = "";
+ }
+
+ # Unescape escaped characters
+ $key =~ s!\\(.)!$1!g;
+ $val =~ s!\\(.)!$1!g;
+
+ my $class;
+ if ( exists $lcfields{ lc $key } ) {
+ $key = $lcfields{ lc $key };
+ $class = $FIELDS{$key}->[0];
+ }
+ if ( $class ne 'INT' ) {
+ $val = "'$val'";
+ }
+
+ push @actions, [ "Unknown field: $key", -1 ] unless $class;
+
+ $want = PAREN | AGGREG;
+ }
+ else {
+ push @actions, [ "I'm lost", -1 ];
+ }
+
+ if ( $current & VALUE ) {
+ if ( $key =~ /^CF./ ) {
+ $key = "'" . $key . "'";
+ }
+ my $clause = {
+ Key => $key,
+ Op => $op,
+ Value => $val
+ };
+
+ # explicity add a child to it
+ $lastnode = Tree::Simple->new($clause, $parentnode);
+ $lastnode->getParent()->setNodeValue($ea);
+
+ ( $ea, $key, $op, $value ) = ( "", "", "", "" );
+ }
+
+ $last = $current;
+ } # while
+
+ push @actions, [ "Incomplete query", -1 ]
+ unless ( ( $want | PAREN ) || ( $want | KEYWORD ) );
+
+ push @actions, [ "Incomplete Query", -1 ]
+ unless ( $last && ( $last | PAREN ) || ( $last || VALUE ) );
+
+ # This will never happen, because the parser will complain
+ push @actions, [ "Mismatched parentheses", -1 ]
+ unless $depth == 1;
+}
+
+sub _match {
+
+ # Case insensitive equality
+ my ( $y, $x ) = @_;
+ return 1 if $x =~ /^$y$/i;
+
+ # return 1 if ((lc $x) eq (lc $y)); # Why isnt this equiv?
+ return 0;
+}
+
+sub debug {
+ my $message = shift;
+ $m->print($message . "<br>");
+}
+
+# }}}
+
+# }}}
+
+# {{{ Deal with format changes
+($Format, $$AvailableColumns, $$CurrentFormat) = $m->comp('/Search/Elements/BuildFormatString', cfqueues => \%queues, %ARGS, Format => $Format);
+# }}}
+
+
+# {{{ if we're asked to save the current search, save it
+if ( $ARGS{'Save'} ) {
+
+ if ($search && $search->id) {
+ # This search is based on a previously loaded search -- so
+ # just update the current search object with new values
+ $search->SetSubValues(
+ Format => $Format,
+ Query => $Query,
+ Order => $Order,
+ OrderBy => $OrderBy,
+ RowsPerPage => $RowsPerPage,
+ );
+ $search->SetDescription( $Description );
+
+ }
+ elsif ( $SearchId eq 'new' && $ARGS{'Owner'} =~ /^(.*?)-(\d+)$/ ) {
+ # We're saving a new search
+ my $obj_type = $1;
+ my $obj_id = $2;
+
+
+ # Find out if we're saving on the user, or a group
+ my $container_object;
+ if ( $obj_type eq 'RT::User' && $obj_id == $session{'CurrentUser'}->Id) {
+ $container_object = $session{'CurrentUser'}->UserObj;
+ }
+ elsif ($obj_type eq 'RT::Group') {
+ $container_object = RT::Group->new($session{'CurrentUser'});
+ $container_object->Load($obj_id);
+ }
+
+ if ($container_object->id ) {
+ # If we got one or the other, add the saerch
+ my ( $search_id, $search_msg ) = $container_object->AddAttribute(
+ Name => 'SavedSearch',
+ Description => $Description,
+ Content => {
+ Format => $Format,
+ Query => $Query,
+ Order => $Order,
+ OrderBy => $OrderBy,
+ RowsPerPage => $RowsPerPage,
+ }
+ );
+ $search = $session{'CurrentUser'}->UserObj->Attributes->WithId($search_id);
+ # Build new SearchId
+ $SearchId = ref( $session{'CurrentUser'}->UserObj ) . '-'
+ . $session{'CurrentUser'}->UserObj->Id . '-SavedSearch-' . $search->Id;
+ }
+ unless ($search->id) {
+ push @actions, [loc("Can't find a saved search to work with"), 0];
+ }
+
+ }
+ else {
+ push @actions, [loc("Can't save this search"), 0];
+ }
+
+}
+# }}}
+
+# {{{ If we're modifying an old query, check if it has changed
+$dirty = 1 if defined $search and
+ ($search->SubValue('Format') ne $Format or
+ $search->SubValue('Query') ne $Query or
+ $search->SubValue('Order') ne $Order or
+ $search->SubValue('OrderBy') ne $OrderBy or
+ $search->SubValue('RowsPerPage') ne $RowsPerPage);
+# }}}
+
+# {{{ Push the updates into the session so we don't loose 'em
+$search_hash->{'SearchId'} = $SearchId;
+$search_hash->{'Format'} = $Format;
+$search_hash->{'Query'} = $Query;
+$search_hash->{'Description'} = $Description;
+$search_hash->{'Object'} = $search;
+$search_hash->{'Order'} = $Order;
+$search_hash->{'OrderBy'} = $OrderBy;
+$search_hash->{'RowsPerPage'} = $RowsPerPage;
+
+$session{'CurrentSearchHash'} = $search_hash;
+# }}}
+
+# {{{ Show the results, if we were asked.
+if ( $ARGS{"DoSearch"} ) {
+ $m->comp("../Results.html" , Query => $Query, Format => $Format, Order => $Order, OrderBy => $OrderBy, Rows => $RowsPerPage, BaseQuery => $BaseQuery);
+ $m->abort();
+}
+# }}}
+
+$$results = \@actions;
+
+return ( $Query, $Format, $Order, $OrderBy, $RowsPerPage );
+
+</%INIT>
+
+<%ARGS>
+$NewQuery => 0
+$SearchId => undef
+$BaseQuery => undef
+$Query => undef
+$Format => undef
+$Description => undef
+$Order => undef
+$OrderBy => undef
+$RowsPerPage => undef
+$HideResults => 0
+%queues => ()
+$results => undef
+$optionlist => undef
+$search_hash => undef
+$dirty => 0
+$AvailableColumns => undef
+$CurrentFormat => undef
+</%ARGS>
Added: rtir/branches/1.1/html/RTIR/Search/Elements/ShowResults
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Elements/ShowResults Wed Aug 18 00:47:21 2004
@@ -0,0 +1,29 @@
+<& /Elements/TicketList,
+ Query => $Query,
+ AllowSorting => 1,
+ OrderBy => $OrderBy,
+ Order => $Order,
+ Rows => $Rows,
+ Page => $Page,
+ Format => $Format,
+ BaseURL => $RT::WebPath."/Search/Results.html?"
+
+ &>
+<div align=right>
+<a href="<%$RT::WebPath%>/Search/Bulk.html<%$QueryString%>"><&|/l&>Update multiple tickets</&></a><br>
+<a href="<%$RT::WebPath%>/Search/Results.html<%$QueryString%>"><&|/l&>Bookmarkable link</&></a><br>
+<a href="<%$RT::WebPath%>/Search/Results.tsv<%$QueryString%>"><&|/l&>spreadsheet</&></a> |
+<a href="<%$RT::WebPath%>/Search/Results.rdf<%$QueryString%>"><&|/l&>RSS</&></a> |
+<a href="<%$RT::WebPath%>/Tools/Offline.html<%$QueryString%>"><&|/l&>Work offline</&></a><br>
+</div>
+
+<%ARGS>
+$Query => undef
+$Format => undef
+$HideResults => 0
+$Rows => 50
+$Page => 1
+$OrderBy => 'id'
+$Order => 'ASC'
+$QueryString => undef
+</%ARGS>
Added: rtir/branches/1.1/html/RTIR/Search/Results.html
==============================================================================
--- (empty file)
+++ rtir/branches/1.1/html/RTIR/Search/Results.html Wed Aug 18 00:47:21 2004
@@ -0,0 +1,121 @@
+%# {{{ BEGIN BPS TAGGED BLOCK
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# }}} END BPS TAGGED BLOCK
+<& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'} &>
+<& '/RTIR/'.$Type.'/Elements/Tabs',
+ current_tab => "RTIR/Search/Results.html?Queue=$Queue$QueryString",
+ current_subtab => "RTIR/Search/Results.html?Queue=$Queue$QueryString",
+ Title => $title,
+ Format => $Format,
+ Query => $Query,
+ Rows => $Rows,
+ OrderBy => $OrderBy,
+ Order => $Order,
+ QueryString => $QueryString,
+&>
+<hr>
+
+<& Elements/ShowResults, QueryString => $QueryString, %ARGS &>
+
+<%INIT>
+my ($Type, @states) = $m->comp("/RTIR/Elements/Type", Queue => $Queue);
+
+my ($title, $ticketcount);
+$session{'i'}++;
+$session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) unless ($session{'tickets'});
+$session{'tickets'}->FromSQL($Query) if ($Query);
+$session{'tickets'}->OrderBy(FIELD => $OrderBy, ORDER => $Order);
+
+if ($OrderBy ne $session{'CurrentSearchHash'}->{'OrderBy'}
+ or $Order ne $session{'CurrentSearchHash'}->{'Order'}) {
+ $session{'CurrentSearchHash'}->{'OrderBy'} = $OrderBy;
+ $session{'CurrentSearchHash'}->{'Order'} = $Order;
+ # Invalidate the ordering cache
+ undef $session{'tickets'}->{'items_array'};
+}
+
+
+if ( $session{'tickets'}->Query()) {
+ $ticketcount = $session{tickets}->CountAll();
+ $title = loc('Found [quant,_1,ticket]', $ticketcount);
+} else {
+ $title = loc("Find tickets");
+}
+
+if (!$Query) {
+ $Query = $m->comp('/RTIR/Elements/NewQuery', Queue => $Queue);
+}
+
+$ARGS{'Query'} = $Query;
+
+my $QueryString = "&".$m->comp('/Elements/QueryString',
+ Query => $Query,
+ Format => $Format,
+ Rows => $Rows,
+ OrderBy => $OrderBy,
+ Order => $Order,
+ Page => $Page);
+
+if (!$BaseQuery) {
+ $BaseQuery = $m->comp('/RTIR/Elements/BaseQuery', Queue => $Queue);
+}
+
+</%INIT>
+
+<%CLEANUP>
+$session{'tickets'}->PrepForSerialization();
+</%CLEANUP>
+
+<%ARGS>
+$BaseQuery => undef
+$Query => undef
+$Format => undef
+$HideResults => 0
+$Rows => 50
+$Page => 1
+$OrderBy => 'id'
+$Order => 'ASC'
+$Queue => undef
+</%ARGS>
Modified: rtir/branches/1.1/html/RTIR/Split.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Split.html (original)
+++ rtir/branches/1.1/html/RTIR/Split.html Wed Aug 18 00:47:21 2004
@@ -40,8 +40,7 @@
<%INIT>
my $TicketObj = LoadTicket($Ticket);
-my $Type = $m->scomp('Elements/Type', Ticket => $TicketObj->Id);
-$Type =~ s/\s+$//;
+my ($Type, undef) = $m->comp('Elements/Type', Ticket => $TicketObj->Id);
my $Incident;
if ($Type ne 'Incident') {
Modified: rtir/branches/1.1/html/RTIR/Tools/Lookup.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Tools/Lookup.html (original)
+++ rtir/branches/1.1/html/RTIR/Tools/Lookup.html Wed Aug 18 00:47:21 2004
@@ -214,8 +214,7 @@
}
if ($ticket) {
- $TicketType = $m->scomp("/RTIR/Elements/Type", Ticket => $ticket);
- $TicketType =~ s/\s*$//;
+ ($TicketType, undef) = $m->comp("/RTIR/Elements/Type", Ticket => $ticket);
$TicketObj = LoadTicket($ticket);
}
Modified: rtir/branches/1.1/html/RTIR/Update.html
==============================================================================
--- rtir/branches/1.1/html/RTIR/Update.html (original)
+++ rtir/branches/1.1/html/RTIR/Update.html Wed Aug 18 00:47:21 2004
@@ -106,8 +106,7 @@
my $title;
my $Ticket = LoadTicket($id);
-my $Type = $m->scomp('Elements/Type', Ticket => $Ticket->Id);
-$Type =~ s/\s+$//;
+my ($Type, undef) = $m->comp('Elements/Type', Ticket => $Ticket->Id);
my $name;
if ($Type eq 'Report') {
More information about the Rt-commit
mailing list