# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-use Carp;
-use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64);
+use Crypt::Eksblowfish::Bcrypt qw( bcrypt );
use Koha::Database;
use Koha::Exceptions::Config;
=head2 Class methods
-=head3 new
+=head3 new_from_statistic
+
+ Creates new object from a passed Koha::Statistic object
=cut
if ( grep { $_ eq 'holdingbranch' } @t_fields_to_copy ) {
$values->{holdingbranch} = $statistic->item->holdingbranch;
}
+ if ( grep { $_ eq 'homebranch' } @t_fields_to_copy ) {
+ $values->{homebranch} = $statistic->item->homebranch;
+ }
if ( grep { $_ eq 'transaction_type' } @t_fields_to_copy ) {
$values->{transaction_type} = $statistic->type;
}
@t_fields_to_copy = grep {
$_ ne 'transaction_branchcode'
&& $_ ne 'holdingbranch'
+ && $_ ne 'homebranch'
&& $_ ne 'transaction_type'
&& $_ ne 'itemcallnumber'
} @t_fields_to_copy;
$values->{has_cardnumber} = $patron->cardnumber ? 1 : 0;
- return $class->SUPER::new($values);
+ my $self = $class->SUPER::new($values);
+
+ my $extended_attributes = $patron->extended_attributes->unblessed;
+ for my $attribute (@$extended_attributes) {
+ next unless Koha::Patron::Attribute::Types->find(
+ $attribute->{code} )->keep_for_pseudonymization;
+
+ delete $attribute->{id};
+ delete $attribute->{borrowernumber};
+
+ $self->_result->create_related('pseudonymized_borrower_attributes', $attribute);
+ }
+
+ return $self;
}
+=head3 get_hash
+
+ Generates a hashed value for $s (e.g. borrowernumber) with Bcrypt.
+ Needs config entry 'bcrypt_settings' in koha-conf.
+
+=cut
+
sub get_hash {
my ( $class, $s ) = @_;
- my $key = C4::Context->config('key');
+ my $bcrypt_settings = C4::Context->config('bcrypt_settings');
Koha::Exceptions::Config::MissingEntry->throw(
- "Missing 'key' entry in config file") unless $key;
+ "Missing 'bcrypt_settings' entry in config file") unless $bcrypt_settings;
- return bcrypt($s, $key);
+ return bcrypt($s, $bcrypt_settings);
}
=head2 Internal methods