From db0ebb3ab54748058ad5606a8845cef506c99c60 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 3 Feb 2022 10:54:25 -0300 Subject: [PATCH] Bug 29844: Simplify Koha::Clubs->get_enrollable This patch removes the wantarray use in Koha::Clubs->get_enrollable and adjusts the callers. Also, reference to some unused params in Koha::Patron clubs-related methods are removed as well. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- Koha/Clubs.pm | 14 +------------- Koha/Patron.pm | 4 ++-- .../prog/en/modules/circ/circulation.tt | 4 ++-- .../prog/en/modules/members/moremember.tt | 4 ++-- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 4 ++-- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Koha/Clubs.pm b/Koha/Clubs.pm index f78e766eba..2f60648959 100644 --- a/Koha/Clubs.pm +++ b/Koha/Clubs.pm @@ -70,19 +70,7 @@ sub get_enrollable { ] ]; - my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } ); - - if (wantarray) { - my $class = ref($self) ? ref($self) : $self; - - return $class->_wrap( $rs->all() ); - - } - else { - my $class = ref($self) ? ref($self) : $self; - - return $class->_new_from_dbic($rs); - } + return $self->search( $params, { prefetch => 'club_template' } ); } =head3 filter_out_empty diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 1f0ca44c3c..add13d1501 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1355,7 +1355,7 @@ sub first_valid_email_address { =cut sub get_club_enrollments { - my ( $self, $return_scalar ) = @_; + my ( $self ) = @_; return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } ); } @@ -1365,7 +1365,7 @@ sub get_club_enrollments { =cut sub get_enrollable_clubs { - my ( $self, $is_enrollable_from_opac, $return_scalar ) = @_; + my ( $self, $is_enrollable_from_opac ) = @_; my $params; $params->{is_enrollable_from_opac} = $is_enrollable_from_opac diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index a5ada8c27b..13d80518d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -805,8 +805,8 @@
  • [% debarments.count | html %] Restrictions
  • - [% SET enrollments = patron.get_club_enrollments(1) %] - [% SET enrollable = patron.get_enrollable_clubs(0,1) %] + [% SET enrollments = patron.get_club_enrollments %] + [% SET enrollable = patron.get_enrollable_clubs(0) %] [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 951c3e1023..81602072d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -732,8 +732,8 @@
  • [% debarments.size | html %] Restrictions
  • - [% SET enrollments = patron.get_club_enrollments(1) %] - [% SET enrollable = patron.get_enrollable_clubs(0,1) %] + [% SET enrollments = patron.get_club_enrollments %] + [% SET enrollable = patron.get_enrollable_clubs(0) %] [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 45ce195e88..352111cd4e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -10,8 +10,8 @@ [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %] -[% SET borrower_club_enrollments = logged_in_user.get_club_enrollments(1) %] -[% SET borrower_enrollable_clubs = logged_in_user.get_enrollable_clubs(1,1) %] +[% SET borrower_club_enrollments = logged_in_user.get_club_enrollments %] +[% SET borrower_enrollable_clubs = logged_in_user.get_enrollable_clubs(1) %] [% INCLUDE 'doc-head-open.inc' %] Your library home › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog -- 2.39.5