[rt-users] "Forward" to 3rd party patch

Simon Cozens rt at netthink.co.uk
Mon Mar 18 09:51:25 EST 2002


Here are three patches (sorry, Perforce won't let me easily combine them into
a single patch) which apply with -p2 to an RT source tree to add the "Forward"
action to each transaction. This allows you to forward a transaction onto a
third party. If the third party happens to have permission to correspond on
the ticket, then they'll be able to reply straight back into RT. 

It also needs an entry in the scripconditions table and one in the
scripactions table:

    scripactions 
        name       : ForwardToThirdParty
        description: Forward to a third party
        execmodule : SendToThirdParty

    scripconditions
        name                : OnForward
        description         : Forwarding to third party
        execmodule          : AnyTransaction
        applicabletranstypes: Forward

If you don't know how to do that, you probably don't want to be playing
with this patch yet. :)

-- 
CLUELESSNESS:
    There are No Stupid Questions,
    But There Are a LOT of Inquisitive Idiots
                                                    http://www.despair.com
-------------- next part --------------
Change 14965 by simon at simon-squash on 2002/03/18 13:05:58

	 I believe this gives us forward-to-third-party.

Affected files ...

... //systems/src/rt/lib/RT/Action/SendToThirdParty.pm#1 add
... //systems/src/rt/lib/RT/Interface/Web.pm#3 edit
... //systems/src/rt/lib/RT/Ticket.pm#13 edit
... //systems/src/rt/lib/RT/Transaction.pm#3 edit
... //systems/src/rt/webrt/Elements/MessageBox#3 edit
... //systems/src/rt/webrt/Ticket/Elements/ShowTransaction#15 edit
... //systems/src/rt/webrt/Ticket/Update.html#3 edit

Differences ...

==== //systems/src/rt/lib/RT/Interface/Web.pm#3 (text) ====
Index: src/rt/lib/RT/Interface/Web.pm
--- src/rt/lib/RT/Interface/Web.pm.~1~	Mon Mar 18 14:07:51 2002
+++ src/rt/lib/RT/Interface/Web.pm	Mon Mar 18 14:07:51 2002
@@ -249,8 +249,14 @@
 		  MIMEObj => $Message,
 		  TimeTaken => $args{ARGSRef}->{'UpdateTimeWorked'});
 	    push(@{$args{Actions}}, $Description);
-	} 
-	else {
+	} elsif ($args{ARGSRef}->{'UpdateType'} eq 'forward') {
+	    my ($Transaction, $Description) = $args{TicketObj}->Forward
+		( ForwardTo => $args{ARGSRef}->{'ForwardTo'},
+		  BccMessageTo => $args{ARGSRef}->{'UpdateBcc'},
+		  MIMEObj => $Message,
+		  TimeTaken => $args{ARGSRef}->{'UpdateTimeWorked'});
+	    push(@{$args{Actions}}, $Description);
+	} else {
 	    push(@{$args{'Actions'}}, "Update type was neither correspondence nor comment. Update not recorded");
 	}
     }

==== //systems/src/rt/lib/RT/Ticket.pm#13 (xtext) ====
Index: src/rt/lib/RT/Ticket.pm
--- src/rt/lib/RT/Ticket.pm.~1~	Mon Mar 18 14:07:51 2002
+++ src/rt/lib/RT/Ticket.pm	Mon Mar 18 14:07:51 2002
@@ -1758,6 +1758,48 @@
 
 # }}}
 
+# {{{ sub Forward
+
+=head2 Forward
+
+Forward this ticket onto a third party.
+Takes a hashref with the follwoing attributes:
+
+MIMEObj, TimeTaken, ForwardTo
+
+=cut
+
+sub Forward {
+  my $self = shift;
+  
+  my %args = (
+	      
+	      MIMEObj => undef,
+          ForwardTo => undef,
+	      TimeTaken => 0,
+	      @_ );
+
+  unless (($self->CurrentUserHasRight('ReplyToTicket')) or
+	  ($self->CurrentUserHasRight('ModifyTicket'))) {
+      return (0, "Permission Denied");
+  }
+
+  unless ($args{ForwardTo}) {
+      return (0, "No Forwarding Address Given");
+  }
+  
+  
+  #Record the correspondence (write the transaction)
+  my ($Trans, $Msg, $TransObj) = $self->_NewTransaction( Type => 'Forward',
+				      Data =>$args{'ForwardTo'},
+				      TimeTaken => $args{'TimeTaken'},
+				      MIMEObj => $args{'MIMEObj'}
+				    );
+  
+  
+  return ($Trans, "Message Forwarded");
+}
+
 # }}}
 
 # {{{ Routines dealing with Links and Relations between tickets

