Bug 13485: Add a page to display links to restricted sites

To test:

I) Apply the patch
II) Run updatedatabase.pl

scenario I)

1) Add some content in RestrictedPageContent and RestrictedPageTitle sysprefs.
2) Add your machine ip (ex. 127.0.0)
3) Validate cgi-bin/koha/opac-proxypage.pl shows a page with RestrictedPageContent and RestrictedPageTitle contents.

scenario II)

1) Logout opac page
2) Add some content in RestrictedPageContent and RestrictedPageTitle 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 RestrictedPageContent and RestrictedPageTitle contents after login.

Followed both scenarios, works as expected.
Signed-off-by: Marc Veron <veron@veron.ch>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Bug 13485 [QA Followup]

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Bug 13485 - Atomic Update + Rename Proxy page to Restricted page

Test plan:

I) Apply the patch
II) Run updatedatabase.pl

scenario I)

1) Add some content in RestrictedPageContent and RestrictedPageTitle sysprefs.
2) Add your machine ip (ex. 127.0.0)
3) Validate cgi-bin/koha/opac-restrictedpage.pl shows a page with RestrictedPageContent and RestrictedPageTitle contents.

scenario II)

1) Logout opac page
2) Add some content in RestrictedPageContent and RestrictedPageTitle sysprefs.
3) Add a diffrent ip.
4) Validate: cgi-bin/koha/opac-restrictedpage.pl shows a login page.
5) Validate: cgi-bin/koha/opac-restrictedpage.pl shows a page with RestrictedPageContent and RestrictedPageTitle contents after login.

	new file:   installer/data/mysql/atomicupdate/Bug13485_RestrictedSitesPage.sql
	modified:   installer/data/mysql/sysprefs.sql
	modified:   koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
	renamed:    koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-proxypage.tt -> koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-restrictedpage.tt
	renamed:    opac/opac-proxypage.pl -> opac/opac-restrictedpage.pl

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
This commit is contained in:
Simith D'Oliveira 2014-12-19 14:44:48 -05:00 committed by Tomas Cohen Arazi
parent dcb5bf00aa
commit 43fadbadea
5 changed files with 125 additions and 0 deletions

View file

@ -0,0 +1,4 @@
INSERT INTO systempreferences (variable,value,options,explanation,type)
VALUES ('RestrictedPageLocalIPs','',NULL,'Beginning of IP addresses considered as local (comma separated ex: \"127.0.0,127.0.2\")','Free'),
('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'),
('RestrictedPageTitle','',NULL,'Title of the restricted page (breadcrumb and header)','Free')

View file

@ -365,6 +365,9 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice'),
('ReservesMaxPickUpDelay','7','','Define the Maximum delay to pick up an item on hold','Integer'),
('ReservesNeedReturns','1','','If ON, a hold placed on an item available in this library must be checked-in, otherwise, a hold on a specific item, that is in the library & available is considered available','YesNo'),
('RestrictedPageLocalIPs','',NULL,'Beginning of IP addresses considered as local (comma separated ex: "127.0.0,127.0.2")','Free'),
('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'),
('RestrictedPageTitle','',NULL,'Title of the restricted page (breadcrumb and header)','Free'),
('ReturnBeforeExpiry','0',NULL,'If ON, checkout will be prevented if returndate is after patron card expiry','YesNo'),
('ReturnLog','1',NULL,'If ON, enables the circulation (returns) log','YesNo'),
('ReturnToShelvingCart','0','','If set, when any item is \'checked in\', it\'s location code will be changed to CART.','YesNo'),

View file

@ -601,6 +601,21 @@ OPAC:
track: "Track"
no: "Don't track"
- links that patrons click on
Restricted page:
-
- "Access from IP addresses beginning with"
- pref: RestrictedPageLocalIPs
- "do not need to be authenticated (comma separated - ex: '127.0.0,127.0.1')"
-
- "HTML content of your restricted page"
- pref: RestrictedPageContent
type: textarea
class: HTML
-
- Use
- pref: RestrictedPageTitle
class: long
- "as title of your restricted page (appears in the breadcrumb and on the top of the restricted page)"
Shelf Browser:
-

View file

@ -0,0 +1,50 @@
[% USE Koha %]
[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>
[% IF ( LibraryNameTitle ) %]
[% LibraryNameTitle %]
[% ELSE %]
Koha online
[% END %]
catalog
[% IF RestrictedPageTitle %]
&rsaquo; [% RestrictedPageTitle %]
[% END %]
</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
<body id="opac-account" class="scrollto">
[% INCLUDE 'masthead.inc' %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a></li>
[% IF ( RestrictedPageTitle ) %]
<li> <span class="divider">&rsaquo;</span> [% RestrictedPageTitle %]</li>
[% END %]
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<div id="navigation">
[% INCLUDE 'navigation.inc' %]
</div>
</div>
<div class="span10">
<div id="restrictedcontent" class="maincontent">
[% IF ( RestrictedPageTitle ) %]
<h1>[% RestrictedPageTitle %]</h1>
[% END %]
[% RestrictedPageContent %]
</div>
</div> <!-- / .span10 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
</div> <!-- / .main -->
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %][% END %]

53
opac/opac-restrictedpage.pl Executable file
View file

@ -0,0 +1,53 @@
#!/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 Modern::Perl;
use CGI;
use C4::Auth;
use C4::Output;
my $localNetwork = C4::Context->preference('RestrictedPageLocalIPs');
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-restrictedpage.tt",
query => $query,
type => "opac",
authnotrequired => $withinNetwork,
flagsrequired => { borrow => 1 },
debug => 1,
}
);
$template->param(
RestrictedPageContent => C4::Context->preference('RestrictedPageContent'),
RestrictedPageTitle => C4::Context->preference('RestrictedPageTitle')
);
output_html_with_http_headers $query, $cookie, $template->output;