import of rt 3.0.9
[freeside.git] / rt / html / Ticket / Display.html
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <& /Elements/Header, 
25     Title => loc("#[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject) &>
26 <& /Ticket/Elements/Tabs, 
27     Ticket => $TicketObj, 
28     current_tab => 'Ticket/Display.html?id='.$TicketObj->id,
29     Title => loc("#[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject) &>
30
31 <& /Elements/ListActions, actions => \@Actions &>
32
33 <& /Ticket/Elements/ShowSummary,  Ticket => $TicketObj &>
34
35
36 <BR>
37 <& /Ticket/Elements/ShowHistory , 
38       Ticket => $TicketObj, 
39       Collapsed => $ARGS{'Collapsed'}, 
40       ShowHeaders => $ARGS{'ShowHeaders'} &> 
41
42   
43 <%ARGS>
44 $id => undef
45 $Create => undef
46 $ShowHeaders => undef
47 $Collapsed => undef
48 $TicketObj => undef
49 </%ARGS>
50
51 <%INIT>
52   my ($linkid, $message, $tid, @Actions);  
53
54 unless ($id || $TicketObj) {
55     Abort('No ticket specified');
56 }
57
58 if ($ARGS{'id'} eq 'new') {
59     # {{{ Create a new ticket
60     
61     my $Queue = new RT::Queue($session{'CurrentUser'}); 
62     unless ($Queue->Load($ARGS{'Queue'})) {
63         Abort('Queue not found');
64     }
65     
66     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
67         Abort('You have no permission to create tickets in that queue.');
68     }
69     ($TicketObj, @Actions) =
70         CreateTicket(Attachments => $session{'Attachments'}, %ARGS);
71     delete $session{'Attachments'};
72     unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
73         Abort("No permission to view newly created ticket #".$TicketObj->id.".");
74         }
75     # }}}
76 } else { 
77     if (!$TicketObj) {
78
79         $TicketObj = RT::Ticket->new($session{'CurrentUser'});
80
81         $TicketObj = LoadTicket($ARGS{'id'});
82         unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
83             Abort("No permission to view ticket");
84         }
85     }
86
87     if (defined $ARGS{'Action'}) {
88         if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
89             my $action = $1;
90             my ($res, $msg)=$TicketObj->$action();
91             push(@Actions, $msg);
92         }
93     }
94
95     if ( $ARGS{'UpdateContent'} || $session{'Attachments'}) {
96         $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
97         if ( $session{'Attachments'} || 
98              (   $ARGS{'UpdateContent'} ne ''
99                  && $ARGS{'UpdateContent'} ne "-- \n"
100                  . $session{'CurrentUser'}->UserObj->Signature )) {
101             $ARGS{UpdateAttachments} = $session{'Attachments'};
102             ProcessUpdateMessage( ARGSRef   => \%ARGS,
103                                   Actions   => \@Actions,
104                                   TicketObj => $TicketObj );
105             delete $session{'Attachments'};
106         }
107     }
108     #Process status updates
109     my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$TicketObj);
110     my @results = ProcessTicketLinks( TicketObj => $TicketObj, ARGSRef => \%ARGS);                            
111
112     push (@Actions, @BasicActions, @results);
113 }
114 </%INIT>
115
116
117
118