]> git.uio.no Git - usit-rt.git/blame - share/html/m/ticket/reply
Merge branch 'master' of git.uio.no:usit-rt
[usit-rt.git] / share / html / m / ticket / reply
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
5%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
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<&|/m/_elements/wrapper, title => loc('Update ticket #[_1]', $t->id) &>
49<& /m/_elements/ticket_menu, ticket => $t &>
50<& /Elements/ListActions, actions => \@results &>
51<div class="ticket-reply">
52<&|/Widgets/TitleBox &>
53<form action="reply" id="update"
54 method="post" enctype="multipart/form-data">
55<input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
56<input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
57
58% if ($gnupg_widget) {
59<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
60% }
61
62<div class="entry"><span class="label"><&|/l&>Status</&>:</span>
63<div class="value">
64<& /Elements/SelectStatus, Name=>"Status", TicketObj => $t, DefaultLabel => loc("[_1] (Unchanged)", loc($t->Status)), Default => $ARGS{'Status'} || ($t->Status eq $DefaultStatus ? undef : $DefaultStatus)&>
65</div></div>
66
67<div class="entry"><span class="label"><&|/l&>Owner</&>:</span>
68<div class="value">
69<& /Elements/SelectOwner,
70 Name => "Owner",
71 TicketObj => $t,
72 QueueObj => $t->QueueObj,
73 DefaultLabel => loc("[_1] (Unchanged)", $m->scomp('/Elements/ShowUser', User => $t->OwnerObj)),
74 Default => $ARGS{'Owner'}
75&>
76</div></div>
77<div class="entry timefield"><span class="label"><&|/l&>Worked</&>:</span><span class="value">
78<& /Elements/EditTimeValue,
79 Name => 'UpdateTimeWorked',
80 Default => $ARGS{UpdateTimeWorked}||'',
81 InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
82&>
83</span></div>
84<input type="hidden" class="hidden" name="id" value="<%$t->Id%>" /><br />
85<div class="entry"><span class="label"><&|/l&>Update Type</&>:</span>
86<div class="value"><select name="UpdateType">
87% if ($CanComment) {
88<option value="private" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
89% }
90% if ($CanRespond) {
91<option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
92% }
93</select>
94</div></div>
95<div class="entry"><span class="label"><&|/l&>Subject</&>:</span><div class="value"> <input type="text" name="UpdateSubject" size="60" value="<% $ARGS{UpdateSubject} || $t->Subject()%>" />
96% $m->callback( %ARGS, CallbackName => 'AfterSubject' );
97</div></div>
98
99<div class="entry"><span class="label"><&|/l&>One-time Cc</&>:</span><span class="value"><& /Elements/EmailInput, Name => 'UpdateCc', Size => '60', Default => $ARGS{UpdateCc} &></span></div>
100
101<div class="entry"><span class="label"><&|/l&>One-time Bcc</&>:</span><span class="value"><& /Elements/EmailInput, Name => 'UpdateBcc', Size => '60', Default => $ARGS{UpdateBcc} &></span></div>
102
103<div class="entry"><span class="label" ><&|/l&>Message</&>:</span><div class="value">
104% if (exists $ARGS{UpdateContent}) {
105% # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
106% my $temp = $ARGS{'QuoteTransaction'};
107% delete $ARGS{'QuoteTransaction'};
108<& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
109% $ARGS{'QuoteTransaction'} = $temp;
110% } else {
111% my $IncludeSignature = 1;
112% $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
113<& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
114% }
115</div></div>
116
117% if (exists $session{'Attachments'}) {
118
119<%loc("Attached file") %>
120
121<%loc("Check box to delete")%><br />
122% foreach my $attach_name (keys %{$session{'Attachments'}}) {
123<input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
124% } # end of foreach
125
126
127% } # end of if
128
129<div class="entry">
130<span class="label"><&|/l&>Attach file</&>:</span>
131<div class="value">
132<input type="file" name="Attach" />
133<input type="submit" class="button" name="AddMoreAttach" value="<% loc("Add More Files") %>" />
134</div>
135</div>
136
137% if ( $gnupg_widget ) {
138<& /Elements/GnuPG/SignEncryptWidget, self => $gnupg_widget, QueueObj => $t->QueueObj &>
139% }
140
141<& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
142</form>
143</&>
144</div>
145</&>
146<%INIT>
147my $CanRespond = 0;
148my $CanComment = 0;
149my $checks_failure = 0;
150my $title;
151
152my $t = LoadTicket($id);
153
154my @results;
155
156$m->callback( Ticket => $t, ARGSRef => \%ARGS, results => \@results, CallbackName => 'Initial' );
157
158unless($DefaultStatus){
159 $DefaultStatus=($ARGS{'Status'} ||$t->Status());
160}
161
162if ($DefaultStatus eq 'new'){
163 $DefaultStatus='open';
164}
165
166if ($DefaultStatus eq 'resolved') {
167 $title = loc("Resolve ticket #[_1] ([_2])", $t->id, $t->Subject);
168} else {
169 $title = loc("Update ticket #[_1] ([_2])", $t->id, $t->Subject);
170}
171
172# Things needed in the template - we'll do the processing here, just
173# for the convenience:
174
175my ($CommentDefault, $ResponseDefault);
176if ($Action ne 'Respond') {
177 $CommentDefault = qq[ selected="selected"];
178 $ResponseDefault = "";
179} else {
180 $CommentDefault = "";
181 $ResponseDefault = qq[ selected="selected"];
182}
183
184
185
186$CanRespond = 1 if ( $t->CurrentUserHasRight('ReplyToTicket') or
187 $t->CurrentUserHasRight('ModifyTicket') );
188
189$CanComment = 1 if ( $t->CurrentUserHasRight('CommentOnTicket') or
190 $t->CurrentUserHasRight('ModifyTicket') );
191
192
193# deal with deleting uploaded attachments
194foreach my $key (keys %ARGS) {
195 if ($key =~ m/^DeleteAttach-(.+)$/) {
196 delete $session{'Attachments'}{$1};
197 }
198 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
199}
200
201# store the uploaded attachment in session
202if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
203 my $attachment = MakeMIMEEntity(
204 AttachmentFieldName => 'Attach'
205 );
206
207 my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
208 $session{'Attachments'} = {
209 %{$session{'Attachments'} || {}},
210 $file_path => $attachment,
211 };
212}
213
214# delete temporary storage entry to make WebUI clean
215unless ( keys %{ $session{'Attachments'} }
216 && ( exists $ARGS{'AddMoreAttach'} || exists $ARGS{'SubmitTicket'} ) )
217{
218 delete $session{'Attachments'};
219}
220
221# check email addresses for RT's
222{
223 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
224 my $value = $ARGS{ $field };
225 next unless defined $value && length $value;
226
227 my @emails = Email::Address->parse( $value );
228 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
229 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)) );
230 $checks_failure = 1;
231 $email = undef;
232 }
233 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
234 }
235}
236
237my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
238$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
239 self => $gnupg_widget,
240 TicketObj => $t,
241);
242
243if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
244 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
245 self => $gnupg_widget,
246 TicketObj => $t,
247 );
248 $checks_failure = 1 unless $status;
249 return $m->comp('/m/ticket/show', TicketObj => $t, %ARGS);
250}
251</%INIT>
252
253<%ARGS>
254$id => undef
255$Action => 'Respond'
256$DefaultStatus => undef
257</%ARGS>