summaryrefslogtreecommitdiff
path: root/rt/share/html/Search/Elements
diff options
context:
space:
mode:
Diffstat (limited to 'rt/share/html/Search/Elements')
-rw-r--r--rt/share/html/Search/Elements/BuildFormatString250
-rw-r--r--rt/share/html/Search/Elements/Chart147
-rw-r--r--rt/share/html/Search/Elements/ConditionRow97
-rw-r--r--rt/share/html/Search/Elements/DisplayOptions134
-rw-r--r--rt/share/html/Search/Elements/EditFormat113
-rw-r--r--rt/share/html/Search/Elements/EditQuery243
-rw-r--r--rt/share/html/Search/Elements/EditSearches296
-rw-r--r--rt/share/html/Search/Elements/Graph50
-rw-r--r--rt/share/html/Search/Elements/NewListActions66
-rw-r--r--rt/share/html/Search/Elements/PickBasics214
-rw-r--r--rt/share/html/Search/Elements/PickCFs104
-rw-r--r--rt/share/html/Search/Elements/PickCriteria72
-rw-r--r--rt/share/html/Search/Elements/ResultViews80
-rw-r--r--rt/share/html/Search/Elements/SearchPrivacy55
-rw-r--r--rt/share/html/Search/Elements/SearchesForObject65
-rw-r--r--rt/share/html/Search/Elements/SelectAndOr53
-rw-r--r--rt/share/html/Search/Elements/SelectChartType58
-rw-r--r--rt/share/html/Search/Elements/SelectGroup67
-rw-r--r--rt/share/html/Search/Elements/SelectGroupBy63
-rw-r--r--rt/share/html/Search/Elements/SelectLinks66
-rw-r--r--rt/share/html/Search/Elements/SelectPersonType84
-rw-r--r--rt/share/html/Search/Elements/SelectSearchObject68
-rw-r--r--rt/share/html/Search/Elements/SelectSearchesForObjects69
23 files changed, 2514 insertions, 0 deletions
diff --git a/rt/share/html/Search/Elements/BuildFormatString b/rt/share/html/Search/Elements/BuildFormatString
new file mode 100644
index 000000000..972851160
--- /dev/null
+++ b/rt/share/html/Search/Elements/BuildFormatString
@@ -0,0 +1,250 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%ARGS>
+$Format => RT->Config->Get('DefaultSearchResultFormat')
+
+%cfqueues => ()
+
+$Face => undef
+$Size => undef
+$Link => undef
+$Title => undef
+
+$AddCol => undef
+$RemoveCol => undef
+$ColUp => undef
+$ColDown => undef
+
+$SelectDisplayColumns => undef
+$CurrentDisplayColumns => undef
+</%ARGS>
+<%init>
+# This can't be in a <once> block, because otherwise we return the
+# same \@fields every request, and keep tacking more CustomFields onto
+# it -- and it grows per request.
+
+# All the things we can display in the format string by default
+my @fields = qw(
+ id QueueName Subject
+ Status ExtendedStatus UpdateStatus
+ Type
+
+ OwnerName Requestors Cc AdminCc CreatedBy LastUpdatedBy
+
+ Priority InitialPriority FinalPriority
+
+ TimeWorked TimeLeft TimeEstimated
+
+ Starts StartsRelative
+ Started StartedRelative
+ Created CreatedRelative
+ LastUpdated LastUpdatedRelative
+ Told ToldRelative
+ Due DueRelative
+ Resolved ResolvedRelative
+
+ RefersTo ReferredToBy
+ DependsOn DependedOnBy
+ MemberOf Members
+ Parents Children
+
+ Bookmark
+
+ NEWLINE
+); # loc_qw
+
+$m->callback( CallbackOnce => 1, CallbackName => 'SetFieldsOnce', Fields => \@fields );
+
+my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'});
+foreach my $id (keys %cfqueues) {
+ # Gotta load up the $queue object, since queues get stored by name now. my $id
+ my $queue = RT::Queue->new($session{'CurrentUser'});
+ $queue->Load($id);
+ unless ($queue->id) {
+ # XXX TODO: This ancient code dates from a former developer
+ # we have no idea what it means or why cfqueues are so encoded.
+ $id =~ s/^.'*(.*).'*$/$1/;
+ $queue->Load($id);
+ }
+ $CustomFields->LimitToQueue($queue->Id);
+}
+$CustomFields->LimitToGlobal;
+
+while ( my $CustomField = $CustomFields->Next ) {
+ push @fields, "CustomField.{" . $CustomField->Name . "}";
+}
+
+$m->callback( Fields => \@fields, ARGSRef => \%ARGS );
+
+my ( @seen);
+
+$Format ||= RT->Config->Get('DefaultSearchResultFormat');
+my @format = split( /,\s*/, $Format );
+foreach my $field (@format) {
+ my %column = ();
+ $field =~ s/'(.*)'/$1/;
+ my ( $prefix, $suffix );
+ if ( $field =~ m/(.*)__(.*)__(.*)/ ) {
+ $prefix = $1;
+ $suffix = $3;
+ $field = $2;
+ }
+ $field = "<blank>" if !$field;
+ $column{Prefix} = $prefix;
+ $column{Suffix} = $suffix;
+ $field =~ s/\s*(.*)\s*/$1/;
+ $column{Column} = $field;
+ push @seen, \%column;
+}
+
+if ( $RemoveCol ) {
+ # we do this regex match to avoid a non-numeric warning
+ my ($index) = $CurrentDisplayColumns =~ /^(\d+)/;
+ my $column = $seen[$index];
+ if ($index) {
+ delete $seen[$index];
+ my @temp = @seen;
+ @seen = ();
+ foreach my $element (@temp) {
+ next unless $element;
+ push @seen, $element;
+ }
+ }
+}
+elsif ( $AddCol ) {
+ if ( defined $SelectDisplayColumns ) {
+ my $selected = $SelectDisplayColumns;
+ my @columns;
+ if (ref($selected) eq 'ARRAY') {
+ @columns = @$selected;
+ } else {
+ push @columns, $selected;
+ }
+ foreach my $col (@columns) {
+ my %column = ();
+ $column{Column} = $col;
+
+ if ( $Face eq "Bold" ) {
+ $column{Prefix} .= "<b>";
+ $column{Suffix} .= "</b>";
+ }
+ if ( $Face eq "Italic" ) {
+ $column{Prefix} .= "<i>";
+ $column{Suffix} .= "</i>";
+ }
+ if ($Size) {
+ $column{Prefix} .= "<" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
+ $column{Suffix} .= "</" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
+ }
+ if ( $Link eq "Display" ) {
+ $column{Prefix} .= q{<a HREF="__WebPath__/Ticket/Display.html?id=__id__">};
+ $column{Suffix} .= "</a>";
+ }
+ elsif ( $Link eq "Take" ) {
+ $column{Prefix} .= q{<a HREF="__WebPath__/Ticket/Display.html?Action=Take&id=__id__">};
+ $column{Suffix} .= "</a>";
+ }
+ elsif ( $Link eq "Respond" ) {
+ $column{Prefix} .= q{<a HREF="__WebPath__/Ticket/Update.html?Action=Respond&id=__id__">};
+ $column{Suffix} .= "</a>";
+ }
+ elsif ( $Link eq "Comment" ) {
+ $column{Prefix} .= q{<a HREF="__WebPath__/Ticket/Update.html?Action=Comment&id=__id__">};
+ $column{Suffix} .= "</a>";
+ }
+ elsif ( $Link eq "Resolve" ) {
+ $column{Prefix} .= q{<a HREF="__WebPath__/Ticket/Update.html?Action=Comment&DefaultStatus=resolved&id=__id__">};
+ $column{Suffix} .= "</a>";
+ }
+
+ if ($Title) {
+ $column{Suffix} .= "/TITLE:" . $m->interp->apply_escapes( $Title, 'h' );
+ }
+ push @seen, \%column;
+ }
+ }
+}
+elsif ( $ColUp ) {
+ my $index = $CurrentDisplayColumns;
+ if ( defined $index && ( $index - 1 ) >= 0 ) {
+ my $column = $seen[$index];
+ $seen[$index] = $seen[ $index - 1 ];
+ $seen[ $index - 1 ] = $column;
+ $CurrentDisplayColumns = $index - 1;
+ }
+}
+elsif ( $ColDown ) {
+ my $index = $CurrentDisplayColumns;
+ if ( defined $index && ( $index + 1 ) < scalar @seen ) {
+ my $column = $seen[$index];
+ $seen[$index] = $seen[ $index + 1 ];
+ $seen[ $index + 1 ] = $column;
+ $CurrentDisplayColumns = $index + 1;
+ }
+}
+
+
+my @format_string;
+foreach my $field (@seen) {
+ next unless $field;
+ my $row = "'";
+ $row .= $field->{'Prefix'} if defined $field->{'Prefix'};
+ $row .= "__" . ($field->{'Column'} =~ m/\(/ ? $field->{'Column'} # func, don't escape
+ : $m->interp->apply_escapes( $field->{'Column'}, 'h' )) . "__"
+ unless ( $field->{'Column'} eq "<blank>" );
+ $row .= $field->{'Suffix'} if defined $field->{'Suffix'};
+ $row .= "'";
+ push( @format_string, $row );
+}
+
+$Format = join(",\n", @format_string);
+
+
+return($Format, \@fields, \@seen);
+
+</%init>
diff --git a/rt/share/html/Search/Elements/Chart b/rt/share/html/Search/Elements/Chart
new file mode 100644
index 000000000..3db92c4d8
--- /dev/null
+++ b/rt/share/html/Search/Elements/Chart
@@ -0,0 +1,147 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+$Query => "id > 0"
+$PrimaryGroupBy => 'Queue'
+$SecondaryGroupBy => undef
+$ChartStyle => 'bars'
+</%args>
+<%init>
+use RT::Report::Tickets;
+$PrimaryGroupBy ||= 'Queue'; # make sure PrimaryGroupBy is not undef
+
+my $tix = RT::Report::Tickets->new( $session{'CurrentUser'} );
+my ($count_name, $value_name) = $tix->SetupGroupings(
+ Query => $Query, GroupBy => $PrimaryGroupBy,
+);
+
+my %class = (
+ Queue => 'RT::Queue',
+ Owner => 'RT::User',
+ Creator => 'RT::User',
+ LastUpdatedBy => 'RT::User',
+);
+my $class = $class{ $PrimaryGroupBy };
+
+my (@keys, @values);
+while ( my $entry = $tix->Next ) {
+ if ($class) {
+ my $q = $class->new( $session{'CurrentUser'} );
+ $q->Load( $entry->__Value( $value_name ) );
+ push @keys, $q->Name;
+ }
+ else {
+ push @keys, $entry->__Value( $value_name );
+ }
+ $keys[-1] ||= loc('(no value)');
+ push @values, $entry->__Value( $count_name );
+}
+
+# XXX: Convert 1970-01-01 date to the 'Not Set'
+# this code should be generalized!!!
+if ( $PrimaryGroupBy =~ /(Daily|Monthly|Annually)$/ ) {
+ my $re;
+ $re = qr{1970-01-01} if $PrimaryGroupBy =~ /Daily$/;
+ $re = qr{1970-01} if $PrimaryGroupBy =~ /Monthly$/;
+ $re = qr{1970} if $PrimaryGroupBy =~ /Annually$/;
+ foreach (@keys) {
+ s/^$re/loc('Not Set')/e;
+ }
+}
+
+my %data;
+my %loc_keys;
+foreach my $key (@keys) { $data{$key} = shift @values; $loc_keys{$key} = loc($key); }
+my @sorted_keys = map { $loc_keys{$_}} sort { $loc_keys{$a} cmp $loc_keys{$b} } keys %loc_keys;
+my @sorted_values = map { $data{$_}} sort { $loc_keys{$a} cmp $loc_keys{$b} } keys %loc_keys;
+
+
+my $query_string = $m->comp('/Elements/QueryString', %ARGS);
+</%init>
+
+<% loc('Query:') %>&nbsp;<% $Query %><br />
+
+% if (RT->Config->Get('DisableGD')) {
+<% loc('Graphical charts are not available.') %><br />
+% } else {
+<img src="<%RT->Config->Get('WebPath')%>/Search/Chart?<%$query_string|n%>" /><br />
+% }
+
+<table class="collection-as-table">
+<tr>
+<th class="collection-as-table"><% loc($tix->Label($PrimaryGroupBy)) %>
+</th>
+<th class="collection-as-table"><&|/l&>Tickets</&>
+</th>
+</tr>
+% my ($i,$total);
+% while (my $key = shift @sorted_keys) {
+% $i++;
+% my $value = shift @sorted_values;
+% $total += $value;
+<tr class="<%$i%2 ? 'evenline' : 'oddline' %>">
+<td class="label collection-as-table">
+<%$key%>
+</td>
+<td class="value collection-as-table">
+<%$value%>
+</td>
+</tr>
+% }
+
+%$i++;
+<tr class="<%$i%2 ? 'evenline' : 'oddline' %>">
+<td class="label collection-as-table">
+<%loc('Total')%>
+</td>
+<td class="value collection-as-table">
+<%$total||''%>
+</td>
+</tr>
+
+</table>
diff --git a/rt/share/html/Search/Elements/ConditionRow b/rt/share/html/Search/Elements/ConditionRow
new file mode 100644
index 000000000..d45c6621b
--- /dev/null
+++ b/rt/share/html/Search/Elements/ConditionRow
@@ -0,0 +1,97 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 class="label"><% $handle_block->( $Condition->{'Field'}, $Condition->{'Name'} .'Field' ) |n %></td>
+<td class="operator"><% $handle_block->( $Condition->{'Op'}, $Condition->{'Name'} .'Op') |n %></td>
+<td class="value"><% $handle_block->( $Condition->{'Value'}, 'ValueOf'. $Condition->{'Name'} ) |n %></td>
+</tr>
+<%INIT>
+return unless $Condition && $Condition->{'Name'};
+
+$m->callback( Condition => \$Condition );
+return unless $Condition;
+
+my $handle_block;
+$handle_block = sub {
+ my $box = shift;
+ return $box unless ref $box;
+
+ my $name = shift;
+ if ( UNIVERSAL::isa($box, 'ARRAY') ) {
+ my $res = '';
+ $res .= $handle_block->( $_, $name ) foreach @$box;
+ return $res;
+ }
+
+ return undef unless UNIVERSAL::isa($box, 'HASH');
+ if ( $box->{'Type'} eq 'component' ) {
+ $box->{'Arguments'} ||= {},
+ return $m->scomp( $box->{'Path'}, %{ $box->{'Arguments'} }, Name => $name );
+ }
+ if ( $box->{'Type'} eq 'text' ) {
+ my $default = $box->{'Default'} || '';
+ my $size = $box->{'Size'}? qq{size="$box->{'Size'}"} : '';
+ return qq{<input id="$name" name="$name" value="$default" $size />};
+ }
+ if ( $box->{'Type'} eq 'select' ) {
+ my $res = '';
+ $res .= qq{<select id="$name" name="$name">};
+ my @options = @{ $box->{'Options'} };
+ while( my $k = shift @options ) {
+ my $v = shift @options;
+ $res .= qq{<option value="$k">$v</option>};
+ }
+ $res .= qq{</select>};
+ return $res;
+ }
+};
+
+</%INIT>
+<%ARGS>
+$Condition => {}
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/DisplayOptions b/rt/share/html/Search/Elements/DisplayOptions
new file mode 100644
index 000000000..40d976cfd
--- /dev/null
+++ b/rt/share/html/Search/Elements/DisplayOptions
@@ -0,0 +1,134 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<&| /Widgets/TitleBox, title => loc("Sorting"), id => 'sorting' &>
+<table valign="top">
+
+% for my $o (0..3) {
+% $Order[$o] ||= ''; $OrderBy[$o] ||= '';
+<tr>
+<td class="label">
+% if ($o == 0) {
+<&|/l&>Order by</&>:
+% }
+</td>
+<td class="value">
+<select name="OrderBy">
+% if ($o > 0) {
+<option value=""><&|/l&>~[none~]</&></option>
+% }
+% foreach my $field (sort keys %fields) {
+% next unless $field;
+<option value="<%$field%>"
+% if (defined $OrderBy[$o] and $field eq $OrderBy[$o]) {
+selected="selected"
+% }
+><% loc($field) %></option>
+% }
+</select>
+<select name="Order">
+<option value="ASC"
+% unless ( ($Order[$o]||'') eq "DESC" ) {
+selected="selected"
+% }
+><&|/l&>Asc</&></option>
+<option value="DESC"
+% if ( ($Order[$o]||'') eq "DESC" ) {
+selected="selected"
+% }
+><&|/l&>Desc</&></option>
+</select>
+</td>
+</tr>
+% }
+<tr>
+<td class="label">
+<&|/l&>Rows per page</&>:
+</td><td class="value">
+<& /Elements/SelectResultsPerPage,
+ Name => "RowsPerPage",
+ Default => $RowsPerPage &>
+</td>
+</tr>
+</table>
+</&>
+<&| /Widgets/TitleBox, title => loc("Display Columns"), id => 'columns' &>
+<& EditFormat, %ARGS &>
+</&>
+
+<%INIT>
+my $tickets = new RT::Tickets($session{'CurrentUser'});
+my %fields = %{$tickets->FIELDS};
+map { $fields{$_}->[0] =~ /^(?:ENUM|INT|DATE|STRING|ID)$/ || delete $fields{$_} } keys %fields;
+delete $fields{'EffectiveId'};
+$fields{'Owner'} = 1;
+$fields{ $_ . '.EmailAddress' } = 1 foreach( qw(Requestor Cc AdminCc) );
+
+# Add all available CustomFields to the list of sortable columns.
+my @cfs = grep /^CustomField/, @{$ARGS{AvailableColumns}};
+$fields{$_}=1 for @cfs;
+
+# Add PAW sort
+$fields{'Custom.Ownership'} = 1;
+
+my @Order = split /\|/, $Order;
+my @OrderBy = split /\|/, $OrderBy;
+if ($Order =~ /\|/) {
+ @Order = split /\|/, $Order;
+} else {
+ @Order = ( $Order );
+}
+
+</%INIT>
+
+<%ARGS>
+$Order => undef
+$OrderBy => undef
+$RowsPerPage => undef
+$Format => undef
+$GroupBy => 'id'
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/EditFormat b/rt/share/html/Search/Elements/EditFormat
new file mode 100644
index 000000000..9dd616039
--- /dev/null
+++ b/rt/share/html/Search/Elements/EditFormat
@@ -0,0 +1,113 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<table>
+
+<tr>
+<th><&|/l&>Add Columns</&>:</th>
+<th><&|/l&>Format</&>:</th>
+<th></th>
+<th><&|/l&>Show Columns</&>:</th>
+</tr>
+
+<tr>
+
+<td valign="top"><select size="6" name="SelectDisplayColumns" multiple="multiple">
+% my %seen;
+% foreach my $field ( grep !$seen{lc $_}++, @$AvailableColumns) {
+<option value="<% $field %>"><% loc($field) %></option>
+% }
+</select></td>
+
+<td><&|/l&>Link</&>:
+<select name="Link">
+<option value="None">-</option>
+<option value="Display"><&|/l&>Display</&></option>
+<option value="Take"><&|/l&>Take</&></option>
+<option value="Respond"><&|/l&>Respond</&></option>
+<option value="Comment"><&|/l&>Comment</&></option>
+<option value="Resolve"><&|/l&>Resolve</&></option>
+</select>
+<br /><&|/l&>Title</&>: <input name="Title" size="10" />
+<br /><&|/l&>Size</&>:
+<select name="Size">
+<option value="">-</option>
+<option value="Small"><&|/l&>Small</&></option>
+<option value="Large"><&|/l&>Large</&></option>
+</select>
+<br /><&|/l&>Style</&>:
+<select name="Face">
+<option value="">-</option>
+<option value="Bold"><&|/l&>Bold</&></option>
+<option value="Italic"><&|/l&>Italic</&></option>
+</select>
+</td>
+
+<td><input type="submit" class="button" name="AddCol" value=" &rarr; " /></td>
+
+<td valign="top">
+<select size="4" name="CurrentDisplayColumns">
+% my $i=0;
+% foreach my $field ( @$CurrentFormat ) {
+<option value="<% $i++ %>><% $field->{Column} %>"><% loc( $field->{Column} ) %></option>
+% }
+</select>
+<br />
+<center>
+<input type="submit" class="button" name="ColUp" value=" &uarr; " />
+<input type="submit" class="button" name="ColDown" value=" &darr; " />
+<input type="submit" class="button" name="RemoveCol" value="<%loc('Delete')%>" />
+</center>
+</td>
+
+</tr>
+</table>
+
+<%ARGS>
+$CurrentFormat => undef
+$AvailableColumns => undef
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/EditQuery b/rt/share/html/Search/Elements/EditQuery
new file mode 100644
index 000000000..9a10ddff6
--- /dev/null
+++ b/rt/share/html/Search/Elements/EditQuery
@@ -0,0 +1,243 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<& NewListActions, actions => $actions &>
+<&|/Widgets/TitleBox, title => join(': ', grep defined, loc("Current search"), $Description) &>
+
+<select size="10" name="clauses" style="width: 100%" multiple="multiple">
+% $m->out($optionlist);
+</select>
+
+<p align="center">
+<input type="submit" class="button" name="Up" value=" &uarr; " />
+<input type="submit" class="button" name="Down" value=" &darr; " />
+<input type="submit" class="button" name="Left" value=" &larr; " />
+<input type="submit" class="button" name="Right" value=" &rarr; " />
+<input type="submit" class="button" name="Toggle" value="<&|/l&>And/Or</&>" />
+<input type="submit" class="button" name="DeleteClause" value="<&|/l&>Delete</&>" />
+%#<input type="submit" class="button" name="EditQuery" value="Advanced" />
+</p>
+
+</&>
+<%ARGS>
+$Description => undef
+$optionlist => ''
+$actions => []
+</%ARGS>
+
+<%METHOD Process>
+<%ARGS>
+$Tree
+$Selected
+@New => ()
+</%ARGS>
+<%INIT>
+
+my @NewSelection = ();
+
+my @results;
+if ( $ARGS{'Up'} || $ARGS{'Down'} ) {
+ if (@$Selected) {
+ foreach my $value (@$Selected) {
+ my $parent = $value->getParent;
+ my $index = $value->getIndex;
+ my $newindex = $index;
+ $newindex++ if $ARGS{'Down'};
+ $newindex-- if $ARGS{'Up'};
+ if ( $newindex < 0 || $newindex >= $parent->getChildCount ) {
+ push( @results, [ loc("error: can't move up"), -1 ] ) if $ARGS{'Up'};
+ push( @results, [ loc("error: can't move down"), -1 ] ) if $ARGS{'Down'};
+ next;
+ }
+
+ $parent->removeChild( $index );
+ $parent->insertChild( $newindex, $value );
+ }
+ }
+ else {
+ push( @results, [ loc("error: nothing to move"), -1 ] );
+ }
+}
+elsif ( $ARGS{"Left"} ) {
+ if (@$Selected) {
+ foreach my $value (@$Selected) {
+ my $parent = $value->getParent;
+ if( $value->isRoot || $parent->isRoot ) {
+ push( @results, [ loc("error: can't move left"), -1 ] );
+ next;
+ }
+
+ my $grandparent = $parent->getParent;
+ if( $grandparent->isRoot ) {
+ push( @results, [ loc("error: can't move left"), -1 ] );
+ next;
+ }
+
+ my $index = $parent->getIndex;
+ $parent->removeChild($value);
+ $grandparent->insertChild( $index, $value );
+ if ( $parent->isLeaf ) {
+ $grandparent->removeChild($parent);
+ }
+ }
+ }
+ else {
+ push( @results, [ loc("error: nothing to move"), -1 ] );
+ }
+}
+elsif ( $ARGS{"Right"} ) {
+ if (@$Selected) {
+ foreach my $value (@$Selected) {
+ my $parent = $value->getParent;
+ my $index = $value->getIndex;
+
+ my $newparent;
+ if ( $index > 0 ) {
+ my $sibling = $parent->getChild( $index - 1 );
+ $newparent = $sibling unless $sibling->isLeaf;
+ }
+ $newparent ||= RT::Interface::Web::QueryBuilder::Tree->new( $ARGS{'AndOr'} || 'AND', $parent );
+
+ $parent->removeChild($value);
+ $newparent->addChild($value);
+ }
+ }
+ else {
+ push( @results, [ loc("error: nothing to move"), -1 ] );
+ }
+}
+elsif ( $ARGS{"DeleteClause"} ) {
+ if (@$Selected) {
+ my (@top);
+ my %Selected = map { $_ => 1 } @$Selected;
+ foreach my $node ( @$Selected ) {
+ my $tmp = $node->getParent;
+ while ( !$Selected{ $tmp } && !$tmp->isRoot ) {
+ $tmp = $tmp->getParent;
+ }
+ next if $Selected{ $tmp };
+ push @top, $node;
+ }
+
+ my %seen;
+ my @non_siblings_top = grep !$seen{ $_->getParent }++, @top;
+
+ foreach ( @New ) {
+ my $add = $_->clone;
+ foreach my $selected( @non_siblings_top ) {
+ my $newindex = $selected->getIndex + 1;
+ $selected->insertSibling( $newindex, $add );
+ }
+ $add->getParent->setNodeValue( $ARGS{'AndOr'} );
+ push @NewSelection, $add;
+ }
+ @New = ();
+
+ while( my $node = shift @top ) {
+ my $parent = $node->getParent;
+ $parent->removeChild($node);
+ $node->DESTROY;
+ }
+ @$Selected = ();
+ }
+ else {
+ push( @results, [ loc("error: nothing to delete"), -1 ] );
+ }
+}
+elsif ( $ARGS{"Toggle"} ) {
+ if (@$Selected) {
+ my %seen;
+ my @unique_nodes = grep !$seen{ $_ + 0 }++,
+ map ref $_->getNodeValue? $_->getParent: $_,
+ @$Selected;
+
+ foreach my $node ( @unique_nodes ) {
+ if ( $node->getNodeValue eq 'AND' ) {
+ $node->setNodeValue('OR');
+ }
+ else {
+ $node->setNodeValue('AND');
+ }
+ }
+ }
+ else {
+ push( @results, [ loc("error: nothing to toggle"), -1 ] );
+ }
+}
+
+if ( @New && @$Selected ) {
+ my %seen;
+ my @non_siblings_selected = grep !$seen{ $_->getParent }++, @$Selected;
+
+ foreach ( @New ) {
+ my $add = $_->clone;
+ foreach my $selected( @non_siblings_selected ) {
+ my $newindex = $selected->getIndex + 1;
+ $selected->insertSibling( $newindex, $add );
+ }
+ $add->getParent->setNodeValue( $ARGS{'AndOr'} );
+ push @NewSelection, $add;
+ }
+ @$Selected = ();
+}
+elsif ( @New ) {
+ foreach ( @New ) {
+ my $add = $_->clone;
+ $Tree->addChild( $add );
+ push @NewSelection, $add;
+ }
+ $Tree->setNodeValue( $ARGS{'AndOr'} );
+}
+$_->DESTROY foreach @New;
+
+push @$Selected, @NewSelection;
+
+$Tree->PruneChildlessAggregators;
+
+return @results;
+</%INIT>
+</%METHOD>
diff --git a/rt/share/html/Search/Elements/EditSearches b/rt/share/html/Search/Elements/EditSearches
new file mode 100644
index 000000000..62871fd5f
--- /dev/null
+++ b/rt/share/html/Search/Elements/EditSearches
@@ -0,0 +1,296 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<&| /Widgets/TitleBox, title => loc($Title)&>
+
+%# Hide all the save functionality if the user shouldn't see it.
+% if ( $can_modify ) {
+<&|/l&>Privacy:</&>
+<& SelectSearchObject, Name => 'SavedSearchOwner', Objects => \@Objects, Object => ( $Object && $Object->id ) ? $Object->Object : '' &>
+<br />
+<&|/l&>Description</&>:
+<input size="25" name="SavedSearchDescription" value="<% $Description || '' %>" />
+
+% if ($Id ne 'new') {
+<nobr>
+% if ( $Dirty ) {
+<input type="submit" class="button" name="SavedSearchRevert" value="<%loc('Revert')%>" />
+% }
+<input type="submit" class="button" name="SavedSearchDelete" value="<%loc('Delete')%>" />
+% if ( $AllowCopy ) {
+<input type="submit" class="button" name="SavedSearchCopy" value="<%loc('Save as New')%>" />
+% }
+</nobr>
+% }
+% if ( $Object && $Object->Id ) {
+<input type="submit" class="button" name="SavedSearchSave" value="<%loc('Update')%>" />
+% } else {
+<input type="submit" class="button" name="SavedSearchSave" value="<%loc('Save')%>" />
+%}
+% }
+<br />
+<hr />
+<&|/l&>Load saved search:</&>
+<& SelectSearchesForObjects, Name => 'SavedSearchLoad', Objects => \@Objects, SearchType => $Type &>
+<input type="submit" value="<% loc('Load') %>" class="button" />
+
+</&>
+
+<%INIT>
+return unless $session{'CurrentUser'}->HasRight(
+ Right => 'LoadSavedSearch',
+ Object => $RT::System,
+);
+
+my $can_modify = $session{'CurrentUser'}->HasRight(
+ Right => 'CreateSavedSearch',
+ Object => $RT::System,
+);
+
+use RT::SavedSearches;
+my @Objects = RT::SavedSearches->new($session{CurrentUser})->_PrivacyObjects;
+push @Objects, RT::System->new( $session{'CurrentUser'} )
+ if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
+ Right => 'SuperUser' );
+
+my $is_dirty = sub {
+ my %arg = (
+ Query => {},
+ SavedSearch => {},
+ SearchFields => [qw(Query Format OrderBy Order RowsPerPage)],
+ @_
+ );
+
+ my $obj = $arg{'SavedSearch'}->{'Object'};
+ return 0 unless $obj && $obj->id;
+
+ foreach( @{ $arg{'SearchFields'} } ) {
+ return 1 if $obj->SubValue( $_ ) ne $arg{'Query'}->{$_};
+ }
+
+ return 0;
+};
+
+# If we're modifying an old query, check if it's been changed
+my $Dirty = $is_dirty->(
+ Query => $CurrentSearch,
+ SavedSearch => { Id => $Id, Object => $Object, Description => $Description },
+ SearchFields => \@SearchFields,
+);
+
+</%INIT>
+
+<%ARGS>
+$Id => 'new'
+$Object => undef
+$Type => 'Ticket'
+$Description => ''
+$CurrentSearch => {}
+@SearchFields => ()
+$AllowCopy => 1
+$Title => loc('Saved searches')
+</%ARGS>
+
+<%METHOD Init>
+<%ARGS>
+$Query => {}
+$SavedSearch => {}
+@SearchFields => qw(Query Format OrderBy Order RowsPerPage)
+</%ARGS>
+<%INIT>
+
+$SavedSearch->{'Id'} = ( $ARGS{Type} && $ARGS{Type} eq 'Chart' ?
+$ARGS{'SavedChartSearchId'} : $ARGS{'SavedSearchId'} ) || 'new';
+$SavedSearch->{'Description'} = $ARGS{'SavedSearchDescription'} || undef;
+$SavedSearch->{'Privacy'} = $ARGS{'SavedSearchOwner'} || undef;
+
+my @results;
+
+if ( $ARGS{'SavedSearchRevert'} ) {
+ $ARGS{'SavedSearchLoad'} = $SavedSearch->{'Id'};
+}
+
+if ( $ARGS{'SavedSearchLoad'} ) {
+ my ($container, $id ) = _parse_saved_search ($ARGS{'SavedSearchLoad'});
+ if ( $container ) {
+ my $search = $container->Attributes->WithId( $id );
+ $SavedSearch->{'Id'} = $ARGS{'SavedSearchLoad'};
+ $SavedSearch->{'Object'} = $search;
+ $SavedSearch->{'Description'} = $search->Description;
+ $Query->{$_} = $search->SubValue($_) foreach @SearchFields;
+
+ if ( $ARGS{'SavedSearchRevert'} ) {
+ push @results, loc('Loaded original "[_1]" saved search', $SavedSearch->{'Description'} );
+ } else {
+ push @results, loc('Loaded saved search "[_1]"', $SavedSearch->{'Description'} );
+ }
+ }
+ else {
+ push @results, loc( 'Can not load saved search "[_1]"',
+ $ARGS{'SavedSearchLoad'} );
+ return @results;
+ }
+}
+elsif ( $ARGS{'SavedSearchDelete'} ) {
+ # We set $SearchId to 'new' above already, so peek into the %ARGS
+ my ($container, $id) = _parse_saved_search( $SavedSearch->{'Id'} );
+ if ( $container && $container->id ) {
+ # We have the object the entry is an attribute on; delete the entry...
+ $container->Attributes->DeleteEntry( Name => 'SavedSearch', id => $id );
+ }
+ $SavedSearch->{'Id'} = 'new';
+ $SavedSearch->{'Object'} = undef;
+ $SavedSearch->{'Description'} = undef;
+ push @results, loc("Deleted saved search");
+}
+elsif ( $ARGS{'SavedSearchCopy'} ) {
+ my ($container, $id ) = _parse_saved_search( $ARGS{'SavedSearchId'} );
+ $SavedSearch->{'Object'} = $container->Attributes->WithId( $id );
+ if ( $ARGS{'SavedSearchDescription'} && $ARGS{'SavedSearchDescription'} ne $SavedSearch->{'Object'}->Description ) {
+ $SavedSearch->{'Description'} = $ARGS{'SavedSearchDescription'};
+ } else {
+ $SavedSearch->{'Description'} = loc( "[_1] copy", $SavedSearch->{'Object'}->Description );
+ }
+ $SavedSearch->{'Id'} = 'new';
+ $SavedSearch->{'Object'} = undef;
+}
+
+if ( $SavedSearch->{'Id'} && $SavedSearch->{'Id'} ne 'new'
+ && !$SavedSearch->{'Object'} )
+{
+ my ($container, $id ) = _parse_saved_search( $ARGS{'SavedSearchId'} );
+ $SavedSearch->{'Object'} = $container->Attributes->WithId( $id );
+ $SavedSearch->{'Description'} ||= $SavedSearch->{'Object'}->Description;
+}
+
+return @results;
+
+</%INIT>
+</%METHOD>
+
+<%METHOD Save>
+<%ARGS>
+$Query => {}
+$SavedSearch => {}
+@SearchFields => qw(Query Format OrderBy Order RowsPerPage)
+</%ARGS>
+<%INIT>
+
+return unless $ARGS{'SavedSearchSave'} || $ARGS{'SavedSearchCopy'};
+
+my @results;
+my $obj = $SavedSearch->{'Object'};
+my $id = $SavedSearch->{'Id'};
+my $desc = $SavedSearch->{'Description'};
+my $privacy = $SavedSearch->{'Privacy'};
+
+my %params = map { $_ => $Query->{$_} } @SearchFields;
+my ($new_obj_type, $new_obj_id) = split(/\-/, ($privacy || ''));
+
+if ( $obj && $obj->id ) {
+ # permission check
+ if ($obj->Object->isa('RT::System')) {
+ unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser')) {
+ push @results, loc("No permission to save system-wide searches");
+ return @results;
+ }
+ }
+
+ $obj->SetSubValues( %params );
+ $obj->SetDescription( $desc );
+
+ my $obj_type = ref($obj->Object);
+ # We need to get current obj_id now, because when we change obj_type to
+ # RT::System, $obj->Object->Id returns 1, not the old one :(
+ my $obj_id = $obj->Object->Id;
+
+ if ( $new_obj_type && $new_obj_id ) {
+ my ($val, $msg);
+ if ( $new_obj_type ne $obj_type ) {
+ ($val, $msg ) = $obj->SetObjectType($new_obj_type);
+ push @results, loc ('Unable to set privacy object: [_1]', $msg) unless ( $val );
+ }
+ if ( $new_obj_id != $obj_id ) {
+ ($val, $msg) = $obj->SetObjectId($new_obj_id);
+ push @results, loc ('Unable to set privacy id: [_1]', $msg) unless ( $val );
+ }
+ } else {
+ push @results, loc('Unable to determine object type or id');
+ }
+ push @results, loc('Updated saved search "[_1]"', $desc);
+}
+elsif ( $id eq 'new' ) {
+ my $saved_search = RT::SavedSearch->new( $session{'CurrentUser'} );
+ my ($status, $msg) = $saved_search->Save(
+ Privacy => $privacy,
+ Name => $desc,
+ Type => $SavedSearch->{'Type'},
+ SearchParams => \%params,
+ );
+
+ if ( $status ) {
+ $SavedSearch->{'Object'} =
+ $session{'CurrentUser'}->UserObj->Attributes->WithId( $saved_search->Id );
+ # Build new SearchId
+ $SavedSearch->{'Id'} =
+ ref( $session{'CurrentUser'}->UserObj ) . '-'
+ . $session{'CurrentUser'}->UserObj->Id
+ . '-SavedSearch-'
+ . $SavedSearch->{'Object'}->Id;
+ }
+ else {
+ push @results, loc("Can't find a saved search to work with").': '.loc($msg);
+ }
+}
+else {
+ push @results, loc("Can't save this search");
+}
+
+return @results;
+
+</%INIT>
+</%METHOD>
diff --git a/rt/share/html/Search/Elements/Graph b/rt/share/html/Search/Elements/Graph
new file mode 100644
index 000000000..620cbc59e
--- /dev/null
+++ b/rt/share/html/Search/Elements/Graph
@@ -0,0 +1,50 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%INIT>
+return $m->comp('/Ticket/Graphs/Elements/ShowGraph', %ARGS);
+</%INIT>
diff --git a/rt/share/html/Search/Elements/NewListActions b/rt/share/html/Search/Elements/NewListActions
new file mode 100644
index 000000000..8e2cbab6f
--- /dev/null
+++ b/rt/share/html/Search/Elements/NewListActions
@@ -0,0 +1,66 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<b><%loc('Results')%></b><br />
+% foreach my $action (@actions) {
+% my @item = @$action;
+% if ($item[1] < 0) {
+<font color="red">
+% }
+&nbsp;<%$item[0]%><br />
+% if ($item[1] < 0) {
+</font>
+% }
+% }
+<br />
+<%init>
+@actions = map ref $_? $_: [$_, 0], grep defined && length, @actions;
+return unless @actions;
+</%init>
+<%ARGS>
+@actions => undef
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/PickBasics b/rt/share/html/Search/Elements/PickBasics
new file mode 100644
index 000000000..7e4bc7357
--- /dev/null
+++ b/rt/share/html/Search/Elements/PickBasics
@@ -0,0 +1,214 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+% foreach( @lines ) {
+<& ConditionRow, Condition => $_ &>
+% }
+<%INIT>
+
+my @lines = (
+ {
+ Name => 'id',
+ Field => loc('id'),
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectEqualityOperator',
+ },
+ Value => { Type => 'text', Size => 5 }
+ },
+ {
+ Name => 'Attachment',
+ Field => {
+ Type => 'component',
+ Path => '/Elements/SelectAttachmentField',
+ },
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectBoolean',
+ Arguments => {
+ True => loc("matches"),
+ False => loc("doesn't match"),
+ TrueVal => 'LIKE',
+ FalseVal => 'NOT LIKE',
+ },
+ },
+ Value => { Type => 'text', Size => 20 },
+ },
+ {
+ Name => 'Queue',
+ Field => loc('Queue'),
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectBoolean',
+ Arguments => { TrueVal=> '=', FalseVal => '!=' },
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectQueue',
+ Arguments => { NamedValues => 1, CheckQueueRight => 'ShowTicket' },
+ },
+ },
+ {
+ Name => 'Status',
+ Field => loc('Status'),
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectBoolean',
+ Arguments => { TrueVal=> '=', FalseVal => '!=' },
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectStatus',
+ Arguments => { SkipDeleted => 1 },
+ },
+ },
+ {
+ Name => 'Actor',
+ Field => {
+ Type => 'select',
+ Options => [
+ Owner => loc('Owner'),
+ Creator => loc('Creator'),
+ LastUpdatedBy => loc('Last updated by'),
+ ],
+ },
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectBoolean',
+ Arguments => { TrueVal=> '=', FalseVal => '!=' },
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectOwner',
+ Arguments => { ValueAttribute => 'Name' },
+ },
+ },
+ {
+ Name => 'Watcher',
+ Field => {
+ Type => 'component',
+ Path => 'SelectPersonType',
+ Arguments => { Default => 'Requestor' },
+ },
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectMatch',
+ },
+ Value => { Type => 'text', Size => 20 }
+ },
+ {
+ Name => 'Date',
+ Field => {
+ Type => 'component',
+ Path => '/Elements/SelectDateType',
+ },
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectDateRelation',
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectDate',
+ Arguments => { ShowTime => 0, Default => '' },
+ },
+ },
+ {
+ Name => 'Time',
+ Field => {
+ Type => 'select',
+ Options => [
+ TimeWorked => loc('Time Worked'),
+ TimeEstimated => loc('Time Estimated'),
+ TimeLeft => loc('Time Left'),
+ ],
+ },
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectEqualityOperator',
+ },
+ Value => [
+ { Type => 'text', Size => 5 },
+ {
+ Type => 'component',
+ Path => '/Elements/SelectTimeUnits',
+ },
+ ],
+ },
+ {
+ Name => 'Priority',
+ Field => {
+ Type => 'select',
+ Options => [
+ Priority => loc('Priority'),
+ InitialPriority => loc('Initial Priority'),
+ FinalPriority => loc('Final Priority'),
+ ],
+ },
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectEqualityOperator',
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectPriority',
+ },
+ },
+ {
+ Name => 'Links',
+ Field => { Type => 'component', Path => 'SelectLinks' },
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectBoolean',
+ Arguments => { TrueVal=> '=', FalseVal => '!=' },
+ },
+ Value => { Type => 'text', Size => 5 }
+ },
+);
+
+$m->callback( Conditions => \@lines );
+
+</%INIT>
diff --git a/rt/share/html/Search/Elements/PickCFs b/rt/share/html/Search/Elements/PickCFs
new file mode 100644
index 000000000..ba25cdeda
--- /dev/null
+++ b/rt/share/html/Search/Elements/PickCFs
@@ -0,0 +1,104 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+% foreach( @lines ) {
+<& ConditionRow, Condition => $_ &>
+% }
+<%INIT>
+my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'});
+foreach my $id (keys %cfqueues) {
+ # Gotta load up the $queue object, since queues get stored by name now. my $id
+ my $queue = RT::Queue->new($session{'CurrentUser'});
+ $queue->Load($id);
+ unless ($queue->id) {
+ # XXX TODO: This ancient code dates from a former developer
+ # we have no idea what it means or why cfqueues are so encoded.
+ $id =~ s/^.'*(.*).'*$/$1/;
+
+ # unescape internal quotes
+ $id =~ s/(\\(.))/$2 eq "'" ? "'" : $1/eg;
+
+ $queue->Load($id);
+ }
+ $CustomFields->LimitToQueue($queue->Id);
+}
+$CustomFields->LimitToGlobal;
+$m->callback(
+ CallbackName => 'MassageCustomFields',
+ CustomFields => $CustomFields,
+);
+
+
+my @lines;
+while ( my $CustomField = $CustomFields->Next ) {
+ my %line;
+ $line{'Name'} = "'CF.{" . $CustomField->Name . "}'";
+ $line{'Field'} = $CustomField->Name;
+ $line{'Op'} = {
+ Type => 'component',
+ Path => '/Elements/SelectCustomFieldOperator',
+ Arguments => { True => loc("is"),
+ False => loc("isn't"),
+ TrueVal=> '=',
+ FalseVal => '!=',
+ },
+ };
+ $line{'Value'} = {
+ Type => 'component',
+ Path => '/Elements/SelectCustomFieldValue',
+ Arguments => { CustomField => $CustomField },
+ };
+ push @lines, \%line;
+}
+
+$m->callback( Conditions => \@lines, Queues => \%cfqueues );
+
+</%INIT>
+
+<%ARGS>
+%cfqueues => undef
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/PickCriteria b/rt/share/html/Search/Elements/PickCriteria
new file mode 100644
index 000000000..b024775ef
--- /dev/null
+++ b/rt/share/html/Search/Elements/PickCriteria
@@ -0,0 +1,72 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<&| /Widgets/TitleBox, title => loc('Add Criteria')&>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+
+
+
+<& PickBasics &>
+<& PickCFs, cfqueues => \%cfqueues &>
+
+<tr class="separator"><td colspan="3"><hr /></td></tr>
+<tr>
+<td class="label"><&|/l&>Aggregator</&></td>
+<td class="operator" colspan="2"><& SelectAndOr, Name => "AndOr" &></td>
+
+</tr>
+
+</table>
+
+</&>
+
+<%ARGS>
+$addquery => 0
+$query => undef
+%cfqueues => undef
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/ResultViews b/rt/share/html/Search/Elements/ResultViews
new file mode 100644
index 000000000..b438b56a0
--- /dev/null
+++ b/rt/share/html/Search/Elements/ResultViews
@@ -0,0 +1,80 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+$QueryString => undef
+$Query => undef
+$Format => undef
+$Rows => undef
+$OrderBy => undef
+$Order => undef
+$RSSFeedURL => undef
+$ShortQueryString => undef
+
+</%args>
+<ul class="search-result-views">
+<li><a href="<%RT->Config->Get('WebPath')%>/Search/Results.tsv<%$QueryString%>"><&|/l&>Spreadsheet</&></a></li>
+<li><a href="<%$RSSFeedURL%>"><&|/l&>RSS</&></a></li>
+<li><a href="<%RT->Config->Get('WebURL')%>/NoAuth/iCal/<% $ical_path %>"><% loc('iCal') %></a></li>
+<li><a href="<%RT->Config->Get('WebPath')%>/Tools/Offline.html<%$ShortQueryString%>"><&|/l&>Editable text</&></a></li>
+% # Now let callbacks add their extra tools
+% $m->callback( %ARGS, CallbackName => 'AfterTools' );
+</ul>
+<form method="get" action="<%RT->Config->Get('WebPath')%>/Search/Chart.html">
+% my %hiddens = (Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order);
+% foreach my $key (keys(%hiddens)) {
+<input type="hidden" class="hidden" name="<%$key%>" value="<%defined($hiddens{$key})?$hiddens{$key}:''%>" />
+% }
+<&|/l, $m->scomp('SelectChartType', Name => 'ChartStyle'), $m->scomp('SelectGroupBy', Name => 'PrimaryGroupBy', Query => $Query)
+&>[_1] chart by [_2]</&><input type="submit" class="button" value="<%loc('Go')%>" />
+</form>
+<%init>
+my $ical_path = join '/', map $m->interp->apply_escapes($_, 'u'),
+ $session{'CurrentUser'}->UserObj->Name,
+ $session{'CurrentUser'}->UserObj->GenerateAuthString( $Query ),
+ $Query;
+</%init>
diff --git a/rt/share/html/Search/Elements/SearchPrivacy b/rt/share/html/Search/Elements/SearchPrivacy
new file mode 100644
index 000000000..a3640fb01
--- /dev/null
+++ b/rt/share/html/Search/Elements/SearchPrivacy
@@ -0,0 +1,55 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+$Object => undef
+</%args>
+% if (ref($Object) eq 'RT::User' && $Object->id == $session{'CurrentUser'}->Id) {
+<&|/l&>My saved searches</&>
+% } else {
+<&|/l, $Object->Name&>[_1]'s saved searches</&>
+% }
diff --git a/rt/share/html/Search/Elements/SearchesForObject b/rt/share/html/Search/Elements/SearchesForObject
new file mode 100644
index 000000000..8534f8df5
--- /dev/null
+++ b/rt/share/html/Search/Elements/SearchesForObject
@@ -0,0 +1,65 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+$Object => undef
+</%args>
+<%init>
+# Returns an array of search objects associated on $Object,
+# in the form of [Description, searchObj]
+my @result;
+while (my $search = $Object->Attributes->Next) {
+ my $desc;
+ if ($search->Name eq 'SavedSearch') {
+ push @result, [$search->Description, $search];
+ }
+ elsif ($search->Name =~ m/^Search - (.*)/) {
+ push @result, [$1, $search];
+ }
+}
+return @result;
+</%init>
diff --git a/rt/share/html/Search/Elements/SelectAndOr b/rt/share/html/Search/Elements/SelectAndOr
new file mode 100644
index 000000000..52685ba3f
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectAndOr
@@ -0,0 +1,53 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<input type="radio" class="radio" name="<%$Name%>" checked="checked" value="AND" /><&|/l&>AND</&>
+<input type="radio" class="radio" name="<%$Name%>" value="OR" /><&|/l&>OR</&>
+
+<%ARGS>
+$Name => "Operator"
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/SelectChartType b/rt/share/html/Search/Elements/SelectChartType
new file mode 100644
index 000000000..fcb723497
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectChartType
@@ -0,0 +1,58 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+$Name => 'ChartType'
+$Default => 'bar'
+</%args>
+<select id="<%$Name%>" name="<%$Name%>">
+% foreach my $option qw(bar pie) {
+% # 'bar' # loc
+% # 'pie' # loc
+<option value="<%$option%>"<% $option eq $Default ? qq[ selected="selected"] : '' |n %>><%loc($option)%></option>
+% }
+</select>
diff --git a/rt/share/html/Search/Elements/SelectGroup b/rt/share/html/Search/Elements/SelectGroup
new file mode 100644
index 000000000..f6583b114
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectGroup
@@ -0,0 +1,67 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<select id="<%$Name%>" name="<%$Name%>">
+% if ($AllowNull) {
+<option value="">-</option>
+% }
+%while (my $group = $groups->Next) {
+<option value="<%$group->id%>"<%$group->id eq $Default && qq[ selected="selected"] |n %>><%$group->Name%></option>
+%}
+</select>
+
+<%INIT>
+my $groups = new RT::Groups($session{'CurrentUser'});
+$groups->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => $Domain);
+
+</%INIT>
+<%ARGS>
+$AllowNull => 1
+$Default=> ''
+$Name => 'Group'
+$Domain => 'UserDefined';
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/SelectGroupBy b/rt/share/html/Search/Elements/SelectGroupBy
new file mode 100644
index 000000000..2a1b38718
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectGroupBy
@@ -0,0 +1,63 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+$Name => 'GroupBy'
+$Default => 'Status'
+$Query => ''
+</%args>
+<select id="<% $Name %>" name="<% $Name %>">
+% while (@options) {
+% my ($text, $value) = (shift @options, shift @options);
+<option value="<% $value %>" <% $value eq $Default ? 'selected="selected"' : '' |n%>><% loc($text) %></option>
+% }
+</select>
+<%init>
+use RT::Report::Tickets;
+my $report = RT::Report::Tickets->new( $session{'CurrentUser'} );
+my @options = $report->Groupings( Query => $Query );
+</%init>
diff --git a/rt/share/html/Search/Elements/SelectLinks b/rt/share/html/Search/Elements/SelectLinks
new file mode 100644
index 000000000..219a19241
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectLinks
@@ -0,0 +1,66 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<select name="<%$Name%>">
+% foreach (@fields) {
+<option value="<%$_%>"><% loc($_) %></option>
+% }
+</select>
+<%ARGS>
+$Name => 'LinksField'
+</%ARGS>
+
+<%INIT>
+my @fields = ('HasMember',
+ 'MemberOf',
+ 'DependsOn',
+ 'DependedOnBy',
+ 'RefersTo',
+ 'ReferredToBy',
+ 'LinkedTo',
+ );
+</%INIT>
diff --git a/rt/share/html/Search/Elements/SelectPersonType b/rt/share/html/Search/Elements/SelectPersonType
new file mode 100644
index 000000000..5f6ac7365
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectPersonType
@@ -0,0 +1,84 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<select id="<%$Name%>" name="<%$Name%>">
+% if ($AllowNull) {
+<option value="">-</option>
+% }
+% for my $option (@types) {
+% if ($Suffix) {
+<option value="<% $option %><% $Suffix %>"<%$option eq $Default && qq[ selected="selected"] |n %> ><%loc($option)%></option>
+% next;
+% }
+% foreach my $subtype (@subtypes) {
+<option value="<%"$option.$subtype"%>"<%$option eq $Default && $subtype eq 'EmailAddress' && qq[ selected="selected"] |n %> ><% loc($option) %> <% loc($subtype) %></option>
+% }
+% }
+</select>
+
+<%INIT>
+my @types;
+if ($Scope =~ 'queue') {
+ @types = qw(Cc AdminCc);
+}
+elsif ($Suffix eq 'Group') {
+ @types = qw(Requestor Cc AdminCc Watcher);
+}
+else {
+ @types = qw(Requestor Cc AdminCc Watcher Owner QueueCc QueueAdminCc QueueWatcher);
+}
+
+my @subtypes = qw(EmailAddress Name RealName Nickname Organization Address1 Address2 WorkPhone HomePhone MobilePhone PagerPhone id);
+
+</%INIT>
+<%ARGS>
+$AllowNull => 1
+$Suffix => ''
+$Default=>undef
+$Scope => 'ticket'
+$Name => 'WatcherType'
+</%ARGS>
diff --git a/rt/share/html/Search/Elements/SelectSearchObject b/rt/share/html/Search/Elements/SelectSearchObject
new file mode 100644
index 000000000..c38f5c396
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectSearchObject
@@ -0,0 +1,68 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+@Objects => undef
+$Name => undef
+$Object => undef
+</%args>
+<%init>
+my $default_privacy = '';
+if ( $Object && $Object->Id ) {
+ $default_privacy = ref($Object).'-'.$Object->Id;
+}
+</%init>
+<select id="<%$Name%>" name="<%$Name%>">
+% foreach my $object (@Objects) {
+% my $privacy = ref($object).'-'.$object->id;
+% if (ref($object) eq 'RT::User' && $object->id == $session{'CurrentUser'}->Id) {
+<option value="<%$privacy%>" <% ( $privacy eq $default_privacy ) ? "selected='selected'" : '' |n %> ><&|/l&>My saved searches</&></option>
+% } else {
+<option value="<%$privacy%>" <% ( $privacy eq $default_privacy ) ? "selected='selected'" : '' |n %> ><&|/l, $object->Name&>[_1]'s saved searches</&></option>
+% }
+% }
+</select>
diff --git a/rt/share/html/Search/Elements/SelectSearchesForObjects b/rt/share/html/Search/Elements/SelectSearchesForObjects
new file mode 100644
index 000000000..1a53ad931
--- /dev/null
+++ b/rt/share/html/Search/Elements/SelectSearchesForObjects
@@ -0,0 +1,69 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse@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., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# 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 }}}
+<%args>
+@Objects => undef
+$Name => undef
+$SearchType => 'Ticket',
+</%args>
+<select id="<%$Name%>" name="<%$Name%>">
+% foreach my $object (@Objects) {
+% if (ref($object) eq 'RT::User' && $object->id == $session{'CurrentUser'}->Id) {
+<option value=""><&|/l&>My saved searches</&></option>
+% } else {
+<option value=""></option>
+<option value=""><&|/l, $object->Name&>[_1]'s saved searches</&></option>
+% }
+% my @searches = $object->Attributes->Named('SavedSearch');
+% foreach my $search (@searches) {
+% # Skip it if it is not of search type we want.
+% next if ($search->SubValue('SearchType')
+% && $search->SubValue('SearchType') ne $SearchType);
+<option value="<%ref($object)%>-<%$object->id%>-SavedSearch-<%$search->Id%>"> -<%$search->Description||loc('Unnamed search')%></option>
+% }
+% }
+</select>