[Koha-patches] [PATCH] Bug 1003 Added lists to bib details pages

Nicole Engard nengard at gmail.com
Fri Aug 28 23:40:16 CEST 2009


>From 821656ae63a812d3c75970430cd666a371d89dfd Mon Sep 17 00:00:00 2001
From: Nicole Engard <nengard at gmail.com>
Date: Thu, 27 Aug 2009 11:22:15 -0400
Subject: [PATCH] Bug 1003 Added lists to bib details pages
Content-Type: text/plain; charset="utf-8"

This patch adds links to all public lists that a bib
record belongs to to the detail page in the OPAC and
the Inranet. If the item is not in any lists nothing
shows on the detail page.  The same goes if virtualshelves
is turned OFF.
---
 C4/VirtualShelves.pm                               |   19 +++++++++++++++++++
 catalogue/detail.pl                                |    7 +++++++
 .../prog/en/modules/catalogue/detail.tmpl          |   11 +++++++++++
 .../opac-tmpl/prog/en/modules/opac-detail.tmpl     |    9 +++++++++
 opac/opac-detail.pl                                |    8 ++++++++
 5 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm
index 76786e9..5047550 100644
--- a/C4/VirtualShelves.pm
+++ b/C4/VirtualShelves.pm
@@ -44,6 +44,7 @@ BEGIN {
             &ModShelf
             &ShelfPossibleAction
             &DelFromShelf &DelShelf
+            &GetBibliosShelves
 	);
         @EXPORT_OK = qw(
             &GetShelvesSummary &GetRecentShelves
@@ -532,6 +533,24 @@ sub DelShelf {
 	return $sth->execute(shift);
 }

+=item GetBibShelves
+
+This finds all the lists that this bib record is in.
+
+=cut
+
+sub GetBibliosShelves {
+  my ( $biblionumber )  = @_;
+  my $dbh = C4::Context->dbh;
+  my $sth = $dbh->prepare('SELECT vs.shelfname, vs.shelfnumber FROM
virtualshelves vs LEFT JOIN virtualshelfcontents vc ON
(vs.shelfnumber= vc.shelfnumber) WHERE vs.category != 1 AND
vc.biblionumber= ?');
+  $sth->execute( $biblionumber );
+  my @lists;
+  while (my $data = $sth->fetchrow_hashref){
+    push @lists,$data;
+  }
+  return \@lists;
+}
+
 =item RefreshShelvesSummary

 	($total, $pubshelves, $barshelves) =
RefreshShelvesSummary($sessionID, $loggedinuser, $row_count);
diff --git a/catalogue/detail.pl b/catalogue/detail.pl
index 9c9ebe9..6c2afdc 100755
--- a/catalogue/detail.pl
+++ b/catalogue/detail.pl
@@ -35,6 +35,7 @@ use C4::Serials;
 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
 use C4::External::Amazon;
 use C4::Search;		# enabled_staff_search_views
+use C4::VirtualShelves;

 # use Smart::Comments;

@@ -225,6 +226,12 @@ $template->param(

 # $debug and $template->param(debug_display => 1);

+# Lists
+
+if (C4::Context->preference("virtualshelves") ) {
+   $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
+}
+
 # XISBN Stuff
 if (C4::Context->preference("FRBRizeEditions")==1) {
     eval {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
index e330f7f..251c6df 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
@@ -100,6 +100,7 @@ function verify_images() {
             <!-- /TMPL_LOOP --></ul>
 </li>
     <!-- /TMPL_IF -->
+
     <!-- TMPL_IF name="OpacUrl" -->
     	<li><strong>OPAC View:</strong>
     	<a href="http://<!-- TMPL_VAR name="OpacUrl"
-->/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR
NAME="biblionumber" -->" target="_blank">Open in new window</a>
@@ -150,6 +151,16 @@ function verify_images() {
                 <!-- /TMPL_LOOP -->
             </li>
         <!-- /TMPL_IF -->
+        <!--This grabs all of the lists a bib record appears in -->
+        <!-- TMPL_IF NAME="GetShelves" -->
+	        <li><strong>Lists that include this title: </strong>
+	        <ul>
+	        <!-- TMPL_LOOP NAME="GetShelves" -->
+		        <li><a
href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=<!-- TMPL_VAR
NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname" --></a></li>
+	        <!-- /TMPL_LOOP -->
+	        </ul>
+	        </li>
+        <!-- /TMPL_IF -->
         </ul>
 </div>
 </div>
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 12a5003..ae40837 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
@@ -216,6 +216,15 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
     </span>
 <!-- /TMPL_IF -->

+<!--This grabs all of the lists a bib record appears in -->
+<!-- TMPL_IF NAME="GetShelves" -->
+	<span class="results_summary"><span class="label">List(s) this item
appears in: </span>
+	<!-- TMPL_LOOP NAME="GetShelves" -->
+		<a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR
NAME="shelfnumber" -->&sortfield=title"><!-- TMPL_VAR NAME="shelfname"
--></a>
+		<!-- TMPL_IF NAME="__LAST__" --><!-- TMPL_ELSE -->|<!-- /TMPL_IF -->
+	<!-- /TMPL_LOOP -->
+	</span>
+<!-- /TMPL_IF -->

     <!-- TMPL_IF NAME="TagsShowOnDetail" -->
         <div class="results_summary">
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 52562c7..c3b104b 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -38,6 +38,7 @@ use C4::External::Syndetics qw(get_syndetics_index
get_syndetics_summary get_syn
 use C4::Review;
 use C4::Serials;
 use C4::Members;
+use C4::VirtualShelves;
 use C4::XSLT;

 BEGIN {
@@ -266,6 +267,13 @@ $template->param(
     loggedincommenter   => $loggedincommenter
 );

+# Lists
+
+if (C4::Context->preference("virtualshelves") ) {
+   $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
+}
+
+
 # XISBN Stuff
 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
     eval {
-- 
1.5.6.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-Bug-1003-Added-lists-to-bib-details-pages.patch
Type: application/octet-stream
Size: 5635 bytes
Desc: not available
URL: </pipermail/koha-patches/attachments/20090828/eb1e49bb/attachment-0001.obj>


More information about the Koha-patches mailing list