View | Details | Raw Unified | Return to bug 41674
Collapse All | Expand All

(-)a/Koha/Template/Plugin/LinkPref.pm (-1 / +69 lines)
Line 0 Link Here
0
- 
1
package Koha::Template::Plugin::LinkPref;
2
3
# Copyright Athens County Public Libraries 2026
4
# Author: Owen Leonard <oleonard@myacpl.org>
5
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# Koha is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with Koha; if not, see <https://www.gnu.org/licenses>.
20
21
use Modern::Perl;
22
23
use Koha::Patrons;
24
25
use Template::Plugin::Filter;
26
use base qw( Template::Plugin::Filter );
27
our $DYNAMIC = 1;
28
29
sub filter {
30
    my ( $self, $text ) = @_;
31
    return "" unless $text;
32
    my $span;
33
34
    if ( $self->{_CONTEXT}->stash->{'CAN_user_parameters_manage_sysprefs'} ) {
35
        $span .= '<a class="link_preference" href="/cgi-bin/koha/admin/preferences.pl?op=search&ok=Search&searchfield=';
36
        $span .= $text;
37
        $span .= '">';
38
        $span .= $text;
39
        $span .= '</a>';
40
    } else {
41
        $span .= '<span class="link_preference">';
42
        $span .= $text;
43
        $span .= '</span>';
44
    }
45
46
    return $span;
47
}
48
49
1;
50
51
=head1 NAME
52
53
Koha::Template::Plugin::LinkPref - TT plugin for wrapping a system preference name in a link to that preference if the user has permission
54
55
=head1 SYNOPSIS
56
57
[% USE LinkPref %]
58
59
[% "SYSTEM_PREFERENCE_NAME" | html | $LinkPref %]
60
61
This filter scrubs HTML using profiles predefined in C4::Scrubber
62
63
=head1 METHODS
64
65
=head2 filter
66
67
Returns the system preference variable name as an HTML link or plain text based on the logged-in user's permissions
68
69
=cut

Return to bug 41674