[rt-devel] forward patch
ivan
ivan-rt-devel at 420.am
Mon Sep 24 22:26:08 EDT 2001
this is a forward patch i ported from pre-2.0 somewhere to 2.0.4. If
there's been churn between 2.0.4 and the current state of the world wrt
anything the forward patch touches, let me know and i'll see what I can
do.
i know this has been an oft-requested feature. hope it can help.
--
_ivan
-------------- next part --------------
diff -urN rt-2-0-4.dist/lib/RT/Action/Forward.pm rt-2-0-4.ivan1/lib/RT/Action/Forward.pm
--- rt-2-0-4.dist/lib/RT/Action/Forward.pm Wed Dec 31 16:00:00 1969
+++ rt-2-0-4.ivan1/lib/RT/Action/Forward.pm Mon Sep 24 18:52:09 2001
@@ -0,0 +1,49 @@
+#$Header$
+
+package RT::Action::Forward;
+require RT::Action::SendEmail;
+ at ISA = qw(RT::Action::SendEmail);
+
+sub SetRecipients {
+ my $self=shift;
+
+ #get To: from the MIME header (should have been shoved in there by
+ # RT::Interface::Web::ProcessUpdateMessage).
+ @To = split(/\s*,\s*/,
+ ( map { /^To:\s*(.*\S)\s*$/; $1 }
+ grep { /^To:/i }
+ split(/\n/,$self->TransactionObj->Message->First->Headers)
+ )[0]
+ );
+
+ if (@To) {
+ $To = join(',', at To);
+ }
+ else {
+ #$To = 'Undisclosed recipients;';
+ #NO. causes mail loops
+ $To = '';
+ }
+
+ $Cc = join(',', at Cc);
+ $Bcc = join(',', at Bcc);
+
+ $self->SetTo($To);
+ $self->SetCc($Cc);
+ $self->SetBcc($Bcc);
+
+ return(1);
+
+}
+
+sub SetReturnAddress {
+ my $self = shift;
+ my $friendly_name=$self->TransactionObj->CreatorObj->RealName;
+ my $email_address=$self->TransactionObj->CreatorObj->EmailAddress;
+ $self->TemplateObj->MIMEObj->head->add('From', "$friendly_name <$email_address>");
+ $self->TemplateObj->MIMEObj->head->add('Reply-To', $email_address);
+}
+
+sub SetSubjectToken { 1; }
+
+1;
diff -urN rt-2-0-4.dist/lib/RT/Attachment.pm rt-2-0-4.ivan1/lib/RT/Attachment.pm
--- rt-2-0-4.dist/lib/RT/Attachment.pm Fri Jul 6 15:32:58 2001
+++ rt-2-0-4.ivan1/lib/RT/Attachment.pm Mon Sep 24 19:03:53 2001
@@ -282,6 +282,44 @@
}
# }}}
+# {{{ sub Forward
+sub Forward {
+ my $self = shift;
+
+ my $from = ( map { /^From:\s*(.*\S)\s*$/; $1 }
+ grep { /^From:/i }
+ split(/\n/,$self->Headers)
+ )[0];
+
+ my $body = '';
+
+ #Attache the user's signature if we have it.
+ $body .= "\n\n-- \n" . $self->CurrentUser->UserObj->Signature
+ if ($self->CurrentUser->UserObj->Signature);
+
+ $body .= "\n\n----- Forwarded message from $from -----\n\n".
+ $self->Headers. "\n";
+
+ if ( $self->ContentType =~ m{^(text/plain|message)}i ) {
+ $body .= $self->Content;
+ } else {
+ $body .= "[Attachment]\n";
+ }
+
+ $body .= "\n\n----- End forwarded message -----\n";
+
+ my $max = 0;
+ foreach (split (/\n/,$body)) {
+ $max=length if ( length > $max);
+ }
+ $max += 2;
+
+ return (\$body, $max);
+
+}
+
+# }}}
+
# {{{ sub NiceHeaders - pulls out only the most relevant headers
sub NiceHeaders {
my $self=shift;
diff -urN rt-2-0-4.dist/lib/RT/Interface/Web.pm rt-2-0-4.ivan1/lib/RT/Interface/Web.pm
--- rt-2-0-4.dist/lib/RT/Interface/Web.pm Sun Jul 22 21:30:38 2001
+++ rt-2-0-4.ivan1/lib/RT/Interface/Web.pm Mon Sep 24 19:01:30 2001
@@ -127,23 +127,34 @@
Data => \@UpdateContent);
## TODO: Implement public comments
- if ($args{ARGSRef}->{'UpdateType'} =~ /^(private|public)$/) {
- my ($Transaction, $Description) = $args{TicketObj}->Comment
- ( CcMessageTo => $args{ARGSRef}->{'UpdateCc'},
- BccMessageTo => $args{ARGSRef}->{'UpdateBcc'},
- MIMEObj => $Message,
- TimeTaken => $args{ARGSRef}->{'UpdateTimeWorked'});
- push(@{$args{Actions}}, $Description);
- }
- elsif ($args{ARGSRef}->{'UpdateType'} eq 'response') {
- my ($Transaction, $Description) = $args{TicketObj}->Correspond
- ( CcMessageTo => $args{ARGSRef}->{'UpdateCc'},
- BccMessageTo => $args{ARGSRef}->{'UpdateBcc'},
- MIMEObj => $Message,
- TimeTaken => $args{ARGSRef}->{'UpdateTimeWorked'});
- push(@{$args{Actions}}, $Description);
- }
+
+ if ($args{ARGSRef}->{'UpdateType'} =~ /^(private|public)$/) {
+ $method = 'Comment';
+ } elsif ($args{ARGSRef}->{'UpdateType'} eq 'response') {
+ $method = 'Correspond';
+ } elsif ($args{ARGSRef}->{'UpdateType'} eq 'forward') {
+ $method = 'Forward';
+ $mime_args{'To'} = $args{ARGSRef}->{'TransactionCc'};
+ $mime_args{'From'} = $session{'CurrentUser'}->UserObj->EmailAddress;
+ $mime_args{'Reply-To'} = $session{'CurrentUser'}->UserObj->EmailAddress;
+ $mime_args{'Subject'} = 'Fwd: '. $mime_args{'Subject'};
+ }
+
+ my %update_args = ();
+ if ($args{ARGSRef}->{'UpdateType'} =~ /^(private|public|response)$/) {
+ $update_args{'CcMessageTo'} = $args{ARGSRef}->{'UpdateCc'};
+ $update_args{'BccMessageTo'} = $args{ARGSRef}->{'UpdateBcc'};
+ }
+
+ my ($Transaction, $Description) = $args{Ticket}->$method(
+ MIMEObj => MIME::Entity->build ( %mime_args ),
+ TimeTaken => $args{ARGSRef}->{'UpdateTimeWorked'},
+ %update_args,
+ );
+ push(@{$args{Actions}}, $Description);
+
}
+
}
# }}}
diff -urN rt-2-0-4.dist/lib/RT/Ticket.pm rt-2-0-4.ivan1/lib/RT/Ticket.pm
--- rt-2-0-4.dist/lib/RT/Ticket.pm Wed Jul 18 13:06:45 2001
+++ rt-2-0-4.ivan1/lib/RT/Ticket.pm Mon Sep 24 18:41:50 2001
@@ -1673,6 +1725,39 @@
}
return ($Trans, "correspondence sent");
+}
+
+# }}}
+
+# {{{ sub Forward
+
+=head2 Forward
+
+=cut
+
+sub Forward {
+ my $self = shift;
+ my %args = (
+ MIMEObj => undef,
+ TimeTaken => 0,
+ @_ );
+
+ #TODO: ACL check
+
+ unless ($args{'MIMEObj'}) {
+ return(0,"No message attached");
+ }
+
+ #Do the forward (write the transaction)
+ my ($Trans, $Msg, $TransObj) = $self->_NewTransaction(
+ Type => 'Forward',
+ Data =>($args{'MIMEObj'}->head->get('subject') || 'No Subject'),
+ TimeTaken => $args{'TimeTaken'},
+ MIMEObj => $args{'MIMEObj'},
+ );
+
+ return ($Trans, "Message forwarded.");
+
}
# }}}
diff -urN rt-2-0-4.dist/lib/RT/Transaction.pm rt-2-0-4.ivan1/lib/RT/Transaction.pm
--- rt-2-0-4.dist/lib/RT/Transaction.pm Wed Jul 18 13:13:48 2001
+++ rt-2-0-4.ivan1/lib/RT/Transaction.pm Mon Sep 24 18:46:41 2001
@@ -469,6 +469,10 @@
elsif ($self->Type eq 'Comment') {
return( "Comments added");
}
+
+ elsif ($self->Type eq 'Forward') {
+ return( "Mail forwarded" );
+ }
elsif ($self->Type eq 'Keyword') {
diff -urN rt-2-0-4.dist/webrt/Elements/MessageBox rt-2-0-4.ivan1/webrt/Elements/MessageBox
--- rt-2-0-4.dist/webrt/Elements/MessageBox Mon May 21 12:54:40 2001
+++ rt-2-0-4.ivan1/webrt/Elements/MessageBox Mon Sep 24 19:07:41 2001
@@ -17,6 +17,13 @@
($code, $Default)=RT::Link->GetContent($MessageURI);
}
if ($QuoteTransaction) {
+ my $method;
+ if ( $Action eq 'Forward' ) {
+ $method = 'Forward'
+ #} elsif ( $Action eq 'Comment' || $Action eq 'Respond' ) {
+ } else {
+ $method = 'Quote';
+ }
require RT::Ticket;
require RT::Transaction;
my $transaction=RT::Transaction->new($session{'CurrentUser'});
@@ -24,7 +31,7 @@
my $message=$transaction->Message->First;
my $dumb="";
my $d=\$dumb;
- ($d, $Width)=$message->Quote(Reply=>$Default)
+ ($d, $Width)=$message->$method(Reply=>$Default)
if $message;
$Default=$$d;
}
diff -urN rt-2-0-4.dist/webrt/Ticket/Elements/ShowTransaction rt-2-0-4.ivan1/webrt/Ticket/Elements/ShowTransaction
--- rt-2-0-4.dist/webrt/Ticket/Elements/ShowTransaction Fri Jul 6 15:26:15 2001
+++ rt-2-0-4.ivan1/webrt/Ticket/Elements/ShowTransaction Mon Sep 24 19:11:46 2001
@@ -87,6 +87,12 @@
"&QuoteTransaction=".$Transaction->Id.
"&Action=Comment\">Comment</a>]";
}
+ #if ($Transaction->TicketObj->CurrentUserHasRight('Forward')) {
+ $titlebar_commands .=
+ "[<a class='inverse' href=\"Update.html?id=".$Transaction->Ticket.
+ "&QuoteTransaction=".$Transaction->Id.
+ "&Action=Forward\">Forward</a>]";
+ #}
}
</%INIT>
diff -urN rt-2-0-4.dist/webrt/Ticket/Update.html rt-2-0-4.ivan1/webrt/Ticket/Update.html
--- rt-2-0-4.dist/webrt/Ticket/Update.html Mon May 21 10:20:05 2001
+++ rt-2-0-4.ivan1/webrt/Ticket/Update.html Mon Sep 24 19:15:09 2001
@@ -54,8 +54,14 @@
% if ($CanRespond) {
<option value="response" <%$ResponseDefault%>>Response to requestors</option>
% }
+% if ($CanForward) {
+ <option value="forward" <%$ForwardDefault%>>Forward to TransactionCc</option>
+
+% }
</select>
<br>
+TransactionCc: <INPUT TYPE="text" NAME="TransactionCc" SIZE=40> (forwards only)
+ <br>
Subject: <input name="UpdateSubject" size=60 value="Re: <% $Ticket->Subject %>"> <br>
<& /Elements/MessageBox, Name=>"UpdateContent", QuoteTransaction=>$ARGS{QuoteTransaction} &>
@@ -89,7 +95,7 @@
my $CommentDefault=$Action eq "Comment" ? "SELECTED" : "";
my $ResponseDefault=$Action eq "Respond" ? "SELECTED" : "";
-
+my $ForwardDefault=$Action eq "Forward" ? "SELECTED" : "";
$DefaultStatus = $Ticket->Status() unless ($DefaultStatus);
More information about the Rt-devel
mailing list