1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 %# CONTRIBUTION SUBMISSION POLICY:
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
45 %# END BPS TAGGED BLOCK }}}
57 $SelectDisplayColumns => undef
58 $CurrentDisplayColumns => undef
63 $Format = $RT::DefaultSearchResultFormat;
67 # All the things we can display in the format string by default
112 my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'});
113 foreach my $id (keys %cfqueues) {
114 # What does this _do_? What are the keys to cfqueues
115 $id =~ s/^.'*(.*).'*$/$1/;
116 # Gotta load up the $queue object, since queues get stored by name now.
117 my $queue = RT::Queue->new($session{'CurrentUser'});
119 $CustomFields->LimitToQueue($queue->Id);
121 $CustomFields->LimitToGlobal;
123 while ( my $CustomField = $CustomFields->Next ) {
124 push @fields, "CustomField.{" . $CustomField->Name . "}";
129 my @format = split( /,\s*/, $Format );
130 foreach my $field (@format) {
132 $field =~ s/'(.*)'/$1/;
133 my ( $prefix, $suffix );
134 if ( $field =~ m/(.*)__(.*)__(.*)/ ) {
139 $field = "<blank>" if !$field;
140 $column{Prefix} = $prefix;
141 $column{Suffix} = $suffix;
142 $field =~ s/\s*(.*)\s*/$1/;
143 $column{Column} = $field;
144 push @seen, \%column;
148 my $index = $CurrentDisplayColumns;
149 my $column = $seen[$index];
151 delete $seen[$index];
154 foreach my $element (@temp) {
155 next unless $element;
156 push @seen, $element;
161 if ( defined $SelectDisplayColumns ) {
162 my $selected = $SelectDisplayColumns;
164 if (ref($selected) eq 'ARRAY') {
165 @columns = @$selected;
167 push @columns, $selected;
169 foreach my $col (@columns) {
171 $column{Column} = $col;
173 if ( $Face eq "Bold" ) {
174 $column{Prefix} .= "<B>";
175 $column{Suffix} .= "</B>";
177 if ( $Face eq "Italic" ) {
178 $column{Prefix} .= "<I>";
179 $column{Suffix} .= "</I>";
182 $column{Prefix} .= "<" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
183 $column{Suffix} .= "</" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
185 if ( $Link eq "Display" ) {
187 "<A HREF=\"" . $RT::WebPath . "/Ticket/Display.html?id=__id__\">";
188 $column{Suffix} .= "</a>";
190 elsif ( $Link eq "Take" ) {
191 $column{Prefix} .= "<A HREF=\"" . $RT::WebPath
192 . "/Ticket/Display.html?Action=Take&id=__id__\">";
193 $column{Suffix} .= "</a>";
197 $column{Suffix} .= "/TITLE:" . $m->interp->apply_escapes( $Title, 'h' );
199 push @seen, \%column;
204 my $index = $CurrentDisplayColumns;
205 if ( defined $index && ( $index - 1 ) >= 0 ) {
206 my $column = $seen[$index];
207 $seen[$index] = $seen[ $index - 1 ];
208 $seen[ $index - 1 ] = $column;
209 $CurrentDisplayColumns = $index - 1;
213 my $index = $CurrentDisplayColumns;
214 if ( defined $index && ( $index + 1 ) < scalar @seen ) {
215 my $column = $seen[$index];
216 $seen[$index] = $seen[ $index + 1 ];
217 $seen[ $index + 1 ] = $column;
218 $CurrentDisplayColumns = $index + 1;
224 foreach my $field (@seen) {
226 my $row = "'" . $field->{Prefix};
227 $row .= "__" . $m->interp->apply_escapes( $field->{Column}, 'h' ) . "__"
228 unless ( $field->{Column} eq "<blank>" );
229 $row .= $field->{Suffix} . "'";
230 push( @format_string, $row );
233 $Format = join(",\n", @format_string);
236 return($Format, \@fields, \@seen);