Bugzilla – Attachment 101221 Details for
Bug 20443
Move C4::Members::Attributes to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20443: Remove C4::Members::AttributeTypes
Bug-20443-Remove-C4MembersAttributeTypes.patch (text/plain), 28.56 KB, created by
Jonathan Druart
on 2020-03-20 15:05:43 UTC
(
hide
)
Description:
Bug 20443: Remove C4::Members::AttributeTypes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 15:05:43 UTC
Size:
28.56 KB
patch
obsolete
>From 36791162d72d67d7ef353739ed15af85571aea02 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Jul 2018 20:17:22 -0300 >Subject: [PATCH] Bug 20443: Remove C4::Members::AttributeTypes > >We do no longer need this package, we can use >Koha::Patron::Attribute::Types directly instead. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Auth_with_ldap.pm | 1 - > C4/Members/AttributeTypes.pm | 475 ---------------------- > Koha/Patrons/Import.pm | 7 +- > members/memberentry.pl | 5 +- > members/moremember.pl | 1 - > opac/opac-memberentry.pl | 4 +- > opac/opac-user.pl | 1 - > t/Members_AttributeTypes.t | 77 ---- > t/db_dependent/Koha/Patrons.t | 40 +- > t/db_dependent/Koha/Patrons/Import.t | 4 +- > t/db_dependent/Members/Attributes.t | 30 +- > t/db_dependent/Utils/Datatables_Members.t | 17 +- > tools/modborrowers.pl | 4 +- > 13 files changed, 63 insertions(+), 603 deletions(-) > delete mode 100644 C4/Members/AttributeTypes.pm > delete mode 100755 t/Members_AttributeTypes.t > >diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm >index 026178eb3e..020ade48b6 100644 >--- a/C4/Auth_with_ldap.pm >+++ b/C4/Auth_with_ldap.pm >@@ -23,7 +23,6 @@ use Carp; > use C4::Debug; > use C4::Context; > use C4::Members::Attributes; >-use C4::Members::AttributeTypes; > use C4::Members::Messaging; > use C4::Auth qw(checkpw_internal); > use Koha::Patrons; >diff --git a/C4/Members/AttributeTypes.pm b/C4/Members/AttributeTypes.pm >deleted file mode 100644 >index 646a97eab3..0000000000 >--- a/C4/Members/AttributeTypes.pm >+++ /dev/null >@@ -1,475 +0,0 @@ >-package C4::Members::AttributeTypes; >- >-# Copyright (C) 2008 LibLime >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY 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, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >-use C4::Context; >- >- >- >-=head1 NAME >- >-C4::Members::AttributeTypes - mananage extended patron attribute types >- >-=head1 SYNOPSIS >- >- my $attr_type = C4::Members::AttributeTypes->new($code, $description); >- $attr_type->code($code); >- $attr_type->description($description); >- $attr_type->repeatable($repeatable); >- $attr_type->unique_id($unique_id); >- $attr_type->opac_display($opac_display); >- $attr_type->opac_editable($opac_editable); >- $attr_type->staff_searchable($staff_searchable); >- $attr_type->authorised_value_category($authorised_value_category); >- $attr_type->store(); >- $attr_type->delete(); >- >- my $attr_type = C4::Members::AttributeTypes->fetch($code); >- $attr_type = C4::Members::AttributeTypes->delete($code); >- >-=head1 FUNCTIONS >- >-=head1 METHODS >- >- my $attr_type = C4::Members::AttributeTypes->new($code, $description); >- >-Create a new attribute type. >- >-=cut >- >-sub new { >- my $class = shift; >- my $self = {}; >- >- $self->{'code'} = shift; >- $self->{'description'} = shift; >- $self->{'repeatable'} = 0; >- $self->{'unique_id'} = 0; >- $self->{'opac_display'} = 0; >- $self->{'opac_editable'} = 0; >- $self->{'staff_searchable'} = 0; >- $self->{'display_checkout'} = 0; >- $self->{'authorised_value_category'} = ''; >- $self->{'category_code'} = ''; >- $self->{'category_description'} = ''; >- $self->{'class'} = ''; >- >- bless $self, $class; >- return $self; >-} >- >-=head2 fetch >- >- my $attr_type = C4::Members::AttributeTypes->fetch($code); >- >-Fetches an attribute type from the database. If no >-type with the given C<$code> exists, returns undef. >- >-=cut >- >-sub fetch { >- my $class = shift; >- my $code = shift; >- my $self = {}; >- my $dbh = C4::Context->dbh(); >- >- my $sth = $dbh->prepare_cached(" >- SELECT borrower_attribute_types.*, categories.description AS category_description >- FROM borrower_attribute_types >- LEFT JOIN categories ON borrower_attribute_types.category_code=categories.categorycode >- WHERE code =?"); >- $sth->execute($code); >- my $row = $sth->fetchrow_hashref; >- $sth->finish(); >- return unless defined $row; >- >- $self->{'code'} = $row->{'code'}; >- $self->{'description'} = $row->{'description'}; >- $self->{'repeatable'} = $row->{'repeatable'}; >- $self->{'unique_id'} = $row->{'unique_id'}; >- $self->{'opac_display'} = $row->{'opac_display'}; >- $self->{'opac_editable'} = $row->{'opac_editable'}; >- $self->{'staff_searchable'} = $row->{'staff_searchable'}; >- $self->{'display_checkout'} = $row->{'display_checkout'}; >- $self->{'authorised_value_category'} = $row->{'authorised_value_category'}; >- $self->{'category_code'} = $row->{'category_code'}; >- $self->{'category_description'} = $row->{'category_description'}; >- $self->{'class'} = $row->{'class'}; >- >- $sth = $dbh->prepare("SELECT branchcode, branchname FROM borrower_attribute_types_branches, branches WHERE b_branchcode = branchcode AND bat_code = ?;"); >- $sth->execute( $code ); >- while ( my $data = $sth->fetchrow_hashref ) { >- push @{ $self->{branches} }, $data; >- } >- $sth->finish(); >- >- bless $self, $class; >- return $self; >-} >- >-=head2 store >- >- $attr_type->store(); >- >-Stores attribute type in the database. If the type >-previously retrieved from the database via the fetch() >-method, the DB representation of the type is replaced. >- >-=cut >- >-sub store { >- my $self = shift; >- >- my $dbh = C4::Context->dbh; >- my $sth; >- my $existing = __PACKAGE__->fetch($self->{'code'}); >- if (defined $existing) { >- $sth = $dbh->prepare_cached("UPDATE borrower_attribute_types >- SET description = ?, >- repeatable = ?, >- unique_id = ?, >- opac_display = ?, >- opac_editable = ?, >- staff_searchable = ?, >- authorised_value_category = ?, >- display_checkout = ?, >- category_code = ?, >- class = ? >- WHERE code = ?"); >- } else { >- $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types >- ( description, >- repeatable, >- unique_id, >- opac_display, >- opac_editable, >- staff_searchable, >- authorised_value_category, >- display_checkout, >- category_code, >- class, >- code >- ) >- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); >- } >- >- $sth->execute( >- $self->{'description'}, >- $self->{'repeatable'}, >- $self->{'unique_id'}, >- $self->{'opac_display'}, >- $self->{'opac_editable'}, >- $self->{'staff_searchable'} || 0, >- $self->{'authorised_value_category'}, >- $self->{'display_checkout'}, >- $self->{'category_code'} || undef, >- $self->{'class'}, >- $self->{'code'} >- ); >- >- if ( defined $$self{branches} ) { >- $sth = $dbh->prepare("DELETE FROM borrower_attribute_types_branches WHERE bat_code = ?"); >- $sth->execute( $$self{code} ); >- $sth = $dbh->prepare( >- "INSERT INTO borrower_attribute_types_branches >- ( bat_code, b_branchcode ) >- VALUES ( ?, ? )" >- ); >- for my $branchcode ( @{$$self{branches}} ) { >- next if not $branchcode; >- $sth->bind_param( 1, $$self{code} ); >- $sth->bind_param( 2, $branchcode ); >- $sth->execute; >- } >- } >- $sth->finish; >-} >- >-=head2 code >- >- my $code = $attr_type->code(); >- $attr_type->code($code); >- >-Accessor. Note that the code is immutable once >-a type is created or fetched from the database. >- >-=cut >- >-sub code { >- my $self = shift; >- return $self->{'code'}; >-} >- >-=head2 description >- >- my $description = $attr_type->description(); >- $attr_type->description($description); >- >-Accessor. >- >-=cut >- >-sub description { >- my $self = shift; >- @_ ? $self->{'description'} = shift : $self->{'description'}; >-} >- >-=head2 branches >- >-my $branches = $attr_type->branches(); >-$attr_type->branches($branches); >- >-Accessor. >- >-=cut >- >-sub branches { >- my $self = shift; >- @_ ? $self->{branches} = shift : $self->{branches}; >-} >- >-=head2 repeatable >- >- my $repeatable = $attr_type->repeatable(); >- $attr_type->repeatable($repeatable); >- >-Accessor. The C<$repeatable> argument >-is interpreted as a Perl boolean. >- >-=cut >- >-sub repeatable { >- my $self = shift; >- @_ ? $self->{'repeatable'} = ((shift) ? 1 : 0) : $self->{'repeatable'}; >-} >- >-=head2 unique_id >- >- my $unique_id = $attr_type->unique_id(); >- $attr_type->unique_id($unique_id); >- >-Accessor. The C<$unique_id> argument >-is interpreted as a Perl boolean. >- >-=cut >- >-sub unique_id { >- my $self = shift; >- @_ ? $self->{'unique_id'} = ((shift) ? 1 : 0) : $self->{'unique_id'}; >-} >- >-=head2 opac_display >- >- my $opac_display = $attr_type->opac_display(); >- $attr_type->opac_display($opac_display); >- >-Accessor. The C<$opac_display> argument >-is interpreted as a Perl boolean. >- >-=cut >- >-sub opac_display { >- my $self = shift; >- @_ ? $self->{'opac_display'} = ((shift) ? 1 : 0) : $self->{'opac_display'}; >-} >- >-=head2 opac_editable >- >- my $opac_editable = $attr_type->opac_editable(); >- $attr_type->opac_editable($opac_editable); >- >-Accessor. The C<$opac_editable> argument >-is interpreted as a Perl boolean. >- >-=cut >- >-sub opac_editable { >- my $self = shift; >- @_ ? $self->{'opac_editable'} = ((shift) ? 1 : 0) : $self->{'opac_editable'}; >-} >- >-=head2 staff_searchable >- >- my $staff_searchable = $attr_type->staff_searchable(); >- $attr_type->staff_searchable($staff_searchable); >- >-Accessor. The C<$staff_searchable> argument >-is interpreted as a Perl boolean. >- >-=cut >- >-sub staff_searchable { >- my $self = shift; >- @_ ? $self->{'staff_searchable'} = ((shift) ? 1 : 0) : $self->{'staff_searchable'}; >-} >- >-=head2 display_checkout >- >-my $display_checkout = $attr_type->display_checkout(); >-$attr_type->display_checkout($display_checkout); >- >-Accessor. The C<$display_checkout> argument >-is interpreted as a Perl boolean. >- >-=cut >- >-sub display_checkout { >- my $self = shift; >- @_ ? $self->{'display_checkout'} = ((shift) ? 1 : 0) : $self->{'display_checkout'}; >-} >- >-=head2 authorised_value_category >- >- my $authorised_value_category = $attr_type->authorised_value_category(); >- $attr_type->authorised_value_category($authorised_value_category); >- >-Accessor. >- >-=cut >- >-sub authorised_value_category { >- my $self = shift; >- @_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'}; >-} >- >-=head2 category_code >- >-my $category_code = $attr_type->category_code(); >-$attr_type->category_code($category_code); >- >-Accessor. >- >-=cut >- >-sub category_code { >- my $self = shift; >- @_ ? $self->{'category_code'} = shift : $self->{'category_code'}; >-} >- >-=head2 category_description >- >-my $category_description = $attr_type->category_description(); >-$attr_type->category_description($category_description); >- >-Accessor. >- >-=cut >- >-sub category_description { >- my $self = shift; >- @_ ? $self->{'category_description'} = shift : $self->{'category_description'}; >-} >- >-=head2 class >- >-my $class = $attr_type->class(); >-$attr_type->class($class); >- >-Accessor. >- >-=cut >- >-sub class { >- my $self = shift; >- @_ ? $self->{'class'} = shift : $self->{'class'}; >-} >- >- >-=head2 delete >- >- $attr_type->delete(); >- C4::Members::AttributeTypes->delete($code); >- >-Delete an attribute type from the database. The attribute >-type may be specified either by an object or by a code. >- >-=cut >- >-sub delete { >- my $arg = shift; >- my $code; >- if (ref($arg) eq __PACKAGE__) { >- $code = $arg->{'code'}; >- } else { >- $code = shift; >- } >- >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare_cached("DELETE FROM borrower_attribute_types WHERE code = ?"); >- $sth->execute($code); >- $sth->finish; >-} >- >-=head2 num_patrons >- >- my $count = $attr_type->num_patrons(); >- >-Returns the number of patron records that use >-this attribute type. >- >-=cut >- >-sub num_patrons { >- my $self = shift; >- >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare_cached("SELECT COUNT(DISTINCT borrowernumber) >- FROM borrower_attributes >- WHERE code = ?"); >- $sth->execute($self->{code}); >- my ($count) = $sth->fetchrow_array; >- $sth->finish; >- return $count; >-} >- >-=head2 get_patrons >- >- my @borrowernumbers = $attr_type->get_patrons($attribute); >- >-Returns the borrowernumber of the patron records that >-have an attribute with the specifie value. >- >-=cut >- >-sub get_patrons { >- my $self = shift; >- my $value = shift; >- >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare_cached("SELECT DISTINCT borrowernumber >- FROM borrower_attributes >- WHERE code = ? >- AND attribute = ?"); >- $sth->execute($self->{code}, $value); >- my @results; >- while (my ($borrowernumber) = $sth->fetchrow_array) { >- push @results, $borrowernumber; >- } >- return @results; >-} >- >-=head1 AUTHOR >- >-Koha Development Team <http://koha-community.org/> >- >-Galen Charlton <galen.charlton@liblime.com> >- >-=cut >- >-1; >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index 60243cf2d8..9d76aeeec8 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -25,7 +25,6 @@ use Encode qw( decode_utf8 ); > > use C4::Members; > use C4::Members::Attributes qw(:all); >-use C4::Members::AttributeTypes; > > use Koha::Libraries; > use Koha::Patrons; >@@ -431,12 +430,12 @@ Returns an attribute type based on matchpoint parameter. > sub set_attribute_types { > my ($self, $params) = @_; > >- my $attribute_types; >+ my $attribute_type; > if( $params->{extended} ) { >- $attribute_types = C4::Members::AttributeTypes->fetch($params->{matchpoint}); >+ $attribute_type = Koha::Patron::Attribute::Types->find($params->{matchpoint}); > } > >- return $attribute_types; >+ return $attribute_type; > } > > =head2 set_column_keys >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 77c8b88c9b..06ebbb8253 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -31,7 +31,6 @@ use C4::Context; > use C4::Output; > use C4::Members; > use C4::Members::Attributes; >-use C4::Members::AttributeTypes; > use C4::Koha; > use C4::Log; > use C4::Letters; >@@ -407,11 +406,11 @@ if ($op eq 'save' || $op eq 'insert'){ > eval {$attribute->check_unique_id}; > if ( $@ ) { > push @errors, "ERROR_extended_unique_id_failed"; >- my $attr_info = C4::Members::AttributeTypes->fetch($attr->{code}); >+ my $attr_type = Koha::Patron::Attribute::Types->find($attr->code); > $template->param( > ERROR_extended_unique_id_failed_code => $attr->{code}, > ERROR_extended_unique_id_failed_value => $attr->{attribute}, >- ERROR_extended_unique_id_failed_description => $attr_info->description() >+ ERROR_extended_unique_id_failed_description => $attr_type->description() > ); > } > } >diff --git a/members/moremember.pl b/members/moremember.pl >index 0e3a31b8d6..cf0496dd2e 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -32,7 +32,6 @@ use CGI qw ( -utf8 ); > use C4::Context; > use C4::Auth; > use C4::Output; >-use C4::Members::AttributeTypes; > use C4::Form::MessagingPreferences; > use List::MoreUtils qw/uniq/; > use Koha::Patron::Attribute::Types; >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 5899380454..9515815d05 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -101,11 +101,11 @@ foreach my $attr (@$attributes) { > my $attribute = Koha::Patron::Attribute->new($attr); > eval {$attribute->check_unique_id}; > if ( $@ ) { >- my $attr_info = C4::Members::AttributeTypes->fetch($attr->{code}); >+ my $attr_type = Koha::Patron::Attribute::Types->find($attr->{code}); > $template->param( > extended_unique_id_failed_code => $attr->{code}, > extended_unique_id_failed_value => $attr->{attribute}, >- extended_unique_id_failed_description => $attr_info->description() >+ extended_unique_id_failed_description => $attr_type->description, > ); > $conflicting_attribute = 1; > } >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 16a1c0f36d..60cc5d26b2 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -27,7 +27,6 @@ use C4::Circulation; > use C4::External::BakerTaylor qw( image_url link_url ); > use C4::Reserves; > use C4::Members; >-use C4::Members::AttributeTypes; > use C4::Output; > use C4::Biblio; > use C4::Items; >diff --git a/t/Members_AttributeTypes.t b/t/Members_AttributeTypes.t >deleted file mode 100755 >index 1c8608db54..0000000000 >--- a/t/Members_AttributeTypes.t >+++ /dev/null >@@ -1,77 +0,0 @@ >-#!/usr/bin/perl >- >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY 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, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >- >-use Test::MockModule; >-use Test::More; >- >-use Module::Load::Conditional qw/check_install/; >- >-use Koha::Patron::Attribute::Types; >- >-BEGIN { >- if ( check_install( module => 'Test::DBIx::Class' ) ) { >- plan tests => 8; >- } else { >- plan skip_all => "Need Test::DBIx::Class" >- } >-} >- >-use_ok('C4::Members::AttributeTypes'); >- >-use Test::DBIx::Class; >- >-fixtures_ok [ >- Category => [ >- ['categorycode'], >- ['orange'], ['yellow'], >- ], >- BorrowerAttributeType => [ >- [ >- 'code', 'description', >- 'repeatable', 'unique_id', >- 'opac_display', >- 'staff_searchable', 'authorised_value_category', >- 'display_checkout', 'category_code', >- 'class' >- ], >- [ 'one', 'ISBN', '1', '1', '1', '1', 'red', '1', 'orange', 'green' ], >- [ 'two', 'ISSN', '0', '0', '0', '0', 'blue', '0', 'yellow', 'silver' ] >- >- ], >-], 'add fixtures'; >- >-my $db = Test::MockModule->new('Koha::Database'); >-$db->mock( _new_schema => sub { return Schema(); } ); >- >-my @members_attributetypes = @{Koha::Patron::Attribute::Types->search->unblessed}; >- >-is( $members_attributetypes[0]->{'code'}, 'one', 'First code value is one' ); >- >-is( $members_attributetypes[1]->{'code'}, 'two', 'Second code value is two' ); >- >-is( $members_attributetypes[0]->{'class'}, >- 'green', 'First class value is green' ); >- >-is( $members_attributetypes[1]->{'class'}, >- 'silver', 'Second class value is silver' ); >- >-ok( C4::Members::AttributeTypes->fetch('one'), "testing fetch feature" ); >- >-ok( !C4::Members::AttributeTypes->fetch('FAKE'), >- "testing fetch feature doesn't work if value not in database" ); >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 69331d9be9..4e606beee6 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -38,6 +38,7 @@ use Koha::Holds; > use Koha::Old::Holds; > use Koha::Patrons; > use Koha::Old::Patrons; >+use Koha::Patron::Attribute::Types; > use Koha::Patron::Categories; > use Koha::Patron::Relationship; > use Koha::Database; >@@ -2029,42 +2030,49 @@ subtest 'extended_attributes' => sub { > > set_logged_in_user($patron_1); > >- my $attribute_type1 = C4::Members::AttributeTypes->new('my code1', 'my description1'); >- $attribute_type1->unique_id(1); >- $attribute_type1->store(); >- >- my $attribute_type2 = C4::Members::AttributeTypes->new('my code2', 'my description2'); >- $attribute_type2->opac_display(1); >- $attribute_type2->staff_searchable(1); >- $attribute_type2->store(); >+ my $attribute_type1 = Koha::Patron::Attribute::Type->new( >+ { >+ code => 'my code1', >+ description => 'my description1', >+ unique_id => 1 >+ } >+ )->store; >+ my $attribute_type2 = Koha::Patron::Attribute::Type->new( >+ { >+ code => 'my code2', >+ description => 'my description2', >+ opac_display => 1, >+ staff_searchable => 1 >+ } >+ )->store; > > my $new_library = $builder->build( { source => 'Branch' } ); >- my $attribute_type_limited = C4::Members::AttributeTypes->new('my code3', 'my description3'); >- $attribute_type_limited->branches([ $new_library->{branchcode} ]); >- $attribute_type_limited->store; >+ my $attribute_type_limited = Koha::Patron::Attribute::Type->new( >+ { code => 'my code3', description => 'my description3' } )->store; >+ $attribute_type_limited->library_limits( [ $new_library->{branchcode} ] ); > > my $attributes_for_1 = [ > { >- value => 'my attribute1', >+ attribute => 'my attribute1', > code => $attribute_type1->code(), > }, > { >- value => 'my attribute2', >+ attribute => 'my attribute2', > code => $attribute_type2->code(), > }, > { >- value => 'my attribute limited', >+ attribute => 'my attribute limited', > code => $attribute_type_limited->code(), > } > ]; > > my $attributes_for_2 = [ > { >- value => 'my attribute12', >+ attribute => 'my attribute12', > code => $attribute_type1->code(), > }, > { >- value => 'my attribute limited 2', >+ attribute => 'my attribute limited 2', > code => $attribute_type_limited->code(), > } > ]; >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index fd68c296c4..afdd4d5b30 100644 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -503,8 +503,8 @@ subtest 'test_set_column_keys' => sub { > my $attr_type_3 = $patrons_import->set_attribute_types($params_3); > > # Then ... >- isa_ok($attr_type_3, 'C4::Members::AttributeTypes'); >- is($attr_type_3->{code}, $code_3, 'Got the expected code attribute type from set attribute types'); >+ isa_ok($attr_type_3, 'Koha::Patron::Attribute::Type'); >+ is($attr_type_3->code, $code_3, 'Got the expected code attribute type from set attribute types'); > }; > > subtest 'test_set_column_keys' => sub { >diff --git a/t/db_dependent/Members/Attributes.t b/t/db_dependent/Members/Attributes.t >index 593bb50a1a..32e9c7e365 100644 >--- a/t/db_dependent/Members/Attributes.t >+++ b/t/db_dependent/Members/Attributes.t >@@ -21,7 +21,6 @@ use Modern::Perl; > > use C4::Context; > use C4::Members; >-use C4::Members::AttributeTypes; > use Koha::Database; > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -57,19 +56,26 @@ my $patron = $builder->build( > t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); > my $borrowernumber = $patron->{borrowernumber}; > >-my $attribute_type1 = C4::Members::AttributeTypes->new('my code1', 'my description1'); >-$attribute_type1->unique_id(1); >-$attribute_type1->store(); >- >-my $attribute_type2 = C4::Members::AttributeTypes->new('my code2', 'my description2'); >-$attribute_type2->opac_display(1); >-$attribute_type2->staff_searchable(1); >-$attribute_type2->store(); >+my $attribute_type1 = Koha::Patron::Attribute::Type->new( >+ { >+ code => 'my code1', >+ description => 'my description1', >+ unique_id => 1 >+ } >+)->store; >+my $attribute_type2 = Koha::Patron::Attribute::Type->new( >+ { >+ code => 'my code2', >+ description => 'my description2', >+ opac_display => 1, >+ staff_searchable => 1 >+ } >+)->store; > > my $new_library = $builder->build( { source => 'Branch' } ); >-my $attribute_type_limited = C4::Members::AttributeTypes->new('my code3', 'my description3'); >-$attribute_type_limited->branches([ $new_library->{branchcode} ]); >-$attribute_type_limited->store; >+my $attribute_type_limited = Koha::Patron::Attribute::Type->new( >+ { code => 'my code3', description => 'my description3' } )->store; >+$attribute_type_limited->library_limits( [ $new_library->{branchcode} ] ); > > $patron = Koha::Patrons->find($borrowernumber); > my $borrower_attributes = $patron->extended_attributes; >diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t >index 2e76da5615..f9459b54d5 100644 >--- a/t/db_dependent/Utils/Datatables_Members.t >+++ b/t/db_dependent/Utils/Datatables_Members.t >@@ -23,7 +23,6 @@ use C4::Context; > use C4::Members; > > use C4::Members::Attributes; >-use C4::Members::AttributeTypes; > > use Koha::Library; > use Koha::Patrons; >@@ -276,14 +275,18 @@ $search_results = C4::Utils::DataTables::Members::search({ > is( $search_results->{ iTotalDisplayRecords }, 0, > "No members are found by userid, surname search"); > >-my $attribute_type = C4::Members::AttributeTypes->new( 'ATM_1', 'my attribute type' ); >-$attribute_type->{staff_searchable} = 1; >-$attribute_type->store; >+my $attribute_type = Koha::Patron::Attribute::Type->new( >+ { >+ code => 'ATM_1', >+ description => 'my attribute type', >+ staff_searchable => 1 >+ } >+)->store; > > Koha::Patrons->find( $john_doe->{borrowernumber} )->extended_attributes( > [ > { >- code => $attribute_type->{code}, >+ code => $attribute_type->code, > attribute => 'the default value for a common user' > } > ] >@@ -291,7 +294,7 @@ Koha::Patrons->find( $john_doe->{borrowernumber} )->extended_attributes( > Koha::Patrons->find( $jane_doe->{borrowernumber} )->extended_attributes( > [ > { >- code => $attribute_type->{code}, >+ code => $attribute_type->code, > attribute => 'the default value for another common user' > } > ] >@@ -299,7 +302,7 @@ Koha::Patrons->find( $jane_doe->{borrowernumber} )->extended_attributes( > Koha::Patrons->find( $john_smith->{borrowernumber} )->extended_attributes( > [ > { >- code => $attribute_type->{code}, >+ code => $attribute_type->code, > attribute => 'Attribute which not appears even if contains "Dupont"' > } > ] >diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl >index bc6446c177..5c3b5f7a5b 100755 >--- a/tools/modborrowers.pl >+++ b/tools/modborrowers.pl >@@ -379,9 +379,9 @@ if ( $op eq 'do' ) { > my $attribute; > $attribute->{code} = $_; > $attribute->{attribute} = $attr_values[$i]; >- my $attr_type = C4::Members::AttributeTypes->fetch( $_ ); >+ my $attr_type = Koha::Patron::Attribute::Types->find($_); > # If this borrower is not in the category of this attribute, we don't want to modify this attribute >- ++$i and next if $attr_type->{category_code} and $attr_type->{category_code} ne $patron->category_code; >+ ++$i and next if $attr_type->category_code and $attr_type->category_code ne $patron->category_code; > my $valuename = "attr" . $i . "_value"; > if ( grep { $_ eq $valuename } @disabled ) { > # The attribute is disabled, we remove it for this borrower ! >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20443
:
101122
|
101123
|
101124
|
101125
|
101126
|
101127
|
101128
|
101129
|
101130
|
101131
|
101132
|
101133
|
101134
|
101135
|
101136
|
101137
|
101138
|
101139
|
101140
|
101141
|
101142
|
101143
|
101144
|
101145
|
101146
|
101147
|
101148
|
101149
|
101150
|
101209
|
101210
|
101211
|
101212
|
101213
|
101214
|
101215
|
101216
|
101217
|
101218
|
101219
|
101220
| 101221 |
101222
|
101223
|
101224
|
101225
|
101226
|
101227
|
101228
|
101229
|
101230
|
101231
|
101232
|
101233
|
101234
|
101235
|
101236
|
101237
|
101472
|
104519