[Rt-commit] r9890 - in rtir/branches/2.3-EXPERIMENTAL/html/RTIR: .
Elements
ruz at bestpractical.com
ruz at bestpractical.com
Tue Dec 11 09:55:44 EST 2007
Author: ruz
Date: Tue Dec 11 09:55:44 2007
New Revision: 9890
Modified:
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/UpdateData
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Create.html
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html
Log:
* get rid of a lot of duplicated code by using new GnuPG widget
Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html (original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html Tue Dec 11 09:55:44 2007
@@ -69,7 +69,7 @@
<a name="top"></a>
-<& /Elements/GnuPGKeyIssues, Issues => \@gnupg_keys_issues, SignAddresses => \@cannot_sign_as &>
+<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
<&| /Widgets/TitleBox, contentbg => "#cccccc", title => $Title &>
<table border="0" cellpadding="0" cellspacing="2">
@@ -269,11 +269,9 @@
</tr>
<tr><td colspan="3"><& SELF:AttachmentsForm &></td><tr>
-% if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
+% if ( $gnupg_widget ) {
<tr><td> </td><td colspan="2">
- <% loc('Sign')%> <& /Widgets/Form/Boolean:InputOnly, Name => 'Sign', CurrentValue => $ARGS{'Sign'} &>
-
- <% loc('Encrypt')%> <& /Widgets/Form/Boolean:InputOnly, Name => 'Encrypt', CurrentValue => $ARGS{'Encrypt'} &>
+ <& /Elements/GnuPG/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
</td></tr>
% }
@@ -344,18 +342,6 @@
return $m->comp( "/RTIR/$Type/Create.html", %ARGS );
}
-if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
- require RT::Crypt::GnuPG;
-
- foreach ( qw(Sign Encrypt) ) {
- $ARGS{ $_ } = $m->comp( '/Widgets/Form/Boolean:Process',
- Name => $_,
- DefaultValue => $QueueObj->$_,
- Arguments => \%ARGS,
- );
- }
-}
-
my ($Status, $name);
if ( $Type eq 'Report' ) {
$name = 'Incident Report';
@@ -408,37 +394,20 @@
push @results, $m->comp( 'SELF:ProcessAttachments', %ARGS );
-# check to see if we have a good passphrase
-my @cannot_sign_as;
-if ( $ARGS{'Create'} && $ARGS{'Sign'} ) {
- my $address = $QueueObj->CorrespondAddress
- || RT->Config->Get('CorrespondAddress');
- unless ( RT::Crypt::GnuPG::DrySign( $address ) ) {
- push @cannot_sign_as, $address;
- $checks_failure = 1;
- }
-}
-
-my @gnupg_keys_issues;
-if ( $ARGS{'Create'} && $ARGS{'Encrypt'} ) {
-
- my @recipients = $m->comp(
- '/Ticket/Elements/PreviewScrips:GetRecipientsOnCreate',
- %ARGS
+my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
+$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
+ self => $gnupg_widget,
+ QueueObj => $QueueObj,
+);
+if ( $ARGS{'Create'} && $gnupg_widget ) {
+ my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
+ self => $gnupg_widget,
+ Operation => 'Create',
+ QueueObj => $QueueObj,
);
-
- RT::Crypt::GnuPG::UseKeyForEncryption(
- map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
- grep $ARGS{$_} && /^UseKey-/,
- keys %ARGS
- );
-
- my $status;
- ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
$checks_failure = 1 unless $status;
}
-# checks
if ( $ARGS{'Create'} ) {
if ( $Type eq 'Investigation' && !$ARGS{'Requestors'} ) {
push @results, loc( "You must enter a correspondent" );
Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/UpdateData
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/UpdateData (original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/UpdateData Tue Dec 11 09:55:44 2007
@@ -42,11 +42,12 @@
</&></td></tr>
% }
-% if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
+% if ( $GnuPGWidget ) {
<tr><td> </td><td>
-<% loc('Sign')%> <& /Widgets/Form/Boolean:InputOnly, Name => 'Sign', CurrentValue => $ARGS{'Sign'} &>
-
-<% loc('Encrypt')%> <& /Widgets/Form/Boolean:InputOnly, Name => 'Encrypt', CurrentValue => $ARGS{'Encrypt'} &>
+<& /Elements/GnuPG/SignEncryptWidget,
+ self => $gnupg_widget,
+ TicketObj => $Ticket,
+&>
</td></tr>
% }
@@ -64,17 +65,9 @@
$Ticket => undef
$UpdateCc => ''
$UpdateBcc => ''
+$GnuPGWidget => undef
</%ARGS>
<%INIT>
-if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
- foreach ( qw(Sign Encrypt) ) {
- $ARGS{ $_ } = $m->comp( '/Widgets/Form/Boolean:Process',
- Name => $_,
- DefaultValue => $Ticket? $Ticket->QueueObj->$_: 0,
- Arguments => \%ARGS,
- );
- }
-}
my $siblings;
if ( $Ticket ) {
Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Create.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Create.html (original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Create.html Tue Dec 11 09:55:44 2007
@@ -55,7 +55,6 @@
<input type="hidden" name="Status" value="<% $ARGS{'Status'} || 'open' %>" />
% if ( $ChildObj ) {
<input type="hidden" name="Child" value="<% $Child %>" />
-%#<input type="hidden" name="MemberOf-new" value="<% $Child %>" />
% }
% if ( $TicketObj ) {
<input type="hidden" name="Split" value="<% $Split %>" />
@@ -63,7 +62,7 @@
% }
<a name="top" />
-<& /Elements/GnuPGKeyIssues, Issues => \@gnupg_keys_issues, SignAddresses => \@cannot_sign_as &>
+<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
<&| /Widgets/TitleBox, title => $Title &>
<table border="0" cellpadding="0" cellspacing="2">
@@ -98,11 +97,9 @@
<& Elements/Create, Title => $Title, TicketObj => $TicketObj, QueueObj => $QueueObj, ChildObj => $ChildObj, %ARGS &>
-% if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
+% if ( $gnupg_widget ) {
<tr><td> </td><td>
-<% loc('Sign')%> <& /Widgets/Form/Boolean:InputOnly, Name => 'Sign', CurrentValue => $ARGS{'Sign'} &>
-
-<% loc('Encrypt')%> <& /Widgets/Form/Boolean:InputOnly, Name => 'Encrypt', CurrentValue => $ARGS{'Encrypt'} &>
+<& /Elements/GnuPG/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
</td></tr>
% }
@@ -220,45 +217,22 @@
my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
$QueueObj->Load( 'Incidents' ) || Abort( loc("Queue could not be loaded.") );
-if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
- foreach ( qw(Sign Encrypt) ) {
- $ARGS{ $_ } = $m->comp( '/Widgets/Form/Boolean:Process',
- Name => $_,
- DefaultValue => $QueueObj->$_,
- Arguments => \%ARGS,
- );
- }
-}
-
$m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS );
my $checks_failure = 0;
-my @cannot_sign_as;
-if ( $CreateIncident && $ARGS{'Sign'} ) {
- my $address = $QueueObj->CorrespondAddress || RT->Config->Get('CorrespondAddress');
- unless ( RT::Crypt::GnuPG::DrySign( $address ) ) {
- push @cannot_sign_as, $address;
- $checks_failure = 1;
- }
-}
-
-my @gnupg_keys_issues;
-if ( $CreateIncident && $ARGS{'Encrypt'} ) {
-
- my @recipients = $m->comp(
- '/Ticket/Elements/PreviewScrips:GetRecipientsOnCreate',
- %ARGS
+my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
+$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
+ self => $gnupg_widget,
+ QueueObj => $QueueObj,
+);
+
+if ( $CreateIncident && $gnupg_widget ) {
+ my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
+ self => $gnupg_widget,
+ Operation => 'Create',
+ QueueObj => $QueueObj,
);
-
- RT::Crypt::GnuPG::UseKeyForEncryption(
- map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
- grep $ARGS{$_} && /^UseKey-/,
- keys %ARGS
- );
-
- my $status;
- ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
$checks_failure = 1 unless $status;
}
Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html (original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Incident/Reply.html Tue Dec 11 09:55:44 2007
@@ -45,7 +45,7 @@
<input type="hidden" name="All" value="<% $All %>" />
<input type="hidden" name="Query" value="<% $Query %>" />
-<& /Elements/GnuPGKeyIssues, Issues => \@gnupg_keys_issues, SignAddresses => \@cannot_sign_as &>
+<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
% my $recipients = 0;
@@ -100,7 +100,11 @@
<h2 class="no-recipients">Warning: no recipients!</h2>
% }
-<& Elements/ReplyForm, %ARGS, TicketObj => $IncidentObj, Status => $Status &>
+<& Elements/ReplyForm, %ARGS,
+ TicketObj => $IncidentObj,
+ Status => $Status,
+ $GnuPGWidget => $gnupg_widget,
+&>
<& /Elements/Submit, Name => "SubmitTicket", Caption => $SubmitCaption, Label => $SubmitLabel &>
</form>
@@ -111,7 +115,7 @@
my $IncidentObj = LoadTicket( $id );
$id = $ARGS{'id'} = $IncidentObj->id;
-$m->callback(CallbackName => 'Initial', %ARGS, Ticket => $IncidentObj);
+$m->callback( %ARGS, CallbackName => 'Initial', Ticket => $IncidentObj );
# XXX: we should get rid of DefaultStatus argument at all. use Status
$Status ||= $DefaultStatus; $DefaultStatus ||= $Status;
@@ -155,15 +159,12 @@
my $checks_failure = 0;
-my %sign_addresses;
-my @cannot_sign_as;
-
-my @gnupg_keys_issues;
-if ( $SubmitTicket && ( $ARGS{'Encrypt'} || $ARGS{'Sign'} ) ) {
- require RT::Crypt::GnuPG;
-
- my @recipients;
-
+my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
+$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
+ self => $gnupg_widget,
+ QueueObj => $IncidentObj->QueueObj,
+);
+if ( $SubmitTicket && $gnupg_widget ) {
foreach my $id( @SelectedReports, @SelectedInvestigations, @SelectedBlocks ) {
my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
$Ticket->Load( $id );
@@ -171,36 +172,11 @@
push @results, loc( "Ticket [_1]: Couldn't load ticket.", $id );
next;
}
-
- if ( $ARGS{'Sign'} ) {
- my $address = $Ticket->QueueObj->CorrespondAddress
- || RT->Config->Get('CorrespondAddress');
- $sign_addresses{ $address } = 1;
- }
-
- push @recipients, $m->comp(
- '/Ticket/Elements/PreviewScrips:GetRecipients',
- %ARGS, TicketObj => $Ticket
- ) if $ARGS{'Encrypt'};
- }
-
- RT::Crypt::GnuPG::UseKeyForEncryption(
- map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
- grep $ARGS{$_} && /^UseKey-/,
- keys %ARGS
- );
-
- my $status;
- ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
- $checks_failure = 1 unless $status;
-}
-
-if ( $SubmitTicket && $ARGS{'Sign'} ) {
- for my $address (keys %sign_addresses) {
- unless ( RT::Crypt::GnuPG::DrySign( $address ) ) {
- push @cannot_sign_as, $address;
- $checks_failure = 1;
- }
+ my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
+ self => $gnupg_widget,
+ TicketObj => $Ticket,
+ );
+ $checks_failure = 1 unless $status;
}
}
Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html (original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html Tue Dec 11 09:55:44 2007
@@ -40,7 +40,7 @@
<input type="hidden" name="Action" value="<% $Action || '' %>" />
<input type="hidden" name="TakeOrStealFirst" value="<% $ARGS{TakeOrStealFirst} || '' %>" />
-<& /Elements/GnuPGKeyIssues, Issues => \@gnupg_keys_issues, SignAddresses => \@cannot_sign_as &>
+<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
<table>
<tr><td><a href="Edit.html?id=<% $id %>"><&|/l&>Correspondents</&></a></td><td align="right" colspan=2></td></tr>
@@ -88,7 +88,7 @@
</td></tr>
<tr><td align="right"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size="60" value="<% $Subject || '' %>" /></td></tr>
-<& /RTIR/Elements/UpdateData, Ticket => $Ticket, Type => 'Incident', %ARGS &>
+<& /RTIR/Elements/UpdateData, %ARGS, Ticket => $Ticket, Type => 'Incident' &>
<input type="hidden" name="id" value="<% $id %>" /><br />
</table>
@@ -165,41 +165,16 @@
my $checks_failure;
-if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
- require RT::Crypt::GnuPG;
-}
-
-# check to see if we have a good passphrase
-my @cannot_sign_as;
-if ( $ARGS{'SubmitTicket'} && $ARGS{'Sign'} ) {
- my $address = $ARGS{'UpdateType'} eq "private"
- ? ( $Ticket->QueueObj->CommentAddress
- || RT->Config->Get('CommentAddress') )
- : ( $Ticket->QueueObj->CorrespondAddress
- || RT->Config->Get('CorrespondAddress') );
-
- unless ( RT::Crypt::GnuPG::DrySign( $address ) ) {
- push @cannot_sign_as, $address;
- $checks_failure = 1;
- }
-}
-
-my @gnupg_keys_issues;
-if ( $ARGS{'SubmitTicket'} && $ARGS{'Encrypt'} ) {
-
- my @recipients = $m->comp(
- '/Ticket/Elements/PreviewScrips:GetRecipients',
- %ARGS, TicketObj => $Ticket
- );
-
- RT::Crypt::GnuPG::UseKeyForEncryption(
- map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
- grep $ARGS{$_} && /^UseKey-/,
- keys %ARGS
+my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
+$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
+ self => $gnupg_widget,
+ TicketObj => $TicketObj,
+);
+if ( $ARGS{'SubmitTicket'} ) {
+ my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
+ self => $gnupg_widget,
+ TicketObj => $TicketObj,
);
-
- my $status;
- ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
$checks_failure = 1 unless $status;
}
More information about the Rt-commit
mailing list