import rt 3.8.10
[freeside.git] / rt / html / Ticket / Display.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC 
6 %#                                          <jesse@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 => loc("#[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject) &>
50 <& /Ticket/Elements/Tabs, 
51     Ticket => $TicketObj, 
52     current_tab => 'Ticket/Display.html?id='.$TicketObj->id,
53     Title => loc("#[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject) &>
54
55 <& /Elements/ListActions, actions => \@Actions &>
56 <& /Elements/Callback, _CallbackName => 'BeforeShowSummary', Ticket => $TicketObj, %ARGS &>
57 <&| /Widgets/TitleBox, title => loc('Ticket metadata') &>
58 <& /Ticket/Elements/ShowSummary,  Ticket => $TicketObj, Attachments => $attachments &>
59 </&>
60
61 <br />
62
63 <& /Elements/Callback, _CallbackName => 'BeforeShowHistory', Ticket => $TicketObj, %ARGS &>
64
65 <& /Ticket/Elements/ShowHistory , 
66       Ticket => $TicketObj, 
67       Tickets => $Tickets, 
68       Collapsed => $ARGS{'Collapsed'}, 
69       ShowHeaders => $ARGS{'ShowHeaders'},
70       Attachments => $attachments,
71       AttachmentContent => $attachment_content
72       
73       &> 
74
75 <& /Elements/Callback, _CallbackName => 'AfterShowHistory', Ticket => $TicketObj, 
76 current_tab => 'Ticket/Display.html?id=' . $TicketObj->id, %ARGS &>
77
78 <%ARGS>
79 $id => undef
80 $Create => undef
81 $ShowHeaders => 0
82 $Collapsed => undef
83 $TicketObj => undef
84 </%ARGS>
85
86 <%INIT>
87
88 $m->comp('/Elements/Callback', _CallbackName => 'Initial', TicketObj => $TicketObj, ARGSRef => \%ARGS);
89
90 my ($linkid, $message, $tid, @Actions, $Tickets);  
91
92 unless ($id || $TicketObj) {
93     Abort('No ticket specified');
94 }
95
96 if ($ARGS{'id'} eq 'new') {
97     # {{{ Create a new ticket
98     
99     my $Queue = new RT::Queue($session{'CurrentUser'}); 
100     unless ($Queue->Load($ARGS{'Queue'})) {
101         Abort('Queue not found');
102     }
103     
104     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
105         Abort('You have no permission to create tickets in that queue.');
106     }
107     ($TicketObj, @Actions) =
108         CreateTicket(Attachments => $session{'Attachments'}, %ARGS);
109     delete $session{'Attachments'};
110     unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
111         Abort("No permission to view newly created ticket #".$TicketObj->id.".");
112         }
113     # }}}
114 } else { 
115     if (!$TicketObj) {
116
117         $TicketObj = RT::Ticket->new($session{'CurrentUser'});
118
119         $TicketObj = LoadTicket($ARGS{'id'});
120         unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
121             Abort("No permission to view ticket");
122         }
123     }
124
125     $m->comp('/Elements/Callback', _CallbackName => 'BeforeProcessArguments',
126          TicketObj => $TicketObj, Tickets => $Tickets, 
127          ActionsRef => \@Actions, ARGSRef => \%ARGS);
128
129     if (defined $ARGS{'Action'}) {
130         if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
131             my $action = $1;
132             my ($res, $msg)=$TicketObj->$action();
133             push(@Actions, $msg);
134         }
135     }
136
137     $ARGS{'UpdateContent'} =~ s/\r\n/\n/g if defined $ARGS{'UpdateContent'};
138     if ( ( defined $ARGS{'UpdateContent'}
139         && $ARGS{'UpdateContent'} ne ''
140             && $ARGS{'UpdateContent'} ne "-- \n"
141                . $session{'CurrentUser'}->UserObj->Signature ) || $session{'Attachments'} )
142     {
143             $ARGS{UpdateAttachments} = $session{'Attachments'};
144             ProcessUpdateMessage(
145             ARGSRef   => \%ARGS,
146                         Actions   => \@Actions,
147                         TicketObj => $TicketObj,
148         );
149             delete $session{'Attachments'};
150     } elsif ( $ARGS{'UpdateTimeWorked'} ) {
151         # Add UpdateTimeWorked to TimeWorked (processed below with ProcessTicketBasics)
152         $ARGS{'TimeWorked'} = $TicketObj->TimeWorked + $ARGS{'UpdateTimeWorked'};
153     }
154     #Process status updates
155     my @PeopleActions = ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj=>$TicketObj);
156     my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$TicketObj);
157     my @results = ProcessTicketLinks( TicketObj => $TicketObj, ARGSRef => \%ARGS);
158
159     push (@Actions, @PeopleActions, @BasicActions, @results);
160 }
161
162 $m->comp('/Elements/Callback', _CallbackName => 'BeforeDisplay',
163          TicketObj => \$TicketObj,
164      Tickets => \$Tickets,
165      Actions => \@Actions,
166      ARGSRef => \%ARGS,
167 );
168
169 # This code does automatic redirection if any updates happen. 
170
171 if (@Actions) {
172     # We've done something, so we need to clear the decks to avoid 
173     # resubmission on refresh.
174     # But we need to store Actions somewhere too, so we don't lose them.
175     $session{"Actions"} = \@Actions;
176     RT::Interface::Web::Redirect($RT::WebURL."Ticket/Display.html?id=".$TicketObj->id);
177 } else {
178     @Actions = @{ delete $session{"Actions"} || [] };
179 }
180
181 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets);
182 my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj);
183
184 </%INIT>