Bugzilla – Attachment 57922 Details for
Bug 17556
Move GetHideLostItemsPreference to Koha::Patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17556: Koha::Patrons - Remove GetHideLostItemsPreference
Bug-17556-KohaPatrons---Remove-GetHideLostItemsPre.patch (text/plain), 6.33 KB, created by
Marcel de Rooy
on 2016-12-02 11:46:58 UTC
(
hide
)
Description:
Bug 17556: Koha::Patrons - Remove GetHideLostItemsPreference
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-12-02 11:46:58 UTC
Size:
6.33 KB
patch
obsolete
>From bce8dbe85ac11c5539a0de6b6e9c3fc3cb9299d1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 4 Nov 2016 15:12:53 +0000 >Subject: [PATCH] Bug 17556: Koha::Patrons - Remove GetHideLostItemsPreference >Content-Type: text/plain; charset=utf-8 > >The subroutine C4::Members::GetHideLostItemsPreference can easily be >replaced with Koha::Patron->find(42)->category->hidelostitems > >Test plan: >Create 2 patron categories, 1 with "Lost items in staff client" set to >"shown" and another one to "Hidden by default" >Create 2 patrons using them >On the result search page, the detail page of a record, the item list >page and the page to place a hold, make sure the lost items are >shown/hidden as expected > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Members.pm | 21 --------------------- > C4/Search.pm | 5 +++-- > catalogue/detail.pl | 4 +++- > catalogue/moredetail.pl | 5 +++-- > reserve/request.pl | 5 ++++- > 5 files changed, 13 insertions(+), 27 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 9b44b32..57d1fbd 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -72,8 +72,6 @@ BEGIN { > > &GetAge > >- &GetHideLostItemsPreference >- > &GetMemberAccountRecords > &GetBorNotifyAcctRecord > >@@ -1283,25 +1281,6 @@ sub SetAge{ > return $borrower; > } # sub SetAge > >-=head2 GetHideLostItemsPreference >- >- $hidelostitemspref = &GetHideLostItemsPreference($borrowernumber); >- >-Returns the HideLostItems preference for the patron category of the supplied borrowernumber >-C<&$hidelostitemspref>return value of function, 0 or 1 >- >-=cut >- >-sub GetHideLostItemsPreference { >- my ($borrowernumber) = @_; >- my $dbh = C4::Context->dbh; >- my $query = "SELECT hidelostitems FROM borrowers,categories WHERE borrowers.categorycode = categories.categorycode AND borrowernumber = ?"; >- my $sth = $dbh->prepare($query); >- $sth->execute($borrowernumber); >- my $hidelostitems = $sth->fetchrow; >- return $hidelostitems; >-} >- > =head2 GetBorrowersToExpunge > > $borrowers = &GetBorrowersToExpunge( >diff --git a/C4/Search.pm b/C4/Search.pm >index b1b9b0e..65aa255 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -26,13 +26,13 @@ use Koha::Libraries; > use Lingua::Stem; > use C4::Search::PazPar2; > use XML::Simple; >-use C4::Members qw(GetHideLostItemsPreference); > use C4::XSLT; > use C4::Reserves; # GetReserveStatus > use C4::Debug; > use C4::Charset; > use Koha::AuthorisedValues; > use Koha::Libraries; >+use Koha::Patrons; > use YAML; > use URI::Escape; > use Business::ISBN; >@@ -2089,7 +2089,8 @@ sub searchResults { > # For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item > my $userenv = C4::Context->userenv; > if ( $item->{onloan} >- && !( C4::Members::GetHideLostItemsPreference( $userenv->{'number'} ) && $item->{itemlost} ) ) >+ && $userenv >+ && !( Koha::Patrons->find($userenv->{number})->category->hidelostitems && $item->{itemlost} ) ) > { > $onloan_count++; > my $key = $prefix . $item->{onloan} . $item->{barcode}; >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 2bf81c2..a31a0c5 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -42,6 +42,7 @@ use C4::HTML5Media; > use C4::CourseReserves qw(GetItemCourseReservesInfo); > use C4::Acquisition qw(GetOrdersByBiblionumber); > use Koha::AuthorisedValues; >+use Koha::Patrons; > use Koha::Virtualshelves; > > my $query = CGI->new(); >@@ -132,8 +133,9 @@ my $dbh = C4::Context->dbh; > > my @all_items = GetItemsInfo( $biblionumber ); > my @items; >+my $patron = Koha::Patrons->find( $borrowernumber ); > for my $itm (@all_items) { >- push @items, $itm unless ( $itm->{itemlost} && GetHideLostItemsPreference($borrowernumber) && !$showallitems); >+ push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems); > } > > # flag indicating existence of at least one item linked via a host record >diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl >index 1d50d50..b5b13d5 100755 >--- a/catalogue/moredetail.pl >+++ b/catalogue/moredetail.pl >@@ -32,13 +32,13 @@ use C4::Auth; > use C4::Serials; > use C4::Members; # to use GetMember > use C4::Search; # enabled_staff_search_views >-use C4::Members qw/GetHideLostItemsPreference/; > use C4::Reserves qw(GetReservesFromBiblionumber); > > use Koha::Acquisition::Bookseller; > use Koha::AuthorisedValues; > use Koha::DateUtils; > use Koha::Items; >+use Koha::Patrons; > > my $query=new CGI; > >@@ -93,9 +93,10 @@ my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); > my $fw = GetFrameworkCode($biblionumber); > my @all_items= GetItemsInfo($biblionumber); > my @items; >+my $patron = Koha::Patrons->find( $loggedinuser ); > for my $itm (@all_items) { > push @items, $itm unless ( $itm->{itemlost} && >- GetHideLostItemsPreference($loggedinuser) && >+ $patron->category->hidelostitems && > !$showallitems && > ($itemnumber != $itm->{itemnumber})); > } >diff --git a/reserve/request.pl b/reserve/request.pl >index bc55fdf..3f4dba3 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -45,6 +45,7 @@ use C4::Search; # enabled_staff_search_views > use Koha::DateUtils; > use Koha::Holds; > use Koha::Libraries; >+use Koha::Patrons; > > my $dbh = C4::Context->dbh; > my $input = new CGI; >@@ -201,6 +202,8 @@ $template->param( messageborrower => $messageborrower ); > # FIXME launch another time GetMember perhaps until > my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold ); > >+my $logged_in_patron = Koha::Patrons->find( $borrowernumber ); >+ > my $itemdata_enumchron = 0; > my @biblioloop = (); > foreach my $biblionumber (@biblionumbers) { >@@ -412,7 +415,7 @@ foreach my $biblionumber (@biblionumbers) { > : $item->{itemlost} == 2 ? "(long overdue)" > : ""; > $item->{backgroundcolor} = 'other'; >- if (GetHideLostItemsPreference($borrowernumber) && !$showallitems) { >+ if ($logged_in_patron->category->hidelostitems && !$showallitems) { > $item->{hide} = 1; > $hiddencount++; > } >-- >2.1.4
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 17556
:
57215
|
57246
|
57361
| 57922