==== //systems/src/rt/lib/RT/Transaction.pm#3 (xtext) ====
Index: src/rt/lib/RT/Transaction.pm
--- src/rt/lib/RT/Transaction.pm.~1~	Mon Mar 18 14:07:51 2002
+++ src/rt/lib/RT/Transaction.pm	Mon Mar 18 14:07:51 2002
@@ -332,7 +332,7 @@
 	    $content=$wrapper->wrap($content);
 	}
 
-	$content =~ s/^/> /gm;
+	$content =~ s/^/> /gm unless $args{'Quote'} == 2; # Secondary quoting style
 	$content = '[' . $self->CreatorObj->Name() . ' - ' . $self->CreatedAsString()
 	            . "]:\n\n"
    	        . $content . "\n\n";

==== //systems/src/rt/webrt/Elements/MessageBox#3 (text) ====
Index: src/rt/webrt/Elements/MessageBox
--- src/rt/webrt/Elements/MessageBox.~1~	Mon Mar 18 14:07:51 2002
+++ src/rt/webrt/Elements/MessageBox	Mon Mar 18 14:07:51 2002
@@ -10,11 +10,11 @@
 if ($QuoteTransaction) {
     my $transaction=RT::Transaction->new($session{'CurrentUser'});
     $transaction->Load($QuoteTransaction);
-    $message=$transaction->Content(Quote => 1);
+    $message=$transaction->Content(Quote => $Style+1);
 }
 
 my $signature = '';
-if ($session{'CurrentUser'}->UserObj->Signature) {
+if ($session{'CurrentUser'}->UserObj->Signature and $Style != 1) {
 	$signature = "-- \n".$session{'CurrentUser'}->UserObj->Signature;
 }
 
@@ -26,5 +26,6 @@
 $DefaultURI => undef
 $Width => 72
 $MessageURI => undef
+$Style => 0 # Style 0 is ordinary replying, style 1 is forwarding
 </%ARGS>
 

==== //systems/src/rt/webrt/Ticket/Elements/ShowTransaction#15 (xtext) ====
Index: src/rt/webrt/Ticket/Elements/ShowTransaction
--- src/rt/webrt/Ticket/Elements/ShowTransaction.~1~	Mon Mar 18 14:07:51 2002
+++ src/rt/webrt/Ticket/Elements/ShowTransaction	Mon Mar 18 14:07:51 2002
@@ -126,6 +126,10 @@
 	  	  "[<a class='inverse' href=\"Update.html?id=".
 		  $Transaction->Ticket . "&DefaultStatus=resolved&QuoteTransaction=".$Transaction->Id.
 		  "&Action=Respond\">Resolve</a>] ";
+		$titlebar_commands .= 
+	  	  "[<a class='inverse' href=\"Update.html?id=".
+		  $Transaction->Ticket . "&QuoteTransaction=".$Transaction->Id.
+		  "&Action=Forward\">Forward</a>] ";
 	}
 }
 

==== //systems/src/rt/webrt/Ticket/Update.html#3 (xtext) ====
Index: src/rt/webrt/Ticket/Update.html
--- src/rt/webrt/Ticket/Update.html.~1~	Mon Mar 18 14:07:51 2002
+++ src/rt/webrt/Ticket/Update.html	Mon Mar 18 14:07:51 2002
@@ -34,8 +34,6 @@
 </TD>
 </TR>
 </TABLE>
-
-
 <hr>
 
 Update Type: <select name="UpdateType">
@@ -44,9 +42,14 @@
 % }
 % if ($CanRespond) {
    <option value="response" <%$ResponseDefault%>>Response to requestors</option>
+   <option value="forward" <%$ForwardDefault%>>Forward to 3rd Party</option>
 % }
 	  </select> 
 	  <br>
+% if ($Action eq "Forward") {
+Forwarding address:
+<input name="ForwardTo" size=60><br>
+% }
 
 Status:
 <& /Elements/SelectStatus, Name=>"Status", Default => $DefaultStatus &>
