From f7850ea5cfc3c206d0689d487491c094073e801d Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 16 Feb 2008 15:01:13 +1300 Subject: [PATCH] various virtual shelves/lists fixes Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/VirtualShelves.pm | 13 ++++++++++++- C4/VirtualShelves/Page.pm | 16 ++++++++++++---- .../opac-tmpl/prog/en/includes/masthead.inc | 4 ++-- koha-tmpl/opac-tmpl/prog/en/js/basket.js | 6 +++++- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index f075c6fdb9..159881cff5 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -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 diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index 72db7f4c10..8aca40921f 100755 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -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; } diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc index 0a63dca922..69a200793f 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -81,7 +81,7 @@ @@ -90,7 +90,7 @@ diff --git a/koha-tmpl/opac-tmpl/prog/en/js/basket.js b/koha-tmpl/opac-tmpl/prog/en/js/basket.js index 5505879b69..1b6303865a 100644 --- a/koha-tmpl/opac-tmpl/prog/en/js/basket.js +++ b/koha-tmpl/opac-tmpl/prog/en/js/basket.js @@ -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; + } } } -- 2.39.5