Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Copyright 2021 Aleisha Amohia <aleisha@catalyst.net.nz> |
6 |
# |
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. |
11 |
# |
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. |
16 |
# |
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>. |
19 |
|
20 |
use Modern::Perl; |
21 |
use CGI qw ( -utf8 ); |
22 |
use C4::Auth qw( get_template_and_user ); |
23 |
use C4::Output qw( output_html_with_http_headers ); |
24 |
use Koha::AdditionalContents; |
25 |
|
26 |
my $input = CGI->new; |
27 |
my $dbh = C4::Context->dbh; |
28 |
|
29 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
30 |
{ |
31 |
template_name => "opac-custompages.tt", |
32 |
type => "opac", |
33 |
query => $input, |
34 |
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), |
35 |
} |
36 |
); |
37 |
|
38 |
my $casAuthentication = C4::Context->preference('casAuthentication'); |
39 |
$template->param( |
40 |
casAuthentication => $casAuthentication, |
41 |
); |
42 |
|
43 |
my $homebranch; |
44 |
if (C4::Context->userenv) { |
45 |
$homebranch = C4::Context->userenv->{'branch'}; |
46 |
} |
47 |
if (defined $input->param('branch') and length $input->param('branch')) { |
48 |
$homebranch = $input->param('branch'); |
49 |
} |
50 |
elsif (C4::Context->userenv and defined $input->param('branch') and length $input->param('branch') == 0 ){ |
51 |
$homebranch = ""; |
52 |
} |
53 |
|
54 |
my $news_id = $input->param('news_id'); |
55 |
my $koha_news; |
56 |
|
57 |
if (defined $news_id){ |
58 |
$koha_news = Koha::AdditionalContents->search({ idnew => $news_id, location => ['opac_only', 'staff_and_opac'] }); # get news that is not staff-only news |
59 |
if ( $koha_news->count > 0){ |
60 |
$template->param( news_item => $koha_news->next ); |
61 |
} else { |
62 |
$template->param( single_news_error => 1 ); |
63 |
} |
64 |
} else { |
65 |
$koha_news = Koha::AdditionalContents->search_for_display( |
66 |
{ |
67 |
category => 'news', |
68 |
location => ['opac_only', 'staff_and_opac'], |
69 |
lang => $template->lang, |
70 |
library_id => $homebranch, |
71 |
} |
72 |
); |
73 |
} |
74 |
|
75 |
$template->param( |
76 |
koha_news => $koha_news, |
77 |
branchcode => $homebranch, |
78 |
daily_quote => Koha::Quotes->get_daily_quote(), |
79 |
); |
80 |
|
81 |
output_html_with_http_headers $input, $cookie, $template->output; |