From 6d8c508345437b3694914fcd1c3f7ad893c92ddf Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 27 Feb 2019 06:59:08 -0500 Subject: [PATCH] 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 Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit c1af56eb54043909f7e32b4597baa4f2d4d3e7dd) Signed-off-by: Andrew Fuerste-Henry --- .../intranet-tmpl/prog/en/modules/members/moremember.tt | 4 ++++ members/deletemem.pl | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index bcc9f755ad..593a6da317 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -51,6 +51,10 @@

Unable to delete patrons from other libraries with current settings

Insufficient privileges.

[% END %] + [% IF ( error == 'CANT_DELETE_ANONYMOUS_PATRON' ) %] +

Unable to delete patron that is set as AnonymousPatron

+

This patron cannot be deleted while set as AnonymousPatron in the system preferences.

+ [% END %] [% IF ( error == 'CANT_DELETE' ) %]

Unable to delete patron

Insufficient privileges.

diff --git a/members/deletemem.pl b/members/deletemem.pl index 389a79c4d5..e7d6d1c271 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -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; -- 2.39.5