From 92e204713b60a8211b110275104097787326485e Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 19 Oct 2009 17:23:53 +0200 Subject: [PATCH] MT 1713 : Updated opacSerialDefaultTab syspref --- .../data/mysql/en/mandatory/sysprefs.sql | 2 +- .../unimarc_standard_systemprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 12 +++++ .../prog/en/modules/opac-detail.tmpl | 6 +-- kohaversion.pl | 2 +- opac/opac-detail.pl | 49 ++++++++++++++++--- 6 files changed, 61 insertions(+), 12 deletions(-) diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 490e1e2109..c2c28b21ca 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -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'); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql index d8f5547177..749d0e04a1 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql @@ -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'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 89505f14fc..6c872e4b96 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -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) diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index b9f7c8199b..1156a8d309 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -285,7 +285,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
diff --git a/kohaversion.pl b/kohaversion.pl index e3ef29dc29..385ca7b245 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -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 diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index f5fe1bdb6a..2eb819b949 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -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; -- 2.39.5