1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2013 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 <& /Elements/Header, Title => $title &>
51 % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
52 <& /Elements/ListActions, actions => \@results &>
54 <form action="Update.html" name="TicketUpdate"
55 method="post" enctype="multipart/form-data">
56 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS, Ticket => $TicketObj, CanRespond => $CanRespond, CanComment => $CanComment, ResponseDefault => $ResponseDefault, CommentDefault => $CommentDefault );
57 <input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction}||'' %>" />
58 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
59 <input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
61 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
63 <div id="ticket-update-metadata">
64 <&|/Widgets/TitleBox, title => loc('Ticket and Transaction') &>
65 <table width="100%" border="0">
66 % $m->callback(CallbackName => 'AfterTableOpens', ARGSRef => \%ARGS, Ticket => $TicketObj);
69 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
71 <input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
73 <tr><td class="label"><&|/l&>Update Type</&>:</td>
74 <td><select name="UpdateType" id="UpdateType">
76 <option value="private" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
79 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
83 <script type="text/javascript">
85 jQuery("#UpdateType").change(function(ev) {
86 jQuery(".messagebox-container")
87 .removeClass("action-response action-private")
88 .addClass("action-"+ev.target.value);
92 jQuery("input[name=TxnSendMailTo]").change(function(ev) {
93 jQuery("input[name=TxnSendMailTo][value="+ev.target.value+"]")
94 .attr("checked",jQuery(ev.target).attr('checked'));
99 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
102 <& /Ticket/Elements/EditBasics,
103 TicketObj => $TicketObj,
107 comp => '/Elements/SelectStatus',
110 DefaultLabel => loc("[_1] (Unchanged)", loc($TicketObj->Status)),
111 Default => $ARGS{'Status'} || ($TicketObj->Status eq $DefaultStatus ? undef : $DefaultStatus),
112 TicketObj => $TicketObj,
113 QueueObj => $TicketObj->QueueObj
117 comp => '/Elements/SelectOwner',
120 TicketObj => $TicketObj,
121 QueueObj => $TicketObj->QueueObj,
122 DefaultLabel => loc("[_1] (Unchanged)", $m->scomp('/Elements/ShowUser', User => $TicketObj->OwnerObj)),
123 Default => $ARGS{'Owner'}
127 comp => '/Elements/EditTimeValue',
129 Name => 'UpdateTimeWorked',
130 Default => $ARGS{UpdateTimeWorked}||'',
131 InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
137 % $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $TicketObj );
139 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, AsTable => 1 &>
145 <div id="ticket-update-message">
146 <& /Ticket/Elements/ShowSimplifiedRecipients, TicketObj => $TicketObj, %ARGS &>
148 <&|/Widgets/TitleBox, title => loc('Message'), class => 'messagedetails' &>
149 <table width="100%" border="0">
150 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
152 % if ( $gnupg_widget ) {
153 <tr><td> </td><td>
154 <& /Elements/GnuPG/SignEncryptWidget,
155 self => $gnupg_widget,
156 TicketObj => $TicketObj,
160 % $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
162 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input type="text" name="UpdateSubject" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject || '' %>" />
163 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
166 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td>
167 <td class="messagebox-container action-<% $type %>">
168 <& /Articles/Elements/BeforeMessageBox, %ARGS &>
169 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
170 % if (exists $ARGS{UpdateContent}) {
171 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
172 % my $temp = $ARGS{'QuoteTransaction'};
173 % delete $ARGS{'QuoteTransaction'};
174 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
175 % $ARGS{'QuoteTransaction'} = $temp;
177 % my $IncludeSignature = 1;
178 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
179 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
181 % $m->callback( %ARGS, CallbackName => 'AfterMessageBox' );
184 <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $TicketObj &>
188 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', id => 'SubmitTicket' &>
190 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
191 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients'), id => 'previewscrips', rolledup => RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) &>
192 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
197 % if (my $recips = $m->notes("DryRun-Recipients-".$TicketObj->Id)) {
198 <input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %{$recips} %>" />
206 my $checks_failure = 0;
208 my $TicketObj = LoadTicket($id);
212 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure, results => \@results, CallbackName => 'Initial' );
214 unless($DefaultStatus){
215 $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
218 my $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject||'');
220 # Things needed in the template - we'll do the processing here, just
221 # for the convenience:
223 my ($CommentDefault, $ResponseDefault);
224 if ($Action ne 'Respond') {
225 $CommentDefault = qq[ selected="selected"];
226 $ResponseDefault = "";
228 $CommentDefault = "";
229 $ResponseDefault = qq[ selected="selected"];
232 my $type = $ARGS{'UpdateType'} ? $ARGS{'UpdateType'} :
233 lc $ARGS{'Action'} eq 'respond' ? 'response' :
234 lc $ARGS{'Action'} eq 'comment' ? 'private' :
238 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
239 $TicketObj->CurrentUserHasRight('ModifyTicket') );
241 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
242 $TicketObj->CurrentUserHasRight('ModifyTicket') );
245 # deal with deleting uploaded attachments
246 foreach my $key (keys %ARGS) {
247 if ($key =~ m/^DeleteAttach-(.+)$/) {
248 delete $session{'Attachments'}{$1};
250 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
253 # store the uploaded attachment in session
254 if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
255 my $attachment = MakeMIMEEntity(
256 AttachmentFieldName => 'Attach'
259 my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
260 $session{'Attachments'} = {
261 %{$session{'Attachments'} || {}},
262 $file_path => $attachment,
266 # delete temporary storage entry to make WebUI clean
267 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
268 delete $session{'Attachments'};
271 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
272 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
273 self => $gnupg_widget,
274 TicketObj => $TicketObj,
277 if ( $ARGS{'SubmitTicket'} ) {
279 my %squelched = ProcessTransactionSquelching( \%ARGS );
280 $ARGS{'SquelchMailTo'} = [keys %squelched] if keys %squelched;
282 my $CFs = $TicketObj->TransactionCustomFields;
283 my $ValidCFs = $m->comp(
284 '/Elements/ValidateCustomFields',
285 CustomFields => $CFs,
286 NamePrefix => "Object-RT::Transaction--CustomField-",
289 unless ( $ValidCFs ) {
291 while (my $CF = $CFs->Next) {
292 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
293 push @results, loc($CF->Name) . ': ' . $msg;
296 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
297 self => $gnupg_widget,
298 TicketObj => $TicketObj,
300 $checks_failure = 1 unless $status;
303 # check email addresses for RT's
305 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
306 my $value = $ARGS{ $field };
307 next unless defined $value && length $value;
309 my @emails = Email::Address->parse( $value );
310 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
311 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)) );
315 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
319 $m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
320 checks_failure => $checks_failure, results => \@results, TicketObj => $TicketObj );
322 if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
323 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
324 return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
331 $DefaultStatus => undef