Bugzilla – Attachment 63256 Details for
Bug 18559
Koha::Clubs - methods should not get the return type in parameter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18559: Koha::Clubs - Remove $return_scalar from parameters
Bug-18559-KohaClubs---Remove-returnscalar-from-par.patch (text/plain), 9.85 KB, created by
Jonathan Druart
on 2017-05-08 18:50:18 UTC
(
hide
)
Description:
Bug 18559: Koha::Clubs - Remove $return_scalar from parameters
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-05-08 18:50:18 UTC
Size:
9.85 KB
patch
obsolete
>From 2110e545b247f1b6a488c448534c08b83a1309c1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 8 May 2017 15:49:51 -0300 >Subject: [PATCH] Bug 18559: Koha::Clubs - Remove $return_scalar from > parameters > >--- > Koha/Clubs.pm | 20 ++++---------------- > Koha/Patron.pm | 17 +++++------------ > clubs/patron-clubs-tab.pl | 8 ++++---- > .../prog/en/modules/circ/circulation.tt | 10 +++++----- > .../prog/en/modules/clubs/patron-clubs-tab.tt | 4 ++-- > .../prog/en/modules/members/moremember.tt | 6 +++--- > .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 10 +++++----- > opac/clubs/clubs-tab.pl | 8 ++++---- > 8 files changed, 32 insertions(+), 51 deletions(-) > >diff --git a/Koha/Clubs.pm b/Koha/Clubs.pm >index 7d62d2299b..9817af7195 100644 >--- a/Koha/Clubs.pm >+++ b/Koha/Clubs.pm >@@ -50,9 +50,9 @@ sub get_enrollable { > my $borrower = $params->{borrower}; > if ($borrower) { > delete( $params->{borrower} ); >- my @enrollments = $borrower->get_club_enrollments(); >- if (@enrollments) { >- $params->{'me.id'} = { -not_in => [ map { $_->club()->id() } @enrollments ] }; >+ my $enrollments = $borrower->get_club_enrollments(); >+ if ($enrollments->count) { >+ $params->{'me.id'} = { -not_in => [ $enrollments->get_column('id') ] }; > } > } > >@@ -62,19 +62,7 @@ sub get_enrollable { > -or => [ 'me.branchcode' => $borrower->branchcode, 'me.branchcode' => undef ] > ]; > >- 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 type >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index b97bceb258..b6de71496f 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -600,13 +600,10 @@ sub first_valid_email_address { > =cut > > sub get_club_enrollments { >- my ( $self, $return_scalar ) = @_; >- >- my $e = Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } ); >- >- return $e if $return_scalar; >+ my ( $self ) = @_; > >- return wantarray ? $e->as_list : $e; >+ my $club_rs = $self->_result->club_enrollments->search( { date_canceled => undef } ); >+ return Koha::Club::Enrollments->_new_from_dbic($club_rs); > } > > =head3 get_enrollable_clubs >@@ -614,7 +611,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 >@@ -623,11 +620,7 @@ sub get_enrollable_clubs { > > $params->{borrower} = $self; > >- my $e = Koha::Clubs->get_enrollable($params); >- >- return $e if $return_scalar; >- >- return wantarray ? $e->as_list : $e; >+ return Koha::Clubs->get_enrollable($params); > } > > =head3 type >diff --git a/clubs/patron-clubs-tab.pl b/clubs/patron-clubs-tab.pl >index f50da65a5a..7c4fbf2f01 100755 >--- a/clubs/patron-clubs-tab.pl >+++ b/clubs/patron-clubs-tab.pl >@@ -43,12 +43,12 @@ my $patronnumber = $cgi->param('borrowernumber'); > > my $patron = Koha::Patrons->find($patronnumber); > >-my @enrollments = $patron->get_club_enrollments(); >-my @clubs = $patron->get_enrollable_clubs(); >+my $enrollments = $patron->get_club_enrollments(); >+my $clubs = $patron->get_enrollable_clubs(); > > $template->param( >- enrollments => \@enrollments, >- clubs => \@clubs, >+ enrollments => $enrollments, >+ clubs => $clubs, > borrowernumber => $patronnumber > ); > >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 adfe9c02dd..7ae3669dcd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -895,12 +895,12 @@ No patron matched <span class="ex">[% message | html %]</span> > [% END %] > </li> > >- [% SET enrollments = patron.get_club_enrollments(1) %] >- [% SET enrollable = patron.get_enrollable_clubs(0,1) %] >- [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %] >+ [% SET nb_enrollments = patron.get_club_enrollments.count %] >+ [% SET nb_enrollable = patron.get_enrollable_clubs.count %] >+ [% IF CAN_user_clubs && ( nb_enrollable || nb_enrollments ) %] > <li> > <a id="clubs-tab-link" href="#clubs-tab"> >- Clubs ([% enrollments.count %]/[% enrollable.count %]) >+ Clubs ([% nb_enrollments %]/[% nb_enrollable %]) > </a> > </li> > [% END %] >@@ -953,7 +953,7 @@ No patron matched <span class="ex">[% message | html %]</span> > </div> > [% END %] > >-[% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %] >+[% IF CAN_user_clubs && ( nb_enrollable|| nb_enrollments ) %] > <div id="clubs-tab"> > Loading... > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >index 30cb710724..df8ad4add4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >@@ -1,6 +1,6 @@ > [% USE KohaDates %] > >-[% IF enrollments %] >+[% IF enrollments.count %] > <table> > <thead> > <tr> >@@ -35,7 +35,7 @@ > </table> > [% END %] > >-[% IF clubs %] >+[% IF clubs.count %] > <table> > <thead> > <tr> >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 dc4ff75125..dc1e3ea643 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -524,9 +524,9 @@ function validate1(date) { > [% END %] > <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li> > >- [% SET enrollments = patron.get_club_enrollments(1) %] >- [% SET enrollable = patron.get_enrollable_clubs(0,1) %] >- [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %] >+ [% SET nb_enrollments = patron.get_club_enrollments.count %] >+ [% SET nb_enrollable = patron.get_enrollable_clubs.count %] >+ [% IF CAN_user_clubs && ( nb_enrollable || nb_enrollments ) %] > <li> > <a id="clubs-tab-link" href="#clubs-tab"> > Clubs ([% enrollments.count %]/[% enrollable.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 cded80d2e5..ffa872310a 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -4,8 +4,8 @@ > [% USE ItemTypes %] > [% USE Price %] > >-[% SET borrower_club_enrollments = borrower.get_club_enrollments(1) %] >-[% SET borrower_enrollable_clubs = borrower.get_enrollable_clubs(1,1) %] >+[% SET nb_club_enrollments = borrower.get_club_enrollments.count %] >+[% SET nb_enrollable_clubs = borrower.get_enrollable_clubs(1).count %] > > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your library home</title> >@@ -139,10 +139,10 @@ Using this account is not recommended because some parts of Koha will not functi > [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% amountoutstanding | $Price %])</a></li>[% END %] > [% END %] > >- [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %] >+ [% IF nb_club_enrollments || borrower_enrollable_clubs %] > <li> > <a id="opac-user-clubs-tab-link" href="#opac-user-clubs"> >- Clubs ([% borrower_club_enrollments.count || 0 %]/[% borrower_enrollable_clubs.count || 0 %]) >+ Clubs ([% nb_club_enrollments %]/[% nb_enrollable_clubs %]) > </a> > </li> > [% END %] >@@ -343,7 +343,7 @@ Using this account is not recommended because some parts of Koha will not functi > [% END # IF issues_count %] > </div> <!-- / .opac-user-checkouts --> > >- [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %] >+ [% IF nb_club_enrollments || nb_enrollable_clubs %] > <div id="opac-user-clubs"> > Loading... > </div> >diff --git a/opac/clubs/clubs-tab.pl b/opac/clubs/clubs-tab.pl >index 82a4be0f54..4efb6e096b 100755 >--- a/opac/clubs/clubs-tab.pl >+++ b/opac/clubs/clubs-tab.pl >@@ -40,12 +40,12 @@ my $borrowernumber = $cgi->param('borrowernumber'); > > my $borrower = Koha::Patrons->find($borrowernumber); > >-my @enrollments = $borrower->get_club_enrollments(); >-my @clubs = $borrower->get_enrollable_clubs( my $opac = 1 ); >+my $enrollments = $borrower->get_club_enrollments(); >+my $clubs = $borrower->get_enrollable_clubs( my $opac = 1 ); > > $template->param( >- enrollments => \@enrollments, >- clubs => \@clubs, >+ enrollments => $enrollments, >+ clubs => $clubs, > borrower => $borrower, > ); > >-- >2.11.0
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 18559
: 63256