[% END %]
- [% IF category == PRIVATE || Koha.Preference('OpacAllowPublicListCreation') %]
+ [% IF !public || Koha.Preference('OpacAllowPublicListCreation') %]
[% IF loggedinusername %]
[% ELSE %]
@@ -677,9 +675,9 @@
[% IF shelves.count %]
- [% IF category == PRIVATE %]
+ [% IF !public %]
Your lists
- [% ELSIF category == PUBLIC %]
+ [% ELSIF public %]
Public lists
[% END %]
@@ -707,7 +705,7 @@
[% IF s.can_be_managed( loggedinusernumber ) %]
[% pagination_bar | $raw %]
[% ELSE %]
- [% IF category == PUBLIC %]
+ [% IF public %]
No public lists.
[% ELSIF loggedinusernumber %]
No private lists.
@@ -1035,17 +1033,17 @@ function sortMenu( sorting_form ){
}
function AdjustRemark() {
- var category;
- if( $("#category").length > 0 ) {
- category = $("#category").val();
+ var public;
+ if( $("#public").length > 0 ) {
+ public = $("#public").val();
} else {
- category = "[% category | html %]";
+ public = "[% public | html %]";
}
var perms = $("#allow_changes_from").val();
if( perms < 2 ) {
$("#anyone_remark").hide();
- } else if( category==1 ) {
+ } else if( public==0 ) {
// If we move to Private (without shares), show Anyone remark
// Note: the number of shares is not tested real-time
[% IF !shelf.is_shared %]
--- a/opac/opac-shelves.pl
+++ a/opac/opac-shelves.pl
@@ -83,8 +83,8 @@ if (C4::Context->preference("BakerTaylorEnabled")) {
}
my $referer = $query->param('referer') || $op;
-my $category = 1;
-$category = 2 if $query->param('category') && $query->param('category') == 2;
+my $public = 0;
+$public = 1 if $query->param('public') && $query->param('public') == 1;
my ( $shelf, $shelfnumber, @messages );
@@ -96,7 +96,7 @@ if ( $op eq 'add_form' ) {
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ( $shelf ) {
- $category = $shelf->category;
+ $public = $shelf->public;
my $patron = Koha::Patrons->find( $shelf->owner );
$template->param( owner => $patron, );
unless ( $shelf->can_be_managed( $loggedinuser ) ) {
@@ -113,7 +113,7 @@ if ( $op eq 'add_form' ) {
$shelf = Koha::Virtualshelf->new(
{ shelfname => scalar $query->param('shelfname'),
sortfield => scalar $query->param('sortfield'),
- category => $category,
+ public => $public,
allow_change_from_owner => $allow_changes_from > 0,
allow_change_from_others => $allow_changes_from == ANYONE,
owner => scalar $loggedinuser,
@@ -147,7 +147,7 @@ if ( $op eq 'add_form' ) {
my $allow_changes_from = $query->param('allow_changes_from');
$shelf->allow_change_from_owner( $allow_changes_from > 0 );
$shelf->allow_change_from_others( $allow_changes_from == ANYONE );
- $shelf->category( $category );
+ $shelf->public( $public );
eval { $shelf->store };
if ($@) {
@@ -259,7 +259,7 @@ if ( $op eq 'view' ) {
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ( $shelf ) {
if ( $shelf->can_be_viewed( $loggedinuser ) ) {
- $category = $shelf->category;
+ $public = $shelf->public;
# Sortfield param may still include sort order with :asc or :desc, but direction overrides it
my( $sortfield, $direction );
@@ -424,7 +424,7 @@ if ( $op eq 'view' ) {
if ( $op eq 'list' ) {
my $shelves;
my ( $page, $rows ) = ( $query->param('page') || 1, 20 );
- if ( $category == 1 ) {
+ if ( !$public ) {
$shelves = Koha::Virtualshelves->get_private_shelves({ page => $page, rows => $rows, borrowernumber => $loggedinuser, });
} else {
$shelves = Koha::Virtualshelves->get_public_shelves({ page => $page, rows => $rows, });
@@ -435,7 +435,7 @@ if ( $op eq 'list' ) {
shelves => $shelves,
pagination_bar => pagination_bar(
q||, $pager->last_page - $pager->first_page + 1,
- $page, "page", { op => 'list', category => $category, }
+ $page, "page", { op => 'list', public => $public, }
),
);
}
@@ -445,7 +445,7 @@ $template->param(
referer => $referer,
shelf => $shelf,
messages => \@messages,
- category => $category,
+ public => $public,
print => scalar $query->param('print') || 0,
listsview => 1,
);
--- a/svc/virtualshelves/search
+++ a/svc/virtualshelves/search
@@ -22,7 +22,7 @@ my ($template, $user, $cookie) = get_template_and_user({
my $shelfname = $input->param('shelfname');
my $count = $input->param('count');
my $owner = $input->param('owner');
-my $type = $input->param('type');
+my $public = $input->param('public');
my $sortby = $input->param('sortby');
# variable information for DataTables (id)
@@ -36,10 +36,10 @@ foreach (grep {$_ =~ /^mDataProp/} keys %dt_params) {
my $results = C4::Utils::DataTables::VirtualShelves::search(
{
shelfname => $shelfname,
- count => $count,
- owner => $owner,
- type => $type,
- sortby => $sortby,
+ count => $count,
+ owner => $owner,
+ public => $public,
+ sortby => $sortby,
dt_params => \%dt_params,
}
);
--- a/t/db_dependent/Utils/Datatables_Virtualshelves.t
+++ a/t/db_dependent/Utils/Datatables_Virtualshelves.t
@@ -87,7 +87,7 @@ $john_smith{borrowernumber} = Koha::Patron->new( \%john_smith )->store->borrower
my $shelf1 = Koha::Virtualshelf->new(
{
shelfname => 'my first private list (empty)',
- category => 1, # private
+ public => 0,
sortfield => 'author',
owner => $john_doe{borrowernumber},
}
@@ -96,7 +96,7 @@ my $shelf1 = Koha::Virtualshelf->new(
my $shelf2 = Koha::Virtualshelf->new(
{
shelfname => 'my second private list',
- category => 1, # private
+ public => 0,
sortfield => 'title',
owner => $john_doe{borrowernumber},
}
@@ -115,7 +115,7 @@ $shelf2->add_biblio( $biblionumber5, $john_doe{borrowernumber} );
my $shelf3 = Koha::Virtualshelf->new(
{
shelfname => 'The first public list',
- category => 2, # public
+ public => 1,
sortfield => 'author',
owner => $jane_doe{borrowernumber},
}
@@ -130,7 +130,7 @@ $shelf3->add_biblio( $biblionumber8, $jane_doe{borrowernumber} );
my $shelf4 = Koha::Virtualshelf->new(
{
shelfname => 'my second public list',
- category => 2, # public
+ public => 1,
sortfield => 'title',
owner => $jane_doe{borrowernumber},
}
@@ -147,7 +147,7 @@ $shelf3->add_biblio( $biblionumber12, $jane_doe{borrowernumber} );
my $shelf5 = Koha::Virtualshelf->new(
{
shelfname => 'my third private list',
- category => 1, # private
+ public => 0,
sortfield => 'title',
owner => $jane_doe{borrowernumber},
}
@@ -169,7 +169,7 @@ for my $i ( 6 .. 15 ) {
Koha::Virtualshelf->new(
{
shelfname => "another public list $i",
- category => 2,
+ public => 1,
owner => $john_smith{borrowernumber},
}
)->store;
@@ -188,7 +188,7 @@ t::lib::Mocks::mock_userenv({ patron => $john_doe_patron });
$search_results = C4::Utils::DataTables::VirtualShelves::search({
shelfname => "ist",
dt_params => \%dt_params,
- type => 1,
+ public => 0,
});
is( $search_results->{ iTotalRecords }, 2,
@@ -203,7 +203,7 @@ is( @{ $search_results->{ shelves } }, 2,
# Search by type only
$search_results = C4::Utils::DataTables::VirtualShelves::search({
dt_params => \%dt_params,
- type => 2,
+ public => 1,
});
is( $search_results->{ iTotalRecords }, 12,
"There should be 12 public shelves in total" );
@@ -218,7 +218,7 @@ is( @{ $search_results->{ shelves } }, 10,
$search_results = C4::Utils::DataTables::VirtualShelves::search({
owner => "jane",
dt_params => \%dt_params,
- type => 2,
+ public => 1,
});
is( $search_results->{ iTotalRecords }, 12,
"There should be 12 public shelves in total" );
@@ -234,7 +234,7 @@ $search_results = C4::Utils::DataTables::VirtualShelves::search({
owner => "smith",
shelfname => "public list 1",
dt_params => \%dt_params,
- type => 2,
+ public => 1,
});
is( $search_results->{ iTotalRecords }, 12,
"There should be 12 public shelves in total" );
--- a/t/db_dependent/Virtualshelves.t
+++ a/t/db_dependent/Virtualshelves.t
@@ -34,7 +34,7 @@ subtest 'CRUD' => sub {
my $shelf = Koha::Virtualshelf->new({
shelfname => "my first shelf",
owner => $patron->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
@@ -61,7 +61,7 @@ subtest 'CRUD' => sub {
$shelf = Koha::Virtualshelf->new({
shelfname => "my first shelf",
owner => $patron->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
};
@@ -77,7 +77,7 @@ subtest 'CRUD' => sub {
$shelf = Koha::Virtualshelf->new({
shelfname => "my first shelf",
owner => $another_patron->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
$number_of_shelves = Koha::Virtualshelves->search->count;
@@ -109,14 +109,14 @@ subtest 'Sharing' => sub {
my $shelf_to_share = Koha::Virtualshelf->new({
shelfname => "my first shelf",
owner => $patron_wants_to_share->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
my $shelf_not_to_share = Koha::Virtualshelf->new({
shelfname => "my second shelf",
owner => $patron_wants_to_share->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
@@ -186,7 +186,7 @@ subtest 'Shelf content' => sub {
my $shelf = Koha::Virtualshelf->new(
{ shelfname => "my first shelf",
owner => $patron1->{borrowernumber},
- category => 1,
+ public => 0,
lastmodified => $dt_yesterday,
}
)->store;
@@ -263,7 +263,7 @@ subtest 'Shelf permissions' => sub {
my $public_shelf = Koha::Virtualshelf->new(
{ shelfname => "my first shelf",
owner => $patron1->{borrowernumber},
- category => 2,
+ public => 1,
allow_change_from_owner => 0,
allow_change_from_others => 0,
}
@@ -307,7 +307,7 @@ subtest 'Shelf permissions' => sub {
my $private_shelf = Koha::Virtualshelf->new(
{ shelfname => "my first shelf",
owner => $patron1->{borrowernumber},
- category => 1,
+ public => 0,
allow_change_from_owner => 0,
allow_change_from_others => 0,
}
@@ -363,31 +363,31 @@ subtest 'Get shelves' => sub {
my $private_shelf1_1 = Koha::Virtualshelf->new({
shelfname => "private shelf 1 for patron 1",
owner => $patron1->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
my $private_shelf1_2 = Koha::Virtualshelf->new({
shelfname => "private shelf 2 for patron 1",
owner => $patron1->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
my $private_shelf2_1 = Koha::Virtualshelf->new({
shelfname => "private shelf 1 for patron 2",
owner => $patron2->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
my $public_shelf1_1 = Koha::Virtualshelf->new({
shelfname => "public shelf 1 for patron 1",
owner => $patron1->{borrowernumber},
- category => 2,
+ public => 1,
}
)->store;
my $public_shelf1_2 = Koha::Virtualshelf->new({
shelfname => "public shelf 2 for patron 1",
owner => $patron1->{borrowernumber},
- category => 2,
+ public => 1,
}
)->store;
@@ -419,19 +419,19 @@ subtest 'Get shelves containing biblios' => sub {
my $shelf1 = Koha::Virtualshelf->new(
{ shelfname => "my first shelf",
owner => $patron1->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
my $shelf2 = Koha::Virtualshelf->new(
{ shelfname => "my x second shelf", # 'x' to make it sorted after 'third'
owner => $patron2->{borrowernumber},
- category => 1,
+ public => 0,
}
)->store;
my $shelf3 = Koha::Virtualshelf->new(
{ shelfname => "my third shelf",
owner => $patron1->{borrowernumber},
- category => 2,
+ public => 1,
}
)->store;
--- a/virtualshelves/shelves.pl
+++ a/virtualshelves/shelves.pl
@@ -52,9 +52,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
-my $op = $query->param('op') || 'list';
-my $referer = $query->param('referer') || $op;
-my $category = $query->param('category') || 1;
+my $op = $query->param('op') || 'list';
+my $referer = $query->param('referer') || $op;
+my $public = $query->param('public') ? 1 : 0;
my ( $shelf, $shelfnumber, @messages );
if ( $op eq 'add_form' ) {
@@ -65,7 +65,7 @@ if ( $op eq 'add_form' ) {
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ( $shelf ) {
- $category = $shelf->category;
+ $public = $shelf->public;
my $patron = Koha::Patrons->find( $shelf->owner )->unblessed;
$template->param( owner => $patron, );
unless ( $shelf->can_be_managed( $loggedinuser ) ) {
@@ -81,7 +81,7 @@ if ( $op eq 'add_form' ) {
$shelf = Koha::Virtualshelf->new(
{ shelfname => scalar $query->param('shelfname'),
sortfield => scalar $query->param('sortfield'),
- category => scalar $query->param('category'),
+ public => $public,
allow_change_from_owner => $allow_changes_from > 0,
allow_change_from_others => $allow_changes_from == ANYONE,
owner => scalar $query->param('owner'),
@@ -113,7 +113,7 @@ if ( $op eq 'add_form' ) {
my $allow_changes_from = $query->param('allow_changes_from');
$shelf->allow_change_from_owner( $allow_changes_from > 0 );
$shelf->allow_change_from_others( $allow_changes_from == ANYONE );
- $shelf->category( scalar $query->param('category') );
+ $shelf->public( scalar $query->param('public') );
eval { $shelf->store };
if ($@) {
@@ -310,14 +310,14 @@ if ( $op eq 'view' ) {
{
borrowernumber => $loggedinuser,
add_allowed => 1,
- category => 1,
+ public => 0,
}
);
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
{
borrowernumber => $loggedinuser,
add_allowed => 1,
- category => 2,
+ public => 1,
}
);
@@ -356,7 +356,7 @@ $template->param(
referer => $referer,
shelf => $shelf,
messages => \@messages,
- category => $category,
+ public => $public,
print => scalar $query->param('print') || 0,
csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
);
--