Bug 41946 - Superlibrarian should be able to set protected status on patron creation
Summary: Superlibrarian should be able to set protected status on patron creation
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 36085
Blocks:
  Show dependency treegraph
 
Reported: 2026-02-26 17:06 UTC by Caroline Cyr La Rose
Modified: 2026-02-26 17:40 UTC (History)
3 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 41946: Allow superlibrarians to set protected flag on patron creation (2.81 KB, patch)
2026-02-26 17:20 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 41946: Allow superlibrarians to set protected flag on patron creation (2.88 KB, patch)
2026-02-26 17:38 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Caroline Cyr La Rose 2026-02-26 17:06:07 UTC
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.

1. With a superlibrarian account, go to Patrons > New patron > Choose any category
  --> Before bug 36085 : In "Library management" section, there is a Protected yes/no field
  --> After bug 36085 : the Protected option is no longer there.

If I create a SIP account, I now have to create the account, then go back an edit it to add the protection.

Non-superlibrarians should still not be able to set the flag on creation.
Comment 1 Paul Derscheid 2026-02-26 17:20:58 UTC
Created attachment 194019 [details] [review]
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
Comment 2 Caroline Cyr La Rose 2026-02-26 17:38:48 UTC
Created attachment 194025 [details] [review]
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 (+ restart_all)
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

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Comment 3 Caroline Cyr La Rose 2026-02-26 17:40:50 UTC
I had to restart_all after applying the patch. I've amended the test plan.

After the patch
Superlibrarian is able to set the protected flag on creation and on edition
Non-superlibrarian is never able to set the protected flag (creation or edition)


Thanks for the speedy patch Paul!

The original patch was added to 24.11. If this one could be backported all the way it would be great.

Thanks!