From 44b7d82bf95221a44a1300bc71cc2f0af4ac1100 Mon Sep 17 00:00:00 2001
From: Fridolin Somers <fridolin.somers@biblibre.com>
Date: Thu, 8 Oct 2015 14:24:36 +0200
Subject: [PATCH] Bug 14980 - Add a page showing one news
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The news system allow to create rich HTML content on OPAC main page.

This enh proposes a new page that shows one of these new.

Test plan :
- Go to Tools > News
- Create a new entry
- Enter a title and a few content
- Save
- You see the new entry in table
- Note its number, for example 3
- Go to opac and enter URL : /cgi-bin/koha/opac-page.pl?id=3

Works as advertised.
Signed-off-by: Marc Véron <veron@veron.ch>
---
 .../opac-tmpl/bootstrap/en/modules/opac-page.tt    |   43 ++++++++++++++++
 opac/opac-page.pl                                  |   52 ++++++++++++++++++++
 2 files changed, 95 insertions(+)
 create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-page.tt
 create mode 100755 opac/opac-page.pl

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-page.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-page.tt
new file mode 100644
index 0000000..a76b231
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-page.tt
@@ -0,0 +1,43 @@
+[% INCLUDE 'doc-head-open.inc' %]
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; [% data.title | html %]</title>
+[% INCLUDE 'doc-head-close.inc' %]
+[% BLOCK cssinclude %]
+[% END %]
+</head>
+[% INCLUDE 'bodytag.inc' bodyid='opac-page' %]
+[% INCLUDE 'masthead.inc' %]
+
+<div class="main">
+
+    <ul class="breadcrumb">
+        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
+        <li><a href="#">[% data.title | html %]</a></li>
+    </ul>
+
+    <div class="container-fluid">
+        <div class="row-fluid">
+            [% IF ( OpacNav||loggedinusername ) %]
+                <div class="span2">
+                    <div id="navigation">
+                        [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
+                    </div>
+                </div>
+                <div class="span10">
+            [% ELSE %]
+                <div class="span12">
+            [% END %]
+
+                    <div id="page-main">
+                        <h4 class="newsheader">[% data.title | html %]</h4>
+                        <div class="newsbody">[% data.new %]</div>
+                        <div class="newsfooter">(published on [% data.expirationdate %])</div>
+                    </div> <!-- /.page-main -->
+
+
+                </div> <!-- / .span10/12 -->
+            </div> <!-- / .row-fluid -->
+        </div> <!-- / .container-fluid -->
+    </div> <!-- / .main -->
+
+[% INCLUDE 'opac-bottom.inc' %]
+[% BLOCK jsinclude %][% END %]
diff --git a/opac/opac-page.pl b/opac/opac-page.pl
new file mode 100755
index 0000000..189cb7e
--- /dev/null
+++ b/opac/opac-page.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+# This script lets the users change their privacy rules
+#
+# copyright 2015, BibLibre
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use strict;
+use warnings;
+
+use CGI qw ( -utf8 );
+
+use C4::Auth qw(get_template_and_user);
+use C4::Context;
+use C4::Output;
+use C4::NewsChannels;
+
+my $query = new CGI;
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-page.tt",
+        query           => $query,
+        type            => "opac",
+        authnotrequired => 1,
+        debug           => 1,
+    }
+);
+
+my $page_id   = $query->param("id");
+my $page_data = get_opac_new($page_id);
+
+# broken
+unless ( $page_data->{'idnew'} ) {
+    print $query->redirect("/cgi-bin/koha/errors/404.pl");
+    exit;
+}
+
+$template->param( data => $page_data, );
+
+output_html_with_http_headers $query, $cookie, $template->output;
-- 
1.7.10.4