[rt-devel] PATCH: 'Bounce' (re-send) action for data transactions

Victor Danilchenko danilche at cs.umass.edu
Tue Oct 28 15:37:24 EST 2003


On Tue, 28 Oct 2003, Victor Danilchenko wrote:

>	Updated patch, incorporating most of the suggested
>modifications, and some new ones I thought of.

	Oops, that patch contained one typo that messed up the default
subject value. Here's the correct one.

-- 
|  Victor  Danilchenko  | When in danger or in doubt,        |
| danilche at cs.umass.edu | run in circles, scream, and shout. |
|   CSCF   |   5-4231   |                    Robert Heinlein |
-------------- next part --------------
--- share/html/Ticket/Elements/ShowTransaction.orig	2003-09-25 16:31:06.000000000 -0400
+++ share/html/Ticket/Elements/ShowTransaction	2003-10-22 16:49:07.000000000 -0400
@@ -164,8 +164,16 @@
 	     $titlebar_commands .= 
 	     "[<a href=\"Update.html?id=".$Transaction->Ticket. 
 	     "&QuoteTransaction=".$Transaction->Id.
-	     "&Action=Comment\">". loc('Comment') ."</a>]";
+	     "&Action=Comment\">". loc('Comment') ."</a>]&nbsp;";
 	}
+
+	if ($Transaction->TicketObj->CurrentUserHasRight('ShowTicket')) {
+		$titlebar_commands .= 
+	  	  "[<a href=\"Bounce.html?id=".
+		  $Transaction->Ticket . "&QuoteTransaction=".$Transaction->Id.
+		  "\">". loc('Bounce') ."</a>]";
+	}
+
 }
 
 </%INIT>
--- share/html/Ticket/Bounce.html	2003-01-30 05:24:37.000000000 -0500
+++ share/html/Ticket/Bounce.html	2003-10-28 15:35:07.000000000 -0500
@@ -0,0 +1,99 @@
+%# BEGIN LICENSE BLOCK
+%# 
+%# Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
+%# 
+%# (Except where explictly superceded by other copyright notices)
+%# 
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%# 
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%# 
+%# Unless otherwise specified, all modifications, corrections or
+%# extensions to this work which alter its source code become the
+%# property of Best Practical Solutions, LLC when submitted for
+%# inclusion in the work.
+%# 
+%# 
+%# END LICENSE BLOCK
+<& /Elements/Header, Title => loc("Bounce Transaction # [_1] [_2]", $Ticket->Id, $Ticket->Subject) &>
+<& /Ticket/Elements/Tabs, 
+    Ticket => $Ticket, current_tab => 'Ticket/Bounce.html?id='.$Ticket->id, 
+    Title => loc("Bounce Transaction # [_1] [_2]", $Ticket->Id, $Ticket->Subject) &>
+
+<%PERL>
+if ($To) {
+    use RT::Action::SendEmail;
+    use MIME::Entity;
+    my $tag  = "[$RT::rtname #" . $Ticket->id . "]";
+    my $sub = "$tag $Subject" unless $Subject =~ /\Q$tag\E/;
+    my $MIMEObj = MIME::Entity->build (Type    => "multipart/mixed",
+				       From    => "$RT::CorrespondAddress",
+				       To      => "$To",
+				       Cc      => "$Cc",
+				       Subject => "$sub");
+
+    for (my $attachments = $Transaction->Attachments; my $attch = $attachments->Next;) {
+	$MIMEObj->attach(Type     => $attch->ContentType,
+			 Data     => $attch->Content,
+			 Filename => $attch->Filename)
+	    if $attch->Content;
+    }
+    
+    $sent = (new RT::Action::SendEmail)->SendMessage($MIMEObj);
+}
+</%PERL>
+
+<% $To && ($sent ? "<h1>Message sent!</h1>" : "<h1>Failed to send message!</h1>") | n %>
+
+<BR>
+<FORM ACTION="Bounce.html" NAME="TicketBounce" 
+	METHOD=GET enctype="multipart/form-data">
+<input type="hidden" name="id" value="<% "$id" %>">
+<input type="hidden" name="QuoteTransaction" value="<% $Transaction->id %>">
+
+<TABLE BORDER=0 cellspacing=0 cellpadding=0>
+<TR><TD align=right>Subject:</TD>
+    <TD><input type="text" name="Subject" size=60 value="<% "$Subject" %>"></TD></TR>
+<TR><TD align=right>To:</TD>
+    <TD><input type="text" name="To" size=60 value="<% "$To" %>"></TD></TR>
+<TR><TD align=right>Cc:</TD>
+    <TD><input type="text" name="Cc" size=60></TD></TR>
+<TR><TD colspan=2>
+<& /Elements/Submit, Name => 'SubmitTicket' &>
+
+    </TD></TR>
+</TABLE>
+
+<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=2 BORDER=0>
+      <& /Ticket/Elements/ShowTransaction, Ticket => $Ticket, Transaction => $Transaction, ShowHeaders => $ARGS{'ShowHeaders'}, ShowTitleBarCommands => $ShowTitleBarCommands, Collapsed => $Collapsed &>
+</TABLE>
+</FORM>
+<%ARGS>
+$id => undef
+$ShowTitleBarCommands => 0
+$Collapsed => 0
+$To => undef
+$Cc => undef
+$Subject => undef
+</%ARGS>
+
+<%INIT>
+
+my $sent = 0;
+my $Ticket = LoadTicket ($id);
+Abort("No permission to view ticket") unless $Ticket->CurrentUserHasRight('ShowTicket');
+my $Transaction;
+
+for (my $trs = $Ticket->Transactions;
+     $Transaction = $trs->Next;) {
+    last if $Transaction->id == $ARGS{'QuoteTransaction'};
+}
+
+$Subject ||= $Transaction->Subject || $Ticket->Subject;
+</%INIT>


More information about the Rt-devel mailing list