[rt-users] Bulk Merge/Link Add & Delete for RT2.0.15 [Patch]

Brook Schofield B.Schofield at mailbox.gu.edu.au
Thu Dec 5 20:31:04 EST 2002


This patch provides support for Bulk addition and removal of Links for 
RT-2.0.15.

This references [fsck.com #1842] which is a patch against 2.1.53 (aka RT3).

-Brook

=========================================================================
=     _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/  _/ Brook Schofield                =
=    _/  _/ _/  _/ _/  _/ _/  _/ _/ _/   B.Schofield at mailbox.gu.edu.au  =
=   _/_/   _/_/_/ _/  _/ _/  _/ _/_/     Ph: +61 7 387 53779 - WCN 0.28 =
=  _/  _/ _/ _/  _/  _/ _/  _/ _/ _/     Directory Services Integration =
= _/_/_/ _/  _/ _/_/_/ _/_/_/ _/  _/     Griffith University QLD 4111   =
=========================================================================
-------------- next part --------------
diff -ur rt-2-0-15.orig/lib/RT/Interface/Web.pm rt-2-0-15/lib/RT/Interface/Web.pm
--- rt-2-0-15.orig/lib/RT/Interface/Web.pm	Sat Jul 13 03:31:41 2002
+++ rt-2-0-15/lib/RT/Interface/Web.pm	Fri Dec  6 11:11:29 2002
@@ -1116,52 +1116,89 @@
             my $type   = $2;
             my $target = $3;
 
-            push @results,
-              "Trying to delete: Base: $base Target: $target  Type $type";
-            my ( $val, $msg ) = $Ticket->DeleteLink(
-                Base   => $base,
-                Type   => $type,
-                Target => $target
-            );
-
-            push @results, $msg;
-
+            # DeleteLink-bulk-(DependsOn|MemberOf|RefersTo)-Ticket
+            if ($base eq 'bulk') {
+                $base = undef;
+                $target = $ARGSRef->{"$arg"};
+
+                for my $luri ( split ( / /, $ARGSRef->{ "$arg" } ) )
+                {
+                    $luri =~ s/\s*$//;    # Strip trailing whitespace
+                    my ( $val, $msg ) = $Ticket->DeleteLink(
+                        Base   => $base,
+                        Type   => $type,
+                        Target => $luri
+                    );
+
+                    push @results, $msg if ($val);
+                }
+            }
+            # DeleteLink-Ticket-(DependsOn|MemberOf|RefersTo)-bulk
+            elsif ($target eq 'bulk') {
+                $base = $ARGSRef->{$arg};
+                $target = undef;
+
+                for my $luri ( split ( / /, $ARGSRef->{ "$arg" } ) )
+                {
+                    $luri =~ s/\s*$//;    # Strip trailing whitespace
+                    my ( $val, $msg ) = $Ticket->DeleteLink(
+                        Base   => $luri,
+                        Type   => $type,
+                        Target => $target
+                    );
+
+                    push @results, $msg if ($val);
+                }
+            }
+            else {
+                push @results,
+                  "Trying to delete: Base: $base Target: $target  Type $type";
+                my ( $val, $msg ) = $Ticket->DeleteLink(
+                    Base   => $base,
+                    Type   => $type,
+                    Target => $target
+                );
+    
+                push @results, $msg;
+            }
         }
