@@ -, +, @@ --- C4/Utils/DataTables/VirtualShelves.pm | 3 +- C4/VirtualShelves.pm | 38 +--------------- .../en/modules/virtualshelves/addbybiblionumber.tt | 52 +++++++++++++--------- .../bootstrap/en/modules/opac-addbybiblionumber.tt | 20 ++++++--- opac/opac-addbybiblionumber.pl | 47 +++++++++++++------ opac/opac-shareshelf.pl | 1 + virtualshelves/addbybiblionumber.pl | 41 ++++++++++++++--- 7 files changed, 115 insertions(+), 87 deletions(-) --- a/C4/Utils/DataTables/VirtualShelves.pm +++ a/C4/Utils/DataTables/VirtualShelves.pm @@ -28,8 +28,7 @@ sub search { my $dbh = C4::Context->dbh; # FIXME refactore the following queries - # We should call C4::VirtualShelves::GetShelves and C4::VirtualShelves::GetAllShelves - # But the code is too dirty to refactor... + # We should call Koha::Virtualshelves my $select = q| SELECT vs.shelfnumber, vs.shelfname, vs.owner, vs.category AS type, vs.created_on, vs.lastmodified as modification_time, --- a/C4/VirtualShelves.pm +++ a/C4/VirtualShelves.pm @@ -47,7 +47,7 @@ BEGIN { &GetBibliosShelves ); @EXPORT_OK = qw( - &GetAllShelves &ShelvesMax + &ShelvesMax ); } @@ -136,42 +136,6 @@ sub GetShelves { return \%shelflist; } -=head2 GetAllShelves - - $shelflist = GetAllShelves($category, $owner) - -This function returns a reference to an array of hashrefs containing all shelves -sorted by the shelf name. - -This function is intended to return a dataset reflecting all the shelves for -the submitted parameters. - -=cut - -sub GetAllShelves { - my ($category,$owner,$adding_allowed) = @_; - my @params; - my $dbh = C4::Context->dbh; - my $query = 'SELECT vs.* FROM virtualshelves vs '; - if($category==1) { - $query.= qq{ - LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber - AND sh.borrowernumber=? - WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) }; - @params = ($owner, $owner, $owner); - } - else { - $query.='WHERE category=2 '; - @params = (); - } - $query.='AND (allow_add=1 OR owner=?) ' if $adding_allowed; - push @params, $owner if $adding_allowed; - $query.= 'ORDER BY shelfname ASC'; - my $sth = $dbh->prepare( $query ); - $sth->execute(@params); - return $sth->fetchall_arrayref({}); -} - =head2 GetSomeShelfNames Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header. --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tt @@ -38,28 +38,35 @@ [% UNLESS ( newshelf ) %]