1 %# {{{ BEGIN BPS TAGGED BLOCK
5 %# This software is Copyright (c) 1996-2004 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
53 $Format = $RT::DefaultSearchResultFormat;
57 "QueueName", "OwnerName",
59 "Subject", "ExtendedStatus",
60 "Priority", "InitialPriority",
61 "FinalPriority", "EffectiveId",
63 "TimeLeft", "TimeEstimated",
65 "AdminCc", "StartsRelative",
66 "StartedRelative", "CreatedRelative",
67 "LastUpdatedRelative", "ToldRelative",
68 "DueRelative", "ResolvedRelative",
70 "Created", "CreatedBy",
71 "LastUpdated", "LastUpdatedBy",
73 "Resolved", "NEWLINE",
74 "RefersTo", "ReferredToBy",
75 "DependsOn", "DependedOnBy",
76 "MemberOf", "Members",
77 "Parents", "Children",
81 my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'});
82 foreach (keys %cfqueues) {
84 $id =~ s/^.'*(.*).'*$/$1/;
85 # Gotta load up the $queue object, since queues get stored by name now.
86 my $queue = RT::Queue->new($session{'CurrentUser'});
88 $CustomFields->LimitToQueue($queue->Id);
90 $CustomFields->LimitToGlobal;
92 while ( my $CustomField = $CustomFields->Next ) {
94 if ($CustomField->QueueObj && $CustomField->QueueObj->Id != 0) {
95 $queuestr = $CustomField->QueueObj->Name . ".";
97 push @fields, "CustomField." . $queuestr . "{" . $CustomField->Name . "}";
102 my @format = split( /,\s*/, $Format );
103 foreach my $field (@format) {
105 $field =~ s/'(.*)'/$1/;
106 my ( $prefix, $suffix );
107 if ( $field =~ m/(.*)__(.*)__(.*)/ ) {
112 $field = "<blank>" if !$field;
113 $column{Prefix} = $prefix;
114 $column{Suffix} = $suffix;
115 $field =~ s/\s*(.*)\s*/$1/;
116 $column{Column} = $field;
117 push @seen, \%column;
120 if ( $ARGS{"RemoveCol"} ) {
121 my $index = $ARGS{'CurrentDisplayColumns'};
122 my $column = $seen[$index];
124 delete $seen[$index];
127 foreach my $element (@temp) {
128 next unless $element;
129 push @seen, $element;
133 elsif ( $ARGS{"AddCol"} ) {
134 if ( defined $ARGS{'SelectDisplayColumns'} ) {
135 my $selected = $ARGS{'SelectDisplayColumns'};
137 if (ref($selected) eq 'ARRAY') {
138 @columns = @$selected;
140 push @columns, $selected;
142 foreach my $col (@columns) {
144 $column{Column} = $fields[ $col ];
146 if ( $ARGS{Face} eq "Bold" ) {
147 $column{Prefix} .= "<B>";
149 if ( $ARGS{Face} eq "Italic" ) {
150 $column{Prefix} .= "<I>";
153 $column{Prefix} .= "<" . $ARGS{Size} . ">";
155 if ( $ARGS{Link} eq "Display" ) {
156 $column{Prefix} .= "<A HREF=\"".$RT::WebPath."/Ticket/Display.html?id=__id__\">";
158 elsif ( $ARGS{Link} eq "Take" ) {
160 "<A HREF=\"".$RT::WebPath."/Ticket/Display.html?Action=Take&id=__id__\">";
164 if ( $ARGS{'Link'} eq "Display" || $ARGS{'Link'} eq "Take" ) {
165 $column{Suffix} .= "</a>";
168 $column{Suffix} .= "</" . $ARGS{Size} . ">";
170 if ( $ARGS{Face} eq "Italic" ) {
171 $column{Suffix} .= "</I>";
173 if ( $ARGS{Face} eq "Bold" ) {
174 $column{Suffix} .= "</B>";
176 if ( $ARGS{Title} ) {
177 $column{Suffix} .= "/TITLE:" . $ARGS{Title};
179 push @seen, \%column;
183 elsif ( $ARGS{"ColUp"} ) {
184 my $index = $ARGS{'CurrentDisplayColumns'};
185 if ( defined $index && ( $index - 1 ) >= 0 ) {
186 my $column = $seen[$index];
187 $seen[$index] = $seen[ $index - 1 ];
188 $seen[ $index - 1 ] = $column;
189 $ARGS{CurrentDisplayColumns} = $index - 1;
192 elsif ( $ARGS{"ColDown"} ) {
193 my $index = $ARGS{'CurrentDisplayColumns'};
194 if ( defined $index && ( $index + 1 ) < scalar @seen ) {
195 my $column = $seen[$index];
196 $seen[$index] = $seen[ $index + 1 ];
197 $seen[ $index + 1 ] = $column;
198 $ARGS{CurrentDisplayColumns} = $index + 1;
203 foreach my $field (@seen) {
205 $Format .= ", \n" if $Format;
207 $Format .= $field->{Prefix};
208 $Format .= "__" . $field->{Column} . "__" if ( $field->{Column} ne "<blank>" ) ;
209 $Format .= $field->{Suffix};
212 return($Format, \@fields, \@seen);