[Rt-commit] r9915 - rt/branches/3.7-RTIR-RELENG/html/Admin/Users

ruz at bestpractical.com ruz at bestpractical.com
Wed Dec 12 11:50:08 EST 2007


Author: ruz
Date: Wed Dec 12 11:50:07 2007
New Revision: 9915

Modified:
   rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html

Log:
* add per user PrivateKey selector

Modified: rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html
==============================================================================
--- rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html	(original)
+++ rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html	Wed Dec 12 11:50:07 2007
@@ -8,20 +8,59 @@
 
 <& /Elements/ListActions, actions => \@results &>
 
-% if ( my $email = $UserObj->EmailAddress ) {
+% if ( $email ) {
 <& /Admin/Elements/ShowKeyInfo, EmailAddress => $email &>
+% } else {
+<h2><% loc("User has empty email address") %></h2>
 % }
 
+<form action="<%RT->Config->Get('WebPath')%>/Admin/Users/GnuPG.html" method="post" enctype="multipart/form-data">
+<input type="hidden" class="hidden" name="id" value="<% $UserObj->Id %>" />
+
+<& /Widgets/Form/Select,
+    Name         => 'PrivateKey',
+    Description  => loc('Private Key'),
+    Values       => [ map $_->{'Key'}, @{ $keys_meta{'info'} } ],
+    CurrentValue => $private_key,
+    DefaultLabel => loc('No private key'),
+&>
+
+<& /Elements/Submit, Name => 'Update', Label => loc('Save Changes') &>
+</form>
+
 <%ARGS>
-$id => undef
+$id         => undef
+$Update     => undef
 </%ARGS>
 <%INIT>
 return unless RT->Config->Get('GnuPG')->{'Enable'};
 
+require RT::Crypt::GnuPG;
+
 my @results;
 
 my $UserObj = RT::User->new( $session{'CurrentUser'} );
 $UserObj->Load( $id );
+unless ( $UserObj->id ) {
+    Abort( loc("Couldn't load user #[_1]", $id) );
+}
+$id = $ARGS{'id'} = $UserObj->id;
+
+my $email = $UserObj->EmailAddress;
+my %keys_meta = RT::Crypt::GnuPG::GetKeysForSigning( $email );
+
+$ARGS{'PrivateKey'} = $m->comp('/Widgets/Form/Select:Process',
+    Name      => 'PrivateKey',
+    Arguments => \%ARGS,
+    Default   => 1,
+);
+
+if ( $Update ) {
+    my ($status, $msg) = $UserObj->SetPrivateKey( $ARGS{'PrivateKey'} );
+    push @results, $msg;
+}
+
+my $private_key = $UserObj->PrivateKey;
 
 my $title = loc("User's GnuPG keys");
 


More information about the Rt-commit mailing list