@@ -56,7 +59,7 @@
 <input size=4 name="UpdateTimeWorked"> minutes<BR>
 Subject: <input name="UpdateSubject" size=60 value="<%$Ticket->Subject()%>"> <br>
 Attach: <input name="UpdateAttachment" type="file"> <br>
-<& /Elements/MessageBox, Name=>"UpdateContent", QuoteTransaction=>$ARGS{QuoteTransaction} &>
+<& /Elements/MessageBox, Name=>"UpdateContent", QuoteTransaction=>$ARGS{QuoteTransaction}, Style => $Action eq "Forward" &>
 		<INPUT TYPE=HIDDEN NAME=id VALUE="<%$Ticket->Id%>"><br>
 
 
@@ -79,6 +82,8 @@
 
 if ($DefaultStatus eq 'resolved') {
 	$title = "Resolve";
+} elsif ($Action eq 'Forward') {
+	$title = "Forward";
 } else {
 	$title = "Update";
 }
@@ -89,6 +94,7 @@
 # for the convinience:
 my $CommentDefault=$Action eq "Comment" ? "SELECTED" : "";
 my $ResponseDefault=$Action eq "Respond" ? "SELECTED" : "";
+my $ForwardDefault=$Action eq "Forward" ? "SELECTED" : "";
 
 $DefaultStatus = $Ticket->Status() unless ($DefaultStatus);
 

==== //systems/src/rt/lib/RT/Action/SendToThirdParty.pm#1 (xtext) ====
Index: src/rt/lib/RT/Action/SendToThirdParty.pm
--- src/rt/lib/RT/Action/SendToThirdParty.pm.~1~	Mon Mar 18 14:07:51 2002
+++ src/rt/lib/RT/Action/SendToThirdParty.pm	Mon Mar 18 14:07:51 2002
@@ -0,0 +1,28 @@
+#$Header: /raid/cvsroot/rt/lib/RT/Action/Notify.pm,v 1.2 2001/11/06 23:04:17 jesse Exp $
+
+package RT::Action::SendToThirdParty;
+require RT::Action::SendEmail;
+ at ISA = qw(RT::Action::SendEmail);
+
+
+# {{{ sub SetRecipients
+
+=head2 SetRecipients
+
+Sets the recipients of this message to the user specified in the
+transaction.
+
+=cut
+
+
+sub SetRecipients {
+    my $self=shift;
+
+    $arg=$self->Argument;
+	@{$self->{'To'}} = @{$self->TransactionObj->Data};
+    return(1);
+}
+
+# }}}
+
+1;
End of Patch.
-------------- next part --------------
Change 14972 by simon at simon-squash on 2002/03/18 14:02:37

	Amusing stupidity.

Affected files ...

... //systems/src/rt/lib/RT/Action/SendToThirdParty.pm#2 edit

Differences ...

==== //systems/src/rt/lib/RT/Action/SendToThirdParty.pm#2 (xtext) ====
Index: src/rt/lib/RT/Action/SendToThirdParty.pm
--- src/rt/lib/RT/Action/SendToThirdParty.pm.~1~	Mon Mar 18 14:08:39 2002
+++ src/rt/lib/RT/Action/SendToThirdParty.pm	Mon Mar 18 14:08:39 2002
@@ -19,7 +19,7 @@
     my $self=shift;
 
     $arg=$self->Argument;
-	@{$self->{'To'}} = @{$self->TransactionObj->Data};
+	@{$self->{'To'}} = $self->TransactionObj->Data;
     return(1);
 }
 
End of Patch.
-------------- next part --------------
Change 14973 by simon at simon-squash on 2002/03/18 14:07:06

	Fix description bogosity.

Affected files ...

... //systems/src/rt/lib/RT/Transaction.pm#4 edit

Differences ...

==== //systems/src/rt/lib/RT/Transaction.pm#4 (xtext) ====
Index: src/rt/lib/RT/Transaction.pm
--- src/rt/lib/RT/Transaction.pm.~1~	Mon Mar 18 14:08:44 2002
+++ src/rt/lib/RT/Transaction.pm	Mon Mar 18 14:08:44 2002
@@ -561,6 +561,8 @@
     
     elsif ($self->Type eq 'Comment')  {
 	return( "Comments added");
+    } elsif ($self->Type eq 'Forward') {
+    return( "Forwarded to ".$self->Data);
     }
     
     elsif ($self->Type eq 'Keyword') {
End of Patch.


More information about the rt-users mailing list