3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
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
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.
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.
24 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
26 <& /Elements/ListActions, actions => \@results &>
28 <TABLE WIDTH="100%" class="ticketsummary" >
30 <TD VALIGN=TOP WIDTH="50%">
31 <& /Elements/TitleBoxStart, title => loc('The Basics'),
32 title_class=> 'inverse',
34 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
35 <& /Elements/TitleBoxEnd &>
37 <TD VALIGN=TOP WIDTH="50%">
38 <& /Elements/TitleBoxStart, title => loc("Dates"),
39 title_class=> 'inverse',
41 <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
42 <& /Elements/TitleBoxEnd &>
49 %#!!pape: selfservice_find_attachments.patch {{
50 <& /Ticket/Elements/ShowHistory, Ticket => $Ticket, AttachPath => "Attachment", Attachments => $attachments, UpdatePath => "Update.html" &>
51 %#!!pape: selfservice_find_attachments.patch }}
57 my ( $field, @results );
60 #If we get handed two ids, mason will make them an array. bleck.
61 # We want teh first one. Just because there's no other sensible way
63 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
65 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
66 if ( $id[0] eq 'new' ) {
68 # {{{ Create a new ticket
70 my $Queue = new RT::Queue( $session{'CurrentUser'} );
71 unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
72 $m->comp( 'Error.html', Why => loc('Queue not found') );
76 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
77 $m->comp( 'Error.html',
79 loc('You have no permission to create tickets in that queue.') );
83 my @Requestors = split ( /\s*,\s*/, $ARGS{'Requestors'} );
84 my @Cc = split ( /\s*,\s*/, $ARGS{'Cc'} );
86 my $MIMEObj = MakeMIMEEntity( Subject => $ARGS{'Subject'},
87 From => $ARGS{'From'},
89 Body => $ARGS{'Content'},
90 AttachmentFieldName => 'Attach' );
92 #TODO in Create_Details.html: priorities and due-date
93 my ( $id, $Trans, $ErrMsg ) = $Ticket->Create( Queue => $ARGS{Queue},
94 Requestor => \@Requestors,
96 Subject => $ARGS{Subject},
97 MIMEObj => $MIMEObj );
98 unless ( $id && $Trans ) {
99 $m->comp( 'Error.html', Why => $ErrMsg );
103 push ( @results, $ErrMsg );
107 # delete temporary storage entry to make WebUI clean
108 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
109 delete $session{'Attachments'};
114 unless ( $Ticket->Load( $id[0] ) ) {
115 $m->comp( 'Error.html',
116 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
123 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
124 $m->comp( 'Error.html',
125 Why => loc("No permission to display that ticket") );
132 if ( ( defined $ARGS{'Status'} )
133 and ( $ARGS{'Status'} ne $Ticket->Status ) ) {
134 ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
135 push @results, "$msg";
138 # {{{ store the uploaded attachment in session
139 if ($ARGS{'Attach'}) { # attachment?
140 $session{'Attachments'} = {} unless defined $session{'Attachments'};
142 my $subject = "$ARGS{'Attach'}";
143 # since CGI.pm deutf8izes the magic field, we need to add it back.
144 Encode::_utf8_on($subject);
145 # strip leading directories
146 $subject =~ s#^.*[\\/]##;
148 my $attachment = MakeMIMEEntity(
151 AttachmentFieldName => 'Attach'
154 $session{'Attachments'} = { %{$session{'Attachments'} || {}},
155 $ARGS{'Attach'} => $attachment };
159 if ( $session{'Attachments'} ||
160 ( $ARGS{'UpdateContent'} ne ''
161 && $ARGS{'UpdateContent'} ne "-- \n"
162 . $session{'CurrentUser'}->UserObj->Signature )) {
163 $ARGS{UpdateAttachments} = $session{'Attachments'};
165 ProcessUpdateMessage( ARGSRef => \%ARGS,
166 Actions => \@results,
167 TicketObj => $Ticket );
169 # delete temporary storage entry to make WebUI clean
170 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
171 delete $session{'Attachments'};
175 my $Transactions = $Ticket->Transactions;
177 #!!pape: selfservice_find_attachments.patch {{
178 my $attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
179 #!!pape: selfservice_find_attachments.patch }}