1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2009 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/licenses/old-licenses/gpl-2.0.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,
49 Refresh => $session{'tickets_refresh_interval'} || RT->Config->Get('SearchResultsRefreshInterval', $session{'CurrentUser'} ),
50 RSSAutoDiscovery => $RSSFeedURL,
51 LinkRel => \%link_rel &>
52 <& /Ticket/Elements/Tabs,
53 current_tab => "Search/Results.html".$QueryString,
60 SavedSearchId => $SavedSearchId,
61 SavedChartSearchId => $SavedChartSearchId,
63 <& /Elements/CollectionList,
71 Class => 'RT::Tickets',
75 % my %hiddens = (Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order, HideResults => $HideResults, Page => $Page, SavedChartSearchId => $SavedChartSearchId );
76 <div align="right" class="refresh">
77 <form method="get" action="<%RT->Config->Get('WebPath')%>/Search/Results.html">
78 % foreach my $key (keys(%hiddens)) {
79 <input type="hidden" class="hidden" name="<%$key%>" value="<% defined($hiddens{$key})?$hiddens{$key}:'' %>" />
81 <& /Elements/Refresh, Name => 'TicketsRefreshInterval', Default => $session{'tickets_refresh_interval'}||RT->Config->Get('SearchResultsRefreshInterval', $session{'CurrentUser'}) &>
82 <input type="submit" class="button" value="<&|/l&>Change</&>" />
85 <div align="right" class="search-result-actions">
86 <& Elements/ResultViews,
87 QueryString => $QueryString,
93 RSSFeedURL => $RSSFeedURL,
94 ShortQueryString => $ShortQueryString,
97 % $m->callback( QueryString => $QueryString, CallbackName => 'SearchActions' );
100 # Read from user preferences
101 my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
103 # These variables are what define a search_hash; this is also
104 # where we give sane defaults.
105 $Format ||= $prefs->{'Format'} || RT->Config->Get('DefaultSearchResultFormat');
106 $Order ||= $prefs->{'Order'} || 'ASC';
107 $OrderBy ||= $prefs->{'OrderBy'} || 'id';
109 # Some forms pass in "RowsPerPage" rather than "Rows"
110 # We call it RowsPerPage everywhere else.
112 if ( !defined($Rows) ) {
113 if (defined $ARGS{'RowsPerPage'} ) {
114 $Rows = $ARGS{'RowsPerPage'};
115 } elsif ( defined $prefs->{'RowsPerPage'} ) {
116 $Rows = $prefs->{'RowsPerPage'};
122 my ($title, $ticketcount);
124 $session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) ;
125 $session{'tickets'}->FromSQL($Query) if ($Query);
127 if ($OrderBy =~ /\|/) {
129 my @OrderBy = split /\|/,$OrderBy;
130 my @Order = split /\|/,$Order;
131 $session{'tickets'}->OrderByCols(
132 map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } ( 0
135 $session{'tickets'}->OrderBy(FIELD => $OrderBy, ORDER => $Order);
138 $session{'CurrentSearchHash'} = {
148 if ( $session{'tickets'}->Query()) {
149 $ticketcount = $session{tickets}->CountAll();
150 $title = loc('Found [quant,_1,ticket]', $ticketcount);
152 $title = loc("Find tickets");
155 my $QueryString = "?".$m->comp('/Elements/QueryString',
162 my $ShortQueryString = "?".$m->comp('/Elements/QueryString', Query => $Query);
163 my $RSSQueryString = "?".$m->comp('/Elements/QueryString', Query => $Query, Order => $Order, OrderBy => $OrderBy);
164 my $RSSFeedURL = RT->Config->Get('WebPath')."/Search/Results.rdf$RSSQueryString";
166 if ($ARGS{'TicketsRefreshInterval'}) {
167 $session{'tickets_refresh_interval'} = $ARGS{'TicketsRefreshInterval'};
173 '/Elements/QueryString',
182 my $BaseURL = RT->Config->Get('WebPath')."/Search/Results.html?";
183 $link_rel{first} = $BaseURL . $genpage->(1) if $Page > 1;
184 $link_rel{prev} = $BaseURL . $genpage->($Page - 1) if $Page > 1;
185 $link_rel{next} = $BaseURL . $genpage->($Page + 1) if ($Page * $Rows) < $ticketcount;
186 $link_rel{last} = $BaseURL . $genpage->(POSIX::ceil($ticketcount/$Rows)) if $Rows and ($Page * $Rows) < $ticketcount;
189 $session{'tickets'}->PrepForSerialization();
199 $SavedSearchId => undef
200 $SavedChartSearchId => undef