1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
6 %# <sales@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 % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket );
52 <& /Elements/ListActions, actions => \@results &>
54 <table width="100%" class="ticketsummary" >
56 <td valign="top" width="50%" class="boxcontainer">
57 <&| /Widgets/TitleBox, title => loc('The Basics'),
58 ($LinkBasicsTitle ? (title_href => $title_box_link) : ()),
59 title_class=> 'inverse',
61 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
62 <& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket &>
65 <td valign="top" width="50%" class="boxcontainer">
66 <&| /Widgets/TitleBox, title => loc("Dates"),
67 title_class=> 'inverse',
69 <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
77 %#!!pape: selfservice_find_attachments.patch {{
78 <& /Ticket/Elements/ShowHistory,
80 URIFile => "Display.html",
81 ShowHeaders => $ARGS{'ShowHeaders'},
82 DownloadableHeaders => 0,
83 AttachPath => "Attachment",
84 Attachments => $attachments,
85 UpdatePath => "Update.html"
87 %#!!pape: selfservice_find_attachments.patch }}
93 my ( $field, @results );
95 $m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
98 #If we get handed two ids, mason will make them an array. bleck.
99 # We want teh first one. Just because there's no other sensible way
101 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
103 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
105 # store the uploaded attachment in session
106 if ( $ARGS{'Attach'} ) { # attachment?
107 $session{'Attachments'} = {} unless defined $session{'Attachments'};
109 my $attachment = MakeMIMEEntity(
110 AttachmentFieldName => 'Attach'
113 my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
114 $session{'Attachments'} = {
115 %{ $session{'Attachments'} || {} },
116 $file_path => $attachment,
120 if ( defined ($id[0]) && $id[0] eq 'new' ) {
122 # {{{ Create a new ticket
124 my $Queue = new RT::Queue( $session{'CurrentUser'} );
125 unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
126 $m->comp( 'Error.html', Why => loc('Queue not found') );
130 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
131 $m->comp( 'Error.html',
133 loc('You have no permission to create tickets in that queue.') );
138 ( $Ticket, @results ) =
139 CreateTicket( Attachments => $session{'Attachments'}, %ARGS, Status => 'new' );
141 unless ( $Ticket->id ) {
142 $m->comp( 'Error.html', Why => join( "\n", @results ));
148 # delete temporary storage entry to make WebUI clean
149 unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
150 delete $session{'Attachments'};
156 unless ( $Ticket->Load( $id[0] ) ) {
157 $m->comp( 'Error.html',
158 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
166 $session{'Attachments'}
167 || ( defined $ARGS{'UpdateContent'}
168 && $ARGS{'UpdateContent'} ne ''
169 && $ARGS{'UpdateContent'} ne "-- \n"
170 . $session{'CurrentUser'}->UserObj->Signature )
173 $ARGS{UpdateAttachments} = $session{'Attachments'};
175 push @results, ProcessUpdateMessage(
179 delete $session{'Attachments'};
181 # delete temporary storage entry to make WebUI clean
182 unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
183 delete $session{'Attachments'};
186 my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
187 push (@results, @cfupdates);
192 if ( ( defined $ARGS{'Status'} )
194 and ( $ARGS{'Status'} ne $Ticket->Status ) )
196 ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
197 push @results, "$msg";
204 # This code does automatic redirection if any updates happen.
206 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
207 $m->comp( 'Error.html',
208 Why => loc("No permission to display that ticket") );
209 # XXX: Why abort? then we loose footer //ruz
214 # We've done something, so we need to clear the decks to avoid
215 # resubmission on refresh.
216 # But we need to store Actions somewhere too, so we don't lose them.
217 my $key = Digest::MD5::md5_hex(rand(1024));
218 push @{ $session{"Actions"}->{$key} ||= [] }, @results;
220 RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."SelfService/Display.html?id=". $Ticket->id."&results=".$key);
223 my $Transactions = $Ticket->Transactions;
226 $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );
228 my $LinkBasicsTitle = $Ticket->CurrentUserHasRight('ModifyTicket')
229 || $Ticket->CurrentUserHasRight('ReplyToTicket');
230 my $title_box_link = RT->Config->Get('WebPath')."/SelfService/Update.html?id=".$Ticket->Id;
231 $m->callback(CallbackName => 'BeforeDisplay', Ticket => \$Ticket, ARGSRef => \%ARGS, title_box_link => \$title_box_link);