1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 %# <sales@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., 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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
50 LinkRel => \%link_rel &>
53 % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@Actions, ARGSRef => \%ARGS, Ticket => $TicketObj);
55 <& /Elements/ListActions, actions => \@Actions &>
56 <& Elements/ShowUpdateStatus, Ticket => $TicketObj &>
58 % $m->callback( %ARGS, Ticket => $TicketObj, Transactions => $transactions, Attachments => $attachments, CallbackName => 'BeforeShowSummary' );
60 <&| /Widgets/TitleBox, title => loc('Ticket metadata') &>
61 <& /Ticket/Elements/ShowSummary, Ticket => $TicketObj, Attachments => $attachments &>
66 % $m->callback( Ticket => $TicketObj, %ARGS, Transactions => $transactions, Attachments => $attachments, CallbackName => 'BeforeShowHistory' );
68 % if (not $ForceShowHistory and RT->Config->Get( 'DeferTransactionLoading', $session{'CurrentUser'} )) {
69 <& /Ticket/Elements/ClickToShowHistory,
73 <& /Ticket/Elements/ShowHistory ,
76 Transactions => $transactions,
77 Collapsed => $ARGS{'Collapsed'},
78 ShowHeaders => $ARGS{'ShowHeaders'},
79 Attachments => $attachments,
80 AttachmentContent => $attachment_content
84 % $m->callback( %ARGS,
85 % Ticket => $TicketObj,
86 % Transactions => $transactions,
87 % Attachments => $attachments,
88 % CallbackName => 'AfterShowHistory',
96 $ForceShowHistory => 0
97 $RedirectToBasics => 0
102 $m->callback( TicketObj => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'Initial' );
104 if ( ! $ARGS{'NoRedirect'} && RT::Interface::Web->MobileClient()) {
105 $id ||= $TicketObj->id if $TicketObj;
106 RT::Interface::Web::Redirect(RT->Config->Get('WebURL').'m/ticket/show?id='.$id);
111 my (@Actions, $Tickets, $title);
114 unless ($id || $TicketObj) {
115 Abort('No ticket specified');
118 if ($ARGS{'id'} eq 'new') {
119 # {{{ Create a new ticket
121 # Massage customer IDs into member links.
122 my @cust_uris = map {
123 /^(\d+)$/ && "freeside://freeside/cust_main/$1"
124 } split(' ', $ARGS{'new-Customer'});
126 $ARGS{'new-MemberOf'} =
127 join(' ', $ARGS{'new-MemberOf'}, @cust_uris);
129 my $Queue = RT::Queue->new( $session{'CurrentUser'} );
130 $Queue->Load($ARGS{'Queue'});
131 unless ( $Queue->id ) {
132 Abort('Queue not found');
135 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
136 Abort('You have no permission to create tickets in that queue.');
139 ($TicketObj, @Actions) = CreateTicket(
140 Attachments => delete $session{'Attachments'},
143 unless ( $TicketObj->CurrentUserHasRight('ShowTicket') ) {
144 Abort("No permission to view newly created ticket #".$TicketObj->id.".");
147 $TicketObj ||= LoadTicket($ARGS{'id'});
149 $TicketObj->CurrentUser->PrincipalObj->HasRights( Object => $TicketObj );
153 $m->callback( CallbackName => 'BeforeProcessArguments',
154 TicketObj => $TicketObj, Tickets => $Tickets,
155 ActionsRef => \@Actions, ARGSRef => \%ARGS,
156 SkipProcessing => \$SkipProcessing );
158 if ( !$SkipProcessing ) {
159 if ( defined $ARGS{'Action'} ) {
160 if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) {
162 my ($res, $msg) = $TicketObj->$action();
163 push(@Actions, $msg);
167 $m->callback(CallbackName => 'ProcessArguments',
168 Ticket => $TicketObj,
170 Actions => \@Actions);
172 $ARGS{UpdateAttachments} = $session{'Attachments'};
174 ProcessUpdateMessage(
176 Actions => \@Actions,
177 TicketObj => $TicketObj,
179 delete $session{'Attachments'};
181 #Process status updates
182 push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $TicketObj );
183 push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj );
184 push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj );
185 push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj );
186 push @Actions, ProcessTicketCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj );
187 # If this fails due to required fields being empty, it will set
188 # notes('RedirectToBasics').
189 push @Actions, ProcessTicketStatus( ARGSRef => \%ARGS, TicketObj => $TicketObj );
191 push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj );
193 unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
195 Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions);
197 Abort("No permission to view ticket");
200 if ( $ARGS{'MarkAsSeen'} ) {
201 $TicketObj->SetAttribute(
202 Name => 'User-'. $TicketObj->CurrentUser->id .'-SeenUpTo',
203 Content => $TicketObj->LastUpdated,
205 push @Actions, loc('Marked all messages as seen');
211 $title = loc("Ticket #[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject || '');
214 CallbackName => 'BeforeDisplay',
215 TicketObj => \$TicketObj,
216 Tickets => \$Tickets,
217 Actions => \@Actions,
222 # This code does automatic redirection if any updates happen.
223 $m->notes('RedirectToBasics' => 1) if $RedirectToBasics;
224 my $path = '/Ticket/'. ( $m->notes('RedirectToBasics') ? 'Modify.html'
226 MaybeRedirectForResults(
227 Actions => \@Actions,
228 $TicketObj->Type eq 'approval' && RT->Config->Get('ForceApprovalsView')
229 ? (Path => "/Approvals/Display.html", Force => 1)
232 Anchor => $ARGS{'Anchor'},
233 Arguments => { id => $TicketObj->id },
236 # Get the transactoins before the attachments, for great ACL justice
237 my $transactions = $m->comp('Elements/FindTransactions',Ticket => $TicketObj, Tickets => $Tickets || undef);
238 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets);
239 my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj);
242 if (defined $session{'tickets'} and ($ARGS{'Query'} or $session{'CurrentSearchHash'}->{'Query'})) {
243 my $item_map = $session{'tickets'}->ItemMap;
244 $link_rel{first} = "Ticket/Display.html?id=" . $item_map->{first} if $item_map->{$TicketObj->Id}{prev};
245 $link_rel{prev} = "Ticket/Display.html?id=" . $item_map->{$TicketObj->Id}{prev} if $item_map->{$TicketObj->Id}{prev};
246 $link_rel{next} = "Ticket/Display.html?id=" . $item_map->{$TicketObj->Id}{next} if $item_map->{$TicketObj->Id}{next};
247 $link_rel{last} = "Ticket/Display.html?id=" . $item_map->{last} if $item_map->{$TicketObj->Id}{next} && $item_map->{last};