[Rt-commit] r7120 - in rt/branches/3.7-EXPERIMENTAL: . html/Ticket/Elements

ruz at bestpractical.com ruz at bestpractical.com
Fri Mar 2 14:35:38 EST 2007


Author: ruz
Date: Fri Mar  2 14:35:37 2007
New Revision: 7120

Added:
   rt/branches/3.7-EXPERIMENTAL/html/Ticket/Forward.html
Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransaction

Log:
 r4642 at cubic-pc:  cubic | 2007-03-02 22:19:23 +0300
 * add Forwarding action


Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransaction
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransaction	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransaction	Fri Mar  2 14:35:37 2007
@@ -194,6 +194,14 @@
               . "&Action=Comment\">"
               . loc('Comment') . "</a>]";
         }
+        if ( $can_modify || $Transaction->TicketObj->CurrentUserHasRight('ForwardMessage') ) {
+            $titlebar_commands .=
+                "[<a href=\"/Ticket/Forward.html?id="
+              . $Transaction->Ticket
+              . "&QuoteTransaction="
+              . $Transaction->Id
+              . "\">". loc('Forward') . "</a>]";
+        }
     }
 }
 </%INIT>

Added: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Forward.html
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Forward.html	Fri Mar  2 14:35:37 2007
@@ -0,0 +1,117 @@
+<& /Elements/Header, Title => $Title &>
+<& /Ticket/Elements/Tabs, 
+    Ticket => $TicketObj, 
+    Title  => $Title,
+&>
+
+<form action="Forward.html" name="ForwardMessage" method="post">
+% $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS );
+<input type="hidden" class="hidden" name="id" value="<% $id %>" /><br />
+<input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{'QuoteTransaction'} %>" />
+
+<table border="0">
+
+<tr><td align="right"><&|/l&>Subject</&>:</td>
+<td><% $TicketObj->Subject %></td></tr>
+
+<tr><td align="right"><&|/l&>To</&>:</td>
+<td><input name="To" size="60" value="<% $ARGS{'To'} %>" /></td></tr>
+
+<tr><td align="right"><&|/l&>Cc</&>:</td>
+<td><input name="Cc" size="60" value="<% $ARGS{'Cc'} %>" /></td></tr>
+
+<tr><td align="right"><&|/l&>BCc</&>:</td>
+<td><input name="Bcc" size="60" value="<% $ARGS{'Bcc'} %>" /></td></tr>
+
+</table>
+
+<& /Elements/Submit, Label => loc('Forward Message'), Name => 'Forward' &>
+</form>
+<%INIT>
+my $TicketObj = LoadTicket($id);
+$id = $ARGS{'id'} = $TicketObj->id;
+
+my $txn = RT::Transaction->new( $session{'CurrentUser'} );
+$txn->Load( $QuoteTransaction );
+Abort( loc("Couldn't load transaction #[_1]", $QuoteTransaction) )
+    unless $txn->id;
+
+my $create_entity = sub {
+    my $attachment = shift;
+
+    my $entity = new MIME::Entity;
+    $entity->head->add( split /:/, $_, 2 )
+        foreach $attachment->SplitHeaders;
+
+    use MIME::Body;
+    $entity->bodyhandle(
+        MIME::Body::Scalar->new( $attachment->OriginalContent )
+    );
+
+    return $entity;
+};
+
+
+if ( $ARGS{'Forward'} ) {
+    my $main_content = $txn->ContentObj;
+
+    my $entity = $create_entity->( $main_content );
+    if ( $main_content->Parent ) {
+        # main content is not top most entity, we shouldn't loose
+        # From/To/Cc headers that are on a top part
+        my $attachments = RT::Attachments->new( $session{'CurrentUser'} );
+        $attachments->Columns(qw(id Parent TransactionId Headers));
+        $attachments->Limit( FIELD => 'TransactionId', VALUE => $txn->id );
+        $attachments->Limit( FIELD => 'Parent', VALUE => 0 );
+        $attachments->Limit( FIELD => 'Parent', OERATOR => 'IS', VALUE => 'NULL', QUOTEVALUE => 0 );
+        $attachments->OrderBy( FIELD => 'id', ORDER => 'ASC' );
+        my $tmp = $attachments->First;
+        if ( $tmp && $tmp->id ne $main_content->id ) {
+            $entity->make_multipart;
+            $entity->head->add( split /:/, $_, 2 ) foreach $tmp->SplitHeaders;
+            $entity->make_singlepart;
+        }
+    }
+
+    my $attachments = RT::Attachments->new( $session{'CurrentUser'} );
+    $attachments->Limit( FIELD => 'TransactionId', VALUE => $txn->id );
+    $attachments->Limit(
+        FIELD => 'id',
+        OPERATOR => '!=',
+        VALUE => $main_content->id,
+    );
+    $attachments->Limit(
+        FIELD => 'ContentType',
+        OPERATOR => 'NOT STARTSWITH',
+        VALUE => 'multipart/',
+    );
+    $attachments->Limit(
+        FIELD => 'Content',
+        OPERATOR => '!=',
+        VALUE => '',
+    );
+    while ( my $a = $attachments->Next ) {
+        $entity->make_multipart;
+        $entity->add_part( $create_entity->( $a ) );
+    }
+
+    my $mail = MIME::Entity->build(
+        To => $ARGS{'To'},
+        Cc => $ARGS{'Cc'},
+        Bcc => $ARGS{'Bcc'},
+        Subject => 'Fwd: '. ($txn->Subject || $TicketObj->Subject ),
+        Type => 'message/rfc822',
+        Encoding => '8bit',
+        Data => $entity->as_string,
+    );
+    RT::Interface::Email::SendEmail( entity => $mail );
+}
+
+my $Title = loc('Forward message');
+
+</%INIT>
+
+<%ARGS>
+$id => undef
+$QuoteTransaction => undef
+</%ARGS>


More information about the Rt-commit mailing list