View | Details | Raw Unified | Return to bug 8897
Collapse All | Expand All

(-)a/C4/GnuPG.pm (+120 lines)
Line 0 Link Here
1
package C4::GnuPG;
2
3
# Copyright 2012/2016 Mirko Tietgen koha.abunchofthings.net
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
21
use strict;
22
use warnings;
23
use C4::Context;
24
use Crypt::GPG;
25
26
=head1 C4::GnuPG
27
28
C4::GnuPG
29
30
=head1 Description
31
32
Provides methods to interact with GnuPG via Crypt::GPG for the purpose of encrypting emails to patrons
33
34
=cut
35
36
our $gpg = new Crypt::GPG;
37
$gpg->gpgbin('/usr/bin/gpg');
38
$gpg->encryptsafe(0); # we have to allow untrusted keys
39
40
=head2 encrypt
41
42
Take email content and patron's email address, send back encrypted content. Call like
43
44
$content = C4::GnuPG->encrypt($content, $patronemail);
45
46
=cut
47
48
sub encrypt {
49
    my ($self, $content, $patronemail) = @_;
50
    $content = $gpg->encrypt($content, $patronemail);
51
    return $content;
52
}
53
54
=head2 does_exist
55
56
Check if there is a GnuPG key for the patron's email address. Call like
57
58
if ( C4::GnuPG->does_exist($patronemail) = 1 ) {
59
    # … encrypt …
60
}
61
62
=cut
63
64
sub does_exist {
65
    # TODO: check if gpg binary is found before encrypting to avoid errors
66
    my ($self, $patronemail) = @_;
67
    if ( $gpg->keydb($patronemail) ) {
68
        return 1;
69
    }
70
    else {
71
        return 0;
72
    }
73
}
74
75
=head2 add_key
76
77
Add or replace a patron's key. If there is already a key present, delete. Then add the new key.
78
79
=cut
80
81
sub add_key {
82
    my ($self, $key, $patronemail) = @_;
83
    # check if it is a public key before doing anything
84
    if ( $key =~ /BEGIN PGP PUBLIC KEY BLOCK/ ) {
85
        # if we already got a key, delete
86
        if ( does_exist($patronemail) ) {
87
            my @oldkey = $gpg->keydb($patronemail);
88
            if ( $oldkey[0] ) {
89
                $gpg->delkey($oldkey[0]);
90
            }
91
        }
92
        # … add new key
93
        $gpg->addkey($key);
94
    }
95
    else {
96
        return 0;
97
    }
98
}
99
100
sub del_key {
101
    my ($self, $patronemail) = @_;
102
    my @key = $gpg->keydb($patronemail);
103
    $gpg->delkey($key[0]);
104
}
105
106
=head2 get_key
107
108
=cut
109
110
sub get_key {
111
    # TODO: check security issue: can i get a secret key with this?
112
    my ($self, $patronemail) = @_;
113
    my @key = $gpg->keydb($patronemail);
114
    my $keystring = $gpg->export($key[0]);
115
    if ( $keystring =~ /BEGIN PGP PUBLIC KEY BLOCK/) {
116
        return $keystring;
117
    }
118
}
119
120
1;
(-)a/C4/Installer/PerlDependencies.pm (+4 lines)
Lines 786-791 our $PERL_DEPS = { Link Here
786
        'usage'    => 'PayPal',
786
        'usage'    => 'PayPal',
787
        'required' => '0',
787
        'required' => '0',
788
        'min_ver'  => '0.03',
788
        'min_ver'  => '0.03',
789
    'Crypt::GPG' => {
790
        'usage'    => 'Messaging (encryption)',
791
        'required'  => '1',
792
        'min_ver'  => '1.52',
789
    },
793
    },
790
};
794
};
791
795
(-)a/C4/Letters.pm (-1 / +11 lines)
Lines 30-35 use C4::Branch; Link Here
30
use C4::Log;
30
use C4::Log;
31
use C4::SMS;
31
use C4::SMS;
32
use C4::Debug;
32
use C4::Debug;
33
use C4::GnuPG;
33
use Koha::DateUtils;
34
use Koha::DateUtils;
34
use Date::Calc qw( Add_Delta_Days );
35
use Date::Calc qw( Add_Delta_Days );
35
use Encode;
36
use Encode;
Lines 433-439 sub SendAlerts { Link Here
433
                },
