@@ -, +, @@ enabled --- Koha/Patron.pm | 32 ++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 13 ++++--- t/Patron.t | 22 ++++++++++- t/db_dependent/Patrons.t | 43 +++++++++++++++++++++- 4 files changed, 103 insertions(+), 7 deletions(-) --- a/Koha/Patron.pm +++ a/Koha/Patron.pm @@ -266,6 +266,21 @@ sub is_debarred { return; } +=head2 is_expired + +my $is_expired = $patron->is_expired; + +Returns true if the patron is passed the expiry date, false otherwise + +=cut + +sub is_expired { + my ($self) = @_; + + return 1 if $self->dateexpiry && dt_from_string( $self->dateexpiry ) < dt_from_string; + return 0; +} + =head2 update_password my $updated = $patron->update_password( $userid, $password ); @@ -449,6 +464,23 @@ sub add_enrolment_fee_if_needed { return $enrolment_fee || 0; } +=head3 should_block_expired_patron_opac_actions + +=cut + +sub should_block_expired_patron_opac_actions { + my ($self) = @_; + + my $patron_category = Koha::Patron::Categories->find( $self->categorycode ); + + if ( $patron_category->BlockExpiredPatronOpacActions == -1 ) { + return C4::Context->preference('BlockExpiredPatronOpacActions'); + } + else { + return $patron_category->BlockExpiredPatronOpacActions; + } +} + =head3 type =cut --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -12,6 +12,9 @@ [% INCLUDE 'bodytag.inc' bodyid='opac-user' bodyclass='scrollto' %] [% INCLUDE 'masthead.inc' %] +[% SET BlockExpiredPatronOpacActions = borrower.should_block_expired_patron_opac_actions %] +[% SET IsExpired = IsExpired %] +