Putting 4.2.0 on top of 4.0.17
[usit-rt.git] / share / html / Elements / ShowHistory
CommitLineData
af59614d
MKG
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="history <% lc $record_type %>" id="<% $histid %>">
49<%perl>
50if ( $ShowDisplayModes or $ShowTitle ) {
51 my $title = $ShowTitle
52 ? loc('History')
53 : '&nbsp;';
54
55 my $titleright = '';
56 if ( $ShowDisplayModes ) {
57 if ( RT->Config->Get( 'QuoteFolding', $session{CurrentUser} ) ) {
58 my $open_all = $m->interp->apply_escapes( loc("Show all quoted text"), 'j' );
59 my $open_html = $m->interp->apply_escapes( loc("Show all quoted text"), 'h' );
60 my $close_all = $m->interp->apply_escapes( loc("Hide all quoted text"), 'j' );
61 $titleright .= '<a href="#" data-direction="open" '
62 . qq{onclick="return toggle_all_folds(this, $open_all, $close_all);"}
63 . ">$open_html</a> &mdash; ";
64 }
65
66 if ($ShowHeaders) {
67 $titleright .= qq{<a href="?ForceShowHistory=1;id=} .
68 $Object->id.qq{#$histid">} .
69 loc("Show brief headers") .
70 qq{</a>};
71 } else {
72 $titleright .= qq{<a href="?ForceShowHistory=1;ShowHeaders=1;id=} .
73 $Object->id.qq{#$histid">} .
74 loc("Show full headers") .
75 qq{</a>};
76 }
77 }
78</%perl>
79<& /Widgets/TitleBoxStart, title => $title, titleright_raw => $titleright &>
80% }
81
82<div class="history-container">
83<%perl>
84my $i = 1;
85while ( my $Transaction = $Transactions->Next ) {
86 my $skip = 0;
87
88 # Skip display of SetWatcher transactions for ticket Owner groups. Owner
89 # was a single member role group and denormalized into a column well before
90 # the generic role group handling and transactions came about. For
91 # tickets, we rely on rendering ownership changes using the Set-Owner
92 # transaction. For all other record types, or even potential ticket single
93 # role groups which aren't Owner, we use SetWatcher to render history and
94 # skip the Set transactions. This complication is necessary to avoid
95 # creating backdated transactions on upgrade which normalize to one type or
96 # another.
97 #
98 # These conditions assumes ticket Owner is a single-member denormalized
99 # role group, which is safe since that is unlikely to ever change in the
100 # future.
101 if ($Object->isa("RT::Ticket") and ($Transaction->Field || '') eq "Owner") {
102 $skip = 1 if $Transaction->Type eq "SetWatcher";
103 } else {
104 $skip = 1 if $Transaction->Type eq "Set"
105 and $Transaction->Field
106 and $Object->DOES("RT::Record::Role::Roles")
107 and $Object->HasRole( $Transaction->Field )
108 and $Object->RoleGroup( $Transaction->Field )->SingleMemberRoleGroupColumn;
109 }
110
111 $m->callback(
112 %ARGS,
113 Transaction => $Transaction,
114 skip => \$skip,
115 CallbackName => 'SkipTransaction',
116 );
117 next if $skip;
118
119 # ARGS is first because we're clobbering the "Attachments" parameter
120 $m->comp( 'ShowTransaction',
121 %ARGS,
122 Object => $Object,
123 Transaction => $Transaction,
124 ShowHeaders => $ShowHeaders,
125 RowNum => $i,
126 Attachments => $trans_attachments->{$Transaction->id} || {},
127 AttachmentContent => $trans_content,
128 );
129
130 # manually flush the content buffer after each txn,
131 # so the user sees some update
132 $m->flush_buffer;
133
134 $i++;
135}
136
137</%perl>
138</div>
139% if ($ShowDisplayModes or $ShowTitle) {
140<& /Widgets/TitleBoxEnd &>
141% }
142</div>
143<%INIT>
144my $trans_content = {};
145my $trans_attachments = {};
146
147for my $content (@{$AttachmentContent->ItemsArrayRef()}) {
148 $trans_content->{$content->TransactionId}->{$content->Id} = $content;
149}
150
151for my $attachment (@{$Attachments->ItemsArrayRef()}) {
152 my $tmp = $trans_attachments->{ $attachment->TransactionId } ||= {};
153 push @{ $tmp->{ $attachment->Parent || 0 } ||= [] }, $attachment;
154}
155
156{
157 my %tmp = (
158 DisplayPath => 'Display.html',
159 AttachmentPath => 'Attachment',
160 UpdatePath => 'Update.html',
161 ForwardPath => 'Forward.html',
162 EmailRecordPath => 'ShowEmailRecord.html',
163 EncryptionPath => 'Crypt.html',
164 );
165
166 while ( my ($arg, $path) = each %tmp ) {
167 next if defined $ARGS{ $arg };
168 $ARGS{ $arg } = $path;
169 }
170}
171
172my $record_type = $Object->RecordType;
173my $histid = "\L$record_type\E-" . $Object->id . "-history";
174</%INIT>
175<%ARGS>
176$Object
177$Transactions => $Object->SortedTransactions
178$Attachments => $Object->Attachments( WithHeaders => 1 )
179$AttachmentContent => $Object->TextAttachments
180
181$ShowHeaders => 0
182$ShowTitle => 1
183$ShowDisplayModes => 1
184</%ARGS>