1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2012 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 }}}
49 $QuoteTransaction => undef
53 $m->callback( CallbackName => "Init", ARGSRef => \%ARGS );
54 my $Queue = $ARGS{Queue};
61 my $key = shift @pairs;
62 my $val = shift @pairs;
64 $m->out("<div class=\"entry\"><span class=\"label\">$key</span><div class=\"value\">$val</div></div>");
73 $CloneTicketObj = RT::Ticket->new( $session{CurrentUser} );
74 $CloneTicketObj->Load($CloneTicket)
75 or Abort( loc("Ticket could not be loaded") );
78 Requestors => join( ',', $CloneTicketObj->RequestorAddresses ),
79 Cc => join( ',', $CloneTicketObj->CcAddresses ),
80 AdminCc => join( ',', $CloneTicketObj->AdminCcAddresses ),
81 InitialPriority => $CloneTicketObj->Priority,
84 $clone->{$_} = $CloneTicketObj->$_()
85 for qw/Owner Subject FinalPriority TimeEstimated TimeWorked
88 $clone->{$_} = $CloneTicketObj->$_->AsString
89 for grep { $CloneTicketObj->$_->Unix }
90 map { $_ . "Obj" } qw/Starts Started Due Resolved/;
92 my $members = $CloneTicketObj->Members;
93 my ( @members, @members_of, @refers, @refers_by, @depends, @depends_by );
94 my $refers = $CloneTicketObj->RefersTo;
95 while ( my $refer = $refers->Next ) {
96 push @refers, $refer->LocalTarget;
98 $clone->{'new-RefersTo'} = join ' ', @refers;
100 my $refers_by = $CloneTicketObj->ReferredToBy;
101 while ( my $refer_by = $refers_by->Next ) {
102 push @refers_by, $refer_by->LocalBase;
104 $clone->{'RefersTo-new'} = join ' ', @refers_by;
105 if (0) { # Temporarily disabled
106 my $depends = $CloneTicketObj->DependsOn;
107 while ( my $depend = $depends->Next ) {
108 push @depends, $depend->LocalTarget;
110 $clone->{'new-DependsOn'} = join ' ', @depends;
112 my $depends_by = $CloneTicketObj->DependedOnBy;
113 while ( my $depend_by = $depends_by->Next ) {
114 push @depends_by, $depend_by->LocalBase;
116 $clone->{'DependsOn-new'} = join ' ', @depends_by;
118 while ( my $member = $members->Next ) {
119 push @members, $member->LocalBase;
121 $clone->{'MemberOf-new'} = join ' ', @members;
123 my $members_of = $CloneTicketObj->MemberOf;
124 while ( my $member_of = $members_of->Next ) {
125 push @members_of, $member_of->LocalTarget;
127 $clone->{'new-MemberOf'} = join ' ', @members_of;
131 my $cfs = $CloneTicketObj->QueueObj->TicketCustomFields();
132 while ( my $cf = $cfs->Next ) {
134 my $cf_values = $CloneTicketObj->CustomFieldValues( $cf->id );
136 while ( my $cf_value = $cf_values->Next ) {
137 push @cf_values, $cf_value->Content;
139 $clone->{"Object-RT::Ticket--CustomField-$cf_id-Value"} = join "\n",
143 for ( keys %$clone ) {
144 $ARGS{$_} = $clone->{$_} if not defined $ARGS{$_};
151 my $title = loc("Create a ticket");
153 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
154 $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
156 $m->callback( QueueObj => $QueueObj, title => \$title, results => \@results, ARGSRef => \%ARGS );
158 $QueueObj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."));
160 my $CFs = $QueueObj->TicketCustomFields();
162 my $ValidCFs = $m->comp(
163 '/Elements/ValidateCustomFields',
164 CustomFields => $CFs,
168 # deal with deleting uploaded attachments
169 foreach my $key (keys %ARGS) {
170 if ($key =~ m/^DeleteAttach-(.+)$/) {
171 delete $session{'Attachments'}{$1};
173 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
176 # store the uploaded attachment in session
177 if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
178 my $attachment = MakeMIMEEntity(
179 AttachmentFieldName => 'Attach'
182 my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
183 $session{'Attachments'} = {
184 %{$session{'Attachments'} || {}},
185 $file_path => $attachment,
189 # delete temporary storage entry to make WebUI clean
190 unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
191 delete $session{'Attachments'};
194 my $checks_failure = 0;
196 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
197 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
198 self => $gnupg_widget,
199 QueueObj => $QueueObj,
203 if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
204 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
205 self => $gnupg_widget,
206 Operation => 'Create',
207 QueueObj => $QueueObj,
209 $checks_failure = 1 unless $status;
212 # check email addresses for RT's
214 foreach my $field ( qw(Requestors Cc AdminCc) ) {
215 my $value = $ARGS{ $field };
216 next unless defined $value && length $value;
218 my @emails = Email::Address->parse( $value );
219 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
220 push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc($field =~ /^(.*?)s?$/) );
224 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
229 $m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, skip_create => \$skip_create,
230 checks_failure => $checks_failure, results => \@results );
232 if ((!exists $ARGS{'AddMoreAttach'}) and (defined($ARGS{'id'}) and $ARGS{'id'} eq 'new')) { # new ticket?
233 if ( $ValidCFs && !$checks_failure && !$skip_create ) {
234 $m->comp('show', %ARGS);
235 $RT::Logger->crit("After display call; error is $@");
238 elsif ( !$ValidCFs ) {
240 while (my $CF = $CFs->Next) {
241 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
242 push @results, $CF->Name . ': ' . $msg;
251 <&| /m/_elements/wrapper, title => $title &>
252 <& /Elements/ListActions, actions => \@results &>
253 <form action="<% RT->Config->Get('WebPath') %>/m/ticket/create" method="post" enctype="multipart/form-data" name="TicketCreate" id="ticket-create">
254 <input type="hidden" class="hidden" name="id" value="new" />
255 % $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
256 % if ($gnupg_widget) {
257 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
261 <div id="ticket-create-simple">
262 <&| /Widgets/TitleBox, title => $QueueObj->Name &>
266 loc("Subject") => '<input type="text" name="Subject" size="30" maxsize="200" value="'.($ARGS{Subject} || '').'" />');
268 <span class="content-label label"><%loc("Describe the issue below")%></span>
269 <& /Elements/MessageBox, exists $ARGS{Content} ? (Default => $ARGS{Content}, IncludeSignature => 0 ) : ( QuoteTransaction => $QuoteTransaction ), Height => 5 &>
272 <&/Elements/Submit, Label => loc("Create") &>
278 <div id="ticket-create-basics">
279 <&| /Widgets/TitleBox &>
280 <input type="hidden" class="hidden" name="Queue" value="<%$QueueObj->id %>" />
285 # loc('Queue') => $m->scomp( '/Ticket/Elements/ShowQueue', QueueObj => $QueueObj ) ,
290 "/Elements/SelectStatus",
292 QueueObj => $QueueObj,
293 Default => $ARGS{Status} || $QueueObj->Lifecycle->DefaultOnCreate,
300 "/Elements/SelectOwner",
302 QueueObj => $QueueObj,
303 Default => $ARGS{Owner} || RT->Nobody->Id,
307 loc("Requestors") => $m->scomp(
308 "/Elements/EmailInput",
309 Name => 'Requestors',
311 Default => $ARGS{Requestors} || $session{CurrentUser}->EmailAddress
316 $m->scomp( "/Elements/EmailInput", Name => 'Cc', Size => '40', Default => $ARGS{Cc} )
317 . '<span class="comment"><i><font size="-2">'
319 "(Sends a carbon-copy of this update to a comma-delimited list of email addresses. These people <strong>will</strong> receive future updates.)"
321 . '</font></i></span>',
325 $m->scomp( "/Elements/EmailInput", Name => 'AdminCc', Size => '40', Default => $ARGS{AdminCc} )
326 . '<span class="comment"><i><font size="-2">'
328 "(Sends a carbon-copy of this update to a comma-delimited list of administrative email addresses. These people <strong>will</strong> receive future updates.)"
330 . '</font></i></span>',
337 <& /Ticket/Elements/EditCustomFields, %ARGS, QueueObj => $QueueObj &>
338 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj &>
340 % if (exists $session{'Attachments'}) {
342 <%loc("Attached file") %>
344 <%loc("Check box to delete")%><br />
345 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
346 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
354 loc("Attach file") =>
356 '<input type="file" name="Attach" />
357 <input type="submit" class="button" name="AddMoreAttach" value="' . loc("Add More Files") . '" />'
362 % if ( $gnupg_widget ) {
363 <& /Elements/GnuPG/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
367 <div class="ticket-info-basics">
368 <&| /Widgets/TitleBox, title => loc('The Basics'),
369 title_class=> 'inverse',
370 color => "#993333" &>
373 loc("Priority") => $m->scomp(
374 "/Elements/SelectPriority",
375 Name => "InitialPriority",
376 Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority,
378 loc("Final Priority") => $m->scomp(
379 "/Elements/SelectPriority",
380 Name => "FinalPriority",
381 Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority,
384 loc("Time Estimated") => '<span class="timefield">'.$m->scomp(
385 "/Elements/EditTimeValue",
386 Name => 'TimeEstimated',
387 Default => $ARGS{TimeEstimated} || '',
388 InUnits => $ARGS{'TimeEstimated-TimeUnits'}
391 loc("Time Worked") => '<span class="timefield">'.$m->scomp(
392 "/Elements/EditTimeValue",
393 Name => 'TimeWorked',
394 Default => $ARGS{TimeWorked} || '',
395 InUnits => $ARGS{'TimeWorked-TimeUnits'}
398 loc("Time Left") => '<span class="timefield">'.$m->scomp(
399 "/Elements/EditTimeValue",
401 Default => $ARGS{TimeLeft} || '',
402 InUnits => $ARGS{'TimeLeft-TimeUnits'}
408 <&|/Widgets/TitleBox, title => loc("Dates"),
409 title_class=> 'inverse',
410 color => "#663366" &>
414 loc("Starts") => $m->scomp( "/Elements/SelectDate", Name => "Starts", Default => ( $ARGS{Starts} || '' )),
415 loc("Due") => $m->scomp( "/Elements/SelectDate", Name => "Due", Default => ($ARGS{Due} || '' ))
421 <&|/Widgets/TitleBox, title => loc('Links'), title_class=> 'inverse' &>
423 <em><%loc("(Enter ticket ids or URLs, separated with spaces)")%></em>
427 loc("Depends on") => '<input type="text" size="10" name="new-DependsOn" value="' . ($ARGS{'new-DependsOn'} || '' ). '" />',
428 loc("Depended on by") => '<input type="text" size="10" name="DependsOn-new" value="' . ($ARGS{'DependsOn-new'} || '' ) . '" />',
429 loc("Parents") => '<input type="text" size="10" name="new-MemberOf" value="' . ($ARGS{'new-MemberOf'} || '') . '" />',
430 loc("Children") => '<input type="text" size="10" name="MemberOf-new" value="' . ($ARGS{'MemberOf-new'} || '') . '" />',
431 loc("Refers to") => '<input type="text" size="10" name="new-RefersTo" value="' . ($ARGS{'new-RefersTo'} || '') . '" />',
432 loc("Referred to by") => '<input type="text" size="10" name="RefersTo-new" value="' . ($ARGS{'RefersTo-new'} || ''). '" />'
439 <& /Elements/Submit, Label => loc("Create") &>