Bug 14708: The patron set as the anonymous patron should not be deletable.

Right now it's possible to delete the anonymous patron at any time. When this happens the system will break just as if anonymouspatron was unset but patrons still have an "always anonymize" privacy setting.

This issue occurs more frequently than one would expect.

We should make it so that the patron set in AnonymousPatron is not deletable.

Test Plan:
1) Apply this patch
2) Set a patron to by AnonymousPatron
3) Attempt to delete that patron from the members toolbar
4) Note the error message!

Signed-off-by: Devinim <kohadevinim@devinim.com.tr>

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Kyle M Hall 2019-02-27 06:59:08 -05:00 committed by Jonathan Druart
parent 880c9242a9
commit c1af56eb54
2 changed files with 11 additions and 0 deletions

View File

@ -51,6 +51,10 @@
<h3>Unable to delete patrons from other libraries with current settings</h3>
<p>Insufficient privileges.</p>
[% END %]
[% IF ( error == 'CANT_DELETE_ANONYMOUS_PATRON' ) %]
<h3>Unable to delete patron that is set as AnonymousPatron</h3>
<p>This patron cannot be deleted while set as AnonymousPatron in the system preferences.</p>
[% END %]
[% IF ( error == 'CANT_DELETE' ) %]
<h3>Unable to delete patron</h3>
<p>Insufficient privileges.</p>

View File

@ -83,6 +83,13 @@ if (C4::Context->preference("IndependentBranches")) {
}
}
if ( my $anonymous_patron = C4::Context->preference("AnonymousPatron") ) {
if ( $patron->id eq $anonymous_patron ) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON");
exit 0; # Exit without error
}
}
my $op = $input->param('op') || 'delete_confirm';
my $dbh = C4::Context->dbh;
my $is_guarantor = $patron->guarantee_relationships->count;