import rt 3.4.6
[freeside.git] / rt / html / SelfService / 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 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
47
48 <& /Elements/ListActions, actions => \@results &>
49
50   <TABLE WIDTH="100%" class="ticketsummary" >
51       <TR>
52         <TD VALIGN=TOP WIDTH="50%" class="boxcontainer">
53           <& /Elements/TitleBoxStart, title => loc('The Basics'), 
54                 title_class=> 'inverse',  
55                 color => "#993333" &>
56                 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
57                 <& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket &>
58           <& /Elements/TitleBoxEnd &>
59 </TD>
60         <TD VALIGN=TOP WIDTH="50%" class="boxcontainer">
61           <& /Elements/TitleBoxStart, title => loc("Dates"),
62                 title_class=> 'inverse',
63                  color => "#663366" &>
64           <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
65           <& /Elements/TitleBoxEnd &>
66 </TD>
67 </TR>
68 </TABLE>
69
70
71
72 %#!!pape: selfservice_find_attachments.patch {{
73 <& /Ticket/Elements/ShowHistory, 
74       Ticket => $Ticket, 
75       URIFile => "Display.html", 
76       ShowHeaders => $ARGS{'ShowHeaders'},
77       AttachPath => "Attachment", 
78       Attachments => $attachments, 
79       UpdatePath => "Update.html" 
80 &>
81 %#!!pape: selfservice_find_attachments.patch }}
82
83
84
85 <%INIT>
86
87 my ( $field, @results );
88
89 # {{{ Load the ticket
90 #If we get handed two ids, mason will make them an array. bleck.
91 # We want teh first one. Just because there's no other sensible way
92 # to deal
93 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
94
95 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
96
97 # store the uploaded attachment in session
98 if ( $ARGS{'Attach'} ) {    # attachment?
99     $session{'Attachments'} = {} unless defined $session{'Attachments'};
100
101     my $subject = "$ARGS{'Attach'}";
102
103     # since CGI.pm deutf8izes the magic field, we need to add it back.
104     Encode::_utf8_on($subject);
105
106     # strip leading directories
107     $subject =~ s#^.*[\\/]##;
108
109     my $attachment = MakeMIMEEntity(
110         Subject             => $subject,
111         Body                => "",
112         AttachmentFieldName => 'Attach'
113     );
114
115     $session{'Attachments'} =
116     { %{ $session{'Attachments'} || {} },
117         $ARGS{'Attach'} => $attachment };
118 }
119
120 if ( $id[0] eq 'new' ) {
121
122     # {{{ Create a new ticket
123
124     my $Queue = new RT::Queue( $session{'CurrentUser'} );
125     unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
126         $m->comp( 'Error.html', Why => loc('Queue not found') );
127         $m->abort;
128     }
129
130     unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
131         $m->comp( 'Error.html',
132             Why =>
133               loc('You have no permission to create tickets in that queue.') );
134         $m->abort;
135     }
136
137
138     ( $Ticket, @results ) =
139     CreateTicket( Attachments => $session{'Attachments'}, %ARGS, Status => 'new' );
140
141     unless ( $Ticket->id ) {
142         $m->comp( 'Error.html', Why => join( "\n", @results ));
143               $m->abort();
144         }
145
146         # }}}
147
148         # delete temporary storage entry to make WebUI clean
149         unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
150             delete $session{'Attachments'};
151         }
152
153         # }}}
154     }
155     else {
156         unless ( $Ticket->Load( $id[0] ) ) {
157             $m->comp( 'Error.html',
158                 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
159             $m->abort();
160         }
161     }
162
163     # }}}
164
165     unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
166         $m->comp( 'Error.html',
167             Why => loc("No permission to display that ticket") );
168         $m->abort();
169     }
170
171     my ( $code, $msg );
172
173     #Update the status
174     if (    ( defined $ARGS{'Status'} )
175         and $ARGS{'Status'}
176         and ( $ARGS{'Status'} ne $Ticket->Status ) )
177     {
178         ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
179         push @results, "$msg";
180     }
181
182     # }}}
183
184     if (
185         $session{'Attachments'}
186         || (   $ARGS{'UpdateContent'} ne ''
187             && $ARGS{'UpdateContent'} ne "-- \n"
188             . $session{'CurrentUser'}->UserObj->Signature )
189       )
190     {
191         $ARGS{UpdateAttachments} = $session{'Attachments'};
192     }
193     ProcessUpdateMessage(
194         ARGSRef   => \%ARGS,
195         Actions   => \@results,
196         TicketObj => $Ticket
197     );
198
199     # delete temporary storage entry to make WebUI clean
200     unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
201         delete $session{'Attachments'};
202     }
203
204     my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
205     push (@results, @cfupdates);
206
207     # }}}
208
209     my $Transactions = $Ticket->Transactions;
210
211     my $attachments =
212       $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );
213
214 </%INIT>
215
216
217 <%ARGS>
218 $id => undef
219 </%ARGS>