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

(-)a/Koha/Anonymized.pm (+35 lines)
Line 0 Link Here
1
package Koha::Anonymized;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
use Crypt::Eksblowfish::Bcrypt qw(bcrypt);
22
23
use Koha::Exceptions::Config;
24
25
sub get_hash {
26
    my ( $class, $s ) = @_;
27
    my $key = C4::Context->config('key');
28
29
    Koha::Exceptions::Config::MissingEntry->throw(
30
        "Missing 'key' entry in config file") unless $key;
31
32
    return bcrypt($s, $key);
33
}
34
35
1;
(-)a/Koha/Anonymized/Patron.pm (-8 / +2 lines)
Lines 18-26 package Koha::Anonymized::Patron; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Carp;
20
use Carp;
21
use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64);
22
21
23
use Koha::Database;
22
use Koha::Database;
23
use Koha::Anonymized;
24
24
25
use base qw(Koha::Object);
25
use base qw(Koha::Object);
26
26
Lines 36-52 Koha::Anonymized::Patron - Koha Anonymized::Patron Object class Link Here
36
36
37
=cut
37
=cut
38
38
39
sub get_hash {
40
    my ( $class, $borrowernumber) = @_;
41
    return bcrypt($borrowernumber, C4::Context->config('key'));
42
}
43
44
45
sub new_from_patron {
39
sub new_from_patron {
46
    my ( $class, $patron ) = @_;
40
    my ( $class, $patron ) = @_;
47
41
48
    my $self = $class->SUPER::new({
42
    my $self = $class->SUPER::new({
49
        hashed_borrowernumber => $class->get_hash($patron->borrowernumber),
43
        hashed_borrowernumber => Koha::Anonymized->get_hash($patron->borrowernumber),
50
    });
44
    });
51
45
52
    $self->update_from_patron($patron);
46
    $self->update_from_patron($patron);
(-)a/Koha/Anonymized/Transaction.pm (-9 / +1 lines)
Lines 18-24 package Koha::Anonymized::Transaction; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Carp;
20
use Carp;
21
use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64);
22
21
23
use Koha::Database;
22
use Koha::Database;
24
23
Lines 36-52 Koha::Anonymized::Transaction - Koha Anonymized::Transaction Object class Link Here
36
35
37
=cut
36
=cut
38
37
39
sub get_hash {
40
    my ( $class, $borrowernumber) = @_;
41
    return bcrypt($borrowernumber, C4::Context->config('key'));
42
}
43
44
45
sub new_from_statistic {
38
sub new_from_statistic {
46
    my ( $class, $statistic ) = @_;
39
    my ( $class, $statistic ) = @_;
47
40
48
    my $values = {
41
    my $values = {
49
        hashed_borrowernumber => $class->get_hash($statistic->borrowernumber),
42
        hashed_borrowernumber => Koha::Anonymized->get_hash($statistic->borrowernumber),
50
    };
43
    };
51
44
52
    my @fields_to_copy = split ',', C4::Context->preference('PseudonymizationTransactionFields') || '';
45
    my @fields_to_copy = split ',', C4::Context->preference('PseudonymizationTransactionFields') || '';
53
- 

Return to bug 24151