1 %# BEGIN LICENSE BLOCK;
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
31 return ColumnMap($Name, $Attr);
35 our ( $COLUMN_MAP, $CUSTOM_FIELD_MAP );
41 # First deal with the simple things from the map
42 if ( $COLUMN_MAP->{$name} ) {
43 return ( $COLUMN_MAP->{$name}->{$attr} );
46 # now, let's deal with harder things, like Custom Fields
48 elsif ( $name =~ /^(?:CF|CustomField).(.*)$/ ) {
51 if ( $CUSTOM_FIELD_MAP->{$field} ) {
52 $cf = $CUSTOM_FIELD_MAP->{$field};
56 $cf = RT::CustomField->new( $session{'CurrentUser'} );
58 if ( $field =~ /^(.+?)\.{(.+)}$/ ) {
59 $cf->LoadByNameAndQueue( Queue => $1, Name => $2 );
62 $field = $1 if $field =~ /^{(.+)}$/; # trim { }
63 $cf->LoadByNameAndQueue( Queue => "0", Name => $field );
65 $CUSTOM_FIELD_MAP->{$field} = $cf if ( $cf->id );
72 if ( $attr eq 'attribute' ) {
75 elsif ( $attr eq 'title' ) {
78 elsif ( $attr eq 'value' ) {
79 my $value = eval "sub {
80 my \$values = \$_[0]->CustomFieldValues('" . $cf->id . "');
81 return ( join( ', ', map { \$_->Content } \@{ \$values->ItemsArrayRef } ))
92 value => sub { return $_[0]->QueueObj->Name }
97 value => sub { return $_[0]->OwnerObj->Name }
102 value => sub { return $_[0]->id }
105 attribute => 'Status',
106 value => sub { return $_[0]->Status }
109 attribute => 'Subject',
110 value => sub { return $_[0]->Subject || "(" . loc('No subject') . ")" }
114 attribute => 'Status',
118 if ( $Ticket->HasUnresolvedDependencies ) {
119 if ( $Ticket->HasUnresolvedDependencies( Type => 'approval' )
120 or $Ticket->HasUnresolvedDependencies( Type => 'code' ) )
122 return "<em>" . loc('(pending approval)') . "</em>";
125 return "<em>" . loc('(pending other Collection)') . "</em>";
129 return loc( $Ticket->Status );
135 attribute => 'Priority',
136 value => sub { return $_[0]->Priority }
139 attribute => 'InitialPriority',
140 value => sub { return $_[0]->InitialPriority }
143 attribute => 'FinalPriority',
144 value => sub { return $_[0]->FinalPriority }
147 attribute => 'EffectiveId',
148 value => sub { return $_[0]->EffectiveId }
152 value => sub { return $_[0]->Type }
155 attribute => 'TimeWorked',
156 value => sub { return $_[0]->TimeWorked }
159 attribute => 'TimeLeft',
160 value => sub { return $_[0]->TimeLeft }
163 attribute => 'TimeEstimated',
164 value => sub { return $_[0]->TimeEstimated }
167 value => sub { return $_[0]->Requestors->MemberEmailAddressesAsString }
170 value => sub { return $_[0]->Cc->MemberEmailAddressesAsString }
173 value => sub { return $_[0]->AdminCc->MemberEmailAddressesAsString }
177 attribute => 'Starts',
178 value => sub { return $_[0]->StartsObj->AgeAsString }
182 attribute => 'Started',
183 value => sub { return $_[0]->StartedObj->AgeAsString }
187 attribute => 'Created',
188 value => sub { return $_[0]->CreatedObj->AgeAsString }
190 LastUpdatedRelative => {
191 title => 'LastUpdated',
192 attribute => 'LastUpdated',
193 value => sub { return $_[0]->LastUpdatedObj->AgeAsString }
198 value => sub { return $_[0]->ToldObj->AgeAsString }
204 my $date = $_[0]->DueObj;
205 if ($date && $date->Unix > 0 && $date->Unix < time()) {
206 return '<span class="overdue">' . $date->AgeAsString . '</span>';
208 return $date->AgeAsString;
212 ResolvedRelative => {
214 attribute => 'Resolved',
215 value => sub { return $_[0]->ResolvedObj->AgeAsString }
218 attribute => 'Starts',
219 value => sub { return $_[0]->StartsObj->AsString }
222 attribute => 'Started',
223 value => sub { return $_[0]->StartedObj->AsString }
226 attribute => 'Created',
227 value => sub { return $_[0]->CreatedObj->AsString }
230 attribute => 'CreatedBy',
231 value => sub { return $_[0]->CreatorObj->Name }
234 attribute => 'LastUpdated',
235 value => sub { return $_[0]->LastUpdatedObj->AsString }
238 attribute => 'LastUpdatedBy',
239 value => sub { return $_[0]->LastUpdatedByObj->Name }
243 value => sub { return $_[0]->ToldObj->AsString }
247 value => sub { return $_[0]->DueObj->AsString }
250 attribute => 'Resolved',
251 value => sub { return $_[0]->ResolvedObj->AsString }
256 my $links = $_[0]->DependedOnBy;
262 . $_->BaseURI->Resolver->HREF . '">'
263 . ( $_->BaseIsLocal ? $_->LocalBase : $_->Base )
265 } @{ $links->ItemsArrayRef }
272 my $links = $_[0]->Members;
278 . $_->BaseURI->Resolver->HREF . '">'
279 . ( $_->BaseIsLocal ? $_->LocalBase : $_->Base )
281 } @{ $links->ItemsArrayRef }
288 my $links = $_[0]->Members;
294 . $_->BaseURI->Resolver->HREF . '">'
295 . ( $_->BaseIsLocal ? $_->LocalBase : $_->Base )
297 } @{ $links->ItemsArrayRef }
304 my $links = $_[0]->ReferredToBy;
310 . $_->BaseURI->Resolver->HREF . '">'
311 . ( $_->BaseIsLocal ? $_->LocalBase : $_->Base )
313 } @{ $links->ItemsArrayRef }
321 my $links = $_[0]->DependsOn;
327 . $_->TargetURI->Resolver->HREF . '">'
328 . ( $_->TargetIsLocal ? $_->LocalTarget : $_->Target )
330 } @{ $links->ItemsArrayRef }
337 my $links = $_[0]->MemberOf;
343 . $_->TargetURI->Resolver->HREF . '">'
344 . ( $_->TargetIsLocal ? $_->LocalTarget : $_->Target )
346 } @{ $links->ItemsArrayRef }
353 my $links = $_[0]->MemberOf;
359 . $_->TargetURI->Resolver->HREF . '">'
360 . ( $_->TargetIsLocal ? $_->LocalTarget : $_->Target )
362 } @{ $links->ItemsArrayRef }
369 my $links = $_[0]->RefersTo;
375 . $_->TargetURI->Resolver->HREF . '">'
376 . ( $_->TargetIsLocal ? $_->LocalTarget : $_->Target )
378 } @{ $links->ItemsArrayRef }
385 value => sub { return $_[1] % 2 ? 'oddline' : 'evenline' }
393 $m->comp( '/Elements/Callback', COLUMN_MAP => $COLUMN_MAP, _CallbackName => 'ColumnMap');