
ruz at bestpractical
Aug 8, 2013, 7:13 AM
Post #1 of 1
(13 views)
Permalink
|
|
rt branch, 4.2/simpler-bulk-links, created. rt-4.1.17-175-g4cdfb64
|
|
The branch, 4.2/simpler-bulk-links has been created at 4cdfb6472a6c072b35068faa7164810fa2f1bd67 (commit) - Log ----------------------------------------------------------------- commit 4cdfb6472a6c072b35068faa7164810fa2f1bd67 Author: Ruslan Zakirov <ruz [at] bestpractical> Date: Tue Aug 6 18:52:54 2013 +0400 make Process*Links more suitable for Bulk update Let functions take "id" as argument that is used in name of inputs and in case of bulk it's really 'Ticket' rather than numeric id. diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm index c7af47c..030d32f 100644 --- a/lib/RT/Interface/Web.pm +++ b/lib/RT/Interface/Web.pm @@ -3314,19 +3314,24 @@ Returns an array of results messages. sub ProcessTicketLinks { my %args = ( TicketObj => undef, + TicketId => undef, ARGSRef => undef, @_ ); my $Ticket = $args{'TicketObj'}; + my $TicketId = $args{'TicketId'} || $Ticket->Id; my $ARGSRef = $args{'ARGSRef'}; - my (@results) = ProcessRecordLinks( RecordObj => $Ticket, ARGSRef => $ARGSRef ); + my (@results) = ProcessRecordLinks( + %args, RecordObj => $Ticket, RecordId => $TicketId, ARGSRef => $ARGSRef, + ); #Merge if we need to - if ( $ARGSRef->{ $Ticket->Id . "-MergeInto" } ) { - $ARGSRef->{ $Ticket->Id . "-MergeInto" } =~ s/\s+//g; - my ( $val, $msg ) = $Ticket->MergeInto( $ARGSRef->{ $Ticket->Id . "-MergeInto" } ); + my $input = $TicketId .'-MergeInto'; + if ( $ARGSRef->{ $input } ) { + $ARGSRef->{ $input } =~ s/\s+//g; + my ( $val, $msg ) = $Ticket->MergeInto( $ARGSRef->{ $input } ); push @results, $msg; } @@ -3337,11 +3342,13 @@ sub ProcessTicketLinks { sub ProcessRecordLinks { my %args = ( RecordObj => undef, + RecordId => undef, ARGSRef => undef, @_ ); my $Record = $args{'RecordObj'}; + my $RecordId = $args{'RecordId'} || $Record->Id; my $ARGSRef = $args{'ARGSRef'}; my (@results); @@ -3368,11 +3375,12 @@ sub ProcessRecordLinks { my @linktypes = qw( DependsOn MemberOf RefersTo ); foreach my $linktype (@linktypes) { - if ( $ARGSRef->{ $Record->Id . "-$linktype" } ) { - $ARGSRef->{ $Record->Id . "-$linktype" } = join( ' ', @{ $ARGSRef->{ $Record->Id . "-$linktype" } } ) - if ref( $ARGSRef->{ $Record->Id . "-$linktype" } ); + my $input = $RecordId .'-'. $linktype; + if ( $ARGSRef->{ $input } ) { + $ARGSRef->{ $input } = join( ' ', @{ $ARGSRef->{ $input } } ) + if ref $ARGSRef->{ $input }; - for my $luri ( split( / /, $ARGSRef->{ $Record->Id . "-$linktype" } ) ) { + for my $luri ( split( / /, $ARGSRef->{ $input } ) ) { next unless $luri; $luri =~ s/\s+$//; # Strip trailing whitespace my ( $val, $msg ) = $Record->AddLink( @@ -3382,11 +3390,12 @@ sub ProcessRecordLinks { push @results, $msg; } } - if ( $ARGSRef->{ "$linktype-" . $Record->Id } ) { - $ARGSRef->{ "$linktype-" . $Record->Id } = join( ' ', @{ $ARGSRef->{ "$linktype-" . $Record->Id } } ) - if ref( $ARGSRef->{ "$linktype-" . $Record->Id } ); + $input = $linktype .'-'. $RecordId; + if ( $ARGSRef->{ $input } ) { + $ARGSRef->{ $input } = join( ' ', @{ $ARGSRef->{ $input } } ) + if ref $ARGSRef->{ $input }; - for my $luri ( split( / /, $ARGSRef->{ "$linktype-" . $Record->Id } ) ) { + for my $luri ( split( / /, $ARGSRef->{ $input } ) ) { next unless $luri; my ( $val, $msg ) = $Record->AddLink( Base => $luri, diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html index eb03b7c..e1b0f9c 100644 --- a/share/html/Search/Bulk.html +++ b/share/html/Search/Bulk.html @@ -298,16 +298,8 @@ unless ( $ARGS{'AddMoreAttach'} ) { my @watchresults = ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS ); - foreach my $type (qw(MergeInto DependsOn MemberOf RefersTo)) { - $ARGS{ $Ticket->id . "-" . $type } = $ARGS{"Ticket-$type"}; - $ARGS{ $type . "-" . $Ticket->id } = $ARGS{"$type-Ticket"}; - } @linkresults = - ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS ); - foreach my $type (qw(MergeInto DependsOn MemberOf RefersTo)) { - delete $ARGS{ $type . "-" . $Ticket->id }; - delete $ARGS{ $Ticket->id . "-" . $type }; - } + ProcessTicketLinks( TicketObj => $Ticket, TicketId => 'Ticket', ARGSRef => \%ARGS ); my @cfresults; ----------------------------------------------------------------------- _______________________________________________ Rt-commit mailing list Rt-commit [at] lists http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
|