From 57288e020d5b89543dbc025d8268b5c24b91809e Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Tue, 13 Dec 2011 21:02:03 -0500 Subject: [PATCH] Bug 1633: [SIGNED-OFF] Don't show image tab when inappropriate This patch corrects the bug spotted by Owen Leonard where the Images tab was showing up even for records that didn't have local cover images attached to them. The tab is now hidden on the OPAC for records that don't have any images. In the Intranet, an Images tab will show for staff with permission to upload images, suggesting that they do so. For staff without that permission, the tab is not shown. This permission also disables returning images via the opac-image.pl and catalogue/image.pl scripts when local cover images have been disabled. Signed-off-by: Magnus Enger Signed-off-by: Koustubha Kale --- catalogue/image.pl | 2 ++ .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 8 +++++++- koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 2 +- opac/opac-image.pl | 2 ++ opac/opac-imageviewer.pl | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/catalogue/image.pl b/catalogue/image.pl index 17621d78bf..2af1246580 100755 --- a/catalogue/image.pl +++ b/catalogue/image.pl @@ -55,6 +55,8 @@ imagenumber, a random image is selected. =cut +error() unless C4::Context->preference("OPACLocalCoverImages"); + if (defined $data->param('imagenumber')) { $imagenumber = $data->param('imagenumber'); } elsif (defined $data->param('biblionumber')) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 8754cf180f..3d308958fe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -233,7 +233,7 @@ function verify_images() { [% IF ( subscriptionsnumber ) %]
  • Subscriptions
  • [% END %] [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]
  • Editions
  • [% END %][% END %] [% IF ( AmazonSimilarItems ) %]
  • Related Titles
  • [% END %] -[% IF ( LocalCoverImages ) %]
  • Images
  • [% END %] +[% IF ( LocalCoverImages ) %][% IF ( localimages || CAN_user_tools_upload_local_cover_images ) %]
  • Images
  • [% END %][% END %]
    @@ -527,12 +527,18 @@ function verify_images() { [% IF ( LocalCoverImages ) %]
    +[% IF ( localimages ) %]
    Click on an image to view it in the image viewer
    [% FOREACH image IN localimages %] [% IF image %] img [% END %] [% END %] +[% ELSE %] +[% IF ( CAN_user_tools_upload_local_cover_images ) %] +

    No images have been uploaded for this bibliographic record yet. Please upload one.

    +[% END %] +[% END %]
    [% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index 65256ad48a..6e70bf964e 100755 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -548,7 +548,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { Serial Collection [% END %] - [% IF ( OPACLocalCoverImages ) %]
  • Images
  • [% END %] + [% IF ( OPACLocalCoverImages ) %][% IF ( localimages ) %]
  • Images
  • [% END %][% END %] [% IF ( serialcollection ) %] diff --git a/opac/opac-image.pl b/opac/opac-image.pl index 444c127ced..eefd573498 100755 --- a/opac/opac-image.pl +++ b/opac/opac-image.pl @@ -55,6 +55,8 @@ imagenumber, a random image is selected. =cut +error() unless C4::Context->preference("OPACLocalCoverImages"); + if (defined $data->param('imagenumber')) { $imagenumber = $data->param('imagenumber'); } elsif (defined $data->param('biblionumber')) { diff --git a/opac/opac-imageviewer.pl b/opac/opac-imageviewer.pl index e3bddb4454..e806267383 100755 --- a/opac/opac-imageviewer.pl +++ b/opac/opac-imageviewer.pl @@ -46,7 +46,7 @@ if (C4::Context->preference("OPACLocalCoverImages")) { $template->{VARS}->{'OPACLocalCoverImages'} = 1; $template->{VARS}->{'images'} = \@images; $template->{VARS}->{'biblionumber'} = $biblionumber; - $template->{VARS}->{'imagenumber'} = $images[0] || ''; + $template->{VARS}->{'imagenumber'} = $imagenumber || $images[0] || ''; } $template->{VARS}->{'biblio'} = $biblio; -- 2.39.5