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/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-1 / +1 lines)
Lines 1-7 Link Here
1
<ul id="action">
1
<ul id="action">
2
    [% UNLESS ( norequests ) %]
2
    [% UNLESS ( norequests ) %]
3
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
3
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
4
            [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
4
            [% IF ( Koha.Preference( 'RequestOnOpac' ) == 1 && cannotReserve ) %]
5
                [% IF ( AllowOnShelfHolds ) %]
5
                [% IF ( AllowOnShelfHolds ) %]
6
                    <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li>
6
                    <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li>
7
                [% ELSE %]
7
                [% ELSE %]
(-)a/opac/opac-detail.pl (+7 lines)
Lines 520-525 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { Link Here
520
520
521
my $dat = &GetBiblioData($biblionumber);
521
my $dat = &GetBiblioData($biblionumber);
522
522
523
#Check if we can place a hold on this biblio.
524
my $canReserve = C4::Reserves::CanBookBeReserved( $biblionumber, $biblionumber );
525
unless ($canReserve ) {
526
	$template->param( cannotReserve => 1 ) ;
527
}
528
529
523
my $itemtypes = GetItemTypes();
530
my $itemtypes = GetItemTypes();
524
# imageurl:
531
# imageurl:
525
my $itemtype = $dat->{'itemtype'};
532
my $itemtype = $dat->{'itemtype'};
(-)a/t/db_dependent/Reserves.t (-2 / +36 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
#Make the borrower too young for our Biblio, the Biblio has been ageRestricted during initialization
479
C4::Context->set_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' );
480
481
#Reserving an not-agerestricted Biblio by a Borrower with no dateofbirth is tested previously.
482
483
#Set the ageRestriction for the Biblio
484
my $record = GetMarcBiblio( $bibnum );
485
my ( $ageres_tagid, $ageres_subfieldid ) = GetMarcFromKohaField( "biblioitems.agerestriction", '' );
486
$record->append_fields(  MARC::Field->new($ageres_tagid, '', '', $ageres_subfieldid => 'PEGI 16')  );
487
C4::Biblio::ModBiblio( $record, $bibnum, '' );
488
489
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving an ageRestricted Biblio without a borrower dateofbirth succeeds" );
490
491
#Set the dateofbirth for the Borrower making him "too young".
492
my $now = DateTime->now();
493
my $duration_15years = DateTime::Duration->new(years => 15);
494
my $past15yearsAgo = DateTime->now()->subtract_duration($duration_15years);
495
C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $past15yearsAgo->ymd() );
496
497
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 0, "Reserving a 'PEGI 16' Biblio by a 15 year old borrower fails");
498
499
#Set the dateofbirth for the Borrower making him "too old".
500
my $duration_30years = DateTime::Duration->new(years => 30);
501
my $past30yearsAgo = DateTime->now()->subtract_duration($duration_30years);
502
C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $past30yearsAgo->ymd() );
503
504
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving a 'PEGI 16' Biblio by a 30 year old borrower succeeds");
505
       ####
506
####### EO Bug 13113 <<<
507
       ####
508
474
$dbh->rollback;
509
$dbh->rollback;
475
510
476
sub count_hold_print_messages {
511
sub count_hold_print_messages {
477
- 

Return to bug 13113