MT 1713 : Updated opacSerialDefaultTab syspref
authorMatthias Meusburger <matthias.meusburger@biblibre.com>
Mon, 19 Oct 2009 15:23:53 +0000 (17:23 +0200)
committerMatthias Meusburger <matthias.meusburger@biblibre.com>
Mon, 19 Oct 2009 15:23:53 +0000 (17:23 +0200)
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
kohaversion.pl
opac/opac-detail.pl

index 490e1e2..c2c28b2 100644 (file)
@@ -69,7 +69,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacCloud',0,'If ON, enables subject cloud on OPAC',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opaccolorstylesheet','colors.css','Define the color stylesheet to use in the OPAC','','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opaccredits','','Define HTML Credits at the bottom of the OPAC page','70|10','Textarea');
-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacSerialDefaultTab', 'serialcollection', 'Define the default tab for serials in OPAC. If set to holdings when there are no items, then serial collections are still displayed by default.', 'holdings|serialcollection', 'Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacSerialDefaultTab', 'subscriptions', 'Define the default tab for serials in OPAC.', 'holdings|serialcollection|subscriptions', 'Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacheader','','Add HTML to be included as a custom header in the OPAC','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opaclayoutstylesheet','opac.css','Enter the name of the layout CSS stylesheet to use in the OPAC','','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacMaintenance',0,'If ON, enables maintenance warning in OPAC','','YesNo');
index d8f5547..749d0e0 100644 (file)
@@ -268,4 +268,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('D
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'Si activé, affiche la photo de l''adhérent lors de l''utilisation de la console de prêt auto-contrôlé', '', 'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('EnableOpacSearchHistory', '1', 'Enable or disable opac search history', 'YesNo','')
-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacSerialDefaultTab', 'serialcollection', 'Ce paramètre définit l''onglet par défaut pour l''affichage des périodiques dans l''OPAC. Si la préférence est sur holdings, mais qu''aucun exemplaire n''est présent, les états de collection seront tout de même affichés par défaut.', 'holdings|serialcollection', 'Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacSerialDefaultTab', 'serialcollection', 'Ce paramètre définit l''onglet par défaut pour l''affichage des périodiques dans l''OPAC.', 'holdings|serialcollection|subscriptions', 'Choice');
index 89505f1..6c872e4 100755 (executable)
@@ -3092,6 +3092,18 @@ $dbh->do("
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.01.00.119";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+$dbh->do("
+       UPDATE `systempreferences` SET `options` = 'holdings|serialcollection|subscriptions',
+       WHERE `systempreferences`.`variable` = 'opacSerialDefaultTab' LIMIT 1 
+       ");
+
+    print "Upgrade to $DBversion done (opac-detail default tag updated)\n";
+    SetVersion ($DBversion);
+}
+
+
 
 
 =item DropAllForeignKeys($table)
index b9f7c81..1156a8d 100644 (file)
@@ -285,7 +285,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 <div id="bibliodescriptions" class="toptabs">
 
 <ul>   
-<li<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#holdings">Holdings
+<li<!-- TMPL_IF EXPR="defaulttab eq 'holdings'"  --> class="ui-tabs-selected"<!-- /TMPL_IF -->><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#holdings">Holdings
     ( <!-- TMPL_VAR NAME="count" --> )</a>
    </li>
  <li> <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#descriptions">Title Notes</a></li>
@@ -310,7 +310,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 <li> <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#LTFLTagBrowse">Tag Browser</a></li>
 <!-- /TMPL_IF -->
 <!-- /TMPL_IF -->
-<!-- TMPL_IF name="subscriptionsnumber" --><li>
+<!-- TMPL_IF name="subscriptionsnumber" --><li<!-- TMPL_IF EXPR="defaulttab eq 'subscriptions'" --> class="ui-tabs-selected"<!-- /TMPL_IF -->>
             <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#subscriptions">Subscriptions</a>
     </li><!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="reviewson" --><li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#comments">Comments</a></li><!-- /TMPL_IF -->
@@ -323,7 +323,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
     <!-- TMPL_IF NAME="Babeltheque" --><li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#babeltheque">Babelthèque</a></li><!-- /TMPL_IF -->
 
     <!-- TMPL_IF NAME="serialcollection" -->
-    <li<!-- TMPL_IF NAME="defaultserialcollection" --> class="ui-tabs-selected"<!-- /TMPL_IF -->><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#serialcollection">Serial Collection</a></li>
+    <li<!-- TMPL_IF  EXPR="defaulttab eq 'serialcollection'"  --> class="ui-tabs-selected"<!-- /TMPL_IF -->><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#serialcollection">Serial Collection</a></li>
     <!-- /TMPL_IF -->
 </ul>
 
index e3ef29d..385ca7b 100644 (file)
@@ -10,7 +10,7 @@
 use strict;
 
 sub kohaversion {
-    our $VERSION = '3.01.00.115';
+    our $VERSION = '3.01.00.119';
     # version needs to be set this way
     # so that it can be picked up by Makefile.PL
     # during install
index f5fe1bd..2eb819b 100755 (executable)
@@ -40,6 +40,7 @@ use C4::Serials;
 use C4::Members;
 use C4::VirtualShelves;
 use C4::XSLT;
+use Switch;
 
 BEGIN {
        if (C4::Context->preference('BakerTaylorEnabled')) {
@@ -125,12 +126,6 @@ foreach my $subscription (@subscriptions) {
 
 $dat->{'count'} = scalar(@items);
 
-# If there are no items or the syspref says so, we show serial collection as default tab
-if ($dat->{'count'} == 0 || C4::Context->preference('opacSerialDefaultTab') eq 'serialcollection') {
-       $dat->{'defaultserialcollection'} = 1;
-       
-}
-
 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
 
 my $norequests = 1;
@@ -586,5 +581,47 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
  $template->param('OPACSearchForTitleIn' => $search_for_title);
 }
 
+# We try to select the best default tab to show, according to what
+# the user wants, and what's available for display
+my $defaulttab;
+switch (C4::Context->preference('opacSerialDefaultTab')) {
+
+    # If the user wants subscriptions by default
+    case "subscriptions" { 
+       # And there are subscriptions, we display them
+       if ($subscriptionsnumber) {
+           $defaulttab = 'subscriptions';
+       } else {
+          # Else, we try next option
+          next; 
+       }
+    }
+
+    case "serialcollection" {
+       if (scalar(@serialcollections) > 0) {
+           $defaulttab = 'serialcollection' ;
+       } else {
+           next;
+       }
+    }
+
+    case "holdings" {
+       if ($dat->{'count'} > 0) {
+          $dat->{'defaultholdings'} = 1; 
+       } else {
+            # As this is the last option, we try other options if there are no items
+            if ($subscriptionsnumber) {
+               $defaulttab = 'subscriptions';
+            } elsif (scalar(@serialcollections) > 0) {
+               $defaulttab = 'serialcollection' ;
+            }
+       }
+
+    }
+
+}
+$template->param('defaulttab' => $defaulttab);
+
+
 
 output_html_with_http_headers $query, $cookie, $template->output;