From d12d3a72a30afb83049133d46198204cca4aa363 Mon Sep 17 00:00:00 2001 From: CJ Lynce Date: Sat, 25 Oct 2025 20:49:23 +0000 Subject: [PATCH] Bug 41101: Add ability to make patron extended attributes read-only in staff interface. This patch adds the ability for a Patron Extended Attrtibute to be marked as read-only in the staff interface for all staff users, except 'superlibrarian's. This allows patron attributes to be used by plugins or other features to track statuses without allow staff users to change these attributes and cause potential unintended issues, while still allowing the statuses to be visible to staff. Testing PREP WORK A. Create a new staff patron and assign the following permissions i. Staff access, allows viewing of catalogue in staff interface (catalogue) ii. Add, modify and view patron information (borrowers) B. Create a couple of new 'Patron attribute types' under Administration i. Vary the following settings a. Staff interface mandatory b. Authorized value category (include some with no authorized value) c. Set some as data values. To Test 1. Apply patches, run updatedatabase, and restart_all services. 2. Login as 'koha' in the staff interface. 3. To go Administration -> Patron attribute types 4. For various attributes, do the following: A. Check the "View-only in Staff interface:" B. Verify 'OPAC mandatory' is unchecked and disabled when 'view-only' is checked. C. Save these settings 5. Open a test patron and edit said patron. 6. Set values for various the extended patron attributes. Leave some blank to test as well. 7. Logout of the 'koha' user. 8. Login to the staff interface with the user you created in PREP WORK A., above. 9. Open the same patron, and edit the patron. 10. Verify the following things related to the extended attributes. A. Attrtibutes marked as view-only cannot be changed. B. Date attributes marked as view-only cannot be changed, and do not show a datepicker. C. Attributes marked as view-only do not have a Clear, remove, or X button to clear. 11. Change some information on the patron and save the patron. 12. In the Patron details view, verify that your attributes are unchanged and still populated. Sponsored-by: Westlake Porter Public Library --- admin/patron-attr-types.pl | 2 ++ .../en/modules/admin/patron-attr-types.tt | 20 ++++++++++++ .../prog/en/modules/members/memberentrygen.tt | 32 +++++++++++++++---- members/memberentry.pl | 1 + 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl index 47c16306a8..13a7bd8c74 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -115,6 +115,7 @@ sub add_update_attribute_type { my $staff_searchable = $input->param('staff_searchable') ? 1 : 0; my $searched_by_default = $input->param('searched_by_default') ? 1 : 0; my $keep_for_pseudonymization = $input->param('keep_for_pseudonymization') ? 1 : 0; + my $staff_viewonly = $input->param('staff_viewonly') ? 1 : 0; my $mandatory = $input->param('mandatory') ? 1 : 0; my $opac_mandatory = $input->param('opac_mandatory') ? 1 : 0; my $authorised_value_category = $input->param('authorised_value_category'); @@ -152,6 +153,7 @@ sub add_update_attribute_type { staff_searchable => $staff_searchable, searched_by_default => $searched_by_default, keep_for_pseudonymization => $keep_for_pseudonymization, + staff_viewonly => $staff_viewonly, mandatory => $mandatory, opac_mandatory => $opac_mandatory, authorised_value_category => $authorised_value_category, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index 631a41867b..f6ff5049e3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -184,6 +184,15 @@ [% END %] If checked, this field will be included in 'Standard' patron searches. Requires field to be marked as searchable above +
  • + [% IF attribute_type AND attribute_type.staff_viewonly %] + + [% ELSE %] + + [% END %] + Check to make this attribute view-only, non-editable by staff in the staff interface. +
  • [% IF attribute_type AND attribute_type.mandatory %] @@ -460,6 +469,17 @@ $("#branches option:first").attr("selected", "selected"); } + $("#staff_viewonly") + .change(function () { + if (this.checked) { + $("#mandatory").prop("checked", false); + $("#mandatory").attr("disabled", true).parent().attr("aria-disabled", "true"); + } else { + $("#mandatory").removeAttr("disabled").parent().removeAttr("aria-disabled"); + } + }) + .change(); + $("#is_date") .change(function () { if (this.checked) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 6a296dd8ff..29814c32a7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1527,7 +1527,12 @@ [% END %] [% IF ( patron_attribute.use_dropdown ) %] - [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %] [% IF auth_val_loo.authorised_value == patron_attribute.value %] @@ -1552,7 +1557,7 @@ /> [% ELSE %] [% END %] [% ELSE %] @@ -1564,18 +1569,33 @@ maxlength="10" size="10" value="[% patron_attribute.value | html %]" - class="flatpickr" + [% IF ( patron_attribute.viewonly AND !CAN_user_superlibrarian ) -%] + disabled + [%- ELSE -%] + class="flatpickr" + [%- END %] /> [% ELSE %] - + [% END %] [% END %] [% END # /IF ( patron_attribute.use_dropdown ) %] + [% IF ( patron_attribute.viewonly AND !CAN_user_superlibrarian ) %] + + [% END %] - [% IF ( !patron_attribute.is_date ) %] + [% IF ( !patron_attribute.is_date AND ( !patron_attribute.viewonly || CAN_user_superlibrarian ) ) %] Clear [% END %] - [% IF ( patron_attribute.repeatable ) %] + [% IF ( patron_attribute.repeatable AND ( !patron_attribute.viewonly || CAN_user_superlibrarian ) ) %] New [% END %] [% IF patron_attribute.mandatory %]Required[% END %] diff --git a/members/memberentry.pl b/members/memberentry.pl index 50343bcc04..e531d4984e 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -959,6 +959,7 @@ sub patron_attributes_form { category => $attr_type->authorised_value_category(), category_code => $attr_type->category_code(), mandatory => $attr_type->mandatory(), + viewonly => $attr_type->staff_viewonly(), is_date => $attr_type->is_date(), }; if ( exists $attr_hash{ $attr_type->code() } ) { -- 2.39.5