Bugzilla – Attachment 191791 Details for
Bug 41674
Add template plugin for linking to system preferences based on user permission
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41674: Add template plugin for linking to system preferences based on user permission
Bug-41674-Add-template-plugin-for-linking-to-syste.patch (text/plain), 3.11 KB, created by
Owen Leonard
on 2026-01-21 15:26:26 UTC
(
hide
)
Description:
Bug 41674: Add template plugin for linking to system preferences based on user permission
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2026-01-21 15:26:26 UTC
Size:
3.11 KB
patch
obsolete
>From eb0cdb5f9278b50e34f3d599642e629b66413993 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 21 Jan 2026 09:19:08 -0500 >Subject: [PATCH] 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&ok=Search&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 >--- > Koha/Template/Plugin/LinkPref.pm | 69 ++++++++++++++++++++++++++++++++ > 1 file changed, 69 insertions(+) > create mode 100644 Koha/Template/Plugin/LinkPref.pm > >diff --git a/Koha/Template/Plugin/LinkPref.pm b/Koha/Template/Plugin/LinkPref.pm >new file mode 100644 >index 00000000000..a53dbda6005 >--- /dev/null >+++ b/Koha/Template/Plugin/LinkPref.pm >@@ -0,0 +1,69 @@ >+package Koha::Template::Plugin::LinkPref; >+ >+# Copyright Athens County Public Libraries 2026 >+# Author: Owen Leonard <oleonard@myacpl.org> >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <https://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Koha::Patrons; >+ >+use Template::Plugin::Filter; >+use base qw( Template::Plugin::Filter ); >+our $DYNAMIC = 1; >+ >+sub filter { >+ my ( $self, $text ) = @_; >+ return "" unless $text; >+ my $span; >+ >+ if ( $self->{_CONTEXT}->stash->{'CAN_user_parameters_manage_sysprefs'} ) { >+ $span .= '<a class="link_preference" href="/cgi-bin/koha/admin/preferences.pl?op=search&ok=Search&searchfield='; >+ $span .= $text; >+ $span .= '">'; >+ $span .= $text; >+ $span .= '</a>'; >+ } else { >+ $span .= '<span class="link_preference">'; >+ $span .= $text; >+ $span .= '</span>'; >+ } >+ >+ return $span; >+} >+ >+1; >+ >+=head1 NAME >+ >+Koha::Template::Plugin::LinkPref - TT plugin for wrapping a system preference name in a link to that preference if the user has permission >+ >+=head1 SYNOPSIS >+ >+[% USE LinkPref %] >+ >+[% "SYSTEM_PREFERENCE_NAME" | html | $LinkPref %] >+ >+This filter scrubs HTML using profiles predefined in C4::Scrubber >+ >+=head1 METHODS >+ >+=head2 filter >+ >+Returns the system preference variable name as an HTML link or plain text based on the logged-in user's permissions >+ >+=cut >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41674
: 191791 |
191792