&ModShelf
&ShelfPossibleAction
&DelFromShelf &DelShelf
+ &GetBibliosShelves
);
@EXPORT_OK = qw(
&GetShelvesSummary &GetRecentShelves
my (@shelflist);
my $total = _shelf_count($owner, $mincategory);
my @params = ($owner, $mincategory, 0, $row_count); #FIXME: offset is hardcoded here, but could be passed in for enhancements
- shift @params if !$owner;
+ shift @params if (not defined $owner);
my $query = "SELECT * FROM virtualshelves";
- $query .= ($owner ? " WHERE owner = ? AND category = ?" : " WHERE category >= ? ");
+ $query .= ((defined $owner) ? " WHERE owner = ? AND category = ?" : " WHERE category >= ? ");
$query .= " ORDER BY lastmodified DESC LIMIT ?, ?";
my $sth = $dbh->prepare($query);
$sth->execute(@params);
$sth->execute($shelfnumber);
my ( $owner, $category ) = $sth->fetchrow;
my $borrower = GetMemberDetails($user);
+ return 0 if not defined($user);
return 1 if ( $category >= 3); # open list
return 1 if (($category >= 2) and
defined($action) and $action eq 'view'); # public list, anybody can view
return $sth->execute(shift);
}
+=item GetBibShelves
+
+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 != 1
+ AND vc.biblionumber= ?
+ ');
+ $sth->execute( $biblionumber );
+ return $sth->fetchall_arrayref({});
+}
+
=item RefreshShelvesSummary
($total, $pubshelves, $barshelves) = RefreshShelvesSummary($sessionID, $loggedinuser, $row_count);
return $total;
}
+sub _biblionumber_sth {
+ my ($shelf) = @_;
+ my $query = 'select biblionumber from virtualshelfcontents where shelfnumber = ?';
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare($query)
+ or die $dbh->errstr;
+ $sth->execute( $shelf )
+ or die $sth->errstr;
+ $sth;
+}
+
+sub each_biblionumbers (&$) {
+ my ($code,$shelf) = @_;
+ my $ref = _biblionumber_sth($shelf)->fetchall_arrayref;
+ map {
+ $_=$$_[0];
+ $code->();
+ } @$ref;
+}
+
1;
__END__