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 ) {
125 if ($CustomField->QueueObj && $CustomField->QueueObj->Id != 0) {
126 $queuestr = $CustomField->QueueObj->Name . ".";
128 push @fields, "CustomField." . $queuestr . "{" . $CustomField->Name . "}";
133 my @format = split( /,\s*/, $Format );
134 foreach my $field (@format) {
136 $field =~ s/'(.*)'/$1/;
137 my ( $prefix, $suffix );
138 if ( $field =~ m/(.*)__(.*)__(.*)/ ) {
143 $field = "<blank>" if !$field;
144 $column{Prefix} = $prefix;
145 $column{Suffix} = $suffix;
146 $field =~ s/\s*(.*)\s*/$1/;
147 $column{Column} = $field;
148 push @seen, \%column;
152 my $index = $CurrentDisplayColumns;
153 my $column = $seen[$index];
155 delete $seen[$index];
158 foreach my $element (@temp) {
159 next unless $element;
160 push @seen, $element;
165 if ( defined $SelectDisplayColumns ) {
166 my $selected = $SelectDisplayColumns;
168 if (ref($selected) eq 'ARRAY') {
169 @columns = @$selected;
171 push @columns, $selected;
173 foreach my $col (@columns) {
175 $column{Column} = $col;
177 if ( $Face eq "Bold" ) {
178 $column{Prefix} .= "<B>";
179 $column{Suffix} .= "</B>";
181 if ( $Face eq "Italic" ) {
182 $column{Prefix} .= "<I>";
183 $column{Suffix} .= "</I>";
186 $column{Prefix} .= "<" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
187 $column{Suffix} .= "</" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
189 if ( $Link eq "Display" ) {
191 "<A HREF=\"" . $RT::WebPath . "/Ticket/Display.html?id=__id__\">";
192 $column{Suffix} .= "</a>";
194 elsif ( $Link eq "Take" ) {
195 $column{Prefix} .= "<A HREF=\"" . $RT::WebPath
196 . "/Ticket/Display.html?Action=Take&id=__id__\">";
197 $column{Suffix} .= "</a>";
201 $column{Suffix} .= "/TITLE:" . $m->interp->apply_escapes( $Title, 'h' );
203 push @seen, \%column;
208 my $index = $CurrentDisplayColumns;
209 if ( defined $index && ( $index - 1 ) >= 0 ) {
210 my $column = $seen[$index];
211 $seen[$index] = $seen[ $index - 1 ];
212 $seen[ $index - 1 ] = $column;
213 $CurrentDisplayColumns = $index - 1;
217 my $index = $CurrentDisplayColumns;
218 if ( defined $index && ( $index + 1 ) < scalar @seen ) {
219 my $column = $seen[$index];
220 $seen[$index] = $seen[ $index + 1 ];
221 $seen[ $index + 1 ] = $column;
222 $CurrentDisplayColumns = $index + 1;
228 foreach my $field (@seen) {
230 my $row = "'" . $field->{Prefix};
231 $row .= "__" . $m->interp->apply_escapes( $field->{Column}, 'h' ) . "__"
232 unless ( $field->{Column} eq "<blank>" );
233 $row .= $field->{Suffix} . "'";
234 push( @format_string, $row );
237 $Format = join(",\n", @format_string);
240 return($Format, \@fields, \@seen);