import rt 3.0.12
[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, Attachments => $attachments &>
34
35
36 <BR>
37 <& /Ticket/Elements/ShowHistory , 
38       Ticket => $TicketObj, 
39       Collapsed => $ARGS{'Collapsed'}, 
40       ShowHeaders => $ARGS{'ShowHeaders'},
41       Attachments => $attachments,
42       AttachmentContent => $attachment_content
43       
44       &> 
45
46   
47 <%ARGS>
48 $id => undef
49 $Create => undef
50 $ShowHeaders => undef
51 $Collapsed => undef
52 $TicketObj => undef
53 </%ARGS>
54
55 <%INIT>
56   my ($linkid, $message, $tid, @Actions);  
57
58 unless ($id || $TicketObj) {
59     Abort('No ticket specified');
60 }
61
62 if ($ARGS{'id'} eq 'new') {
63     # {{{ Create a new ticket
64     
65     my $Queue = new RT::Queue($session{'CurrentUser'}); 
66     unless ($Queue->Load($ARGS{'Queue'})) {
67         Abort('Queue not found');
68     }
69     
70     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
71         Abort('You have no permission to create tickets in that queue.');
72     }
73     ($TicketObj, @Actions) =
74         CreateTicket(Attachments => $session{'Attachments'}, %ARGS);
75     delete $session{'Attachments'};
76     unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
77         Abort("No permission to view newly created ticket #".$TicketObj->id.".");
78         }
79     # }}}
80 } else { 
81     if (!$TicketObj) {
82
83         $TicketObj = RT::Ticket->new($session{'CurrentUser'});
84
85         $TicketObj = LoadTicket($ARGS{'id'});
86         unless ($TicketObj->CurrentUserHasRight('ShowTicket')) {
87             Abort("No permission to view ticket");
88         }
89     }
90
91     if (defined $ARGS{'Action'}) {
92         if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
93             my $action = $1;
94             my ($res, $msg)=$TicketObj->$action();
95             push(@Actions, $msg);
96         }
97     }
98
99     $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
100     if ( $ARGS{'UpdateTimeWorked'} ||
101          $session{'Attachments'} || 
102          (   $ARGS{'UpdateContent'} ne ''
103              && $ARGS{'UpdateContent'} ne "-- \n"
104              . $session{'CurrentUser'}->UserObj->Signature )) {
105         $ARGS{UpdateAttachments} = $session{'Attachments'};
106         ProcessUpdateMessage( ARGSRef   => \%ARGS,
107                               Actions   => \@Actions,
108                               TicketObj => $TicketObj );
109         delete $session{'Attachments'};
110     }
111     #Process status updates
112     my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$TicketObj);
113     my @results = ProcessTicketLinks( TicketObj => $TicketObj, ARGSRef => \%ARGS);                            
114
115     push (@Actions, @BasicActions, @results);
116 }
117
118 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj);
119 my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj);
120
121
122 </%INIT>
123
124
125
126