From f46b03cf2da045c72d8294b7688b547ba9205893 Mon Sep 17 00:00:00 2001 From: Mason James Date: Tue, 7 Dec 2010 17:33:12 +0100 Subject: [PATCH] Bug 4289: 'OpacPublic' feature MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit applied to git tag 'v3.02.00-rc' Frédéric Demians: - Rebased this patch to HEAD - Solved a merge conflict - The patch works as described here: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=4289 Signed-off-by: Frédéric Demians Signed-off-by: Jared Camins-Esakov Signed-off-by: Chris Cormack --- C4/Auth.pm | 6 +++++- installer/data/mysql/updatedatabase.pl | 7 +++++++ koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 4 ++++ 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 | 2 +- opac/opac-authoritiesdetail.pl | 2 +- opac/opac-basket.pl | 2 +- opac/opac-browser.pl | 2 +- opac/opac-detail.pl | 2 +- opac/opac-main.pl | 2 +- opac/opac-review.pl | 2 +- opac/opac-search.pl | 2 +- opac/opac-sendbasket.pl | 2 +- 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-user.pl | 2 +- opac/opac-userupdate.pl | 2 +- 24 files changed, 37 insertions(+), 22 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 2f13b863e9..fc4e3e257d 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -455,6 +455,8 @@ sub get_template_and_user { SyndeticsSeries => C4::Context->preference("SyndeticsSeries"), SyndeticsCoverImageSize => C4::Context->preference("SyndeticsCoverImageSize"), ); + + $template->param(OpacPublic => '1') if ($template->param( 'loggedinusername') || C4::Context->preference("OpacPublic")); } $template->param(listloop=>[{shelfname=>"Freelist", shelfnumber=>110}]); return ( $template, $borrowernumber, $cookie, $flags); @@ -941,8 +943,10 @@ sub checkauth { intranetuserjs => C4::Context->preference("intranetuserjs"), IndependantBranches=> C4::Context->preference("IndependantBranches"), AutoLocation => C4::Context->preference("AutoLocation"), - wrongip => $info{'wrongip'} + wrongip => $info{'wrongip'}, ); + + $template->param( OpacPublic => C4::Context->preference("OpacPublic")); $template->param( loginprompt => 1 ) unless $info{'nopermission'}; if ($cas) { diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index cb88827a34..febb4d176a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3937,6 +3937,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.03.00.xxx"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacPublic','1','If set to OFF and user is not logged in, all OPAC pages require authentication, and OPAC searchbar is removed)','','YesNo')"); + print "Upgrade to $DBversion done (added 'OpacPublic' syspref)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 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 236f296a50..6db1552afa 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -25,6 +25,8 @@ Koha Online Catalog
+ +
+ +
Your cart is empty.
diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index d3ffecc9a9..e022497b66 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -61,7 +61,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-ISBDdetail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), debug => 1, } ); diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 1a9dc34088..fd909f5e81 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -71,7 +71,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-MARCdetail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), debug => 1, } ); diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl index 8cbd2393c9..b1bf2245c5 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("OpacPublic") ? 1 : 0 ), } ); diff --git a/opac/opac-alert-subscribe.pl b/opac/opac-alert-subscribe.pl index c899b4b6e2..7a95750dba 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("OpacPublic") ? 1 : 0 ), debug => 1, } ); diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl index 292d0a8ccb..a87030ef98 100755 --- a/opac/opac-authorities-home.pl +++ b/opac/opac-authorities-home.pl @@ -152,7 +152,7 @@ else { template_name => "opac-authorities-home.tmpl", query => $query, type => 'opac', - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), debug => 1, } ); diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl index 71f746ec7d..7e06310c3d 100755 --- a/opac/opac-authoritiesdetail.pl +++ b/opac/opac-authoritiesdetail.pl @@ -62,7 +62,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-authoritiesdetail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), debug => 1, } ); diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index c453c87d22..2ec664d279 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("OpacPublic") ? 1 : 0 ), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-browser.pl b/opac/opac-browser.pl index 4fe5f501df..0e9a632633 100755 --- a/opac/opac-browser.pl +++ b/opac/opac-browser.pl @@ -44,7 +44,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "opac-browser.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), debug => 1, } ); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 9110ccaa52..6da1eaeccb 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -53,7 +53,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( template_name => "opac-detail.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-main.pl b/opac/opac-main.pl index e0a65a9ae8..177d812506 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("OpacPublic") ? 1 : 0 ), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-review.pl b/opac/opac-review.pl index 7b43c2190f..16ed56af96 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("OpacPublic") ? 1 : 0 ), } ); diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 45cb7664a6..0f526502e6 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -80,7 +80,7 @@ else { template_name => $template_name, query => $cgi, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), } ); diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index 76400a5092..621396542c 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -38,7 +38,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( template_name => "opac-sendbasketform.tmpl", query => $query, type => "opac", - authnotrequired => 0, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), flagsrequired => { borrow => 1 }, } ); diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index abfcc8bcdf..f1b7f965ad 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("OpacPublic") ? 1 : 0 ), }); $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 2e0be7527a..447551289e 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("OpacPublic") ? 1 : 0 ), debug => 1, }); diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl index 19693b0c46..c254d2682d 100755 --- a/opac/opac-showreviews.pl +++ b/opac/opac-showreviews.pl @@ -52,7 +52,7 @@ my ( $template, $borrowernumber, $cookie ) = &get_template_and_user( template_name => $template_name, query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), } ); diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index 75d07910db..a2a6670cf3 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -44,7 +44,7 @@ if ( C4::Context->preference("AnonSuggestions") ) { template_name => "opac-suggestions.tmpl", query => $input, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), } ); if ( !$$suggestion{suggestedby} ) { diff --git a/opac/opac-tags_subject.pl b/opac/opac-tags_subject.pl index 0e3c264210..a19f406db9 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("OpacPublic") ? 1 : 0 ), debug => 1, } ); diff --git a/opac/opac-topissues.pl b/opac/opac-topissues.pl index b4b83f1458..80e7c35aba 100755 --- a/opac/opac-topissues.pl +++ b/opac/opac-topissues.pl @@ -46,7 +46,7 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({template_name => 'opac-topissues.tmpl', query => $input, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), debug => 1, }); my $dbh = C4::Context->dbh; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 634b77a9db..e1e50cfe9d 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -47,7 +47,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( template_name => "opac-user.tmpl", query => $query, type => "opac", - authnotrequired => 0, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), flagsrequired => { borrow => 1 }, debug => 1, } diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl index 18cafdbe22..2e8fb5e255 100755 --- a/opac/opac-userupdate.pl +++ b/opac/opac-userupdate.pl @@ -40,7 +40,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( template_name => "opac-userupdate.tmpl", query => $query, type => "opac", - authnotrequired => 0, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), flagsrequired => { borrow => 1 }, debug => 1, } -- 2.20.1