# user info
$template->param( loggedinusername => $user );
$template->param( sessionID => $sessionID );
- my $shelves;
- if ($shelves = C4::Context->get_shelves_userenv()) {
- $template->param( barshelves => scalar (@$shelves));
- $template->param( barshelvesloop => $shelves);
+
+ my ($pubshelves, $barshelves);
+ if (($pubshelves, $barshelves) = C4::Context->get_shelves_userenv()) {
+ $template->param( barshelves => scalar (@$barshelves));
+ $template->param( pubshelves => scalar (@$pubshelves));
+ $template->param( barshelvesloop => $barshelves);
+ $template->param( pubshelvesloop => $pubshelves);
}
$borrowernumber = getborrowernumber($user);
$template->param( js_widgets => $in->{'js_widgets'} );
$template->param( sessionID => $sessionID );
- my $shelves;
- if ($shelves = C4::Context->get_shelves_userenv()) {
- $template->param( barshelves => scalar (@$shelves));
- $template->param( barshelvesloop => $shelves);
+
+ my ($pubshelves); # an anonymous user has no 'barshelves'...
+ if (($pubshelves) = C4::Context->get_shelves_userenv()) {
+ $template->param( pubshelves => scalar (@$pubshelves));
+ $template->param( pubshelvesloop => $pubshelves);
}
+
}
if ( $in->{'type'} eq "intranet" ) {
# state variables
my $loggedin = 0;
my %info;
- my ( $userid, $cookie, $sessionID, $flags, $shelves );
+ my ( $userid, $cookie, $sessionID, $flags, $barshelves, $pubshelves );
my $logout = $query->param('logout.x');
if ( $userid = $ENV{'REMOTE_USER'} ) {
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('branchprinter')
);
- C4::Context::set_shelves_userenv($session->param('shelves'));
+ C4::Context::set_shelves_userenv('bar',$session->param('barshelves'));
+ C4::Context::set_shelves_userenv('pub',$session->param('pubshelves'));
$debug and printf STDERR "AUTH_SESSION: (%s)\t%s %s - %s\n", map {$session->param($_)} qw(cardnumber firstname surname branch) ;
$ip = $session->param('ip');
$lasttime = $session->param('lasttime');
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('branchprinter')
);
- $shelves = GetShelvesSummary($borrowernumber,2,10);
- $session->param('shelves', $shelves);
- C4::Context::set_shelves_userenv($shelves);
+
+ # Grab borrower's shelves and add to the session...
+ $barshelves = GetShelvesSummary($borrowernumber,2,10);
+ $session->param('barshelves', $barshelves);
+ C4::Context::set_shelves_userenv('bar',$barshelves);
+
+ # Grab the public shelves and add to the session...
+ $pubshelves = GetShelvesSummary(0,2,10);
+ $session->param('pubshelves', $pubshelves);
+ C4::Context::set_shelves_userenv('pub',$pubshelves);
}
else {
if ($userid) {
# if we are here this is an anonymous session; add public lists to it and a few other items...
# anonymous sessions are created only for the OPAC
$debug and warn "Initiating an anonymous session...";
- $shelves = GetShelvesSummary(0,2,10);
- $session->param('shelves', $shelves);
- C4::Context::set_shelves_userenv($shelves);
+
+ # Grab the public shelves and add to the session...
+ $pubshelves = GetShelvesSummary(0,2,10);
+ $session->param('pubshelves', $pubshelves);
+ C4::Context::set_shelves_userenv('pub',$pubshelves);
+
# setting a couple of other session vars...
$session->param('ip',$session->remote_addr());
$session->param('lasttime',time());
return $cell;
}
-sub set_shelves_userenv ($) {
- my $lists = shift or return undef;
+sub set_shelves_userenv ($$) {
+ my ($type, $shelves) = @_ or return undef;
my $activeuser = $context->{activeuser} or return undef;
- $context->{userenv}->{$activeuser}->{shelves} = $lists;
- # die "set_shelves_userenv: $lists";
+ $context->{userenv}->{$activeuser}->{barshelves} = $shelves if $type eq 'bar';
+ $context->{userenv}->{$activeuser}->{pubshelves} = $shelves if $type eq 'pub';
}
+
sub get_shelves_userenv () {
my $active;
unless ($active = $context->{userenv}->{$context->{activeuser}}) {
warn "get_shelves_userenv cannot retrieve context->{userenv}->{context->{activeuser}}";
return undef;
}
- my $lists = $active->{shelves} or return undef;# die "get_shelves_userenv: activeenv has no ->{shelves}";
- return $lists;
+ my $pubshelves = $active->{pubshelves} or undef;
+ my $barshelves = $active->{barshelves} or undef;# die "get_shelves_userenv: activeenv has no ->{shelves}";
+ return $pubshelves, $barshelves;
}
=item _new_userenv
});
$("span.clearall").html("<a id=\"CheckNone\" href=\"#\">Clear All</a>");
$("span.checkall").html("<a id=\"CheckAll\" href=\"#\">Select All</a>");
- $("span.addto").html("<label for=\"addto\">Add to: </label><select name=\"addto\" id=\"addto\"><option value=\"\"></option><!-- TMPL_IF name="opacbookbag" --><option value=\"addtocart\">Cart</option><!-- /TMPL_IF --><!-- TMPL_IF NAME="virtualshelves" --><!-- TMPL_IF NAME="loggedinusername" --><optgroup label=\"Lists:\"><!-- TMPL_IF NAME="barshelves" --><!-- TMPL_LOOP NAME="barshelvesloop" --><!-- TMPL_IF EXPR="category == 1" --><option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option><!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_IF --><option value=\"newlist\">[ New List ]</option></optgroup><!-- TMPL_ELSE --><option value=\"newlist\">List</option><!-- /TMPL_IF --><!-- /TMPL_IF --></select> <input type=\"submit\" class=\"submit\" value=\"Save\" />");
+ $("span.addto").html("<label for=\"addto\">Add to: </label><select name=\"addto\" id=\"addto\"><option value=\"\"></option><!-- TMPL_IF name="opacbookbag" --><option value=\"addtocart\">Cart</option><!-- /TMPL_IF --><!-- TMPL_IF NAME="virtualshelves" --><!-- TMPL_IF NAME="loggedinusername" --><optgroup label=\"Your Lists:\"><!-- TMPL_IF NAME="barshelves" --><!-- TMPL_LOOP NAME="barshelvesloop" --><!-- TMPL_IF EXPR="category == 1" --><option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option><!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_IF --></optgroup><optgroup label=\"Public Lists:\"><!-- TMPL_IF NAME="pubshelves" --><!-- TMPL_LOOP NAME="pubshelvesloop" --><option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option><!-- /TMPL_LOOP --><!-- /TMPL_IF --></optgroup><option value=\"newlist\">[ New List ]</option><!-- TMPL_ELSE --><optgroup label=\"Public Lists:\"><!-- TMPL_IF NAME="pubshelves" --><!-- TMPL_LOOP NAME="pubshelvesloop" --><option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option><!-- /TMPL_LOOP --><!-- /TMPL_IF --></optgroup><!-- /TMPL_IF --><!-- /TMPL_IF --></select> <input type=\"submit\" class=\"submit\" value=\"Save\" />");
$("#addto").change(function(){
cartList();
});
function cartList(){
if($("#addto").find("option:selected").attr("value") == "addtolist"){
var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
- <!-- TMPL_IF NAME="loggedinusername" -->if (vShelfAdd()) {
+ if (vShelfAdd()) {
Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?selectedshelf='+shelfnumber+'&' + vShelfAdd());
- }<!-- TMPL_ELSE --> alert('You must be logged in to create or add to Lists'); <!-- /TMPL_IF -->
+ }
return false;
} else if($("#addto").find("option:selected").attr("value") == "newlist"){
<!-- TMPL_IF NAME="loggedinusername" -->if (vShelfAdd()) {
use C4::Biblio;
use CGI;
use C4::VirtualShelves;
-# use C4::Circulation; # not really used
use C4::Auth;
use C4::Output;
$shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category ) if $newvirtualshelf;
+# verify user is authorized to perform the action on the shelf...
+my $authorized = 1 if ( (ShelfPossibleAction( $loggedinuser, $selectedshelf )) );
+
# multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
my $multiple = 0;
if ($shelfnumber && ($shelfnumber != -1)) {
for my $bib (@biblionumber){
&AddToShelfFromBiblio($bib,$shelfnumber);
- }
+ }
print $query->header;
print "<html><body onload=\"window.close();\"><div>Please close this window to continue.</div></body></html>";
exit;
multiple => (scalar(@biblios) > 1),
total => scalar @biblios,
biblios => \@biblios,
+ authorized => $authorized,
);
output_html_with_http_headers $query, $cookie, $template->output;