From 666165c92b99820e963a83953589da5cfe95b363 Mon Sep 17 00:00:00 2001 From: simith Date: Fri, 19 Dec 2014 14:44:48 -0500 Subject: [PATCH] Bug 13485 - Add a proxy page To test: I) Apply the patch II) Run updatedatabase.pl scenario I) 1) Add some content in ProxyPageContent and ProxyPageTitle sysprefs. 2) Add your machine ip (ex. 127.0.0) 3) Validate cgi-bin/koha/opac-proxypage.pl shows a page with ProxyPageContent and ProxyPageTitle contents. scenario II) 1) Logout opac page 2) Add some content in ProxyPageContent and ProxyPageTitle sysprefs. 3) Add other ip that your machine ip. 4) Validate: cgi-bin/koha/opac-proxypage.pl shows a login page. 5) Validate: cgi-bin/koha/opac-proxypage.pl shows a page with ProxyPageContent and ProxyPageTitle contents after login. Followed both scenarios, works as expected. Signed-off-by: Marc Veron Signed-off-by: Kyle M Hall --- installer/data/mysql/sysprefs.sql | 3 ++ .../prog/en/modules/admin/preferences/opac.pref | 15 ++++++ .../bootstrap/en/modules/opac-proxypage.tt | 40 +++++++++++++++ opac/opac-proxypage.pl | 54 ++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-proxypage.tt create mode 100755 opac/opac-proxypage.pl diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 84ba363..7240f1d 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -344,6 +344,9 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'), ('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'), ('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'), +('ProxyPageLocalIPs','',NULL,'Beginning of IP addresses considered as local (comma separated ex: "127.0.0,127.0.2")','Free'), +('ProxyPageContent','',NULL,'HTML content of the proxy page','TextArea'), +('ProxyPageTitle','',NULL,'Title of the proxy page (breadcrumb and header)','Free'), ('QueryAutoTruncate','1',NULL,'If ON, query truncation is enabled by default','YesNo'), ('QueryFuzzy','1',NULL,'If ON, enables fuzzy option for searches','YesNo'), ('QueryStemming','1',NULL,'If ON, enables query stemming','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index ad0f26f..2fd7b7f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -601,6 +601,21 @@ OPAC: track: "Track" no: "Don't track" - links that patrons click on + Proxy page: + - + - "Access from IP addresses beginning with" + - pref: ProxyPageLocalIPs + - "do not need to be authenticated (comma separated - ex: '127.0.0,127.0.1')" + - + - "HTML content of your proxy page" + - pref: ProxyPageContent + type: textarea + class: HTML + - + - Use + - pref: ProxyPageTitle + class: long + - "as title of your proxy page (appears in the breadcrumb and on the top of the proxy page)" Shelf Browser: - diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-proxypage.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-proxypage.tt new file mode 100644 index 0000000..3ceae77 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-proxypage.tt @@ -0,0 +1,40 @@ +[% USE Koha %] +[% USE KohaDates %] + +[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog[% IF ProxyPageTitle %] › [% ProxyPageTitle %][% END %] + +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + + +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+
+ +
+
+
+ [% IF ( ProxyPageTitle ) %] +

[% ProxyPageTitle %]

+ [% END %] + [% ProxyPageContent %] +
+
+
+
+
+ +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %][% END %] \ No newline at end of file diff --git a/opac/opac-proxypage.pl b/opac/opac-proxypage.pl new file mode 100755 index 0000000..f2f175b --- /dev/null +++ b/opac/opac-proxypage.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl + +# Copyright Solutions inLibro inc 2014 +# +# This file is part of Koha. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +use strict; +use CGI; +use C4::Auth; +use C4::Output; +use warnings; + +my $localNetwork = C4::Context->preference('ProxyPageLocalIPs'); +my $userIP = $ENV{'REMOTE_ADDR'}; + +my $withinNetwork = 0; +foreach my $IPRange ( split( ',', $localNetwork ) ) +{ + $withinNetwork = ( $userIP =~ /^$IPRange/ ); + last if $withinNetwork; +} + +my $query = new CGI; +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-proxypage.tt", + query => $query, + type => "opac", + authnotrequired => $withinNetwork, + flagsrequired => { borrow => 1 }, + debug => 1, + } +); + +$template->param( + ProxyPageContent => C4::Context->preference('ProxyPageContent'), + ProxyPageTitle => C4::Context->preference('ProxyPageTitle') + ); + +output_html_with_http_headers $query, $cookie, $template->output; \ No newline at end of file -- 1.7.9.5