diff --git a/C4/Auth.pm b/C4/Auth.pm index 2fa9e2bed7..affc7ee43a 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1492,10 +1492,6 @@ sub checkauth { my $auth_template_name = ( $type eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt'; my $template = C4::Templates::gettemplate( $auth_template_name, $type, $query ); - my $borrowernumber = $patron and $patron->borrowernumber; - my $anonymous_patron = C4::Context->preference('AnonymousPatron'); - my $is_anonymous_patron = $patron && ( $patron->borrowernumber eq $anonymous_patron ); - $template->param( login => 1, INPUTS => \@inputs, @@ -1530,7 +1526,7 @@ sub checkauth { opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, too_many_login_attempts => ( $patron and $patron->account_locked ), password_has_expired => ( $patron and $patron->password_expired ), - is_anonymous_patron => ($is_anonymous_patron), + is_anonymous_patron => ( $patron and $patron->is_anonymous ), password_expiration_date => ( $patron and $patron->password_expiration_date ), date_enrolled => ( $patron and $patron->dateenrolled ), auth_error => $auth_error, diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 203fa212c3..84e7d2babb 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -473,9 +473,8 @@ ListOwnershipUponPatronDeletion pref, but entries from the borrower to other lis sub delete { my ($self) = @_; - my $anonymous_patron = C4::Context->preference("AnonymousPatron"); Koha::Exceptions::Patron::FailedDeleteAnonymousPatron->throw() - if $anonymous_patron && $self->id eq $anonymous_patron; + if $self->is_anonymous; # Check if patron is protected Koha::Exceptions::Patron::FailedDeleteProtectedPatron->throw() if defined $self->protected && $self->protected == 1; @@ -736,8 +735,7 @@ sub siblings { sub merge_with { my ( $self, $patron_ids ) = @_; - my $anonymous_patron = C4::Context->preference("AnonymousPatron"); - return if $anonymous_patron && $self->id eq $anonymous_patron; + return if $self->is_anonymous; # Do not merge other patrons into a protected patron return if $self->protected; @@ -755,12 +753,12 @@ sub merge_with { sub { foreach my $patron_id (@patron_ids) { - next if $anonymous_patron && $patron_id eq $anonymous_patron; - my $patron = Koha::Patrons->find($patron_id); next unless $patron; + next if $patron->is_anonymous; + # Do not merge protected patrons into other patrons next if $patron->protected; @@ -3048,11 +3046,9 @@ This method tells if the Koha:Patron object can be deleted. Possible return valu sub safe_to_delete { my ($self) = @_; - my $anonymous_patron = C4::Context->preference('AnonymousPatron'); - my $error; - if ( $anonymous_patron && $self->id eq $anonymous_patron ) { + if ( $self->is_anonymous ) { $error = 'is_anonymous_patron'; } elsif ( $self->checkouts->count ) { $error = 'has_checkouts'; @@ -3405,6 +3401,20 @@ sub is_patron_inside_charge_limits { return $patron_charge_limits; } +=head3 is_anonymous + +my $is_anonymous_patron= $patron->is_anonymous(); + +Returns true if the patron the anonymous patron (AnonymousPatron) + +=cut + +sub is_anonymous { + my ($self) = @_; + my $anonymous_patron = C4::Context->preference('AnonymousPatron'); + return ( $anonymous_patron && $self->borrowernumber eq $anonymous_patron ) ? 1 : 0; +} + =head2 Internal methods =head3 _type diff --git a/circ/circulation.pl b/circ/circulation.pl index 5d432b4f80..52871d12b9 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -626,7 +626,7 @@ if ($patron) { $template->param( is_debarred => 1 ); $noissues = 1; } - if ( $patron->borrowernumber eq C4::Context->preference("AnonymousPatron") ) { + if ( $patron->is_anonymous ) { $template->param( is_anonymous => 1 ); $noissues = 1; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt index b1a4735c59..602338097b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt @@ -45,7 +45,7 @@ [% UNLESS Koha.Preference('IntranetReadingHistoryHolds') %]