View | Details | Raw Unified | Return to bug 13113
Collapse All | Expand All

(-)a/C4/Reserves.pm (-2 / +6 lines)
Lines 486-497 sub CanItemBeReserved{ Link Here
486
    # we retrieve borrowers and items informations #
486
    # we retrieve borrowers and items informations #
487
    # item->{itype} will come for biblioitems if necessery
487
    # item->{itype} will come for biblioitems if necessery
488
    my $item = GetItem($itemnumber);
488
    my $item = GetItem($itemnumber);
489
    my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} );
490
    my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber);     
489
491
490
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
492
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
491
    return 0 if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') );
493
    return 0 if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') );
492
494
493
    my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber);     
495
    #Check for the age restriction
494
    
496
    my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower );
497
    return 0 if $daysToAgeRestriction && $daysToAgeRestriction > 0;
498
495
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
499
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
496
    my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
500
    my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
497
501
(-)a/t/db_dependent/Reserves.t (-2 / +33 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 50;
20
use Test::More tests => 53;
21
21
22
use MARC::Record;
22
use MARC::Record;
23
use DateTime::Duration;
23
use DateTime::Duration;
Lines 471-476 is($cancancel, 0, 'Reserve in waiting status cant be canceled'); Link Here
471
471
472
# End of tests for bug 12876
472
# End of tests for bug 12876
473
473
474
       ####
475
####### Testing Bug 13113 - Prevent juvenile/children from reserving ageRestricted material >>>
476
       ####
477
478
C4::Context->set_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' );
479
480
#Reserving an not-agerestricted Biblio by a Borrower with no dateofbirth is tested previously.
481
482
#Set the ageRestriction for the Biblio
483
my $record = GetMarcBiblio( $bibnum );
484
my ( $ageres_tagid, $ageres_subfieldid ) = GetMarcFromKohaField( "biblioitems.agerestriction", '' );
485
$record->append_fields(  MARC::Field->new($ageres_tagid, '', '', $ageres_subfieldid => 'PEGI 16')  );
486
C4::Biblio::ModBiblio( $record, $bibnum, '' );
487
488
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving an ageRestricted Biblio without a borrower dateofbirth succeeds" );
489
490
#Set the dateofbirth for the Borrower making him "too young".
491
my $now = DateTime->now();
492
C4::Members::SetAge( $borrower, '0015-00-00' );
493
C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $borrower->{dateofbirth} );
494
495
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 0, "Reserving a 'PEGI 16' Biblio by a 15 year old borrower fails");
496
497
#Set the dateofbirth for the Borrower making him "too old".
498
C4::Members::SetAge( $borrower, '0030-00-00' );
499
C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $borrower->{dateofbirth} );
500
501
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving a 'PEGI 16' Biblio by a 30 year old borrower succeeds");
502
       ####
503
####### EO Bug 13113 <<<
504
       ####
505
474
$dbh->rollback;
506
$dbh->rollback;
475
507
476
sub count_hold_print_messages {
508
sub count_hold_print_messages {
477
- 

Return to bug 13113