Bug 32050: Add 'page-section' to calendar page
[koha-ffzg.git] / opac / opac-main.pl
index f11aecd..779c06d 100755 (executable)
 
 use Modern::Perl;
 use CGI qw ( -utf8 );
-use C4::Auth;    # get_template_and_user
-use C4::Output;
-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;
@@ -48,7 +47,7 @@ $template->param(
     casAuthentication   => $casAuthentication,
 );
 
-my $homebranch;
+my $homebranch = $ENV{OPAC_BRANCH_DEFAULT};
 if (C4::Context->userenv) {
     $homebranch = C4::Context->userenv->{'branch'};
 }
@@ -63,23 +62,21 @@ my $news_id = $input->param('news_id');
 my $koha_news;
 
 if (defined $news_id){
-    $koha_news = Koha::News->search({ idnew => $news_id, lang => { '!=', 'koha' } }); # get news that is not staff-only news
+    $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 {
-    my $params;
-    $params->{lang} = [ $template->lang, '' ];
-    $params->{branchcode} = [ $homebranch, undef ] if $homebranch;
-    $params->{-or} = [ expirationdate => { '>=' => \'NOW()' },
-                       expirationdate => undef ];
-    $koha_news = Koha::News->search(
-        $params,
+    $koha_news = Koha::AdditionalContents->search_for_display(
         {
-            order_by => 'number'
-        });
+            category   => 'news',
+            location   => ['opac_only', 'staff_and_opac'],
+            lang       => $template->lang,
+            library_id => $homebranch,
+        }
+    );
 }
 
 # For dashboard