434
                },
434
                want_librarian => 1,
435
                want_librarian => 1,
435
            ) or return;
436
            ) or return;
436
437
            my $subject = Encode::encode( "utf8", "" . $letter->{title} );
438
            my $content = Encode::encode( "utf8", "" . $letter->{content} );
439
            if ( C4::GnuPG->does_exist($email) ) {
440
                $subject = 'A message from your library';
441
                $content = C4::GnuPG->encrypt($content, $email);
442
            }
437
            # ... then send mail
443
            # ... then send mail
438
            my $message = Koha::Email->new();
444
            my $message = Koha::Email->new();
439
            my %mail = $message->create_message_headers(
445
            my %mail = $message->create_message_headers(
Lines 1203-1208 sub _send_message_by_email { Link Here
1203
        $branch_replyto = $branchdetail->{'branchreplyto'};
1209
        $branch_replyto = $branchdetail->{'branchreplyto'};
1204
        $branch_returnpath = $branchdetail->{'branchreturnpath'};
1210
        $branch_returnpath = $branchdetail->{'branchreturnpath'};
1205
    }
1211
    }
1212
    if ( C4::GnuPG->does_exist($to_address) ) {
1213
        $subject = 'A message from your library';
1214
        $content = C4::GnuPG->encrypt($content, $to_address);
1215
    }
1206
    my $email = Koha::Email->new();
1216
    my $email = Koha::Email->new();
1207
    my %sendmail_params = $email->create_message_headers(
1217
    my %sendmail_params = $email->create_message_headers(
1208
        {
1218
        {
(-)a/debian/control (+3 lines)
Lines 28-33 Build-Depends: libalgorithm-checkdigits-perl, Link Here
28
 libconvert-basen-perl,
28
 libconvert-basen-perl,
29
 libcrypt-eksblowfish-perl,
29
 libcrypt-eksblowfish-perl,
30
 libcrypt-gcrypt-perl,
30
 libcrypt-gcrypt-perl,
31
 libcrypt-gpg-perl,
31
 libdata-ical-perl,
32
 libdata-ical-perl,
32
 libdate-calc-perl,
33
 libdate-calc-perl,
33
 libdate-manip-perl,
34
 libdate-manip-perl,
Lines 194-199 Depends: ${misc:Depends}, Link Here
194
 cron-daemon,
195
 cron-daemon,
195
 daemon,
196
 daemon,
196
 debconf,
197
 debconf,
198
 gnupg,
197
 idzebra-2.0,
199
 idzebra-2.0,
198
 libjs-jquery,
200
 libjs-jquery,
199
 mysql-client | virtual-mysql-client,
201
 mysql-client | virtual-mysql-client,
Lines 236-241 Depends: libalgorithm-checkdigits-perl, Link Here
236
 libconvert-basen-perl,
238
 libconvert-basen-perl,
237
 libcrypt-eksblowfish-perl,
239
 libcrypt-eksblowfish-perl,
238
 libcrypt-gcrypt-perl,
240
 libcrypt-gcrypt-perl,
241
 libcrypt-gpg-perl,
239
 libdata-ical-perl,
242
 libdata-ical-perl,
240
 libdate-calc-perl,
243
 libdate-calc-perl,
241
 libdate-manip-perl,
244
 libdate-manip-perl,
(-)a/debian/control.in (+1 lines)
Lines 70-75 Depends: ${misc:Depends}, Link Here
70
 cron-daemon,
70
 cron-daemon,
71
 daemon,
71
 daemon,
72
 debconf,
72
 debconf,
73
 gnupg,
73
 idzebra-2.0,
74
 idzebra-2.0,
74
 libjs-jquery,
75
 libjs-jquery,
75
 mysql-client | virtual-mysql-client,
76
 mysql-client | virtual-mysql-client,
(-)a/install_misc/debian.packages (+2 lines)
Lines 2-7 apache2 install Link Here
2
at install
2
at install
3
cvs	install
3
cvs	install
4
daemon install
4
daemon install
5
gnupg install
5
gcc install
6
gcc install
6
gettext install
7
gettext install
7
idzebra-2.0	install
8
idzebra-2.0	install
Lines 23-28 libcgi-session-perl install Link Here
23
libcgi-session-serialize-yaml-perl install
24
libcgi-session-serialize-yaml-perl install
24
libclass-accessor-perl		install
25
libclass-accessor-perl		install
25
libclass-factory-util-perl	install
26
libclass-factory-util-perl	install
27
libcypt-gpg-perl	install
26
libdata-ical-perl	install
28
libdata-ical-perl	install
27
libdata-paginator-perl		install
29
libdata-paginator-perl		install
28
libdate-calc-perl install
30
libdate-calc-perl install
(-)a/install_misc/ubuntu.10.04.packages (+2 lines)
Lines 35-40 libidzebra-2.0-modules install Link Here
35
35
36
# crypto packages
36
# crypto packages
37
37
38
gnupg					install
38
libgcrypt11				install
39
libgcrypt11				install
39
libgcrypt11-dev				install
40
libgcrypt11-dev				install
40
41
Lines 62-67 libcgi-session-perl install Link Here
62
libcgi-session-serialize-yaml-perl	install
63
libcgi-session-serialize-yaml-perl	install
63
libclass-accessor-perl		install
64
libclass-accessor-perl		install
64
libclass-factory-util-perl		install
65
libclass-factory-util-perl		install
66
libcrypt-gpg-perl			install
65
libdata-ical-perl			install
67
libdata-ical-perl			install
66
libdata-paginator-perl		install
68
libdata-paginator-perl		install
67
libdate-calc-perl			install
69
libdate-calc-perl			install
(-)a/install_misc/ubuntu.12.04.packages (+2 lines)
Lines 34-39 libidzebra-2.0-modules install Link Here
34
34
35
# crypto packages
35
# crypto packages
36
36
37
gnupg					install
37
libgcrypt11				install
38
libgcrypt11				install
38
libgcrypt11-dev				install
39
libgcrypt11-dev				install
39
40
Lines 64-69 libchi-driver-memcached-perl install Link Here
64
libchi-perl				install
65
libchi-perl				install
65
libclass-accessor-perl			install
66
libclass-accessor-perl			install
66
libclass-factory-util-perl		install
67
libclass-factory-util-perl		install
68
libcrypt-gpg-perl			install
67
libdata-ical-perl			install
69
libdata-ical-perl			install
68
libdata-paginator-perl		install
70
libdata-paginator-perl		install
69
libdate-calc-perl			install
71
libdate-calc-perl			install
(-)a/install_misc/ubuntu.packages (+2 lines)
Lines 34-39 libidzebra-2.0-modules install Link Here
34
34
35
# crypto packages
35
# crypto packages
36
36
37
gnupg					install
37
libgcrypt11				install
38
libgcrypt11				install
38
libgcrypt11-dev				install
39
libgcrypt11-dev				install
39
40
Lines 64-69 libchi-driver-memcached-perl install Link Here
64
libchi-perl				install
65
libchi-perl				install
65
libclass-accessor-perl			install
66
libclass-accessor-perl			install
66
libclass-factory-util-perl		install
67
libclass-factory-util-perl		install
68
libcrypt-gpg-perl			install
67
libdata-ical-perl			install
69
libdata-ical-perl			install
68
libdata-paginator-perl		install
70
libdata-paginator-perl		install
69
libdate-calc-perl			install
71
libdate-calc-perl			install
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc (+7 lines)
Lines 41-46 Link Here
41
                <a href="/cgi-bin/koha/opac-passwd.pl">change your password</a></li>
41
                <a href="/cgi-bin/koha/opac-passwd.pl">change your password</a></li>
42
            [% END %]
42
            [% END %]
43
43
44
            [% IF ( gnupgview ) %]
45
                <li class="active">
46
            [% ELSE %]
47
                <li>
48
            [% END %]
49
            <a href="/cgi-bin/koha/opac-gnupg.pl">email encryption</a></li>
50
44
            [% IF EnableOpacSearchHistory %]
51
            [% IF EnableOpacSearchHistory %]
45
                [% IF ( searchhistoryview ) %]
52
                [% IF ( searchhistoryview ) %]
46
                    <li class="active">
53
                    <li class="active">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-gnupg.tt (+59 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Add or change your GPG key
2
[% INCLUDE 'doc-head-close.inc' %]
3
</head>
4
<body id="opac-passwd">
5
<div id="doc3" class="yui-t1">
6
   <div id="bd">
7
[% INCLUDE 'masthead.inc' %]
8
9
	<div id="yui-main">
10
	<div class="yui-b"><div class="yui-g">
11
	<div id="usergnupg" class="container">
12
    <h3><a href="/cgi-bin/koha/opac-gnupg.pl">[% firstname %] [% surname %]'s account</a> &#8674; Add or change your GPG key </h3>
13
    <p>If you paste your GPG <strong>public</strong> key here, we will try to encrypt the emails we send you.<br />
14
    If you want to learn about email encryption, you will find some information at link</p>
15
16
    [% IF ( Error_messages ) %]
17
        <div class="dialog error">        <h3>There was a problem with your submission</h3>
18
            <p>
19
                [% IF ( NoGnuPG ) %]
20
                    Could not find the path to GnuPG. This has to be set by the library for encryption to work. Please ask our staff about it.
21
                [% END %]
22
            </p></div>
23
    [% END %]
24
25
    <p>Path to GPG [% IF (gpgbinary) %]found[% ELSE %]not found[% END %].</p>
26
27
    <form action="/cgi-bin/koha/opac-gnupg.pl" name="mainform" id="mainform" method="post">
28
    <fieldset class="brief">
29
        <p><label for="PublicKey">
30
            [% IF ( does_exist ) %]
31
                We have the following public key for your email address:
32
            [% ELSE %]
33
                Paste your public key here:
34
            [% END %]
35
        </p>
36
        <ol><li><textarea id="PublicKey" name="PublicKey" cols="70" rows="30">[% IF (keythingy) %][% keythingy %][% END %]</textarea></li></ol>
37
    </fieldset>
38
    <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/opac-user.pl" class="cancel">Cancel</a></fieldset>
39
    </form>
40
41
    [% IF ( does_exist ) %]
42
    <p>Delete the key from our server if you wish to receive unencrypted emails in the future.</p>
43
    <form action="/cgi-bin/koha/opac-gnupg.pl" name="deleteform" id="deleteform" method="post">
44
        <input type="hidden" name="DeleteKey" value="1" />
45
        <fieldset class="action"><input type="submit" value="Delete my public key" class="submit" /></fieldset>
46
    </form>
47
    [% END %]
48
49
</div>
50
</div>
51
</div>
52
</div>
53
<div class="yui-b">
54
<div id="leftmenus" class="container">
55
[% INCLUDE 'navigation.inc' IsPatronPage=1 %]
56
</div>
57
</div>
58
</div>
59
[% INCLUDE 'opac-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-gnupg.tt (+59 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Add or change your GPG key
2
[% INCLUDE 'doc-head-close.inc' %]
3
</head>
4
<body id="opac-passwd">
5
<div id="doc3" class="yui-t1">
6
   <div id="bd">
7
[% INCLUDE 'masthead.inc' %]
8
9
	<div id="yui-main">
10
	<div class="yui-b"><div class="yui-g">
11
	<div id="usergnupg" class="container">
12
    <h3><a href="/cgi-bin/koha/opac-gnupg.pl">[% firstname %] [% surname %]'s account</a> &#8674; Add or change your GPG key </h3>
13
    <p>If you paste your GPG <strong>public</strong> key here, we will try to encrypt the emails we send you.<br />
14
    If you want to learn about email encryption, you will find some information at link</p>
15
16
    [% IF ( Error_messages ) %]
17
        <div class="dialog error">        <h3>There was a problem with your submission</h3>
18
            <p>
19
                [% IF ( NoGnuPG ) %]
20
                    Could not find the path to GnuPG. This has to be set by the library for encryption to work. Please ask our staff about it.
21
                [% END %]
22
            </p></div>
23
    [% END %]
24
25
    <p>Path to GPG [% IF (gpgbinary) %]found[% ELSE %]not found[% END %].</p>
26
27
    <form action="/cgi-bin/koha/opac-gnupg.pl" name="mainform" id="mainform" method="post">
28
    <fieldset class="brief">
29
        <p><label for="PublicKey">
30
            [% IF ( does_exist ) %]
31
                We have the following public key for your email address:
32
            [% ELSE %]
33
                Paste your public key here:
34
            [% END %]
35
        </p>
36
        <ol><li><textarea id="PublicKey" name="PublicKey" cols="70" rows="30">[% IF (keythingy) %][% keythingy %][% END %]</textarea></li></ol>
37
    </fieldset>
38
    <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/opac-user.pl" class="cancel">Cancel</a></fieldset>
39
    </form>
40
41
    [% IF ( does_exist ) %]
42
    <p>Delete the key from our server if you wish to receive unencrypted emails in the future.</p>
43
    <form action="/cgi-bin/koha/opac-gnupg.pl" name="deleteform" id="deleteform" method="post">
44
        <input type="hidden" name="DeleteKey" value="1" />
45
        <fieldset class="action"><input type="submit" value="Delete my public key" class="submit" /></fieldset>
46
    </form>
47
    [% END %]
48
49
</div>
50
</div>
51
</div>
52
</div>
53
<div class="yui-b">
54
<div id="leftmenus" class="container">
55
[% INCLUDE 'navigation.inc' IsPatronPage=1 %]
56
</div>
57
</div>
58
</div>
59
[% INCLUDE 'opac-bottom.inc' %]
(-)a/opac/opac-gnupg.pl (+83 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013/2016 Mirko Tietgen koha.abunchofthings.net
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
21
22
use strict;
23
use warnings;
24
25
use CGI;
26
27
use C4::Auth;    # checkauth, getborrowernumber.
28
use C4::Context;
29
use Digest::MD5 qw(md5_base64);
30
use C4::Circulation;
31
use C4::Members;
32
use C4::Output;
33
use C4::GnuPG;
34
35
my $query = new CGI;
36
my $dbh   = C4::Context->dbh;
37
38
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
39
    {
40
        template_name   => "opac-gnupg.tt",
41
        query           => $query,
42
        type            => "opac",
43
        authnotrequired => 0,
44
        flagsrequired   => { borrow => 1 },
45
        debug           => 1,
46
    }
47
);
48
49
# get borrower information ....
50
my ( $borr ) = GetMemberDetails( $borrowernumber );
51
my $patronemail = $borr->{'email'};
52
# save key if key received
53
if ( $query->param('PublicKey') ) {
54
    C4::GnuPG->add_key($query->param('PublicKey'), $patronemail);
55
#    $template->param( 'addedkey' => $query->param('PublicKey') );
56
#    $template->param( 'added' => '1' );
57
}
58
elsif ( $query->param('DeleteKey') ) {
59
    C4::GnuPG->del_key($patronemail);
60
}
61
    if ( C4::GnuPG->does_exist($patronemail) ) {
62
        # TODO: display public key if present
63
        my $keythingy = C4::GnuPG->get_key($patronemail);
64
        $template->param( 'does_exist' => '1' );
65
        $template->param( 'keythingy' => $keythingy );
66
    }
67
    # ask for key
68
    #$template->param( 'Ask_data'       => '1' );
69
    #$template->param( 'Error_messages' => '1' );
70
71
 my $gnupgbinary = '/usr/bin/gpg';
72
 if (-e $gnupgbinary) {
73
     $template->param( 'gpgbinary' => '1' );
74
 }
75
76
$template->param(
77
    firstname => $borr->{'firstname'},
78
    surname => $borr->{'surname'},
79
    patronemail => $patronemail,
80
    gnupgview => 1,
81
);
82
83
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/opac-sendbasket.pl (-4 / +19 lines)
Lines 34-39 use C4::Output; Link Here
34
use C4::Biblio;
34
use C4::Biblio;
35
use C4::Members;
35
use C4::Members;
36
use Koha::Email;
36
use Koha::Email;
37
use C4::GnuPG;
37
38
38
my $query = new CGI;
39
my $query = new CGI;
39
40
Lines 156-161 if ( $email_add ) { Link Here
156
    my $boundary = "====" . time() . "====";
157
    my $boundary = "====" . time() . "====";
157
158
158
    $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
159
    $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
160
161
    my $email_header_and_body = $email_header . $body;
162
163
    my $attachmentfilename;
164
    # encrypt the attachment if we have a key
165
    if ( C4::GnuPG->does_exist($email_add) ) {
166
        $mail{'subject'} = "A message from your library";
167
        $email_header_and_body = C4::GnuPG->encrypt($email_header_and_body, $email_add);
168
        $iso2709 = C4::GnuPG->encrypt($iso2709, $email_add);
169
        $attachmentfilename = 'attachment.gpg';
170
    }
171
    else {
172
        $attachmentfilename = 'basket.iso2709';
173
    }
174
159
    my $isofile = encode_base64(encode("UTF-8", $iso2709));
175
    my $isofile = encode_base64(encode("UTF-8", $iso2709));
160
    $boundary = '--' . $boundary;
176
    $boundary = '--' . $boundary;
161
    $mail{body} = <<END_OF_BODY;
177
    $mail{body} = <<END_OF_BODY;
Lines 164-175 MIME-Version: 1.0 Link Here
164
Content-Type: text/plain; charset="UTF-8"
180
Content-Type: text/plain; charset="UTF-8"
165
Content-Transfer-Encoding: quoted-printable
181
Content-Transfer-Encoding: quoted-printable
166
182
167
$email_header
183
$email_header_and_body
168
$body
169
$boundary
184
$boundary
170
Content-Type: application/octet-stream; name="basket.iso2709"
185
Content-Type: application/octet-stream; name=$attachmentfilename
171
Content-Transfer-Encoding: base64
186
Content-Transfer-Encoding: base64
172
Content-Disposition: attachment; filename="basket.iso2709"
187
Content-Disposition: attachment; filename=$attachmentfilename
173
188
174
$isofile
189
$isofile
175
$boundary--
190
$boundary--
(-)a/opac/opac-sendshelf.pl (-5 / +18 lines)
Lines 34-39 use C4::Output; Link Here
34
use C4::Members;
34
use C4::Members;
35
use Koha::Email;
35
use Koha::Email;
36
use Koha::Virtualshelves;
36
use Koha::Virtualshelves;
37
use C4::GnuPG;
37
38
38
my $query = new CGI;
39
my $query = new CGI;
39
40
Lines 151-157 if ( $email ) { Link Here
151
    # We set and put the multipart content
152
    # We set and put the multipart content
152
    $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
153
    $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
153
154
155
    my $email_header_and_body = $email_header . $body;
156
157
    my $attachmentfilename;
158
    # encrypt the attachment if we have a key
159
    if ( C4::GnuPG->does_exist($email) ) {
160
        $mail{'subject'} = "A message from your library";
161
        $email_header_and_body = C4::GnuPG->encrypt($email_header_and_body, $email);
162
        $iso2709 = C4::GnuPG->encrypt($iso2709, $email);
163
        $attachmentfilename = 'attachment.gpg';
164
    }
165
    else {
166
        $attachmentfilename = 'shelf.iso2709';
167
    }
154
    my $isofile = encode_base64(encode("UTF-8", $iso2709));
168
    my $isofile = encode_base64(encode("UTF-8", $iso2709));
169
155
    $boundary = '--' . $boundary;
170
    $boundary = '--' . $boundary;
156
171
157
    $mail{body} = <<END_OF_BODY;
172
    $mail{body} = <<END_OF_BODY;
Lines 160-171 MIME-Version: 1.0 Link Here
160
Content-Type: text/plain; charset="utf-8"
175
Content-Type: text/plain; charset="utf-8"
161
Content-Transfer-Encoding: quoted-printable
176
Content-Transfer-Encoding: quoted-printable
162
177
163
$email_header
178
$email_header_and_body
164
$body
165
$boundary
179
$boundary
166
Content-Type: application/octet-stream; name="list.iso2709"
180
Content-Type: application/octet-stream; name=$attachmentfilename
167
Content-Transfer-Encoding: base64
181
Content-Transfer-Encoding: base64
168
Content-Disposition: attachment; filename="list.iso2709"
182
Content-Disposition: attachment; filename=$attachmentfilename
169
183
170
$isofile
184
$isofile
171
$boundary--
185
$boundary--
172
- 

Return to bug 8897