]> git.uio.no Git - usit-rt.git/blob - share/html/Elements/ShowTransaction
Putting 4.2.0 on top of 4.0.17
[usit-rt.git] / share / html / Elements / ShowTransaction
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
6 %#                                          <sales@bestpractical.com>
7 %#
8 %# (Except where explicitly superseded by other copyright notices)
9 %#
10 %#
11 %# LICENSE:
12 %#
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
16 %# from www.gnu.org.
17 %#
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.
22 %#
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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %#
29 %#
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %#
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %#
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %#
47 %# END BPS TAGGED BLOCK }}}
48 <div class="<% join ' ', @classes %>">
49   <div class="metadata">
50     <span class="type">
51       <a name="txn-<% $Transaction->id %>" \
52 % if ( $DisplayPath ) {
53       href="<% $DisplayPath %>?id=<% $Object->id %>#txn-<% $Transaction->id %>" \
54 % }
55       >#</a>
56     </span>
57 % $m->callback( %ARGS, Transaction => $Transaction, CallbackName => 'AfterAnchor' );
58     <span class="date"><% $date |n %></span>
59     <span class="description">
60       <& /Elements/ShowUser, User => $Transaction->CreatorObj &> - <% $desc |n %>
61 % $m->callback( %ARGS, Transaction => $Transaction, CallbackName => 'AfterDescription' );
62     </span>
63     <span class="time-taken"><% $time %></span>
64 % if ( $actions ) {
65     <span class="actions"><% $actions |n %></span>
66 % }
67   </div>
68
69   <div class="content">
70 <%PERL>
71 if ( $Transaction->CustomFieldValues->Count ) {
72     $m->comp('/Elements/ShowCustomFields', Object => $Transaction );
73 }
74 $m->comp(
75     'ShowTransactionAttachments',
76     %ARGS,
77     Parent => 0
78 ) if $ShowBody;
79 </%PERL>
80   </div>
81 % $m->callback( %ARGS, Transaction => $Transaction, CallbackName => 'AfterContent' );
82 </div>
83
84 <%ARGS>
85 $Transaction
86 $Object => $Transaction->Object
87
88 $Attachments => undef
89 $AttachmentContent => undef
90
91 $ShowBody => 1
92 $ShowActions => 1
93 $RowNum => 1
94
95 $DisplayPath => undef
96 $AttachmentPath => undef
97 $UpdatePath => undef
98 $ForwardPath => undef
99 $EncryptionPath => undef
100 $EmailRecordPath => undef
101 </%ARGS>
102
103 <%ONCE>
104
105 </%ONCE>
106 <%INIT>
107 my $record_type = $Object->RecordType;
108 my $type_class  = $Object->ClassifyTransaction( $Transaction );
109
110 $m->callback(
111     CallbackName => 'MassageTypeClass',
112     Transaction  => $Transaction,
113     TypeClassRef => \$type_class,
114     ARGSRef      => \%ARGS,
115 );
116
117 my @classes = (
118     "transaction",
119     "$record_type-transaction",
120     $type_class,
121     ($RowNum % 2 ? 'odd' : 'even')
122 );
123
124 my $desc = $Transaction->BriefDescriptionAsHTML;
125 if ( $Object->id != $Transaction->ObjectId ) {
126     # merged objects
127     $desc = join " - ",
128         $m->interp->apply_escapes(
129             loc("[_1] #[_2]:", loc($record_type), $Transaction->ObjectId), 'h'),
130         $desc;
131 }
132
133 my $date = $Transaction->CreatedAsString;
134
135 my $time = '';
136 $time = loc('[quant,_1,min,min]', $Transaction->TimeTaken)
137     if $Transaction->TimeTaken;
138
139 if ( $ShowBody && !$Attachments ) {
140     $ARGS{'Attachments'} = $Attachments = {};
141
142     my $attachments = $Transaction->Attachments( WithHeaders => 1 );
143     push @{ $Attachments->{ $_->Parent || 0 } ||= [] }, $_
144         foreach @{ $attachments->ItemsArrayRef };
145 }
146
147 my @actions = ();
148 if ( $ShowActions ) {
149     my $txn_type = $Transaction->Type;
150     if ( $txn_type =~ /EmailRecord$/ ) {
151         push @actions, {
152             title  => loc('Show'),
153             target => '_blank',
154             path   => $EmailRecordPath
155                 .'?id='. $Object->id
156                 .'&Transaction='. $Transaction->id
157                 .'&Attachment='. ( $Attachments->{0}[0] && $Attachments->{0}[0]->id ),
158         } if $EmailRecordPath;
159
160         $ShowBody = 0;
161     }
162
163     # If the transaction has anything attached to it at all
164     elsif ( %$Attachments ) {
165         my %has_right = map {
166             $_ => RT::ACE->CanonicalizeRightName( $_ . $record_type )
167         } qw(Modify CommentOn ReplyTo);
168         $has_right{'Forward'} = RT::ACE->CanonicalizeRightName('ForwardMessage');
169
170         my $can_modify = $has_right{'Modify'}
171             && $Object->CurrentUserHasRight( $has_right{'Modify'} );
172
173         if ( $UpdatePath && $has_right{'ReplyTo'}
174             && ( $can_modify
175                 || $Object->CurrentUserHasRight( $has_right{'ReplyTo'} )
176             )
177         ) {
178             push @actions, {
179                 class  => "reply-link",
180                 title  => loc('Reply'),
181                 path   => $UpdatePath
182                     .'?id='. $Object->id
183                     .'&QuoteTransaction='. $Transaction->id
184                     .'&Action=Respond'
185                 ,
186             };
187         }
188         if ( $UpdatePath && $has_right{'CommentOn'}
189             && ( $can_modify
190                 || $Object->CurrentUserHasRight( $has_right{'CommentOn'} )
191             )
192         ) {
193             push @actions, {
194                 class  => "comment-link",
195                 title  => loc('Comment'),
196                 path   => $UpdatePath
197                     .'?id='. $Object->id
198                     .'&QuoteTransaction='. $Transaction->id
199                     .'&Action=Comment'
200                 ,
201             };
202         }
203         if ( $ForwardPath && $has_right{'Forward'}
204             && $Object->CurrentUserHasRight( $has_right{'Forward'} )
205         ) {
206             push @actions, {
207                 class  => "forward-link",
208                 title  => loc('Forward'),
209                 path   => $ForwardPath
210                     .'?id='. $Object->id
211                     .'&QuoteTransaction='. $Transaction->id
212                 ,
213             };
214         }
215         if ( $EncryptionPath && $can_modify
216             && RT->Config->Get('Crypt')->{'Enable'}
217             && RT->Config->Get('Crypt')->{'AllowEncryptDataInDB'}
218         ) {
219             push @actions, {
220                 class  => "encryption-link",
221                 title  => loc('Encrypt/Decrypt'),
222                 path   => $EncryptionPath
223                     .'?id='. $Transaction->id
224                     .'&QuoteTransaction='. $Transaction->id
225                 ,
226             };
227         }
228     }
229 }
230
231 $m->callback(
232     %ARGS,
233     Transaction => $Transaction,
234     Object      => $Object,
235
236     Classes     => \@classes,
237     Actions     => \@actions,
238     Created     => \$date,
239     TimeTaken   => \$time,
240     Description => \$desc,
241 );
242
243 my $actions = '';
244 if ( @actions ) {
245     my $i = $m->interp;
246
247     foreach my $a ( @actions ) {
248         $a = '<a'
249             .' href="'. $i->apply_escapes( $a->{'path'}, 'h' ) .'"'
250             . ($a->{'target'}
251                 ? ' target="'. $i->apply_escapes( $a->{'target'}, 'h' ) .'"'
252                 : ''
253             )
254             . ($a->{'class'}
255                 ? ' class="'. $i->apply_escapes( $a->{'class'}, 'h' ) .'"'
256                 : ''
257             )
258             .'>'. $i->apply_escapes( $a->{'title'}, 'h' ) .'</a>'
259         ;
260     }
261     $actions = join '&nbsp;', map "[$_]", @actions;
262 }
263
264 # make date unbreakable
265 $date = $m->interp->apply_escapes( $date, 'h' );
266 $date =~ s/\s/&nbsp;/g;
267 </%INIT>