This commit was generated by cvs2svn to compensate for changes in r3921,
[freeside.git] / rt / html / Ticket / Display.html
1 %# {{{ BEGIN BPS TAGGED BLOCK
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2004 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 <& /Ticket/Elements/ShowHistory , 
62       Ticket => $TicketObj, 
63       Tickets => $Tickets, 
64       Collapsed => $ARGS{'Collapsed'}, 
65       ShowHeaders => $ARGS{'ShowHeaders'},
66       Attachments => $attachments,
67       AttachmentContent => $attachment_content
68       
69       &> 
70
71   
72 <%ARGS>
73 $id => undef
74 $Create => undef
75 $ShowHeaders => 0
76 $Collapsed => undef
77 $TicketObj => undef
78 </%ARGS>
79
80 <%INIT>
81
82 $m->comp('/Elements/Callback', _CallbackName => 'Initial', TicketObj => $TicketObj, ARGSRef => \%ARGS);
83
84 my ($linkid, $message, $tid, @Actions, $Tickets);  
85
86 unless ($id || $TicketObj) {
87     Abort('No ticket specified');
88 }
89
90 if ($ARGS{'id'} eq 'new') {
91     # {{{ Create a new ticket
92     
93     my $Queue = new RT::Queue($session{'CurrentUser'}); 
94     unless ($Queue->Load($ARGS{'Queue'})) {
95         Abort('Queue not found');
96     }
97     
98     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
99         Abort('You have no permission to create tickets in that queue.');
100     }
101     ($TicketObj, @Actions) =
102         CreateTicket(Attachments => $session{'Attachments'}, %ARGS);
103     delete $session{'Attachments'};
104     unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
105         Abort("No permission to view newly created ticket #".$TicketObj->id.".");
106         }
107     # }}}
108 } else { 
109     if (!$TicketObj) {
110
111         $TicketObj = RT::Ticket->new($session{'CurrentUser'});
112
113         $TicketObj = LoadTicket($ARGS{'id'});
114         unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
115             Abort("No permission to view ticket");
116         }
117     }
118
119     if (defined $ARGS{'Action'}) {
120         if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
121             my $action = $1;
122             my ($res, $msg)=$TicketObj->$action();
123             push(@Actions, $msg);
124         }
125     }
126
127     $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
128     if ( $ARGS{'UpdateTimeWorked'} ||
129          $session{'Attachments'} || 
130          (   $ARGS{'UpdateContent'} ne ''
131              && $ARGS{'UpdateContent'} ne "-- \n"
132              . $session{'CurrentUser'}->UserObj->Signature )) {
133         $ARGS{UpdateAttachments} = $session{'Attachments'};
134         ProcessUpdateMessage( ARGSRef   => \%ARGS,
135                               Actions   => \@Actions,
136                               TicketObj => $TicketObj );
137         delete $session{'Attachments'};
138     }
139     #Process status updates
140     my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$TicketObj);
141     my @results = ProcessTicketLinks( TicketObj => $TicketObj, ARGSRef => \%ARGS);
142
143     push (@Actions, @BasicActions, @results);
144 }
145
146
147
148 $m->comp('/Elements/Callback', _CallbackName => 'BeforeDisplay',
149          TicketObj => \$TicketObj, Tickets => \$Tickets, ARGSRef => \%ARGS);
150
151
152 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets);
153 my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj);
154
155 </%INIT>