Master to 4.2.8
[usit-rt.git] / share / html / Ticket / Display.html
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
320f0092 5%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
84fb5b46
MKG
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<& /Elements/Header,
49 Title => $title,
50 LinkRel => \%link_rel &>
51<& /Elements/Tabs &>
52
53% $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@Actions, ARGSRef => \%ARGS, Ticket => $TicketObj);
54
55<& /Elements/ListActions, actions => \@Actions &>
56<& Elements/ShowUpdateStatus, Ticket => $TicketObj &>
af59614d 57<& Elements/ShowDependencyStatus, Ticket => $TicketObj &>
84fb5b46 58
b5747ff2 59% $m->callback( %ARGS, Ticket => $TicketObj, Transactions => $transactions, Attachments => $attachments, CallbackName => 'BeforeShowSummary' );
84fb5b46
MKG
60<div class="summary">
61<&| /Widgets/TitleBox, title => loc('Ticket metadata') &>
62<& /Ticket/Elements/ShowSummary, Ticket => $TicketObj, Attachments => $attachments &>
63</&>
64</div>
65<br />
66
b5747ff2 67% $m->callback( Ticket => $TicketObj, %ARGS, Transactions => $transactions, Attachments => $attachments, CallbackName => 'BeforeShowHistory' );
84fb5b46 68
af59614d 69% my $ShowHistory = RT->Config->Get("ShowHistory", $session{'CurrentUser'});
c33a4027 70% if ($ShowHistory eq "delay") {
af59614d
MKG
71 <& /Ticket/Elements/DelayShowHistory,
72 Ticket => $TicketObj,
73 ShowHeaders => $ARGS{'ShowHeaders'},
74 &>
75% } elsif (not $ForceShowHistory and $ShowHistory eq "click") {
84fb5b46
MKG
76 <& /Ticket/Elements/ClickToShowHistory,
77 Ticket => $TicketObj,
af59614d 78 ShowHeaders => $ARGS{'ShowHeaders'},
84fb5b46
MKG
79 &>
80% } else {
af59614d
MKG
81 <& /Elements/ShowHistory ,
82 Object => $TicketObj,
84fb5b46 83 Transactions => $transactions,
84fb5b46
MKG
84 ShowHeaders => $ARGS{'ShowHeaders'},
85 Attachments => $attachments,
86 AttachmentContent => $attachment_content
87 &>
88% }
89
90% $m->callback( %ARGS,
91% Ticket => $TicketObj,
b5747ff2
MKG
92% Transactions => $transactions,
93% Attachments => $attachments,
84fb5b46
MKG
94% CallbackName => 'AfterShowHistory',
95% );
96
97<%ARGS>
98$id => undef
99$TicketObj => undef
100$ShowHeaders => 0
84fb5b46
MKG
101$ForceShowHistory => 0
102</%ARGS>
103
104<%INIT>
105
106$m->callback( TicketObj => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'Initial' );
107
108if ( ! $ARGS{'NoRedirect'} && RT::Interface::Web->MobileClient()) {
109 $id ||= $TicketObj->id if $TicketObj;
110 RT::Interface::Web::Redirect(RT->Config->Get('WebURL').'m/ticket/show?id='.$id);
111 $m->abort;
112}
113
114
af59614d 115my (@Actions, $title);
84fb5b46
MKG
116
117
118unless ($id || $TicketObj) {
119 Abort('No ticket specified');
120}
121
122if ($ARGS{'id'} eq 'new') {
af59614d 123 # Create a new ticket
84fb5b46
MKG
124
125 my $Queue = RT::Queue->new( $session{'CurrentUser'} );
126 $Queue->Load($ARGS{'Queue'});
127 unless ( $Queue->id ) {
128 Abort('Queue not found');
129 }
130
131 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
132 Abort('You have no permission to create tickets in that queue.');
133 }
134
af59614d 135 ($TicketObj, @Actions) = CreateTicket( %ARGS );
84fb5b46
MKG
136 unless ( $TicketObj->CurrentUserHasRight('ShowTicket') ) {
137 Abort("No permission to view newly created ticket #".$TicketObj->id.".");
138 }
139} else {
140 $TicketObj ||= LoadTicket($ARGS{'id'});
141
142 $TicketObj->CurrentUser->PrincipalObj->HasRights( Object => $TicketObj );
143
144 my $SkipProcessing;
145
146 $m->callback( CallbackName => 'BeforeProcessArguments',
af59614d 147 TicketObj => $TicketObj,
84fb5b46
MKG
148 ActionsRef => \@Actions, ARGSRef => \%ARGS,
149 SkipProcessing => \$SkipProcessing );
150
151 if ( !$SkipProcessing ) {
152 if ( defined $ARGS{'Action'} ) {
153 if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) {
154 my $action = $1;
155 my ($res, $msg) = $TicketObj->$action();
156 push(@Actions, $msg);
157 }
158 }
159
160 $m->callback(CallbackName => 'ProcessArguments',
161 Ticket => $TicketObj,
162 ARGSRef => \%ARGS,
163 Actions => \@Actions);
164
af59614d 165 push @Actions, ProcessUpdateMessage(
84fb5b46
MKG
166 ARGSRef => \%ARGS,
167 Actions => \@Actions,
168 TicketObj => $TicketObj,
af59614d 169 );
84fb5b46
MKG
170
171 #Process status updates
172 push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $TicketObj );
173 push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj );
174 push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj );
175 push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj );
176 push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj );
177 push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj );
178
84fb5b46 179 unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
403d7b0b
MKG
180 if (@Actions) {
181 Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions);
182 } else {
183 Abort("No permission to view ticket");
184 }
84fb5b46
MKG
185 }
186 if ( $ARGS{'MarkAsSeen'} ) {
187 $TicketObj->SetAttribute(
188 Name => 'User-'. $TicketObj->CurrentUser->id .'-SeenUpTo',
189 Content => $TicketObj->LastUpdated,
190 );
191 push @Actions, loc('Marked all messages as seen');
192 }
193 }
194}
195
196
197$title = loc("#[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject || '');
198
199$m->callback(
200 CallbackName => 'BeforeDisplay',
201 TicketObj => \$TicketObj,
84fb5b46
MKG
202 Actions => \@Actions,
203 title => \$title,
204 ARGSRef => \%ARGS,
205);
206
207# This code does automatic redirection if any updates happen.
208MaybeRedirectForResults(
209 Actions => \@Actions,
210 $TicketObj->Type eq 'approval' && RT->Config->Get('ForceApprovalsView')
211 ? (Path => "/Approvals/Display.html", Force => 1)
212 : (Path => "/Ticket/Display.html")
213 ,
214 Anchor => $ARGS{'Anchor'},
215 Arguments => { id => $TicketObj->id },
216);
217
af59614d
MKG
218my $transactions = $TicketObj->SortedTransactions;
219my $attachments = $TicketObj->Attachments;
220my $attachment_content = $TicketObj->TextAttachments;
84fb5b46
MKG
221
222my %link_rel;
223if (defined $session{'tickets'} and ($ARGS{'Query'} or $session{'CurrentSearchHash'}->{'Query'})) {
224 my $item_map = $session{'tickets'}->ItemMap;
225 $link_rel{first} = "Ticket/Display.html?id=" . $item_map->{first} if $item_map->{$TicketObj->Id}{prev};
226 $link_rel{prev} = "Ticket/Display.html?id=" . $item_map->{$TicketObj->Id}{prev} if $item_map->{$TicketObj->Id}{prev};
227 $link_rel{next} = "Ticket/Display.html?id=" . $item_map->{$TicketObj->Id}{next} if $item_map->{$TicketObj->Id}{next};
320f0092 228 $link_rel{last} = "Ticket/Display.html?id=" . $item_map->{last} if $item_map->{$TicketObj->Id}{next} && $item_map->{last};
84fb5b46
MKG
229}
230</%INIT>