[Rt-commit] r8956 - rt/branches/3.7-EXPERIMENTAL/html/Ticket

ruz at bestpractical.com ruz at bestpractical.com
Thu Sep 6 18:27:40 EDT 2007


Author: ruz
Date: Thu Sep  6 18:27:34 2007
New Revision: 8956

Modified:
   rt/branches/3.7-EXPERIMENTAL/html/Ticket/Update.html

Log:
* don't allow reply/comment using encryption if an recipient has no public key

Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Update.html
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Update.html	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Update.html	Thu Sep  6 18:27:34 2007
@@ -51,6 +51,7 @@
     Title=> $title &>
     
 % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
+<& /Elements/ListActions, actions => \@results &>
 
 <form action="Update.html" name="TicketUpdate"
     method="post" enctype="multipart/form-data">
@@ -240,13 +241,58 @@
 }
 # }}}
 
+my @results;
+if ( $ARGS{'SubmitTicket'} && $ARGS{'Encrypt'} ) {
+    my $action;
+    if ( ( $ARGS{'UpdateType'} &&  $ARGS{'UpdateType'} eq 'response' )
+        || ( $ARGS{'Action'} && $ARGS{'Action'} eq 'Respond' ) )
+    {
+        $action = 'Correspond';
+    }
+    else {
+        $action = 'Comment';
+    }
+
+    my $Message = MakeMIMEEntity(
+        Subject => $ARGS{'UpdateSubject'},
+        Body    => $ARGS{'UpdateContent'},
+    );
+
+    my ( $id, $msg, $txn ) = $TicketObj->$action(
+        CcMessageTo  => $ARGS{'UpdateCc'},
+        BccMessageTo => $ARGS{'UpdateBcc'},
+        MIMEObj      => $Message,
+        TimeTaken    => $ARGS{'UpdateTimeWorked'},
+        DryRun       => 1
+    );
+    unless ( $id ) {
+        $RT::Logger->error("Couldn't fire '$action' action: $msg");
+    }
+    my @recipients;
+    if ( $txn ) {
+        foreach my $scrip ( @{ $txn->Scrips->Prepared } ) {
+            my $action = $scrip->ActionObj->Action;
+            next unless $action->isa('RT::Action::SendEmail');
+
+            foreach my $type qw(To Cc Bcc) {
+                push @recipients, $action->$type();
+            }
+        }
+    }
+    foreach my $address ( map $_->address, @recipients ) {
+        my %res = RT::Crypt::GnuPG::GetPublicKeyInfo( $address );
+        unless ( $res{'info'} ) {
+            push @results, loc("There is no key for [_1]", $address);
+            $checks_failure = 1;
+        }
+    }
+}
+
 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
     return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
 }
 
-
-
 </%INIT>
 
 <%ARGS>


More information about the Rt-commit mailing list