# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
+use warnings;
+
use Carp;
use C4::Context;
use C4::Circulation;
&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);
($sortfield) = $sth2->fetchrow_array;
}
my $query =
- " SELECT vc.biblionumber, vc.shelfnumber, vc.dateadded,
- biblio.*, biblioitems.itemtype, itemtypes.*
+ " SELECT vc.biblionumber, vc.shelfnumber, vc.dateadded, itemtypes.*,
+ biblio.*, biblioitems.itemtype, biblioitems.publicationyear
FROM virtualshelfcontents vc
LEFT JOIN biblio ON vc.biblionumber = biblio.biblionumber
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
$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__