Bug 23271: Replace search_limited with search_with_library_limits
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 16 Oct 2019 12:53:48 +0000 (14:53 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 21 Apr 2021 13:25:07 +0000 (15:25 +0200)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
22 files changed:
C4/ItemCirculationAlertPreference.pm
Koha/Patron/Categories.pm
Koha/Template/Plugin/Categories.pm
acqui/add_user_search.pl
admin/add_user_search.pl
admin/item_circulation_alerts.pl
admin/patron-attr-types.pl
members/guarantor_search.pl
members/memberentry.pl
members/members-home.pl
members/update-child.pl
patroncards/add_user_search.pl
reports/bor_issues_top.pl
reports/borrowers_out.pl
reports/cat_issues_top.pl
reports/issues_stats.pl
reports/reserves_stats.pl
serials/add_user_search.pl
t/db_dependent/Utils/Datatables_Virtualshelves.t
tools/cleanborrowers.pl
tools/import_borrowers.pl
tools/modborrowers.pl

index 4eb263c..c793516 100644 (file)
@@ -331,7 +331,7 @@ sub grid {
     my ($class, $where) = @_;
     my @branch_prefs = $class->find($where);
     my @default_prefs = $class->find({ branchcode => '*', notification => $where->{notification} });
-    my @cc = Koha::Patron::Categories->search_limited;
+    my @cc = Koha::Patron::Categories->search_with_library_limits;
     my @it = Koha::ItemTypes->search;
     my $notification = $where->{notification};
     my %disabled = map {
index 8ee320d..af59fb8 100644 (file)
@@ -21,7 +21,7 @@ use Koha::Database;
 
 use Koha::Patron::Category;
 
-use base qw(Koha::Objects);
+use base qw(Koha::Objects Koha::Objects::Limit::Library);
 
 =head1 NAME
 
@@ -33,17 +33,6 @@ Koha::Patron::Categories - Koha Patron Category Object set class
 
 =cut
 
-sub search_limited {
-    my ( $self, $params, $attributes ) = @_;
-    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
-    if ( $branch_limit ) {
-        $params->{'categories_branches.branchcode'} = [ $branch_limit, undef ];
-        $attributes->{join} = 'categories_branches';
-    }
-    $attributes->{order_by} = ['description'] unless $attributes->{order_by};
-    return $self->search($params, $attributes);
-}
-
 =head3 type
 
 =cut
index 140f12a..59d3588 100644 (file)
@@ -25,7 +25,7 @@ use Koha::Patron::Categories;
 
 sub all {
     my ( $self, $params ) = @_;
-    return Koha::Patron::Categories->search_limited($params);
+    return Koha::Patron::Categories->search_with_library_limits($params);
 }
 
 sub GetName {
index a81053d..ea7b2ae 100755 (executable)
@@ -50,7 +50,7 @@ my $search_patrons_with_acq_perm_only =
     ( $referer =~ m|acqui/basket.pl| )
         ? 1 : 0;
 
-my $patron_categories = Koha::Patron::Categories->search_limited;
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
 $template->param(
     patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
     view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
index 5d3b5de..027eb15 100755 (executable)
@@ -51,7 +51,7 @@ my $search_patrons_with_acq_perm_only =
     ( $referer =~ m|admin/aqbudgets.pl| )
         ? 1 : 0;
 
-my $patron_categories = Koha::Patron::Categories->search_limited;
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
 $template->param(
     patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
     view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
index 3a93cba..ae6692d 100755 (executable)
@@ -49,7 +49,7 @@ sub show {
     );
 
     my $branch   = $input->param('branch') || '*';
-    my @categories = Koha::Patron::Categories->search_limited;
+    my @categories = Koha::Patron::Categories->search_with_library_limits;
     my @item_types = Koha::ItemTypes->search;
     my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
     my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
index 1924c06..5b357d2 100755 (executable)
@@ -85,7 +85,7 @@ exit 0;
 sub add_attribute_type_form {
     my $template = shift;
 
-    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+    my $patron_categories = Koha::Patron::Categories->search_with_library_limlits({}, {order_by => ['description']});
     $template->param(
         attribute_type_form => 1,
         confirm_op => 'add_attribute_type_confirmed',
index 3bd4165..b5d31ed 100755 (executable)
@@ -43,7 +43,7 @@ my $op = $input->param('op') || '';
 
 my $referer = $input->referer();
 
-my $patron_categories = Koha::Patron::Categories->search_limited;
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
 $template->param(
     view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
     columns => ['cardnumber', 'name', 'dateofbirth', 'address', 'action' ],
index 6511a08..fca1996 100755 (executable)
@@ -671,7 +671,7 @@ my @typeloop;
 my $no_categories = 1;
 my $no_add;
 foreach my $category_type (qw(C A S P I X)) {
-    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => $category_type }, {order_by => ['categorycode']});
+    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({ category_type => $category_type }, {order_by => ['categorycode']});
     $no_categories = 0 if $patron_categories->count > 0;
 
     my @categoryloop;
index 4dc06b1..8ae49fa 100755 (executable)
@@ -44,7 +44,7 @@ if( Koha::Libraries->search->count < 1){
     $template->param(no_branches => 1);
 }
 
-my @categories = Koha::Patron::Categories->search_limited;
+my @categories = Koha::Patron::Categories->search_with_library_limits;
 if(scalar(@categories) < 1){
     $no_add = 1;
     $template->param(no_categories => 1);
index 0789ea5..7e7edad 100755 (executable)
@@ -57,7 +57,7 @@ my $op             = $input->param('op');
 
 my $logged_in_user = Koha::Patrons->find( $loggedinuser );
 
-my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits({ category_type => 'A' }, {order_by => ['categorycode']});
 if ( $op eq 'multi' ) {
     # FIXME - what are the possible upgrade paths?  C -> A , C -> S ...
     #   currently just allowing C -> A
index b01cf6a..8eb2a73 100755 (executable)
@@ -43,7 +43,7 @@ my $op = $input->param('op') || '';
 
 my $referer = $input->referer();
 
-my $patron_categories = Koha::Patron::Categories->search_limited;
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
 $template->param(
     view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
     columns         => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
index 90b6b49..265362b 100755 (executable)
@@ -108,7 +108,7 @@ my $dbh = C4::Context->dbh;
 my @mime  = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
 my $delims = GetDelimiterChoices;
 
-my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
 my $itemtypes = Koha::ItemTypes->search_with_localization;
 $template->param(
            mimeloop => \@mime,
index 394bf38..aee373a 100755 (executable)
@@ -113,7 +113,7 @@ if ($do_it) {
     my $CGIextChoice = ( 'CSV' ); # FIXME translation
        my $CGIsepChoice = GetDelimiterChoices;
 
-    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
+    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
     $template->param(
                     CGIextChoice => $CGIextChoice,
                     CGIsepChoice => $CGIsepChoice,
index 28025cc..ee0c092 100755 (executable)
@@ -132,7 +132,7 @@ if ($do_it) {
 
     @shelvinglocloop = sort {$a->{value} cmp $b->{value}} @shelvinglocloop;
 
-    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
+    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
 
     $template->param(
                     CGIextChoice => $CGIextChoice,
index 8f86fdb..896b443 100755 (executable)
@@ -88,7 +88,7 @@ $template->param(do_it => $do_it,
 
 our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed;
 
-our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
 
 our $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
 our $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
index 23b4229..c28c398 100755 (executable)
@@ -73,7 +73,7 @@ $sep = "\t" if ($sep eq 'tabulation');
 $template->param(do_it => $do_it,
 );
 
-my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
 
 my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
 my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
@@ -330,7 +330,7 @@ sub display_value {
         }
     }
     elsif ( $crit =~ /category/ ) {
-        my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+        my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
         foreach my $patron_category ( @patron_categories ) {
             ( $value eq $patron_category->categorycode ) or next;
             $display_value = $patron_category->description and last;
index dedce1d..b42b5fa 100755 (executable)
@@ -43,7 +43,7 @@ my $op = $input->param('op') || '';
 
 my $referer = $input->referer();
 
-my $patron_categories = Koha::Patron::Categories->search_limited;
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
 $template->param(
     view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
     columns => ['cardnumber', 'name', 'branch', 'action'],
index eaf5ce5..758f93f 100755 (executable)
@@ -38,7 +38,7 @@ my $dbh = C4::Context->dbh;
 $dbh->do(q|DELETE FROM virtualshelves|);
 
 # Pick a categorycode from the DB
-my @categories   = Koha::Patron::Categories->search_limited;
+my @categories   = Koha::Patron::Categories->search_with_library_limits;
 my $categorycode = $categories[0]->categorycode;
 my $branchcode   = "ABC";
 my $branch_data = {
index c323eeb..1afc3f9 100755 (executable)
@@ -178,7 +178,7 @@ elsif ( $step == 3 ) {
     $template->param( patron_lists => [ @non_empty_lists ] );
 }
 
-my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
 
 $template->param(
     step                   => $step,
index a0c4bfb..f722568 100755 (executable)
@@ -77,7 +77,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 );
 
 # get the patron categories and pass them to the template
-my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
 $template->param( categories => \@patron_categories );
 my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
 $columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
index 3a1bd55..ee89684 100755 (executable)
@@ -113,7 +113,7 @@ if ( $op eq 'show' ) {
     my @patron_attributes_codes;
     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']});
+    my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
     while ( my $attr_type = $patron_attribute_types->next ) {
         # TODO Repeatable attributes are not correctly managed and can cause data lost.
         # This should be implemented.