1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/copyleft/gpl.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'},
49 RSSAutoDiscovery => $RSSFeedURL &>
50 <& /Ticket/Elements/Tabs,
51 current_tab => "Search/Results.html".$QueryString,
58 <& /Elements/TicketList,
66 BaseURL => $RT::WebPath."/Search/Results.html?"
69 % my %hiddens = (Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order, HideResults => $HideResults, Page => $Page );
71 <form method="get" action="<%$RT::WebPath%>/Search/Results.html">
72 %foreach my $key (keys(%hiddens)) {
73 <input type="hidden" class="hidden" name="<%$key%>" value="<%defined($hiddens{$key})?$hiddens{$key}:''%>"/>
75 <& /Elements/Refresh, Name => 'TicketsRefreshInterval', Default => $session {'tickets_refresh_interval'} &>
76 <input type="submit" class="button" value="<&|/l&>Go!</&>" />
80 <a href="<%$RT::WebPath%>/Search/Bulk.html<%$QueryString%>"><&|/l&>Update multiple tickets</&></a><br />
81 <a href="<%$RT::WebPath%>/Search/Results.html<%$QueryString%>"><&|/l&>Bookmarkable link</&></a><br />
82 <a href="<%$RT::WebPath%>/Search/Results.tsv<%$QueryString%>"><&|/l&>spreadsheet</&></a> |
83 <a href="<%$RSSFeedURL%>"><&|/l&>RSS</&></a> |
84 <a href="<%$RT::WebPath%>/Tools/Offline.html<%$ShortQueryString%>"><&|/l&>Work offline</&></a><br />
85 <form method="get" action="<%$RT::WebPath%>/Search/Chart.html"><&|/l&>chart</&>
86 % %hiddens = (Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order);
87 %foreach my $key (keys(%hiddens)) {
88 <input type="hidden" class="hidden" name="<%$key%>" value="<%defined($hiddens{$key})?$hiddens{$key}:''%>"/>
90 <&|/l, $m->scomp('Elements/SelectGroupBy', Name => 'PrimaryGroupBy', Query => $Query) &>grouped by [_1]</&>
91 <&|/l, $m->scomp('Elements/SelectChartType', Name => 'ChartStyle') &>style: [_1]</&>
92 <input type="submit" class="button" value="<%loc('Go!')%>" />
94 <& /Elements/Callback, _CallbackName => 'SearchActions', QueryString => $QueryString&>
97 # Read from user preferences
98 my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
100 # These variables are what define a search_hash; this is also
101 # where we give sane defaults.
102 $Format ||= $prefs->{'Format'};
103 $Order ||= $prefs->{'Order'} || 'ASC';
104 $OrderBy ||= $prefs->{'OrderBy'} || 'id';
106 # Some forms pass in "RowsPerPage" rather than "Rows"
107 # We call it RowsPerPage everywhere else.
109 if ( !defined($Rows) ) {
110 if ( $ARGS{'RowsPerPage'} ) {
111 $Rows = $ARGS{'RowsPerPage'};
112 } elsif ( defined $prefs->{'RowsPerPage'} ) {
113 $Rows = $prefs->{'RowsPerPage'};
119 my ($title, $ticketcount);
121 $session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) ;
122 $session{'tickets'}->FromSQL($Query) if ($Query);
124 if ($OrderBy =~ /\|/) {
126 my @OrderBy = split /\|/,$OrderBy;
127 my @Order = split /\|/,$Order;
128 $session{'tickets'}->OrderByCols(
129 map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } ( 0
132 $session{'tickets'}->OrderBy(FIELD => $OrderBy, ORDER => $Order);
135 $session{'CurrentSearchHash'} = {
145 if ( $session{'tickets'}->Query()) {
146 $ticketcount = $session{tickets}->CountAll();
147 $title = loc('Found [quant,_1,ticket]', $ticketcount);
149 $title = loc("Find tickets");
152 my $QueryString = "?".$m->comp('/Elements/QueryString',
159 my $ShortQueryString = "?".$m->comp('/Elements/QueryString', Query => $Query);
160 my $RSSFeedURL = "$RT::WebPath/Search/Results.rdf$ShortQueryString";
162 if ($ARGS{'TicketsRefreshInterval'}) {
163 $session{'tickets_refresh_interval'} = $ARGS{'TicketsRefreshInterval'};
167 $session{'tickets'}->PrepForSerialization();