@@ -, +, @@ --- C4/Letters.pm | 7 +++++++ C4/Message.pm | 5 +++++ installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../prog/en/modules/admin/preferences/admin.pref | 8 ++++++++ 5 files changed, 30 insertions(+), 0 deletions(-) --- a/C4/Letters.pm +++ a/C4/Letters.pm @@ -33,6 +33,7 @@ use Date::Calc qw( Add_Delta_Days ); use Encode; use Unicode::Normalize; use Carp; +use C4::GnuPG; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -782,6 +783,12 @@ sub EnqueueLetter { ); } + # gnupg encrypt content if encryption enabled and key for patron present + my $useremail = $params->{'to_address'}; + if ( (C4::Context->preference("GnuPGPassphrase")) && (C4::Context->preference("GnuPGPassphrase") ne '') && (C4::GnuPG->does_exist($params->{'to_address'}) == 1) ) { + $params->{'letter'}->{'content'} = C4::GnuPG->encrypt($params->{'letter'}->{'content'}, $params->{'to_address'}); + } + my $dbh = C4::Context->dbh(); my $statement = << 'ENDSQL'; INSERT INTO message_queue --- a/C4/Message.pm +++ a/C4/Message.pm @@ -25,6 +25,7 @@ use C4::Context; use C4::Letters; use YAML::Syck; use Carp; +use C4::GnuPG; =head1 NAME @@ -322,6 +323,10 @@ sub append { push @{$metadata->{body}}, $item; $self->metadata($metadata); my $new_content = $self->render_metadata($format); + # gnupg encrypt content if encryption enabled and key for patron present + if ( (C4::Context->preference("GnuPGPassphrase")) && (C4::Context->preference("GnuPGPassphrase") ne '') && (C4::GnuPG->does_exist($self->{'to_address'}) == 1) ) { + $new_content = C4::GnuPG->encrypt($new_content, $self->{'to_address'}) + } return $self->content($new_content); } --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -386,3 +386,5 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidy INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'); INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPath','/usr/bin/gpg','Path to GnuPG','','free'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPassphrase','','Passphrase for GnuPG','','free'); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6011,6 +6011,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = 'XXX'; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPath','/usr/bin/gpg','Path to GnuPG','','free');"); + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPassphrase','','Passphrase for GnuPG','','free');"); + print "Upgrade to $DBversion done (Add GnuPGPath and GnuPGPassphrase sysprefs)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -40,6 +40,14 @@ Administration: yes: Allow no: "Don't allow" - staff and patrons to create and view saved lists of books. + - + - GnuPG passphrase used to encrypt outgoing emails from KohaAdminEmailAddress. Leave blank to disable encryption. You must have GnuPG running and a keypair setup for KohaAdminEmailAddress to use this. + - pref: GnuPGPassphrase + class: password + - + - Path to GnuPG + - pref: GnuPGPath + - class: textarea Login options: - - pref: insecure --