This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / rt / html / Ticket / Display.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
35 %# 
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
44 %# 
45 %# END BPS TAGGED BLOCK }}}
46 <& /Elements/Header, 
47     Title => loc("#[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject) &>
48 <& /Ticket/Elements/Tabs, 
49     Ticket => $TicketObj, 
50     current_tab => 'Ticket/Display.html?id='.$TicketObj->id,
51     Title => loc("#[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject) &>
52
53 <& /Elements/ListActions, actions => \@Actions &>
54
55 <& /Elements/TitleBoxStart, title => loc('Ticket metadata'), contentbg =>
56 '#ffffff' &>
57 <& /Ticket/Elements/ShowSummary,  Ticket => $TicketObj, Attachments => $attachments &>
58 <& /Elements/TitleBoxEnd &>
59
60 <BR>
61
62 <& /Elements/Callback, _CallbackName => 'BeforeShowHistory', Ticket => $TicketObj, %ARGS &>
63
64 <& /Ticket/Elements/ShowHistory , 
65       Ticket => $TicketObj, 
66       Tickets => $Tickets, 
67       Collapsed => $ARGS{'Collapsed'}, 
68       ShowHeaders => $ARGS{'ShowHeaders'},
69       Attachments => $attachments,
70       AttachmentContent => $attachment_content
71       
72       &> 
73
74   
75 <%ARGS>
76 $id => undef
77 $Create => undef
78 $ShowHeaders => 0
79 $Collapsed => undef
80 $TicketObj => undef
81 </%ARGS>
82
83 <%INIT>
84
85 $m->comp('/Elements/Callback', _CallbackName => 'Initial', TicketObj => $TicketObj, ARGSRef => \%ARGS);
86
87 my ($linkid, $message, $tid, @Actions, $Tickets);  
88
89 unless ($id || $TicketObj) {
90     Abort('No ticket specified');
91 }
92
93 if ($ARGS{'id'} eq 'new') {
94     # {{{ Create a new ticket
95     
96     my $Queue = new RT::Queue($session{'CurrentUser'}); 
97     unless ($Queue->Load($ARGS{'Queue'})) {
98         Abort('Queue not found');
99     }
100     
101     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
102         Abort('You have no permission to create tickets in that queue.');
103     }
104     ($TicketObj, @Actions) =
105         CreateTicket(Attachments => $session{'Attachments'}, %ARGS);
106     delete $session{'Attachments'};
107     unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
108         Abort("No permission to view newly created ticket #".$TicketObj->id.".");
109         }
110     # }}}
111 } else { 
112     if (!$TicketObj) {
113
114         $TicketObj = RT::Ticket->new($session{'CurrentUser'});
115
116         $TicketObj = LoadTicket($ARGS{'id'});
117         unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
118             Abort("No permission to view ticket");
119         }
120     }
121
122     if (defined $ARGS{'Action'}) {
123         if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
124             my $action = $1;
125             my ($res, $msg)=$TicketObj->$action();
126             push(@Actions, $msg);
127         }
128     }
129
130     $ARGS{'UpdateContent'} =~ s/\r\n/\n/g if defined $ARGS{'UpdateContent'};
131     if ( $ARGS{'UpdateTimeWorked'} ||
132          $session{'Attachments'} || 
133          (   defined $ARGS{'UpdateContent'}
134              && $ARGS{'UpdateContent'} ne ''
135              && $ARGS{'UpdateContent'} ne "-- \n"
136              . $session{'CurrentUser'}->UserObj->Signature )) {
137         $ARGS{UpdateAttachments} = $session{'Attachments'};
138         ProcessUpdateMessage( ARGSRef   => \%ARGS,
139                               Actions   => \@Actions,
140                               TicketObj => $TicketObj );
141         delete $session{'Attachments'};
142     }
143     #Process status updates
144     my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$TicketObj);
145     my @results = ProcessTicketLinks( TicketObj => $TicketObj, ARGSRef => \%ARGS);
146
147     push (@Actions, @BasicActions, @results);
148 }
149
150
151
152 $m->comp('/Elements/Callback', _CallbackName => 'BeforeDisplay',
153          TicketObj => \$TicketObj, Tickets => \$Tickets, ARGSRef => \%ARGS);
154
155
156 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets);
157 my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj);
158
159 </%INIT>