From 69ac0261a9f0e1266cc156944b7c3c19a15c20a3 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 Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 1fc56e0e47d07d2eadcdb62c6a5740aa9d51c6b2) Signed-off-by: Lucas Gass (cherry picked from commit e207c09ee303b7b957e3f260531ca1fb22666536) Signed-off-by: Arthur Suzuki --- 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 198690406c..4da8748ac4 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 4626a406c9..e26c5e676d 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.39.5