1 package C4::NewsChannels;
3 # This file is part of Koha.
5 # Copyright (C) 2000-2002 Katipo Communications
6 # Copyright (C) 2013 Mark Tompsett
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use C4::Log qw(logaction);
27 use vars qw(@ISA @EXPORT);
38 C4::NewsChannels - Functions to manage OPAC and intranet news
42 This module provides the functions needed to mange OPAC and intranet news.
48 =head2 GetNewsToDisplay
50 $news = &GetNewsToDisplay($lang,$branch);
51 C<$news> is a ref to an array which contains
52 all news with expirationdate > today or expirationdate is null
53 that is applicable for a given branch.
57 sub GetNewsToDisplay {
58 my ($lang,$branch) = @_;
59 my $dbh = C4::Context->dbh;
61 SELECT opac_news.*,published_on AS newdate,
62 borrowers.title AS author_title,
63 borrowers.firstname AS author_firstname,
64 borrowers.surname AS author_surname
66 LEFT JOIN borrowers on borrowers.borrowernumber = opac_news.borrowernumber
68 expirationdate >= CURRENT_DATE()
69 OR expirationdate IS NULL
71 AND published_on <= CURDATE()
72 AND (opac_news.lang = '' OR opac_news.lang = ?)
73 AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?)
76 my $sth = $dbh->prepare($query);
78 $sth->execute($lang,$branch);
80 while ( my $row = $sth->fetchrow_hashref ){
81 $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 });