From 8cec6d7efbe4b72a49f1aaee66d38cc3c3380a02 Mon Sep 17 00:00:00 2001 From: Mason James Date: Wed, 24 Feb 2010 18:54:25 +1300 Subject: [PATCH] Bug 4289 Add a syspref 'OpacNotPublic', to hide OPAC search-bar and force authentication on all OPAC pages Content-Type: text/plain; charset="utf-8" --- C4/Auth.pm | 14 ++++++++++++-- installer/data/mysql/updatedatabase30.pl | 8 +++++++- koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 13 ++++++++++++- kohaversion.pl | 2 +- opac/opac-ISBDdetail.pl | 2 +- opac/opac-MARCdetail.pl | 2 +- opac/opac-addbybiblionumber.pl | 2 +- opac/opac-alert-subscribe.pl | 2 +- opac/opac-authorities-home.pl | 4 ++-- opac/opac-authoritiesdetail.pl | 2 +- opac/opac-basket.pl | 2 +- opac/opac-browser.pl | 2 +- opac/opac-detail.pl | 2 +- opac/opac-detailprint.pl | 2 +- opac/opac-main.pl | 2 +- opac/opac-recentacquisitions.pl | 2 +- opac/opac-review.pl | 2 +- opac/opac-search.pl | 2 +- opac/opac-sendbasket.pl | 2 +- opac/opac-sendshelf.pl | 4 ++-- opac/opac-serial-issues.pl | 4 ++-- opac/opac-shelves.pl | 2 +- opac/opac-showmarc.pl | 2 +- opac/opac-showreviews.pl | 2 +- opac/opac-suggestions.pl | 2 +- opac/opac-tags_subject.pl | 2 +- opac/opac-topissues.pl | 2 +- opac/opac-userupdate.pl | 2 +- 28 files changed, 59 insertions(+), 32 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index a4924a0..f833c6a 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -29,6 +29,8 @@ use C4::Koha; use C4::Branch; # GetBranches use C4::VirtualShelves; +#use Smart::Comments '####'; + # use utf8; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap); @@ -308,6 +310,8 @@ sub get_template_and_user { } elsif($mylibraryfirst){ $opac_name = C4::Branch::GetBranchName($mylibraryfirst); } + + $template->param( OPACAmazonContent => "" . C4::Context->preference("OPACAmazonContent"), OPACAmazonCoverImages => "" . C4::Context->preference("OPACAmazonCoverImages"), @@ -361,6 +365,10 @@ sub get_template_and_user { suggestion => "" . C4::Context->preference("suggestion"), virtualshelves => "" . C4::Context->preference("virtualshelves"), ); + + $template->param( OpacNotPublic => C4::Context->preference("OpacNotPublic") ) + unless ( $template->param( 'loggedinusername' ) ); + } return ( $template, $borrowernumber, $cookie, $flags); } @@ -493,6 +501,8 @@ sub _session_log { close L; } + + sub checkauth { my $query = shift; $debug and warn "Checking Auth"; @@ -821,8 +831,8 @@ sub checkauth { OpacAuthorities => C4::Context->preference("OpacAuthorities"), OpacBrowser => C4::Context->preference("OpacBrowser"), opacheader => C4::Context->preference("opacheader"), - TagsEnabled => C4::Context->preference("TagsEnabled"), - OPACUserCSS => C4::Context->preference("OPACUserCSS"), + OpacNotPublic => C4::Context->preference("OpacNotPublic"), + OPACUserCSS => C4::Context->preference("OPACUserCSS"), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), intranetstylesheet => C4::Context->preference("intranetstylesheet"), diff --git a/installer/data/mysql/updatedatabase30.pl b/installer/data/mysql/updatedatabase30.pl index 5002f0f..fb8e162 100644 --- a/installer/data/mysql/updatedatabase30.pl +++ b/installer/data/mysql/updatedatabase30.pl @@ -26,7 +26,7 @@ use C4::Installer; use MARC::Record; use MARC::File::XML ( BinaryEncoding => 'utf8' ); - + # FIXME - The user might be installing a new database, so can't rely # on /etc/koha.conf anyway. @@ -688,6 +688,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.05.004"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacNotPublic','0','If set, all OPAC pages require authentication, and OPAC-searchbar is hidden - if user is not logged in','','YesNo')"); + print "Upgrade to $DBversion done (added 'OpacNotPublic' syspref)\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc index 74c716e..10ec890 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -7,6 +7,9 @@ + + + + + +
Your cart is empty.
diff --git a/kohaversion.pl b/kohaversion.pl index fa25945..0330642 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = '3.00.05.003'; + our $VERSION = '3.00.05.004'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 88d373a..e230e93 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -64,7 +64,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-ISBDdetail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 9826c24..487deda 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -66,7 +66,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-MARCdetail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl index 4c99ed2..0bf5fd5 100755 --- a/opac/opac-addbybiblionumber.pl +++ b/opac/opac-addbybiblionumber.pl @@ -59,7 +59,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-addbybiblionumber.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), } ); diff --git a/opac/opac-alert-subscribe.pl b/opac/opac-alert-subscribe.pl index 8e827b6..bfd5429 100755 --- a/opac/opac-alert-subscribe.pl +++ b/opac/opac-alert-subscribe.pl @@ -46,7 +46,7 @@ my $biblionumber = $query->param('biblionumber'); template_name => "opac-alert-subscribe.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl index 169e9dd..c71064e 100755 --- a/opac/opac-authorities-home.pl +++ b/opac/opac-authorities-home.pl @@ -75,7 +75,7 @@ if ( $op eq "do_search" ) { template_name => "opac-authoritiessearchresultlist.tmpl", query => $query, type => 'opac', - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); @@ -150,7 +150,7 @@ else { template_name => "opac-authorities-home.tmpl", query => $query, type => 'opac', - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl index 430f0f2..9ee8fa8 100755 --- a/opac/opac-authoritiesdetail.pl +++ b/opac/opac-authoritiesdetail.pl @@ -61,7 +61,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-authoritiesdetail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index a50bdd5..38538bc 100755 --- a/opac/opac-basket.pl +++ b/opac/opac-basket.pl @@ -32,7 +32,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( template_name => "opac-basket.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-browser.pl b/opac/opac-browser.pl index f1d98f0..eb72241 100755 --- a/opac/opac-browser.pl +++ b/opac/opac-browser.pl @@ -42,7 +42,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-browser.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 7febfa0..38f8a5a 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -51,7 +51,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( template_name => "opac-detail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacNotPublic") ? 0 : 1 ), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-detailprint.pl b/opac/opac-detailprint.pl index 8d11cfc..3431406 100755 --- a/opac/opac-detailprint.pl +++ b/opac/opac-detailprint.pl @@ -69,7 +69,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => ('opac-detailprint.tmpl'), query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), } ); diff --git a/opac/opac-main.pl b/opac/opac-main.pl index f724b9d..83f640e 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -36,7 +36,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( template_name => "opac-main.tmpl", type => "opac", query => $input, - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacNotPublic") ? 0 : 1 ), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-recentacquisitions.pl b/opac/opac-recentacquisitions.pl index d721cdf..6638ed5 100755 --- a/opac/opac-recentacquisitions.pl +++ b/opac/opac-recentacquisitions.pl @@ -23,7 +23,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-recentacquisitions.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), flagsrequired => {}, debug => 1, } diff --git a/opac/opac-review.pl b/opac/opac-review.pl index 57a460f..75886ac 100755 --- a/opac/opac-review.pl +++ b/opac/opac-review.pl @@ -36,7 +36,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( template_name => "opac-review.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), } ); diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 74f8fe5..e389cbc 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -56,7 +56,7 @@ else { template_name => $template_name, query => $cgi, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), } ); diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index d450758..a2ff571 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -61,7 +61,7 @@ if ( $email_add ) { template_name => "opac-sendbasket.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index 86b494b..885f826 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -40,7 +40,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( template_name => "opac-sendshelfform.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), flagsrequired => { borrow => 1 }, } ); @@ -64,7 +64,7 @@ if ( $email ) { template_name => "opac-sendshelf.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-serial-issues.pl b/opac/opac-serial-issues.pl index 8993d7f..f824008 100755 --- a/opac/opac-serial-issues.pl +++ b/opac/opac-serial-issues.pl @@ -48,7 +48,7 @@ if ( $selectview eq "full" ) { template_name => "opac-full-serial-issues.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); @@ -86,7 +86,7 @@ else { template_name => "opac-serial-issues.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index dbd598c..27e193f 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -29,7 +29,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ template_name => "opac-shelves.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), }); $template->param(listsview => 1); # if $loggedinuser is not defined, set it to -1, which should diff --git a/opac/opac-showmarc.pl b/opac/opac-showmarc.pl index 2024bcb..5d0d624 100755 --- a/opac/opac-showmarc.pl +++ b/opac/opac-showmarc.pl @@ -48,7 +48,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ template_name => "opac-showmarc.tmpl", query => $input, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, }); diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl index ac8343a..f9e4213 100755 --- a/opac/opac-showreviews.pl +++ b/opac/opac-showreviews.pl @@ -34,7 +34,7 @@ my ( $template, $borrowernumber, $cookie ) = &get_template_and_user( template_name => "opac-showreviews.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), } ); diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index 838cd05..b99cfd9 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -49,7 +49,7 @@ if ( C4::Context->preference("AnonSuggestions") ) { template_name => "opac-suggestions.tmpl", query => $input, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), } ); if ( !$borrowernumber ) { diff --git a/opac/opac-tags_subject.pl b/opac/opac-tags_subject.pl index 5836f70..8316412 100755 --- a/opac/opac-tags_subject.pl +++ b/opac/opac-tags_subject.pl @@ -44,7 +44,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-tags_subject.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, } ); diff --git a/opac/opac-topissues.pl b/opac/opac-topissues.pl index 45130c7..8a566d1 100755 --- a/opac/opac-topissues.pl +++ b/opac/opac-topissues.pl @@ -48,7 +48,7 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({template_name => 'opac-topissues.tmpl', query => $input, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), debug => 1, }); my $dbh = C4::Context->dbh; diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl index cd126dd..4687840 100755 --- a/opac/opac-userupdate.pl +++ b/opac/opac-userupdate.pl @@ -66,7 +66,7 @@ if ( $updateemailaddress eq '' ) { template_name => "kohaerror.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => (C4::Context->preference("OpacNotPublic") ? 0 : 1), flagsrequired => { borrow => 1 }, debug => 1, } -- 1.7.1