Upgrade to 4.2.8
[usit-rt.git] / share / html / Ticket / Update.html
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
3ffc5f4f 5%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
84fb5b46
MKG
6%# <sales@bestpractical.com>
7%#
8%# (Except where explicitly superseded by other copyright notices)
9%#
10%#
11%# LICENSE:
12%#
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
16%# from www.gnu.org.
17%#
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.
22%#
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.
28%#
29%#
30%# CONTRIBUTION SUBMISSION POLICY:
31%#
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.)
37%#
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.
46%#
47%# END BPS TAGGED BLOCK }}}
48<& /Elements/Header, Title => $title &>
49<& /Elements/Tabs &>
50
51% $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
52<& /Elements/ListActions, actions => \@results &>
53
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 ||''%>" />
3ffc5f4f
MKG
59<input type="hidden" class="hidden" name="Action" value="<% $Action %>" />
60<input type="hidden" class="hidden" name="Token" value="<% $ARGS{'Token'} %>" />
84fb5b46 61
3ffc5f4f 62<& /Elements/Crypt/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
84fb5b46
MKG
63
64<div id="ticket-update-metadata">
65 <&|/Widgets/TitleBox, title => loc('Ticket and Transaction') &>
66<table width="100%" border="0">
67% $m->callback(CallbackName => 'AfterTableOpens', ARGSRef => \%ARGS, Ticket => $TicketObj);
68
69% my $skip;
70% $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
71% if (!$skip) {
72<input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
73% }
74<tr><td class="label"><&|/l&>Update Type</&>:</td>
75<td><select name="UpdateType" id="UpdateType">
76% if ($CanComment) {
77<option value="private" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
78% }
79% if ($CanRespond) {
80<option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
81% }
82</select>
83
84<script type="text/javascript">
85 jQuery(function() {
86 jQuery("#UpdateType").change(function(ev) {
87 jQuery(".messagebox-container")
88 .removeClass("action-response action-private")
89 .addClass("action-"+ev.target.value);
90 });
91 });
92 jQuery(function() {
93 jQuery("input[name=TxnSendMailTo]").change(function(ev) {
3ffc5f4f 94 jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == ev.target.value; } ).prop("checked",jQuery(ev.target).prop('checked'));
84fb5b46
MKG
95 });
96 });
97</script>
98
99% $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
100</td></tr>
101
102<& /Ticket/Elements/EditBasics,
103 TicketObj => $TicketObj,
104 InTable => 1,
105 fields => [
106 { name => 'Status',
3ffc5f4f 107 comp => '/Ticket/Elements/SelectStatus',
84fb5b46
MKG
108 args => {
109 Name => 'Status',
3ffc5f4f 110 Default => $DefaultStatus,
84fb5b46 111 TicketObj => $TicketObj,
84fb5b46
MKG
112 },
113 },
114 { name => 'Owner',
115 comp => '/Elements/SelectOwner',
116 args => {
117 Name => "Owner",
118 TicketObj => $TicketObj,
119 QueueObj => $TicketObj->QueueObj,
3ffc5f4f 120 DefaultLabel => loc("[_1] (Unchanged)", $TicketObj->OwnerObj->Format),
84fb5b46
MKG
121 Default => $ARGS{'Owner'}
122 }
123 },
124 { name => 'Worked',
125 comp => '/Elements/EditTimeValue',
126 args => {
127 Name => 'UpdateTimeWorked',
128 Default => $ARGS{UpdateTimeWorked}||'',
129 InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
130 }
131 },
132 ]
133&>
134
135% $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $TicketObj );
136
3ffc5f4f 137<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, InTable => 1, KeepValue => 1, &>
84fb5b46
MKG
138
139 </table>
140 </&>
141</div>
142
143<div id="ticket-update-message">
144 <& /Ticket/Elements/ShowSimplifiedRecipients, TicketObj => $TicketObj, %ARGS &>
145
146 <&|/Widgets/TitleBox, title => loc('Message'), class => 'messagedetails' &>
147 <table width="100%" border="0">
148<& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
149
150% if ( $gnupg_widget ) {
151<tr><td>&nbsp;</td><td>
3ffc5f4f 152<& /Elements/Crypt/SignEncryptWidget,
84fb5b46
MKG
153 self => $gnupg_widget,
154 TicketObj => $TicketObj,
155&>
156</td></tr>
157% }
158% $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
159
160<tr><td class="label"><&|/l&>Subject</&>:</td><td> <input type="text" name="UpdateSubject" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject || '' %>" />
161% $m->callback( %ARGS, CallbackName => 'AfterSubject' );
162</td></tr>
163
164<tr><td class="label" valign="top"><&|/l&>Message</&>:</td>
165<td class="messagebox-container action-<% $type %>">
166<& /Articles/Elements/BeforeMessageBox, %ARGS &>
167% $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
168% if (exists $ARGS{UpdateContent}) {
169% # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
170% my $temp = $ARGS{'QuoteTransaction'};
171% delete $ARGS{'QuoteTransaction'};
172<& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
173% $ARGS{'QuoteTransaction'} = $temp;
174% } else {
175% my $IncludeSignature = 1;
176% $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
177<& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
178% }
179% $m->callback( %ARGS, CallbackName => 'AfterMessageBox' );
180</td></tr>
181
182 <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $TicketObj &>
183 </table>
184</&>
185
3ffc5f4f
MKG
186% $m->callback( %ARGS, CallbackName => 'BeforeSubmit', Ticket => $TicketObj );
187
84fb5b46
MKG
188 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', id => 'SubmitTicket' &>
189
3ffc5f4f
MKG
190% $m->callback( %ARGS, CallbackName => 'BeforeScrips', Ticket => $TicketObj );
191
84fb5b46
MKG
192% if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
193 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients'), id => 'previewscrips', rolledup => RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) &>
194 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
195 </&>
196% }
197</div>
198
3ffc5f4f
MKG
199% $m->callback( %ARGS, CallbackName => 'AfterScrips', Ticket => $TicketObj );
200
84fb5b46
MKG
201% if (my $recips = $m->notes("DryRun-Recipients-".$TicketObj->Id)) {
202<input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %{$recips} %>" />
203% }
204
205</form>
206<hr class="clear" />
3ffc5f4f
MKG
207
208% $m->callback( %ARGS, CallbackName => 'AfterForm', Ticket => $TicketObj );
209
84fb5b46
MKG
210<%INIT>
211my $CanRespond = 0;
212my $CanComment = 0;
213my $checks_failure = 0;
214
215my $TicketObj = LoadTicket($id);
216
217my @results;
218
219$m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure, results => \@results, CallbackName => 'Initial' );
3ffc5f4f 220$m->scomp( '/Articles/Elements/SubjectOverride', Ticket => $TicketObj, ARGSRef => \%ARGS, results => \@results );
84fb5b46
MKG
221
222unless($DefaultStatus){
223 $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
224}
225
226my $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject||'');
227
228# Things needed in the template - we'll do the processing here, just
229# for the convenience:
230
231my ($CommentDefault, $ResponseDefault);
232if ($Action ne 'Respond') {
233 $CommentDefault = qq[ selected="selected"];
234 $ResponseDefault = "";
235} else {
236 $CommentDefault = "";
237 $ResponseDefault = qq[ selected="selected"];
238}
239
240my $type = $ARGS{'UpdateType'} ? $ARGS{'UpdateType'} :
3ffc5f4f
MKG
241 lc $Action eq 'respond' ? 'response' :
242 lc $Action eq 'comment' ? 'private' :
84fb5b46
MKG
243 'none' ;
244
245
246$CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
247 $TicketObj->CurrentUserHasRight('ModifyTicket') );
248
249$CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
250 $TicketObj->CurrentUserHasRight('ModifyTicket') );
251
5b0d0914 252ProcessAttachments(ARGSRef => \%ARGS);
84fb5b46 253
3ffc5f4f
MKG
254my %squelched = ProcessTransactionSquelching( \%ARGS );
255$ARGS{'SquelchMailTo'} = [keys %squelched] if keys %squelched;
256
257my $gnupg_widget = $m->comp('/Elements/Crypt/SignEncryptWidget:new', Arguments => \%ARGS );
258$m->comp( '/Elements/Crypt/SignEncryptWidget:Process',
84fb5b46
MKG
259 self => $gnupg_widget,
260 TicketObj => $TicketObj,
261);
262
263if ( $ARGS{'SubmitTicket'} ) {
264
3ffc5f4f 265 my ($status, @msg) = $m->comp(
84fb5b46 266 '/Elements/ValidateCustomFields',
3ffc5f4f
MKG
267 CustomFields => $TicketObj->TransactionCustomFields,
268 Object => RT::Transaction->new( $session{'CurrentUser'} ),
84fb5b46
MKG
269 ARGSRef => \%ARGS
270 );
3ffc5f4f
MKG
271 unless ( $status ) {
272 push @results, @msg;
84fb5b46 273 $checks_failure = 1;
84fb5b46 274 }
3ffc5f4f 275 $status = $m->comp('/Elements/Crypt/SignEncryptWidget:Check',
84fb5b46
MKG
276 self => $gnupg_widget,
277 TicketObj => $TicketObj,
278 );
279 $checks_failure = 1 unless $status;
280}
281
282# check email addresses for RT's
283{
284 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
285 my $value = $ARGS{ $field };
286 next unless defined $value && length $value;
287
288 my @emails = Email::Address->parse( $value );
289 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
290 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)) );
291 $checks_failure = 1;
292 $email = undef;
293 }
294 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
295 }
296}
297my $skip_update = 0;
298$m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
299 checks_failure => $checks_failure, results => \@results, TicketObj => $TicketObj );
300
301if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
302 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
303 return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
304}
305</%INIT>
306
307<%ARGS>
308$id => undef
3ffc5f4f 309$Action => ''
84fb5b46
MKG
310$DefaultStatus => undef
311</%ARGS>