Bug 33749: Use TrimFields instead of stripWhitespaceChars
[koha.git] / Koha / Item / Templates.pm
1 package Koha::Item::Templates;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20
21 use Koha::Database;
22
23 use Koha::Item::Template;
24
25 use base qw(Koha::Objects);
26
27 =head1 NAME
28
29 Koha::Item::Templates - Koha Item Template Object set class
30
31 =head2 METHODS
32
33 =head3 get_available
34
35 Returns a hashref with keys 'owned' and 'shared' pointing to Koha::Item::Templats objects
36 representing templates owned by the user or shared to the user respectivetly.
37
38 =cut
39
40 sub get_available {
41     my ( $class, $patron_id ) = @_;
42
43     my $params = {
44         order_by => 'name',
45         columns  => [ 'id', 'patron_id', 'name', 'is_shared' ],
46     };
47
48     return {
49         owned => Koha::Item::Templates->search(
50             {
51                 patron_id => $patron_id
52             },
53             $params
54         ),
55         shared => Koha::Item::Templates->search(
56             {
57                 patron_id => { "!=" => $patron_id },
58                 is_shared => 1
59             },
60             $params
61         ),
62     };
63 }
64
65 =head3 _type
66
67 =cut
68
69 sub _type {
70     return 'ItemEditorTemplate';
71 }
72
73 =head3 object_class
74
75 =cut
76
77 sub object_class {
78     return 'Koha::Item::Template';
79 }
80
81 1;