Bugzilla – Attachment 157649 Details for
Bug 34519
Add a template plugin for ExtendedAttributeTypes to fetch searchable patron attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34519: Add a template plugin for fetch searchable patron attributes
Bug-34519-Add-a-template-plugin-for-fetch-searchab.patch (text/plain), 11.97 KB, created by
Nick Clemens (kidclamp)
on 2023-10-23 13:22:21 UTC
(
hide
)
Description:
Bug 34519: Add a template plugin for fetch searchable patron attributes
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-10-23 13:22:21 UTC
Size:
11.97 KB
patch
obsolete
>From 6538d656b074bed6731f3426de8fe8c1a4ea3fcc Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 11 Aug 2023 14:16:12 +0000 >Subject: [PATCH] Bug 34519: Add a template plugin for fetch searchable patron > attributes > >This patch moves code form scripts to a template plguin and unifies the calls > >To test: >1 - Add a searchable patron attribute type >2 - Add values to several patrons and test patron searching from > Patrons home > Patrons search results > Holds request screen > Article request screen > Patron search sidebar >3 - Apply patch >4 - Confirm results are the same > >Signed-off-by: Janusz Kaczmarek <januszop@gmail.com> >--- > .../Template/Plugin/ExtendedAttributeTypes.pm | 71 +++++++++++++++++++ > circ/request-article.pl | 4 -- > .../prog/en/includes/patron-search.inc | 4 +- > .../prog/en/modules/circ/request-article.tt | 2 +- > .../prog/en/modules/members/member.tt | 2 +- > .../prog/en/modules/members/search.tt | 2 +- > .../prog/en/modules/reserve/request.tt | 2 +- > members/member.pl | 3 - > members/members-home.pl | 3 - > members/search.pl | 3 - > reserve/request.pl | 8 --- > 11 files changed, 78 insertions(+), 26 deletions(-) > create mode 100644 Koha/Template/Plugin/ExtendedAttributeTypes.pm > >diff --git a/Koha/Template/Plugin/ExtendedAttributeTypes.pm b/Koha/Template/Plugin/ExtendedAttributeTypes.pm >new file mode 100644 >index 0000000000..991666d164 >--- /dev/null >+++ b/Koha/Template/Plugin/ExtendedAttributeTypes.pm >@@ -0,0 +1,71 @@ >+package Koha::Template::Plugin::ExtendedAttributeTypes; >+ >+# Copyright ByWater Solutions 2023 >+ >+# 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use C4::Koha; >+use C4::Context; >+use Koha::Patron::Attribute::Types; >+ >+sub all { >+ my ( $self, $params ) = @_; >+ return Koha::Patron::Attribute::Types->search($params); >+} >+ >+sub codes { >+ my ( $self, $params ) = @_; >+ return Koha::Patron::Attribute::Types->search($params)->get_column('code'); >+} >+ >+1; >+ >+=head1 NAME >+ >+Koha::Template::Plugin::ExtendedAttributeTypes - TT Plugin for retrieving patron attribute types >+ >+=head1 SYNOPSIS >+ >+[% USE ExtendedAttributeTypes %] >+ >+[% ExtendedAttributeTypes.all() %] >+ >+=head1 ROUTINES >+ >+=head2 all >+ >+In a template, you can get the searchable attribute types with >+the following TT code: [% ExtendedAttributes.all( staff_searchable => 1 ) %] >+ >+The function returns the Koha::Patron::Atribute::Type objects >+ >+=head2 codes >+ >+In a template, you can get the searchable attribute type codes with >+the following TT code: [% ExtendedAttributes.codes( staff_searchable => 1 ) %] >+ >+The function returns the Koha::Patron::Atribute::Type codes as an array >+ >+=head1 AUTHOR >+ >+Nick Clemens <nick@bywatersolutions.com> >+ >+=cut >diff --git a/circ/request-article.pl b/circ/request-article.pl >index a9724749dc..051d13f9d6 100755 >--- a/circ/request-article.pl >+++ b/circ/request-article.pl >@@ -123,10 +123,6 @@ $template->param( > patron => $patron, > subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber), > C4::Search::enabled_staff_search_views, >- attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') >- ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] >- : [] >- ), > ); > > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 18fbf42931..d7803e9e18 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -1,6 +1,7 @@ > [% USE Koha %] > [% USE I18N %] > [% USE Branches %] >+[% USE ExtendedAttributeTypes %] > [% USE raw %] > [% USE Asset %] > [% USE To %] >@@ -231,7 +232,8 @@ > return map; > }, {}); > >- [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] >+ [% IF Koha.Preference('ExtendedPatronAttributes') %] >+ [% SET extended_attribute_types = ExtendedAttributeTypes.codes( staff_searchable => 1 ) %] > let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >index 652dc0418a..18c32347fd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >@@ -441,7 +441,7 @@ > }); > </script> > >- [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber %] >+ [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber %] > > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >index e65241207e..f136834686 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >@@ -390,7 +390,7 @@ > [% ELSE %] > [% SET redirect_url = '/cgi-bin/koha/members/moremember.pl' %] > [% END %] >- [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns,actions => ['edit', 'checkout'], redirect_if_one_result => 1, redirect_url => redirect_url, sticky_header => "searchheader", sticky_to => "searchresults", default_sort_column => 'name-address', display_search_description => 1, remember_selections => 1 %] >+ [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, columns => columns,actions => ['edit', 'checkout'], redirect_if_one_result => 1, redirect_url => redirect_url, sticky_header => "searchheader", sticky_to => "searchresults", default_sort_column => 'name-address', display_search_description => 1, remember_selections => 1 %] > > [% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >index 4d6efc7d51..01adca73c5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >@@ -77,7 +77,7 @@ > }); > </script> > >- [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %] >+ [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %] > [% END %] > > [% SET popup_window = 1 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 3f0a1973b4..56f680ff0c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1734,7 +1734,7 @@ > table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]; > </script> > >- [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_attribute_equal => 'cardnumber' %] >+ [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_attribute_equal => 'cardnumber' %] > <script> > $(document).ready(function() { > $("#holds_patronsearch").on("submit", filter); >diff --git a/members/member.pl b/members/member.pl >index 909341bcd7..26350c4394 100755 >--- a/members/member.pl >+++ b/members/member.pl >@@ -79,9 +79,6 @@ $template->param( > PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20, > do_not_defer_loading => !$defer_loading, > circsearch => $circsearch, >- attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') >- ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] >- : [] ), > ); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/members/members-home.pl b/members/members-home.pl >index e3b903f463..22d341bbbb 100755 >--- a/members/members-home.pl >+++ b/members/members-home.pl >@@ -73,9 +73,6 @@ $template->param( > PatronAutoComplete => C4::Context->preference('PatronAutoComplete'), > patron_lists => [ GetPatronLists() ], > PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20, >- attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') >- ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] >- : [] ), > ); > > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/members/search.pl b/members/search.pl >index c3d80a2e4f..05752ae13d 100755 >--- a/members/search.pl >+++ b/members/search.pl >@@ -46,8 +46,5 @@ $template->param( > columns => \@columns, > filter => $filter, > selection_type => $selection_type, >- attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') >- ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] >- : [] ), > ); > output_html_with_http_headers( $input, $cookie, $template->output ); >diff --git a/reserve/request.pl b/reserve/request.pl >index 0e5b60f056..186b3faff5 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -704,14 +704,6 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > } > $template->param( biblionumbers => \@biblionumbers ); > >-$template->param( >- attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') >- ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] >- : [] >- ), >-); >- >- > # pass the userenv branch if no pickup location selected > $template->param( pickup => $pickup || C4::Context->userenv->{branch} ); > >-- >2.30.2
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 34519
:
154375
|
154376
|
154384
|
154641
|
154646
|
154647
|
154648
|
154649
|
157649
|
157650
|
157651
|
157652
|
158423
|
158424
|
158425
|
158426