Main Koha release repository https://koha-community.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

77 lines
1.8 KiB

  1. package Koha::Template::Plugin::Categories;
  2. # Copyright 2013-2014 BibLibre
  3. #
  4. # Koha is free software; you can redistribute it and/or modify it
  5. # under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # Koha is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with Koha; if not, see <http://www.gnu.org/licenses>.
  16. use Modern::Perl;
  17. use Template::Plugin;
  18. use base qw( Template::Plugin );
  19. use List::Util qw(any);
  20. use Koha::Patron::Categories;
  21. sub all {
  22. my ( $self, $params ) = @_;
  23. return Koha::Patron::Categories->search_limited($params);
  24. }
  25. sub GetName {
  26. my ( $self, $categorycode ) = @_;
  27. return Koha::Patron::Categories->find( $categorycode )->description;
  28. }
  29. sub can_any_reset_password {
  30. return ( any { $_->effective_reset_password } @{ Koha::Patron::Categories->search->as_list } )
  31. ? 1
  32. : 0;
  33. }
  34. 1;
  35. =head1 NAME
  36. Koha::Template::Plugin::Categories - TT Plugin for categories
  37. =head1 SYNOPSIS
  38. [% USE Categories %]
  39. [% Categories.all() %]
  40. =head1 ROUTINES
  41. =head2 all
  42. In a template, you can get the all categories with
  43. the following TT code: [% Categories.all() %]
  44. =head2 GetName
  45. In a template, you can get the name of a patron category using
  46. [% Categories.GetName( categorycode ) %].
  47. =head2 can_any_reset_password
  48. Returns I<true> is any patron category has the I<effective_reset_password> evaluate to I<true>.
  49. Returns I<false> otherwise.
  50. =head1 AUTHOR
  51. Jonathan Druart <jonathan.druart@biblibre.com>
  52. =cut