235
# {{{ deal with deleting uploaded attachments
236
foreach my $key (keys %ARGS) {
237
if ($key =~ m/^DeleteAttach-(.+)$/) {
238
delete $session{'Attachments'}{$1};
240
$session{'Attachments'} = { %{$session{'Attachments'} || {}} };
244
# {{{ store the uploaded attachment in session
245
if ($ARGS{'Attach'}) { # attachment?
246
my $attachment = MakeMIMEEntity(
247
AttachmentFieldName => 'Attach'
250
my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
251
$session{'Attachments'} = {
252
%{$session{'Attachments'} || {}},
253
$file_path => $attachment,
258
# delete temporary storage entry to make WebUI clean
259
unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
260
delete $session{'Attachments'};
224
266
$Format ||= RT->Config->Get('DefaultSearchResultFormat');
274
316
@$cf_add_keys = grep { /^Bulk-Add-CustomField/ } keys %ARGS;
277
while ( my $Ticket = $Tickets->Next ) {
278
next unless ( $ARGS{ "UpdateTicket" . $Ticket->Id } );
281
$ARGS{'id'} = $Ticket->id;
282
$queues{ $Ticket->QueueObj->Id }++;
284
my @updateresults, ProcessUpdateMessage(
285
TicketObj => $Ticket,
318
unless ( $ARGS{'AddMoreAttach'} ) {
319
# Add session attachments if any to be processed by ProcessUpdateMessage
320
$ARGS{'UpdateAttachments'} = $session{'Attachments'} if ( $session{'Attachments'} );
322
while ( my $Ticket = $Tickets->Next ) {
323
next unless ( $ARGS{ "UpdateTicket" . $Ticket->Id } );
326
$ARGS{'id'} = $Ticket->id;
327
$queues{ $Ticket->QueueObj->Id }++;
329
my @updateresults, ProcessUpdateMessage(
330
TicketObj => $Ticket,
336
ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
338
ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS );
342
ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS );
344
foreach my $type qw(MergeInto DependsOn MemberOf RefersTo) {
345
$ARGS{ $Ticket->id . "-" . $type } = $ARGS{"Ticket-$type"};
346
$ARGS{ $type . "-" . $Ticket->id } = $ARGS{"$type-Ticket"};
349
ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS );
350
foreach my $type qw(MergeInto DependsOn MemberOf RefersTo) {
351
delete $ARGS{ $type . "-" . $Ticket->id };
352
delete $ARGS{ $Ticket->id . "-" . $type };
357
foreach my $list ( $cf_add_keys, $cf_del_keys ) {
358
next unless $list->[0];
362
if ( $list->[0] =~ /Add/ ) {
366
elsif ( $list->[0] =~ /Del/ ) {
371
"Got an op that was neither add nor delete. can never happen"
376
foreach my $key (@$list) {
378
next if $key =~ /CustomField-(\d+)-Category$/;
379
if ( $key =~ /CustomField-(\d+)-/ ) {
381
$cf = RT::CustomField->new( $session{'CurrentUser'} );
386
ref( $ARGS{$key} ) eq 'ARRAY'
389
map { s/(\r\n|\r)/\n/g; } @values; # fix the newlines
390
# now break the multiline values into multivalues
391
@values = map { split( /\n/, $_ ) } @values
392
unless ( $cf->SingleValue );
394
my $current_values = $Ticket->CustomFieldValues($cfid);
395
foreach my $value (@values) {
396
if ( $op eq 'del' && $current_values->HasEntry($value) ) {
397
my ( $id, $msg ) = $Ticket->DeleteCustomFieldValue(
401
push @cfresults, $msg;
404
elsif ( $op eq 'add' && !$current_values->HasEntry($value) ) {
405
my ( $id, $msg ) = $Ticket->AddCustomFieldValue(
409
push @cfresults, $msg;
415
@watchresults, @basicresults, @dateresults,
416
@updateresults, @linkresults, @cfresults
291
ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
293
ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS );
297
ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS );
299
foreach my $type qw(MergeInto DependsOn MemberOf RefersTo) {
300
$ARGS{ $Ticket->id . "-" . $type } = $ARGS{"Ticket-$type"};
301
$ARGS{ $type . "-" . $Ticket->id } = $ARGS{"$type-Ticket"};
304
ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS );
305
foreach my $type qw(MergeInto DependsOn MemberOf RefersTo) {
306
delete $ARGS{ $type . "-" . $Ticket->id };
307
delete $ARGS{ $Ticket->id . "-" . $type };
312
foreach my $list ( $cf_add_keys, $cf_del_keys ) {
313
next unless $list->[0];
317
if ( $list->[0] =~ /Add/ ) {
321
elsif ( $list->[0] =~ /Del/ ) {
326
"Got an op that was neither add nor delete. can never happen"
331
foreach my $key (@$list) {
333
next if $key =~ /CustomField-(\d+)-Category$/;
334
if ( $key =~ /CustomField-(\d+)-/ ) {
336
$cf = RT::CustomField->new( $session{'CurrentUser'} );
341
ref( $ARGS{$key} ) eq 'ARRAY'
344
map { s/(\r\n|\r)/\n/g; } @values; # fix the newlines
345
# now break the multiline values into multivalues
346
@values = map { split( /\n/, $_ ) } @values
347
unless ( $cf->SingleValue );
349
my $current_values = $Ticket->CustomFieldValues($cfid);
350
foreach my $value (@values) {
351
if ( $op eq 'del' && $current_values->HasEntry($value) ) {
352
my ( $id, $msg ) = $Ticket->DeleteCustomFieldValue(
356
push @cfresults, $msg;
359
elsif ( $op eq 'add' && !$current_values->HasEntry($value) ) {
360
my ( $id, $msg ) = $Ticket->AddCustomFieldValue(
364
push @cfresults, $msg;
370
@watchresults, @basicresults, @dateresults,
371
@updateresults, @linkresults, @cfresults
375
map { loc( "Ticket [_1]: [_2]", $Ticket->Id, $_ ) } @tempresults;
377
@results = ( @results, @tempresults );
420
map { loc( "Ticket [_1]: [_2]", $Ticket->Id, $_ ) } @tempresults;
422
@results = ( @results, @tempresults );
426
delete $session{'Attachments'};
380
429
my $TxnCFs = RT::CustomFields->new( $session{CurrentUser} );