use Modern::Perl;
use CGI qw ( -utf8 );
-use C4::Auth; # get_template_and_user
-use C4::Output;
-use C4::NewsChannels; # GetNewsToDisplay
-use C4::Languages qw(getTranslatedLanguages accept_language);
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
use Koha::Quotes;
use C4::Members;
-use C4::Overdues;
+use C4::Overdues qw( checkoverdues );
use Koha::Checkouts;
use Koha::Holds;
-use Koha::News;
+use Koha::AdditionalContents;
use Koha::Patron::Messages;
my $input = CGI->new;
casAuthentication => $casAuthentication,
);
-my $homebranch;
+my $homebranch = $ENV{OPAC_BRANCH_DEFAULT};
if (C4::Context->userenv) {
$homebranch = C4::Context->userenv->{'branch'};
}
}
my $news_id = $input->param('news_id');
-my $all_koha_news;
+my $koha_news;
if (defined $news_id){
- $all_koha_news = Koha::News->search({ idnew => $news_id, lang => { '!=', 'koha' } }); # get news that is not staff-only news
- if( $all_koha_news->count ) { # we only expect one btw
- $template->param( news_item => $all_koha_news->next );
+ $koha_news = Koha::AdditionalContents->search({ idnew => $news_id, location => ['opac_only', 'staff_and_opac'] }); # get news that is not staff-only news
+ if ( $koha_news->count > 0){
+ $template->param( news_item => $koha_news->next );
} else {
$template->param( single_news_error => 1 );
}
} else {
- $all_koha_news = &GetNewsToDisplay( $template->lang, $homebranch);
+ $koha_news = Koha::AdditionalContents->search_for_display(
+ {
+ category => 'news',
+ location => ['opac_only', 'staff_and_opac'],
+ lang => $template->lang,
+ library_id => $homebranch,
+ }
+ );
}
# For dashboard
}
$template->param(
- koha_news => $all_koha_news,
+ koha_news => $koha_news,
branchcode => $homebranch,
daily_quote => Koha::Quotes->get_daily_quote(),
);