1 %# {{{ BEGIN BPS TAGGED BLOCK
5 %# This software is Copyright (c) 1996-2004 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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
45 %# }}} END BPS TAGGED BLOCK
46 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
48 <& /Elements/ListActions, actions => \@results &>
50 <TABLE WIDTH="100%" class="ticketsummary" >
52 <TD VALIGN=TOP WIDTH="50%" class="boxcontainer">
53 <& /Elements/TitleBoxStart, title => loc('The Basics'),
54 title_class=> 'inverse',
56 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
57 <& /Elements/TitleBoxEnd &>
59 <TD VALIGN=TOP WIDTH="50%" class="boxcontainer">
60 <& /Elements/TitleBoxStart, title => loc("Dates"),
61 title_class=> 'inverse',
63 <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
64 <& /Elements/TitleBoxEnd &>
71 %#!!pape: selfservice_find_attachments.patch {{
72 <& /Ticket/Elements/ShowHistory, Ticket => $Ticket, AttachPath => "Attachment", Attachments => $attachments, UpdatePath => "Update.html" &>
73 %#!!pape: selfservice_find_attachments.patch }}
79 my ( $field, @results );
82 #If we get handed two ids, mason will make them an array. bleck.
83 # We want teh first one. Just because there's no other sensible way
85 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
87 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
88 if ( $id[0] eq 'new' ) {
90 # {{{ Create a new ticket
92 my $Queue = new RT::Queue( $session{'CurrentUser'} );
93 unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
94 $m->comp( 'Error.html', Why => loc('Queue not found') );
98 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
99 $m->comp( 'Error.html',
101 loc('You have no permission to create tickets in that queue.') );
105 my @Requestors = split ( /\s*,\s*/, $ARGS{'Requestors'} );
106 my @Cc = split ( /\s*,\s*/, $ARGS{'Cc'} );
108 my $MIMEObj = MakeMIMEEntity( Subject => $ARGS{'Subject'},
109 From => $ARGS{'From'},
111 Body => $ARGS{'Content'},
112 AttachmentFieldName => 'Attach' );
114 #TODO in Create_Details.html: priorities and due-date
115 my ( $id, $Trans, $ErrMsg ) = $Ticket->Create( Queue => $ARGS{Queue},
116 Requestor => \@Requestors,
118 Subject => $ARGS{Subject},
119 MIMEObj => $MIMEObj );
120 unless ( $id && $Trans ) {
121 $m->comp( 'Error.html', Why => $ErrMsg );
125 push ( @results, $ErrMsg );
129 # delete temporary storage entry to make WebUI clean
130 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
131 delete $session{'Attachments'};
136 unless ( $Ticket->Load( $id[0] ) ) {
137 $m->comp( 'Error.html',
138 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
145 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
146 $m->comp( 'Error.html',
147 Why => loc("No permission to display that ticket") );
154 if ( ( defined $ARGS{'Status'} ) and $ARGS{'Status'}
155 and ( $ARGS{'Status'} ne $Ticket->Status ) ) {
156 ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
157 push @results, "$msg";
160 # {{{ store the uploaded attachment in session
161 if ($ARGS{'Attach'}) { # attachment?
162 $session{'Attachments'} = {} unless defined $session{'Attachments'};
164 my $subject = "$ARGS{'Attach'}";
165 # since CGI.pm deutf8izes the magic field, we need to add it back.
166 Encode::_utf8_on($subject);
167 # strip leading directories
168 $subject =~ s#^.*[\\/]##;
170 my $attachment = MakeMIMEEntity(
173 AttachmentFieldName => 'Attach'
176 $session{'Attachments'} = { %{$session{'Attachments'} || {}},
177 $ARGS{'Attach'} => $attachment };
181 if ( $session{'Attachments'} ||
182 ( $ARGS{'UpdateContent'} ne ''
183 && $ARGS{'UpdateContent'} ne "-- \n"
184 . $session{'CurrentUser'}->UserObj->Signature )) {
185 $ARGS{UpdateAttachments} = $session{'Attachments'};
187 ProcessUpdateMessage( ARGSRef => \%ARGS,
188 Actions => \@results,
189 TicketObj => $Ticket );
191 # delete temporary storage entry to make WebUI clean
192 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
193 delete $session{'Attachments'};
197 my $Transactions = $Ticket->Transactions;
199 #!!pape: selfservice_find_attachments.patch {{
200 my $attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
201 #!!pape: selfservice_find_attachments.patch }}