various virtual shelves/lists fixes
authorGalen Charlton <galen.charlton@liblime.com>
Sat, 16 Feb 2008 02:01:13 +0000 (15:01 +1300)
committerJoshua Ferraro <jmf@liblime.com>
Sat, 16 Feb 2008 17:29:18 +0000 (11:29 -0600)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/VirtualShelves.pm
C4/VirtualShelves/Page.pm
koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc
koha-tmpl/opac-tmpl/prog/en/js/basket.js

index f075c6f..159881c 100644 (file)
@@ -152,7 +152,18 @@ sub GetShelvesSummary {
        );
        my $sth = $dbh->prepare($query);
        $sth->execute($owner,$mincategory,$limit);
-    return $sth->fetchall_arrayref({});
+
+    my $shelves = $sth->fetchall_arrayref({});
+    # add private flag to each shelf entry --
+    # need to do this because HTML::Template::Pro's EXPR
+    # support complains about a non-initialized 'category'
+    # if the user has no shelves -- the offending line in
+    # masthead.inc was <-- TMPL_IF EXPR="category == 1"...
+    foreach my $shelf (@{ $shelves }) {
+        $shelf->{'private'} = ($shelf->{'category'} == 1);
+    }
+    return $shelves;
+
        # Probably NOT the final implementation since it is still bulky (repeated hash keys).
        # might like an array of rows of delimited values:
        # 1|2||0|blacklist|112
index 72db7f4..8aca409 100755 (executable)
@@ -23,10 +23,10 @@ package C4::VirtualShelves::Page;
 use strict;
 use warnings;
 use CGI;
-use C4::VirtualShelves;
+use C4::VirtualShelves qw/:DEFAULT GetShelvesSummary/;
 use C4::Biblio;
 use C4::Items;
-use C4::Auth;
+use C4::Auth qw/get_session/;
 use C4::Output;
 use Exporter;
 
@@ -121,7 +121,7 @@ SWITCH: {
                        );
                        $shelflist = GetShelves( $loggedinuser, 2 );    # refresh after mods
                } elsif ( $op eq 'modif' ) {
-                       my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) =GetShelf( $query->param('shelf') );
+                       my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) =GetShelf( $query->param('shelfnumber') );
                        $template->param(
                                edit                => 1,
                                shelfnumber         => $shelfnumber2,
@@ -155,7 +155,7 @@ SWITCH: {
         last SWITCH;
     }
     if ( $query->param('shelves') ) {
-               my $stay = 0;
+               my $stay = 1;
         if (my $newshelf = $query->param('addshelf')) {
                        # note: a user can always add a new shelf
             my $shelfnumber = AddShelf(
@@ -197,6 +197,7 @@ SWITCH: {
                        delete $shelflist->{$number};
                        push(@paramsloop, {delete_ok=>$name});
                        # print $query->redirect($pages{$type}->{redirect}); exit;
+                       $stay = 0;
                }
                $showadd = 1;
                $stay and $template->param(shelves => 1);
@@ -249,6 +250,13 @@ if ($template->param( 'shelves' ) or
        $template->param( seflag => 1);
 }
 
+my $sessionID = $query->cookie("CGISESSID") ;
+my $session = get_session($sessionID);
+my $shelves = GetShelvesSummary($loggedinuser, 2, 10);
+$session->param('shelves', $shelves);
+$template->param( barshelves     => scalar (@$shelves));
+$template->param( barshelvesloop => $shelves);
+
 output_html_with_http_headers $query, $cookie, $template->output;
 }      
 
index 0a63dca..69a2007 100644 (file)
@@ -81,7 +81,7 @@
                <!-- TMPL_IF NAME="barshelves" -->
                        <ul class="first-of-type">
                        <!-- TMPL_LOOP NAME="barshelvesloop" -->
-                       <!-- TMPL_IF EXPR="category != 1" --><li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname" --></a></li><!-- /TMPL_IF -->
+                       <!-- TMPL_UNLESS NAME="private" --><li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname" --></a></li><!-- /TMPL_UNLESS -->
                        <!-- /TMPL_LOOP -->
                        </ul>   
                <!-- /TMPL_IF -->
@@ -90,7 +90,7 @@
                <!-- TMPL_IF NAME="barshelves" -->
                        <ul class="first-of-type">
                        <!-- TMPL_LOOP NAME="barshelvesloop" -->
-                       <!-- TMPL_IF EXPR="category == 1" --><li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname" --></a></li><!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="private" --><li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname" --></a></li><!-- /TMPL_IF -->
                        <!-- /TMPL_LOOP -->
                        </ul>   
                <!-- /TMPL_IF -->
index 5505879..1b63038 100644 (file)
@@ -395,6 +395,10 @@ function vShelfAdd() {
                                 bibs.push("biblionumber=" +  document.bookbag_form.biblionumber[i].value);
                         }
                 }
-        return bibs.join("&");
+            return bibs.join("&");
+        } else {
+            if (document.bookbag_form.biblionumber.checked) {
+                return "biblionumber=" + document.bookbag_form.biblionumber.value;
+            }
         }
 }