Bug 41674

Summary: Add template plugin for linking to system preferences based on user permission
Product: Koha Reporter: Owen Leonard <oleonard>
Component: Architecture, internals, and plumbingAssignee: Owen Leonard <oleonard>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41522
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41674: Add template plugin for linking to system preferences based on user permission
Bug 41674: (follow-up) Proof of concept: branches.pl

Description Owen Leonard 2026-01-21 14:18:35 UTC
There are many places in templates where we link to a system preference and we are inconsistent about whether these links are dependent on the permission of the logged-in user. I propose to add a template plugin which handles the permission check.

[% "RequireChoosingExistingAuthority" | html | $LinkPref %]

For a user with 'CAN_user_parameters_manage_sysprefs' permission it outputs:

<a class="link_preference" href="admin/preferences.pl?op=search&amp;ok=Search&amp;searchfield=RequireChoosingExistingAuthority">RequireChoosingExistingAuthority</a>

For a user without permission it outputs:

<span class="link_preference">RequireChoosingExistingAuthority</span>
Comment 1 Owen Leonard 2026-01-21 15:26:26 UTC
Created attachment 191791 [details] [review]
Bug 41674: Add template plugin for linking to system preferences based on user permission

This patch adds a new template plugin, LinkPref, for displaying system
preference names as links depending on the logged-in user's permission.

Syntax:

  [% "SYSTEM_PREFERENCE_NAME" | html | $LinkPref %]

For a user with 'CAN_user_parameters_manage_sysprefs' permission it
outputs:

  <a class="link_preference" href="admin/preferences.pl?op=search&amp;ok=Search&amp;searchfield=SYSTEM_PREFERENCE_NAME">SYSTEM_PREFERENCE_NAME</a>

For a user without permission it outputs:

  <span class="link_preference">SYSTEM_PREFERENCE_NAME</span>

Sponsored-by: Athens County Public Libraries
Comment 2 Owen Leonard 2026-01-21 15:26:29 UTC
Created attachment 191792 [details] [review]
Bug 41674: (follow-up) Proof of concept: branches.pl

This patch implements the new template plugin on Administration ->
Libraries.

- When viewed as a user with permission to manage system preferences,
  the system preference names under "Reply-To", "Return-Path", and "MARC
  organization code" should be linked to system preferences, and the
  link should take you to the correct preference search.
- When viewed as a user without permission the system preference names
  should not be linked.

Sponsored-by: Athens County Public Libraries