1 package Koha::AdditionalContents;
3 # Copyright ByWater Solutions 2015
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use Koha::AdditionalContent;
26 use base qw(Koha::Objects);
30 Koha::AdditionalContents - Koha Additional content object set class
38 =head3 search_for_display
40 my $contents = Koha::AdditionalContents->search_for_display({
41 category => 'news', # news or html_customizations
44 library_id => $branchcode
47 Return Koha::AdditionalContents set for display to user
49 You can limit the results by location, language and library by optional params
51 library_id should be valid branchcode of defined library
53 location is one of this:
54 - slip - for ISSUESLIP notice
55 - staff_only - for intranet
56 - opac_only - for OPAC
57 - staff_and_opac - for intranet and online catalogue
58 - OpacNavRight - Right column in the online catalogue
63 - OpacLoginInstructions
64 - OpacSuggestionInstructions
65 - ArticleRequestsDisclaimerText
69 sub search_for_display {
70 my ( $self, $params ) = @_;
73 $search_params->{location} = $params->{location};
74 $search_params->{branchcode} = $params->{library_id} ? [ $params->{library_id}, undef ] : undef;
75 $search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' };
76 $search_params->{-or} = [ expirationdate => { '>=' => \'CAST(NOW() AS DATE)' },
77 expirationdate => undef ];
79 if ( $params->{lang} ) {
80 # FIXME I am failing to translate the following query
81 # SELECT a1.category, a1.code, COALESCE(a2.title, a1.title)
82 # FROM additional_contents a1
83 # LEFT JOIN additional_contents a2 on a1.code=a2.code AND a2.lang="es-ES"
84 # WHERE a1.lang = 'default';
86 # So we are retrieving the code with a translated content, then the other ones
87 my $translated_contents =
88 $self->SUPER::search( { %$search_params, lang => $params->{lang} } );
89 my $default_contents = $self->SUPER::search(
94 { '-not_in' => [ $translated_contents->get_column('code') ] }
98 return $self->SUPER::search(
101 $translated_contents->get_column('idnew'),
102 $default_contents->get_column('idnew')
105 { order_by => 'number' }
109 return $self->SUPER::search({%$search_params, lang => 'default'}, { order_by => 'number'});
117 return 'AdditionalContent';
125 return 'Koha::AdditionalContent';
130 Kyle M Hall <kyle@bywatersolutions.com>