From 740070ab789846e7e13cbc2d64e20d918cd00426 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Wed, 10 Nov 2010 23:00:54 +0100 Subject: [PATCH] Fix bug on opac-detail.pl with switch statement Signed-off-by: Chris Cormack (cherry picked from commit 5e1b8167c24e0322d94bfc919556d927d875cf97) Signed-off-by: Chris Nighswonger --- opac/opac-detail.pl | 50 +++++++++++---------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 629ebd28dd..29a299fc8f 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -596,44 +596,18 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ # 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) { - $defaulttab = 'holdings'; - } 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' ; - } - } - - } - -} +my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab'); +my $defaulttab = + $opac_serial_default eq 'subscriptions' && $subscriptionsnumber + ? 'subscriptions' : + $opac_serial_default eq 'serialcollection' && @serialcollections > 0 + ? 'serialcollection' : + $opac_serial_default eq 'holdings' && $dat->{'count'} > 0 + ? 'holdings' : + $subscriptionsnumber + ? 'subscriptions' : + @serialcollections > 0 + ? 'serialcollection' : 'subscription'; $template->param('defaulttab' => $defaulttab); - output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5