Bugzilla – Attachment 32621 Details for
Bug 13113
Prevent juvenile/children from reserving ageRestricted material
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13113 - Prevent juvenile/children from reserving ageRestricted material
Bug-13113---Prevent-juvenilechildren-from-reservin.patch (text/plain), 6.89 KB, created by
Olli-Antti Kivilahti
on 2014-10-23 13:08:17 UTC
(
hide
)
Description:
Bug 13113 - Prevent juvenile/children from reserving ageRestricted material
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2014-10-23 13:08:17 UTC
Size:
6.89 KB
patch
obsolete
>From 8f1de4806708264d20eac2ecf8f911a13f1c4daf Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Mon, 20 Oct 2014 15:37:17 +0300 >Subject: [PATCH] Bug 13113 - Prevent juvenile/children from reserving > ageRestricted material > >There is no reason for underage borrowers to reserve ageRestricted material and >then be denied it's check-out due to ageRestriction. > >This patch prevents reserving material for borrowers not suitably aged. > > # # # # # # > # A PRIORI # > # # # # # # >BOTH THE STAFF CLIENT AND THE OPAC >1. Find a Record with Items, update the MARC Subfield 521a to "PEGI 16". >2. Get a Borrower who is younger than 16 years. >3. Place a hold for the underage Borrower for the ageRestricted Record. >4. You can reserve an ageRestricted Record with ease. >STAFF CLIENT ONLY >5. Check-in an Item from the ageRestricted Record and catch the reservation. >6. Check-out the ageRestricted Item for this underage Borrower. >7. You get a notification about being unable to check-out due to age restriction. > How lame is that for a 12 year old? > > # # # # # # # # > # A POSTERIORI # > # # # # # # # # >STAFF CLIENT >1. Find a Record with Items, update the MARC Subfield 521a to "PEGI 16". >2. Get a Borrower who is younger than 16 years. >3. Check-out an ageRestricted Item for this underage Borrower. >4. You get a notification about having the maximum amount of reserves. >5. Place a hold for the underage Borrower for the ageRestricted Record. >6. You get a notification, that placing a hold on ageRestricted material is > forbidden. >OPAC >A. In OPAC go to opac-detail.pl for the ageRestricted Biblio. > The "Place Hold" -button is missing on the right sidebar if the underage > user is logged in. >B. From the opac-search.pl a hold can still be placed, but it will fail giving > an error about age restrictions. > >Includes Unit tests. >--- > C4/Reserves.pm | 8 +++-- > .../bootstrap/en/includes/opac-detail-sidebar.inc | 2 +- > opac/opac-detail.pl | 7 ++++ > t/db_dependent/Reserves.t | 37 +++++++++++++++++++- > 4 files changed, 50 insertions(+), 4 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 7a075a4..97990ac 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -486,12 +486,16 @@ sub CanItemBeReserved{ > # we retrieve borrowers and items informations # > # item->{itype} will come for biblioitems if necessery > my $item = GetItem($itemnumber); >+ my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} ); >+ my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); > > # If an item is damaged and we don't allow holds on damaged items, we can stop right here > return 0 if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') ); > >- my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); >- >+ #Check for the age restriction >+ my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower ); >+ return 0 if $daysToAgeRestriction && $daysToAgeRestriction > 0; >+ > my $controlbranch = C4::Context->preference('ReservesControlBranch'); > my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >index b15333b..d7c0209 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >@@ -1,7 +1,7 @@ > <ul id="action"> > [% UNLESS ( norequests ) %] > [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] >- [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %] >+ [% IF ( Koha.Preference( 'RequestOnOpac' ) == 1 && !cannotReserve ) %] > [% IF ( AllowOnShelfHolds ) %] > <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li> > [% ELSE %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index e4b1cd2..62c1f8d 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -520,6 +520,13 @@ if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { > > my $dat = &GetBiblioData($biblionumber); > >+#Check if we can place a hold on this biblio. >+my $canReserve = C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber ); >+unless ($canReserve ) { >+ $template->param( cannotReserve => 1 ) ; >+} >+ >+ > my $itemtypes = GetItemTypes(); > # imageurl: > my $itemtype = $dat->{'itemtype'}; >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 3ee2832..0bc763b 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 50; >+use Test::More tests => 53; > > use MARC::Record; > use DateTime::Duration; >@@ -471,6 +471,41 @@ is($cancancel, 0, 'Reserve in waiting status cant be canceled'); > > # End of tests for bug 12876 > >+ #### >+####### Testing Bug 13113 - Prevent juvenile/children from reserving ageRestricted material >>> >+ #### >+ >+#Make the borrower too young for our Biblio, the Biblio has been ageRestricted during initialization >+C4::Context->set_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' ); >+ >+#Reserving an not-agerestricted Biblio by a Borrower with no dateofbirth is tested previously. >+ >+#Set the ageRestriction for the Biblio >+my $record = GetMarcBiblio( $bibnum ); >+my ( $ageres_tagid, $ageres_subfieldid ) = GetMarcFromKohaField( "biblioitems.agerestriction", '' ); >+$record->append_fields( MARC::Field->new($ageres_tagid, '', '', $ageres_subfieldid => 'PEGI 16') ); >+C4::Biblio::ModBiblio( $record, $bibnum, '' ); >+ >+is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving an ageRestricted Biblio without a borrower dateofbirth succeeds" ); >+ >+#Set the dateofbirth for the Borrower making him "too young". >+my $now = DateTime->now(); >+my $duration_15years = DateTime::Duration->new(years => 15); >+my $past15yearsAgo = DateTime->now()->subtract_duration($duration_15years); >+C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $past15yearsAgo->ymd() ); >+ >+is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 0, "Reserving a 'PEGI 16' Biblio by a 15 year old borrower fails"); >+ >+#Set the dateofbirth for the Borrower making him "too old". >+my $duration_30years = DateTime::Duration->new(years => 30); >+my $past30yearsAgo = DateTime->now()->subtract_duration($duration_30years); >+C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $past30yearsAgo->ymd() ); >+ >+is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving a 'PEGI 16' Biblio by a 30 year old borrower succeeds"); >+ #### >+####### EO Bug 13113 <<< >+ #### >+ > $dbh->rollback; > > sub count_hold_print_messages { >-- >1.7.9.5
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 13113
:
32539
|
32549
|
32621
|
32626
|
32661
|
32915
|
33071
|
33072