1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
50 <& /Elements/ListActions, actions => \@results &>
52 <table width="100%" class="ticketsummary" >
54 <td valign="top" width="50%" class="boxcontainer">
55 <&| /Widgets/TitleBox, title => loc('The Basics'),
56 title_class=> 'inverse',
58 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
59 <& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket &>
62 <td valign="top" width="50%" class="boxcontainer">
63 <&| /Widgets/TitleBox, title => loc("Dates"),
64 title_class=> 'inverse',
66 <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
74 %#!!pape: selfservice_find_attachments.patch {{
75 <& /Ticket/Elements/ShowHistory,
77 URIFile => "Display.html",
78 ShowHeaders => $ARGS{'ShowHeaders'},
79 AttachPath => "Attachment",
80 Attachments => $attachments,
81 UpdatePath => "Update.html"
83 %#!!pape: selfservice_find_attachments.patch }}
89 my ( $field, @results );
92 #If we get handed two ids, mason will make them an array. bleck.
93 # We want teh first one. Just because there's no other sensible way
95 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
97 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
99 # store the uploaded attachment in session
100 if ( $ARGS{'Attach'} ) { # attachment?
101 $session{'Attachments'} = {} unless defined $session{'Attachments'};
103 my $subject = "$ARGS{'Attach'}";
105 # since CGI.pm deutf8izes the magic field, we need to add it back.
106 Encode::_utf8_on($subject);
108 # strip leading directories
109 $subject =~ s#^.*[\\/]##;
111 my $attachment = MakeMIMEEntity(
114 AttachmentFieldName => 'Attach'
117 $session{'Attachments'} =
118 { %{ $session{'Attachments'} || {} },
119 $ARGS{'Attach'} => $attachment };
122 if ( $id[0] eq 'new' ) {
124 # {{{ Create a new ticket
126 my $Queue = new RT::Queue( $session{'CurrentUser'} );
127 unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
128 $m->comp( 'Error.html', Why => loc('Queue not found') );
132 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
133 $m->comp( 'Error.html',
135 loc('You have no permission to create tickets in that queue.') );
140 ( $Ticket, @results ) =
141 CreateTicket( Attachments => $session{'Attachments'}, %ARGS, Status => 'new' );
143 unless ( $Ticket->id ) {
144 $m->comp( 'Error.html', Why => join( "\n", @results ));
150 # delete temporary storage entry to make WebUI clean
151 unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
152 delete $session{'Attachments'};
158 unless ( $Ticket->Load( $id[0] ) ) {
159 $m->comp( 'Error.html',
160 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
167 if ( ( defined $ARGS{'Status'} )
169 and ( $ARGS{'Status'} ne $Ticket->Status ) )
171 ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
172 push @results, "$msg";
178 $session{'Attachments'}
179 || ( defined $ARGS{'UpdateContent'}
180 && $ARGS{'UpdateContent'} ne ''
181 && $ARGS{'UpdateContent'} ne "-- \n"
182 . $session{'CurrentUser'}->UserObj->Signature )
185 $ARGS{UpdateAttachments} = $session{'Attachments'};
187 ProcessUpdateMessage(
189 Actions => \@results,
192 delete $session{'Attachments'};
194 # delete temporary storage entry to make WebUI clean
195 unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
196 delete $session{'Attachments'};
199 my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
200 push (@results, @cfupdates);
206 # This code does automatic redirection if any updates happen.
208 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
209 $m->comp( 'Error.html',
210 Why => loc("No permission to display that ticket") );
215 # We've done something, so we need to clear the decks to avoid
216 # resubmission on refresh.
217 # But we need to store Actions somewhere too, so we don't lose them.
218 $session{"Actions"} = \@results;
219 RT::Interface::Web::Redirect($RT::WebURL."SelfService/Display.html?id="
222 @results = @{ delete $session{"Actions"} || [] };
225 my $Transactions = $Ticket->Transactions;
228 $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );