Bug 1633: [SIGNED-OFF] Don't show image tab when inappropriate
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 14 Dec 2011 02:02:03 +0000 (21:02 -0500)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 24 Jan 2012 10:16:07 +0000 (11:16 +0100)
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 <magnus@enger.priv.no>
Signed-off-by: Koustubha Kale <kmkale@anantcorp.com>
catalogue/image.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
opac/opac-image.pl
opac/opac-imageviewer.pl

index 17621d7..2af1246 100755 (executable)
@@ -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')) {
index 8754cf1..3d30895 100644 (file)
@@ -233,7 +233,7 @@ function verify_images() {
 [% IF ( subscriptionsnumber ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#subscriptions">Subscriptions</a></li>[% END %]
 [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#editions">Editions</a></li>[% END %][% END %]
 [% IF ( AmazonSimilarItems ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#related">Related Titles</a></li>[% END %]
-[% IF ( LocalCoverImages ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#images">Images</a></li>[% END %]
+[% IF ( LocalCoverImages ) %][% IF ( localimages || CAN_user_tools_upload_local_cover_images ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#images">Images</a></li>[% END %][% END %]
  </ul>
 
 <div id="holdings">
@@ -527,12 +527,18 @@ function verify_images() {
 
 [% IF ( LocalCoverImages ) %]
 <div id="images">
+[% IF ( localimages ) %]
 <div>Click on an image to view it in the image viewer</div>
 [% FOREACH image IN localimages %]
 [% IF image %]
 <span class="localimage"><a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber %]&imagenumber=[% image %]"><img alt="img" src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&imagenumber=[% image %]" /></a></span>
 [% END %]
 [% END %]
+[% ELSE %]
+[% IF ( CAN_user_tools_upload_local_cover_images ) %]
+<p>No images have been uploaded for this bibliographic record yet. Please <a href='/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber %]&filetype=image'>upload</a> one.</p>
+[% END %]
+[% END %]
 </div>
 [% END %]
 
index 65256ad..6e70bf9 100755 (executable)
@@ -548,7 +548,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
                <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#serialcollection">Serial Collection</a></li>
     [% END %]
 
-    [% IF ( OPACLocalCoverImages ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#images">Images</a></li>[% END %]
+    [% IF ( OPACLocalCoverImages ) %][% IF ( localimages ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#images">Images</a></li>[% END %][% END %]
 </ul>
 
 [% IF ( serialcollection ) %]
index 444c127..eefd573 100755 (executable)
@@ -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')) {
index e3bddb4..e806267 100755 (executable)
@@ -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;