From 6ec9f5b15bc2f0a8bc5671a5bd839830aad162e4 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 --- installer/data/mysql/sysprefs.sql | 3 ++ installer/data/mysql/updatedatabase.pl | 7 +++ .../prog/en/modules/admin/preferences/opac.pref | 15 ++++++ .../bootstrap/en/modules/opac-proxypage.tt | 40 ++++++++++++++++ opac/opac-proxypage.pl | 54 ++++++++++++++++++++++ 5 files changed, 119 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 c3e308f..3f5511d 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -340,6 +340,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/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a0698ef..8ef462b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -9585,6 +9585,13 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('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')"); + print "Upgrade done (Proxy page)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) 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 45df9f8..16f1a6c 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 @@ -595,6 +595,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.9.1