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 <& /Elements/Header, Title => $title &>
49 <& /Ticket/Elements/Tabs,
53 % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
54 <& /Elements/ListActions, actions => \@results &>
56 <form action="Update.html" name="TicketUpdate"
57 method="post" enctype="multipart/form-data">
58 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS, Ticket => $TicketObj, CanRespond => $CanRespond, CanComment => $CanComment, ResponseDefault => $ResponseDefault, CommentDefault => $CommentDefault );
59 <input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction}||'' %>" />
60 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
61 <input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
63 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
65 <table width="100%" border="0">
66 % $m->callback(CallbackName => 'AfterTableOpens', ARGSRef => \%ARGS, Ticket => $TicketObj);
68 <tr><td class="label"><&|/l&>Status</&>:</td>
70 <& /Elements/SelectStatus, Name=>"Status", DefaultLabel => loc("[_1] (Unchanged)", loc($TicketObj->Status)), Default => $ARGS{'Status'} || ($TicketObj->Status eq $DefaultStatus ? undef : $DefaultStatus)&>
71 <span class="label"><&|/l&>Owner</&>:</span>
72 <& /Elements/SelectOwner,
74 TicketObj => $TicketObj,
75 QueueObj => $TicketObj->QueueObj,
76 DefaultLabel => loc("[_1] (Unchanged)", $TicketObj->OwnerObj->Name),
77 Default => $ARGS{'Owner'}
79 <span class="label"><&|/l&>Worked</&>:</span>
80 <& /Elements/EditTimeValue,
81 Name => 'UpdateTimeWorked',
82 Default => $ARGS{UpdateTimeWorked}||'',
83 InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
87 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
89 <input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
91 <tr><td class="label"><&|/l&>Update Type</&>:</td>
92 <td><select name="UpdateType">
94 <option value="private" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
97 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
100 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
102 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size="60" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject()%>" />
103 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
106 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
108 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj &>
110 % if (exists $session{'Attachments'}) {
111 <tr><td><&|/l&>Attached file</&>:</td>
113 <&|/l&>Check box to delete</&><br />
114 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
115 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
121 <tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" /><input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" /><input type="hidden" class="hidden" name="UpdateAttach" value="1" />
124 % if ( $gnupg_widget ) {
125 <tr><td> </td><td>
126 <& /Elements/GnuPG/SignEncryptWidget,
127 self => $gnupg_widget,
128 TicketObj => $TicketObj,
132 % $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
134 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td><td>
135 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
136 % if (exists $ARGS{UpdateContent}) {
137 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
138 % my $temp = $ARGS{'QuoteTransaction'};
139 % delete $ARGS{'QuoteTransaction'};
140 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
141 % $ARGS{'QuoteTransaction'} = $temp;
143 % my $IncludeSignature = 1;
144 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
145 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
153 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
154 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
155 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &>
156 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
164 my $checks_failure = 0;
167 my $TicketObj = LoadTicket($id);
171 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, results => \@results, CallbackName => 'Initial' );
173 unless($DefaultStatus){
174 $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
177 if ($DefaultStatus eq 'new'){
178 $DefaultStatus='open';
181 if ($DefaultStatus eq 'resolved') {
182 $title = loc("Resolve ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
184 $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
187 # Things needed in the template - we'll do the processing here, just
188 # for the convenience:
190 my ($CommentDefault, $ResponseDefault);
191 if ($Action ne 'Respond') {
192 $CommentDefault = qq[ selected="selected"];
193 $ResponseDefault = "";
195 $CommentDefault = "";
196 $ResponseDefault = qq[ selected="selected"];
201 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
202 $TicketObj->CurrentUserHasRight('ModifyTicket') );
204 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
205 $TicketObj->CurrentUserHasRight('ModifyTicket') );
208 # {{{ deal with deleting uploaded attachments
209 foreach my $key (keys %ARGS) {
210 if ($key =~ m/^DeleteAttach-(.+)$/) {
211 delete $session{'Attachments'}{$1};
213 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
217 # {{{ store the uploaded attachment in session
218 if ($ARGS{'Attach'}) { # attachment?
219 my $attachment = MakeMIMEEntity(
220 AttachmentFieldName => 'Attach'
223 my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
224 $session{'Attachments'} = {
225 %{$session{'Attachments'} || {}},
226 $file_path => $attachment,
231 # delete temporary storage entry to make WebUI clean
232 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
233 delete $session{'Attachments'};
237 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
238 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
239 self => $gnupg_widget,
240 TicketObj => $TicketObj,
243 if ( $ARGS{'SubmitTicket'} ) {
244 my $CFs = $TicketObj->TransactionCustomFields;
245 my $ValidCFs = $m->comp(
246 '/Elements/ValidateCustomFields',
247 CustomFields => $CFs,
248 NamePrefix => "Object-RT::Transaction--CustomField-",
251 unless ( $ValidCFs ) {
253 while (my $CF = $CFs->Next) {
254 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
255 push @results, loc($CF->Name) . ': ' . $msg;
258 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
259 self => $gnupg_widget,
260 TicketObj => $TicketObj,
262 $checks_failure = 1 unless $status;
265 # check email addresses for RT's
267 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
268 my $value = $ARGS{ $field };
269 next unless defined $value && length $value;
271 my @emails = Email::Address->parse( $value );
272 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
273 push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc(substr($field, 6)) );
277 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
281 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
282 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
283 return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
290 $DefaultStatus => undef