From 9ea498bd7b7462c5b34700f171ebb4df5a4353e4 Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Thu, 26 Feb 2026 18:09:54 +0100 Subject: [PATCH] Bug 41946: Allow superlibrarians to set protected flag on patron creation Since bug 36085, the protected flag in a patron account was removed from the patron creation form, regardless of if the user is a superlibrarian. - Hoist $logged_in_user lookup before the edit_form block - Move superlibrarian capability checks after the block so they apply to all operations including patron creation To test: 1. Sign in as a superlibrarian 2. Go to Patrons > New patron > choose any category 3. Without this patch: the "Protected" yes/no field is missing from the "Library management" section 4. Apply this patch 5. Repeat step 2 - The "Protected" yes/no field is now visible 6. Create the patron with Protected set to "Yes" 7. Confirm the patron is saved as protected 8. Sign in as a non-superlibrarian with edit_borrowers permission 9. Repeat step 2 - The "Protected" field should still be hidden 10. Edit an existing patron as superlibrarian - The "Protected" field is visible and functional 11. Edit an existing patron as non-superlibrarian - The "Protected" field is hidden 12. Sign off --- members/memberentry.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index bade3ad35e6..ecc3d0166ef 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -165,8 +165,8 @@ foreach (@field_check) { $template->param( "quickadd" => 1 ) if ($quickadd); $template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); +my $logged_in_user = Koha::Patrons->find($loggedinuser); if ( $op eq 'edit_form' or $op eq 'cud-save' or $op eq 'duplicate' ) { - my $logged_in_user = Koha::Patrons->find($loggedinuser); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } @@ -176,14 +176,14 @@ if ( $op eq 'edit_form' or $op eq 'cud-save' or $op eq 'duplicate' ) { if ( $patron->is_superlibrarian && !$logged_in_user->is_superlibrarian ) { $NoUpdateEmail = 1; } - if ( $logged_in_user->is_superlibrarian ) { - $CanUpdatePasswordExpiration = 1; - $CanUpdateProtectPatron = 1; - } - $borrower_data = $patron->unblessed; } +if ( $logged_in_user->is_superlibrarian ) { + $CanUpdatePasswordExpiration = 1; + $CanUpdateProtectPatron = 1; +} + my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'}; my $category = Koha::Patron::Categories->find($categorycode); $template->param( patron_category => $category ); -- 2.39.5