Bug 14544: Get rid of GetBibliosShelves
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 6 Aug 2015 14:28:12 +0000 (15:28 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 5 Nov 2015 12:58:01 +0000 (09:58 -0300)
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

C4/VirtualShelves.pm
catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
opac/opac-detail.pl

index 5c072f9..252ca2e 100644 (file)
@@ -42,7 +42,6 @@ BEGIN {
     @EXPORT = qw(
             &GetShelves &GetShelfContents
             &ShelfPossibleAction
-            &GetBibliosShelves
     );
         @EXPORT_OK = qw(
             &ShelvesMax
@@ -333,26 +332,6 @@ sub ShelfPossibleAction {
     return 0;
 }
 
-=head2 GetBibliosShelves
-
-This finds all the public 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 
-        JOIN virtualshelfcontents vc ON (vs.shelfnumber= vc.shelfnumber) 
-        WHERE vs.category=2
-        AND vc.biblionumber= ?
-    ');
-    $sth->execute( $biblionumber );
-    return $sth->fetchall_arrayref({});
-}
-
 =head2 ShelvesMax
 
     $howmany= ShelvesMax($context);
index 30ce2c2..1989a7c 100755 (executable)
@@ -44,6 +44,8 @@ use C4::HTML5Media;
 use C4::CourseReserves qw(GetItemCourseReservesInfo);
 use C4::Acquisition qw(GetOrdersByBiblionumber);
 
+use Koha::Virtualshelves;
+
 my $query = CGI->new();
 
 my $analyze = $query->param('analyze');
@@ -377,7 +379,16 @@ $template->param(
 # Lists
 
 if (C4::Context->preference("virtualshelves") ) {
-   $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
+    my $shelves = Koha::Virtualshelves->search(
+        {
+            biblionumber => $biblionumber,
+            category => 2,
+        },
+        {
+            join => 'virtualshelfcontents',
+        }
+    );
+    $template->param( 'shelves' => $shelves );
 }
 
 # XISBN Stuff
index 7a78ae9..681629a 100644 (file)
@@ -357,10 +357,10 @@ function verify_images() {
     [% IF ( XSLTDetailsDisplay ) %]
         [% XSLTBloc %]
 
-        [% IF ( GetShelves ) %]
+        [% IF shelves %]
             <span class="results_summary"><span class="label">Lists that include this title: </span>
-            [% FOREACH GetShelve IN GetShelves %]
-                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% GetShelve.shelfnumber %]">[% GetShelve.shelfname %]</a>
+            [% FOREACH s IN shelves %]
+                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]">[% s.shelfname %]</a>
                 [% IF ( loop.last ) %][% ELSE %]|[% END %]
             [% END %]
             </span>
@@ -521,14 +521,14 @@ function verify_images() {
             </li>
         [% END %]
         <!--This grabs all of the lists a bib record appears in -->
-        [% IF ( GetShelves ) %]
-               <li><strong>Lists that include this title: </strong>
-               <ul>
-               [% FOREACH GetShelve IN GetShelves %]
-                <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% GetShelve.shelfnumber %]">[% GetShelve.shelfname %]</a></li>
-               [% END %]
-               </ul>
-               </li>
+        [% IF shelves %]
+            <li><strong>Lists that include this title: </strong>
+            <ul>
+            [% FOREACH s IN shelves %]
+                <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]">[% s.shelfname %]</a></li>
+            [% END %]
+            </ul>
+            </li>
         [% END %]
         [% IF ( TagsEnabled &&  TagsShowOnDetail &&  TagLoop ) %]
                 <li><strong>Tags:</strong>
index 1c36c06..cb0daa5 100644 (file)
                     [% END # / LibraryThingForLibrariesID %]
 
                     <!--This grabs all of the lists a bib record appears in -->
-                    [% IF ( GetShelves ) %]
+                    [% IF shelves %]
                         <span class="results_summary lists"><span class="label">List(s) this item appears in: </span>
-                        [% FOREACH GetShelve IN GetShelves %]
-                            <a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% GetShelve.shelfnumber %]">[% GetShelve.shelfname %]</a>
+                        [% FOREACH shelf IN shelves %]
+                            <a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelf.shelfnumber %]">[% shelf.shelfname %]</a>
                             [% IF ( loop.last ) %][% ELSE %]|[% END %]
                         [% END %]
                         </span>
-                    [% END # / GetShelves %]
+                    [% END %]
 
                     [% IF ( TagsShowEnabled ) %]
                         <div class="results_summary tags">
index 35ca0ca..e7a5626 100755 (executable)
@@ -53,6 +53,8 @@ use Koha::DateUtils;
 use C4::HTML5Media;
 use C4::CourseReserves qw(GetItemCourseReservesInfo);
 
+use Koha::Virtualshelves;
+
 BEGIN {
        if (C4::Context->preference('BakerTaylorEnabled')) {
                require C4::External::BakerTaylor;
@@ -844,12 +846,19 @@ $template->param(
 );
 
 # Lists
-
 if (C4::Context->preference("virtualshelves") ) {
-   $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
+    my $shelves = Koha::Virtualshelves->search(
+        {
+            biblionumber => $biblionumber,
+            category => 2,
+        },
+        {
+            join => 'virtualshelfcontents',
+        }
+    );
+    $template->param( shelves => $shelves );
 }
 
-
 # XISBN Stuff
 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
     eval {