ForwardWithMessage: Difference between revisions
(To forward a ticket or transaction WITH a message for the recipient.) |
No edit summary |
||
Line 5: | Line 5: | ||
: Open /local/html/Ticket/Forward.html and insert after | : Open /local/html/Ticket/Forward.html and insert after | ||
<td><input name="Bcc" size="60" value="<% $ARGS{'Bcc'} || '' %>" /></td></tr> | <td><input name="Bcc" size="60" value="<% $ARGS{'Bcc'} || '' %>" /></td></tr>'' | ||
: a new table-row with a textarea for the message:<br /> | : a new table-row with a textarea for the message:<br /> | ||
Line 11: | Line 11: | ||
<tr><td align="right"><&|/l&>Message</&>:</td> | <tr><td align="right"><&|/l&>Message</&>:</td> | ||
<td> | <td> | ||
<textarea name="Message" cols="51"><% $ARGS{'Message'} || '' %></textarea> | <textarea name="Message" cols="51"><% $ARGS{'Message'} || '' %></textarea>'' | ||
</td> | </td> | ||
</tr> | </tr> | ||
Line 35: | Line 35: | ||
my %args = ( To => '', Cc => '', Bcc => ''''', Message => ''''', @_ ); | my %args = ( To => '', Cc => '', Bcc => ''''', Message => ''''', @_ ); | ||
'''my $entity = MIME::Entity->build( | '''my $entity = MIME::Entity->build(''' | ||
''' Type => 'multipart/mixed',''' | |||
''' Description => 'forwarded transaction',''' | |||
''' );''' | |||
''' my $mimeMessage = MIME::Entity->build(''' | |||
''' Type => 'text/plain; charset="utf-8"',''' | |||
''' Data => $args{Message}''' | |||
''' );''' | |||
''' $entity->add_part($mimeMessage);''' | |||
''' $entity->add_part($txn->ContentAsMIME);''' | |||
my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Transaction => $txn ); | my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Transaction => $txn ); | ||
Line 58: | Line 58: | ||
); | ); | ||
''' #Attach message for Recipients to Transaction | ''' #Attach message for Recipients to Transaction''' | ||
''' $createdTrans->_Attach(''' | |||
''' MIME::Entity->build(''' | |||
''' Type => 'text/plain',''' | |||
''' Data => $args{Message})''' | |||
''' );''' | |||
unless ($ret) { | unless ($ret) { | ||
Line 87: | Line 87: | ||
); | ); | ||
''' my $mimeMessage = MIME::Entity->build( | ''' my $mimeMessage = MIME::Entity->build(''' | ||
''' Type => 'text/plain; charset="utf-8"',''' | |||
''' Data => $args{Message}''' | |||
''' );''' | |||
''' $entity->add_part($mimeMessage);''' | |||
$entity->add_part( $_ ) foreach | $entity->add_part( $_ ) foreach | ||
Line 112: | Line 112: | ||
); | ); | ||
''' #Attach message for Recipients to Transaction | ''' #Attach message for Recipients to Transaction''' | ||
''' $createdTrans->_Attach($mimeMessage);''' | |||
unless ($ret) { | unless ($ret) { |
Revision as of 08:00, 14 September 2012
You can't forward a ticket or transaction with a message for the recipient. To change that:
- Insert a textarea for the message on Forward-Page:
- Copy /html/Ticket/Forward.html to /local/html/Ticket/Forward.html
- Open /local/html/Ticket/Forward.html and insert after
<input name="Bcc" size="60" value="<% $ARGS{'Bcc'} || %>" />
- a new table-row with a textarea for the message:
<&|/l&>Message</&>:
<textarea name="Message" cols="51"><% $ARGS{'Message'} || %></textarea>
- Send message per Mail and store it in the Forward-Transaction:
- Create /local/lib/RT/Interface/Email_Local.pm and add following content. (Differences to Email.pm are bold)
use strict; no warnings qw(redefine); package RT::Interface::Email; use Email::Address; use MIME::Entity; use RT::EmailParser; use File::Temp; use UNIVERSAL::require; use Mail::Mailer (); use Text::ParseWords qw/shellwords/; sub ForwardTransaction { my $txn = shift; my %args = ( To => , Cc => , Bcc => , Message => , @_ ); my $entity = MIME::Entity->build( Type => 'multipart/mixed', Description => 'forwarded transaction', ); my $mimeMessage = MIME::Entity->build( Type => 'text/plain; charset="utf-8"', Data => $args{Message} ); $entity->add_part($mimeMessage); $entity->add_part($txn->ContentAsMIME); my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Transaction => $txn ); if ($ret) { my $ticket = $txn->TicketObj; my ( $ret, $msg, $createdTrans ) = $ticket->_NewTransaction( Type => 'Forward Transaction', Field => $txn->id, Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc}, ); #Attach message for Recipients to Transaction $createdTrans->_Attach( MIME::Entity->build( Type => 'text/plain', Data => $args{Message}) ); unless ($ret) { $RT::Logger->error("Failed to create transaction: $msg"); } } return ( $ret, $msg ); } sub ForwardTicket { my $ticket = shift; my %args = ( To => , Cc => , Bcc => , Message=>, @_ ); my $txns = $ticket->Transactions; $txns->Limit( FIELD => 'Type', VALUE => $_, ) for qw(Create Correspond); my $entity = MIME::Entity->build( Type => 'multipart/mixed', Description => 'forwarded ticket', ); my $mimeMessage = MIME::Entity->build( Type => 'text/plain; charset="utf-8"', Data => $args{Message} ); $entity->add_part($mimeMessage); $entity->add_part( $_ ) foreach map $_->ContentAsMIME, @{ $txns->ItemsArrayRef }; my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Ticket => $ticket, Template => 'Forward Ticket', ); if ($ret) { my ( $ret, $msg, $createdTrans ) = $ticket->_NewTransaction( Type => 'Forward Ticket', Field => $ticket->id, Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc} ); #Attach message for Recipients to Transaction $createdTrans->_Attach($mimeMessage); unless ($ret) { $RT::Logger->error("Failed to create transaction: $msg"); } } return ( $ret, $msg ); } 1; That's it. Hopefully it helps someone.