From 566357d5f14457b486886d5f4cc13f8c3688cf0e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 20 Oct 2022 14:13:37 +0000 Subject: [PATCH] Bug 31421: Add a limited option to template plugin This adds a specific 'limited' routine to the Categories plugin, and uses it for the new patron dropdowns To test: 1 - Limit a patron category to some branches 2 - Sign in not at one of those 3 - Confirm the new patron dropdowns don't include the category Bug 31421: (follow-up) Add POD Signed-off-by: Jonathan Druart --- Koha/Template/Plugin/Categories.pm | 12 +++++++++++- .../prog/en/includes/patron-toolbar.inc | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm index 198690406c2..4da8748ac41 100644 --- a/Koha/Template/Plugin/Categories.pm +++ b/Koha/Template/Plugin/Categories.pm @@ -28,6 +28,11 @@ sub all { return Koha::Patron::Categories->search($params); } +sub limited { + my ( $self, $params ) = @_; + return Koha::Patron::Categories->search_with_library_limits($params); +} + sub GetName { my ( $self, $categorycode ) = @_; @@ -56,9 +61,14 @@ Koha::Template::Plugin::Categories - TT Plugin for categories =head2 all -In a template, you can get the all categories with +In a template, you can get all the categories with the following TT code: [% Categories.all() %] +=head2 limited + +In a template, you can get the categories with library limits applied with +the following TT code: [% Categories.limited() %] + =head2 GetName In a template, you can get the name of a patron category using diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc index 4626a406c92..e26c5e676df 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc @@ -1,7 +1,7 @@ [% INCLUDE 'blocking_errors.inc' %] [% USE Categories %] [% USE Koha %] -[% SET categories = Categories.all %] +[% SET categories = Categories.limited %] [% UNLESS ( no_add ) %]
-- 2.25.1