-
     }
 
     my @linktypes = qw( DependsOn MemberOf RefersTo );
 
     foreach my $linktype (@linktypes) {
 
-        for my $luri ( split ( / /, $ARGSRef->{ $Ticket->Id . "-$linktype" } ) )
-        {
-            $luri =~ s/\s*$//;    # Strip trailing whitespace
-            my ( $val, $msg ) = $Ticket->AddLink(
-                Target => $luri,
-                Type   => $linktype
-            );
-            push @results, $msg;
-        }
-
-        for my $luri ( split ( / /, $ARGSRef->{ "$linktype-" . $Ticket->Id } ) )
-        {
-            my ( $val, $msg ) = $Ticket->AddLink(
-                Base => $luri,
-                Type => $linktype
-            );
-
-            push @results, $msg;
+        for my $ticketid ($Ticket->Id, 'bulk') {
+            for my $luri ( split ( / /, $ARGSRef->{ "$ticketid-$linktype" } ) )
+            {
+                $luri =~ s/\s*$//;    # Strip trailing whitespace
+                my ( $val, $msg ) = $Ticket->AddLink(
+                    Target => $luri,
+                    Type   => $linktype
+                );
+                push @results, $msg;
+            }
+    
+            for my $luri ( split ( / /, $ARGSRef->{ "$linktype-$ticketid" } ) )
+            {
+                my ( $val, $msg ) = $Ticket->AddLink(
+                    Base => $luri,
+                    Type => $linktype
+                );
+    
+                push @results, $msg;
+            }
         }
     }
 
     #Merge if we need to
-    if ( $ARGSRef->{ $Ticket->Id . "-MergeInto" } ) {
-        my ( $val, $msg ) =
-          $Ticket->MergeInto( $ARGSRef->{ $Ticket->Id . "-MergeInto" } );
-        push @results, $msg;
+    for my $ticketid ($Ticket->Id, 'bulk') {
+        if ( $ARGSRef->{ "$ticketid-MergeInto" } ) {
+            my ( $val, $msg ) =
+              $Ticket->MergeInto( $ARGSRef->{ "$ticketid-MergeInto" } );
+            push @results, $msg;
+        }
     }
-
     return (@results);
 }
 
diff -ur rt-2-0-15.orig/webrt/Search/Bulk.html rt-2-0-15/webrt/Search/Bulk.html
--- rt-2-0-15.orig/webrt/Search/Bulk.html	Fri Jul 19 15:22:06 2002
+++ rt-2-0-15/webrt/Search/Bulk.html	Fri Dec  6 11:15:36 2002
@@ -59,46 +59,81 @@
 <& /Elements/TitleBoxStart, title => 'Update selected tickets' &>
 <TABLE>
 <TR>
-<TD VALIGN=TOP>
-<UL>
-<li> Make Owner <& /Elements/SelectOwner, Name => "Owner" &>
-(<input type=checkbox name="ForceOwnerChange"> Force change)
-<li> Add Requestor <INPUT Name="AddRequestor" SIZE=20>
-<li> Remove Requestor <INPUT Name="DeleteRequestor" SIZE=20>
-<li> Add Cc <INPUT Name="AddCc" SIZE=20>
-<li> Remove Cc <INPUT Name="DeleteCc" SIZE=20>
-<li> Add AdminCc <INPUT Name="AddAdminCc" SIZE=20>
-<li> Remove AdminCc <INPUT Name="DeleteAdminCc" SIZE=20>
-</UL>
-</TD>
-<TD VALIGN=TOP>
-<UL>
-<li> Make subject <INPUT Name="Subject" SIZE=20>
-<li> Make priority <INPUT Name="Priority" SIZE=4>
-<li> Make queue <& /Elements/SelectQueue, Name => "Queue" &>
-
-<li>Make Status <& /Elements/SelectStatus, Name => "Status" &>
-
-
+<TD>Make Owner:</TD>
+<TD><& /Elements/SelectOwner, Name => "Owner" &>
+(<input type=checkbox name="ForceOwnerChange"> Force change</TD>
+<TD>Make subject:</TD><TD COLSPAN="3"><INPUT Name="Subject" SIZE=20></TD>
+</TR>
+ 
+<TR>
+<TD>Add Requestor:</TD><TD><INPUT Name="AddRequestor" SIZE=20></TD>
+<TD>Make priority:</TD><TD COLSPAN="3"><INPUT Name="Priority" SIZE=4></TD>
+</TR>
+ 
+<TR>
+<TD>Remove Requestor:</TD><TD><INPUT Name="DeleteRequestor" SIZE=20></TD>
+<TD>Make queue:</TD><TD COLSPAN="3"><& /Elements/SelectQueue, Name => "Queue" &></TD>
+</TR>
+ 
+<TR>
+<TD>Add Cc:</TD><TD><INPUT Name="AddCc" SIZE=20></TD>
+<TD>Make Status:</TD><TD COLSPAN="3"><& /Elements/SelectStatus, Name => "Status" &></TD>
+</TR>
+ 
+<TR>
+<TD>Remove Cc:</TD><TD><INPUT Name="DeleteCc" SIZE=20></TD>
+<TD COLSPAN="4"><i>Enter tickets or URIs to link tickets to. Seperate multiple entries with spaces.</i></TD>
+</TR>
 
-<li> Make date Starts <& /Elements/SelectDate, Name => "Starts_Date", ShowTime => 0, Default => '' &>
-<li> Make date Started <& /Elements/SelectDate, Name => "Started_Date", ShowTime => 0, Default => '' &>
-<li> Make date Told <& /Elements/SelectDate, Name => "Told_Date", ShowTime => 0, Default => '' &>
-<li> Make date Due <& /Elements/SelectDate, Name => "Due_Date", ShowTime => 0, Default => '' &>
-<li> Make date Resolved <& /Elements/SelectDate, Name => "Resolved_Date", ShowTime => 0, Default => '' &>
+<TR>
+<TD>Add AdminCc:</TD><TD><INPUT Name="AddAdminCc" SIZE=20></TD>
+<TD>Merge into:</TD><TD COLSPAN="3"><INPUT Name="bulk-MergeInto" SIZE=10>
+<i>(only one ticket)</i></TD>
+</TR>
 
+<TR>
+<TD>Remove AdminCc:</TD><TD><INPUT Name="DeleteAdminCc" SIZE=20></TD>
+<TD>Depends on:</TD><TD><INPUT Name="bulk-DependsOn" SIZE=10></TD>
+<TD>Delete Depends on:</TD><TD><INPUT Name="DeleteLink-bulk-DependsOn-Ticket" SIZE=10></TD>
+</TR>
 
-% while ( my $KeywordSelect = $KeywordSelects->Next ) {
+<TR>
+<TD>Make date Starts:</TD><TD><& /Elements/SelectDate, Name => "Starts_Date", ShowTime => 0, Default => '' &></TD>
+<TD>Depended on by:</TD><TD><INPUT Name="DependsOn-bulk" SIZE=10></TD>
+<TD>Delete Depended on by:</TD><TD><INPUT Name="DeleteLink-Ticket-DependsOn-bulk" SIZE=10></TD>
+</TR>
 
-<li> Add <% $KeywordSelect->Name %> <& /Elements/SelectKeyword, Name => "AddToKeywordSelect".$KeywordSelect->id, KeywordObj => $KeywordSelect->KeywordObj &>
-<li> Remove <% $KeywordSelect->Name %> <& /Elements/SelectKeyword, Name => "DeleteFromKeywordSelect".$KeywordSelect->id, KeywordObj => $KeywordSelect->KeywordObj &>
-% }
+<TR>
+<TD>Make date Started:</TD><TD><& /Elements/SelectDate, Name => "Started_Date", ShowTime => 0, Default => '' &></TD>
+<TD>Parents:</TD><TD><INPUT Name="bulk-MemberOf" SIZE=10></TD>
+<TD>Delete Parents:</TD><TD><INPUT Name="DeleteLink-bulk-MemberOf-Ticket" SIZE=10></TD>
+</TR>
 
-</UL>
+<TR>
+<TD>Make date Told:</TD><TD><& /Elements/SelectDate, Name => "Told_Date", ShowTime => 0, Default => '' &></TD>
+<TD>Children:</TD><TD><INPUT Name="MemberOf-bulk" SIZE=10></TD>
+<TD>Delete Children:</TD><TD><INPUT Name="DeleteLink-Ticket-MemberOf-bulk" SIZE=10></TD>
+</TR>
 
+<TR>
+<TD>Make date Due:</TD><TD><& /Elements/SelectDate, Name => "Due_Date", ShowTime => 0, Default => '' &></TD>
+<TD>Refers to:</TD><TD><INPUT Name="bulk-RefersTo" SIZE=10></TD>
+<TD>Delete Refers to:</TD><TD><INPUT Name="DeleteLink-bulk-RefersTo-Ticket" SIZE=10></TD>
+</TR>
+ 
+<TR>
+<TD>Make date Resolved:</TD><TD><& /Elements/SelectDate, Name => "Resolved_Date", ShowTime => 0, Default => '' &></TD>
+<TD>Referred to by:</TD><TD><INPUT Name="RefersTo-bulk" SIZE=10></TD>
+<TD>Delete Referred to by:</TD><TD><INPUT Name="DeleteLink-Ticket-RefersTo-bulk" SIZE=10></TD>
+</TR>
 
-</TD>
+% while ( my $KeywordSelect = $KeywordSelects->Next ) {
+<TR>
+<TD>Add<% $KeywordSelect->Name %></TD><TD><& /Elements/SelectKeyword, Name => "AddToKeywordSelect".$KeywordSelect->id, KeywordObj => $KeywordSelect->KeywordObj &></TD>
+<TD>Remove<% $KeywordSelect->Name %></TD><TD COLSPAN="3"><& /Elements/SelectKeyword, Name => "DeleteFromKeywordSelect".$KeywordSelect->id, KeywordObj => $KeywordSelect->KeywordObj &></TD>
 </TR>
+% }
+
 </table>
 <& /Elements/TitleBoxEnd&>
 <& /Elements/TitleBoxStart, title => 'Add comments or replies to selected tickets' &>
@@ -167,13 +202,15 @@
     my @watchresults = ProcessTicketWatchers(TicketObj => $Ticket, ARGSRef => \%ARGS);    
     my @selectresults = ProcessTicketObjectKeywords(TicketObj => $Ticket, ARGSRef => \%ARGS);
     
+    #Update the links (merge, memberOf, refers)
+    my @linkresults = ProcessTicketLinks(TicketObj => $Ticket, ARGSRef => \%ARGS);    
    
      my @updateresults; 
      if ($do_comment_reply) {
      ProcessUpdateMessage(TicketObj => $Ticket, ARGSRef => \%ARGS, Actions => \
 @updateresults); 
     } 
-    my @tempresults = (@watchresults, @basicresults, @dateresults, @updateresults);
+    my @tempresults = (@watchresults, @basicresults, @dateresults, @linkresults, @updateresults);
     @tempresults = map { "Ticket ".$Ticket->Id. ": ".$_ } @tempresults;
 
     


More information about the rt-users mailing list