[Rt-commit] r7919 - rt/branches/3.7-EXPERIMENTAL-RTIR-2.4/lib/RT/Interface

ruz at bestpractical.com ruz at bestpractical.com
Thu May 24 01:57:23 EDT 2007


Author: ruz
Date: Thu May 24 01:57:23 2007
New Revision: 7919

Modified:
   rt/branches/3.7-EXPERIMENTAL-RTIR-2.4/lib/RT/Interface/Email.pm

Log:
RT::Interface::Email::SendEmail
* add support for Sign/Encrypt arguments
* make Ticket/Transaction independant when figuring out crypt options
* update docs

Modified: rt/branches/3.7-EXPERIMENTAL-RTIR-2.4/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-RTIR-2.4/lib/RT/Interface/Email.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL-RTIR-2.4/lib/RT/Interface/Email.pm	Thu May 24 01:57:23 2007
@@ -305,9 +305,32 @@
 Sends an email (passed as a L<MIME::Entity> object C<ENTITY>) using
 RT's outgoing mail configuration. If C<BOUNCE> is passed, and is a
 true value, the message will be marked as an autogenerated error, if
-possible.
+possible. Sets Date field of the head to now if it's not set.
 
-Sets Date field of the head to now if it's not set.
+Ticket and Transaction arguments are optional. If Transaction is
+specified and Ticket is not then ticket of the transaction is
+used, but only if the transaction belongs to a ticket.
+
+Returns 1 on success, 0 on error or -1 if message has no recipients
+and hasn't been sent.
+
+=head3 Signing and Encrypting
+
+This function as well signs and/or encrypts the message according to
+headers of a transaction's attachment or properties of a ticket's queue.
+To get full access to the configuration Ticket and/or Transaction
+arguments must be provided, but you can force behaviour using Sign
+and/or Encrypt arguments.
+
+The following precedence of arguments are used to figure out if
+the message should be encrypted and/or signed:
+
+* if Sign or Encrypt argument is defined then its value is used
+
+* else if Transaction's first attachment has X-RT-Sign or X-RT-Encrypt
+header field then it's value is used
+
+* else properties of a queue of the Ticket are used.
 
 =cut
 
@@ -349,14 +372,19 @@
         $args{'Ticket'} = $args{'Transaction'}->Object;
     }
 
-    if ( $args{'Ticket'} && $args{'Transaction'} && RT->Config->Get('GnuPG')->{'Enable'} ) {
-        my $attachment = $args{'Transaction'}->Attachments->First;
-
+    if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
         my %crypt;
+
+        my $attachment;
+        $attachment = $args{'Transaction'}->Attachments->First
+            if $args{'Transaction'};
+
         foreach my $argument ( qw(Sign Encrypt) ) {
+            next if defined $args{ $argument };
+
             if ( $attachment && defined $attachment->GetHeader("X-RT-$argument") ) {
                 $crypt{$argument} = $attachment->GetHeader("X-RT-$argument");
-            } else {
+            } elsif ( $args{'Ticket'} ) {
                 $crypt{$argument} = $args{'Ticket'}->QueueObj->$argument();
             }
         }


More information about the Rt-commit mailing list