Bug 20443: Use search_with_library_limits for attribute types
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 27 Nov 2019 14:35:07 +0000 (15:35 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 23 Mar 2020 13:49:22 +0000 (13:49 +0000)
Dealt with that previously in the module during the rebase.
It conflicted with bug 23281.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Auth_with_ldap.pm
members/memberentry.pl
members/moremember.pl
reports/borrowers_stats.pl
reports/issues_stats.pl
tools/modborrowers.pl

index 0599d9f..36b9071 100644 (file)
@@ -231,7 +231,8 @@ sub checkpw_ldap {
         return 0;   # B2, D2
     }
     if (C4::Context->preference('ExtendedPatronAttributes') && $borrowernumber && ($config{update} ||$config{replicate})) {
-        my $attribute_types = Koha::Patron::Attribute::Types->filter_by_branch_limitations;
+        my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+        my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
         while ( my $attribute_type = $attribute_types->next ) {
             my $code = $attribute_type->code;
             unless (exists($borrower{$code}) && $borrower{$code} !~ m/^\s*$/ ) {
@@ -374,7 +375,8 @@ sub update_local {
     # skip extended patron attributes in 'borrowers' attribute update
     my @keys = keys %$borrower;
     if (C4::Context->preference('ExtendedPatronAttributes')) {
-        my $attribute_types = Koha::Patron::Attribute::Types->filter_by_branch_limitations;
+        my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+        my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
         while ( my $attribute_type = $attribute_types->next ) {
            my $code = $attribute_type->code;
            @keys = grep { $_ ne $code } @keys;
index 8ddfa49..bdeeb07 100755 (executable)
@@ -866,7 +866,8 @@ sub patron_attributes_form {
     my $borrowernumber = shift;
     my $op = shift;
 
-    my $attribute_types = Koha::Patron::Attribute::Types->filter_by_branch_limitations;
+    my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+    my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
     if ( $attribute_types->count == 0 ) {
         $template->param(no_patron_attribute_types => 1);
         return;
index cf0496d..656ee35 100755 (executable)
@@ -154,7 +154,8 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
         attributes_loop => \@attributes_loop
     );
 
-    my $nb_of_attribute_types = Koha::Patron::Attribute::Types->filter_by_branch_limitations->count;
+    my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+    my $nb_of_attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id)->count;
     if ( $nb_of_attribute_types == 0 ) {
         $template->param(no_patron_attribute_types => 1);
     }
index 34c3353..6a95f01 100755 (executable)
@@ -495,7 +495,8 @@ sub parse_extended_patron_attributes {
 sub patron_attributes_form {
     my $template = shift;
 
-    my $attribute_types = Koha::Patron::Attribute::Types->filter_by_branch_limitations;
+    my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+    my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
 
     my %items_by_class;
     while ( my $attr_type = $attribute_types->next ) {
index 994afc1..16a8f77 100755 (executable)
@@ -166,7 +166,8 @@ foreach (sort {$ccodes->{$a} cmp $ccodes->{$b}} keys %$ccodes) {
 my $CGIextChoice = ( 'CSV' ); # FIXME translation
 my $CGIsepChoice=GetDelimiterChoices;
 
-my $attribute_types = Koha::Patron::Attribute::Types->filter_by_branch_limitations;
+my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
 my %attribute_types_by_class;
 while ( my ( $attribute_type ) = $attribute_types->next ) {
     $attribute_type = $attribute_type->unblessed;
index 7ba01f6..6c53a23 100755 (executable)
@@ -113,7 +113,8 @@ if ( $op eq 'show' ) {
     # Construct the patron attributes list
     my @patron_attributes_values;
     my @patron_attributes_codes;
-    my $patron_attribute_types = Koha::Patron::Attribute::Types->filter_by_branch_limitations;
+    my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+    my $patron_attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
     my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
     while ( my $attr_type = $patron_attribute_types->next ) {
         # TODO Repeatable attributes are not correctly managed and can cause data lost.