[Koha-patches] [PATCH] Bug 4289: 'OpacPublic' feature

Mason James mason at kohaaloha.com
Tue Dec 7 14:44:02 CET 2010


applied to git tag 'v3.02.00-rc'


---
 C4/Auth.pm                                        |    6 +++++-
 installer/data/mysql/updatedatabase.pl            |    6 ++++++
 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, 36 insertions(+), 22 deletions(-)

diff --git a/C4/Auth.pm b/C4/Auth.pm
index 593f36e..e3efa26 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -456,6 +456,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);
@@ -943,8 +945,10 @@ sub checkauth {
         TemplateEncoding   => C4::Context->preference("TemplateEncoding"),
         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 2bd4e21..bb9737a 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -3744,6 +3744,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.00.xx.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);
+}
 
 =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 878a412..80ff667 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 @@
    <!-- /TMPL_IF --><a href="/cgi-bin/koha/opac-main.pl"><!-- TMPL_IF NAME="LibraryName" --><!-- TMPL_VAR NAME="LibraryName" --><!-- TMPL_ELSE -->Koha Online Catalog<!-- /TMPL_IF --></a></h1>
 
 <div id="fluid">
+
+<!-- TMPL_IF NAME="OpacPublic" -->
 <div id="fluid-offset">
 <!-- TMPL_UNLESS NAME="advsearch" --><form name="searchform" method="get" action="/cgi-bin/koha/opac-search.pl" id="searchform">
     <label for="masthead_search" class="left"> Search 
@@ -120,6 +122,8 @@
  </div>
 </div>
 
+<!-- /TMPL_IF -->  <!-- OpacPublic --> 
+
 <!-- TMPL_IF NAME="opacbookbag" --><div id="cartDetails">Your cart is empty.</div><!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="virtualshelves" -->
diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl
index 4883e89..03efd74 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("OpacPublic") ? 1 : 0 ),
         debug           => 1,
     }
 );
diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl
index fae749c..2f9e99e 100755
--- a/opac/opac-MARCdetail.pl
+++ b/opac/opac-MARCdetail.pl
@@ -70,7 +70,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 8cbd239..b1bf224 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 c899b4b..7a95750 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 104dff2..b8d91d5 100755
--- a/opac/opac-authorities-home.pl
+++ b/opac/opac-authorities-home.pl
@@ -151,7 +151,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 be4beca..9a8504c 100755
--- a/opac/opac-authoritiesdetail.pl
+++ b/opac/opac-authoritiesdetail.pl
@@ -63,7 +63,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 c453c87..2ec664d 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 4fe5f50..0e9a632 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 629ebd2..6d6305e 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -55,7 +55,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 e0a65a9..177d812 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 7b43c21..16ed56a 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 30bc34a..e9b92d7 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 76400a5..6213965 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 abfcc8b..f1b7f96 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 7eb934e..ac2fbf5 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 ac8343a..19f5e1f 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("OpacPublic") ? 1 : 0 ),
     }
 );
 
diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl
index fc9ce51..b2ed340 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 0e3c264..a19f406 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 1d88850..26776d4 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("OpacPublic") ? 1 : 0 ),
 				debug => 1,
 				});
 my $dbh = C4::Context->dbh;
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index 634b77a..e1e50cf 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 b38a477..2a209ec 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,
     }
-- 
1.7.1



More information about the Koha-patches mailing list