@@ -, +, @@ --- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 13 ++++++- opac/opac-shelves.pl | 45 ++++++++++++---------- 2 files changed, 36 insertions(+), 22 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -132,6 +132,8 @@ This item does not exist. [% CASE 'unauthorized_on_view' %] You do not have permission to view this list. + [% CASE 'unauthorized_on_insert' %] + You do not have permission to insert a new list. [% CASE 'unauthorized_on_update' %] You do not have permission to update this list. [% CASE 'unauthorized_on_delete' %] @@ -637,8 +639,15 @@
[% END %] -
New list
- [% IF shelves %] + [% IF loggedinusername %] +
New list
+ [% ELSE %] + [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] +
Log in to create new lists.
+ [% END %] + [% END %] + + [% IF shelves.count %] --- a/opac/opac-shelves.pl +++ a/opac/opac-shelves.pl @@ -63,27 +63,32 @@ if ( $op eq 'add_form' ) { push @messages, { type => 'error', code => 'does_not_exist' }; } } elsif ( $op eq 'add' ) { - eval { - $shelf = Koha::Virtualshelf->new( - { shelfname => $query->param('shelfname'), - sortfield => $query->param('sortfield'), - category => $query->param('category') || 1, - allow_add => $query->param('allow_add'), - allow_delete_own => $query->param('allow_delete_own'), - allow_delete_other => $query->param('allow_delete_other'), - owner => $query->param('owner'), - } - ); - $shelf->store; - $shelfnumber = $shelf->shelfnumber; - }; - if ($@) { - push @messages, { type => 'error', code => ref($@), msg => $@ }; - } elsif ( not $shelf ) { - push @messages, { type => 'error', code => 'error_on_insert' }; + if ( $loggedinuser ) { + eval { + $shelf = Koha::Virtualshelf->new( + { shelfname => $query->param('shelfname'), + sortfield => $query->param('sortfield'), + category => $query->param('category') || 1, + allow_add => $query->param('allow_add'), + allow_delete_own => $query->param('allow_delete_own'), + allow_delete_other => $query->param('allow_delete_other'), + owner => $loggedinuser, + } + ); + $shelf->store; + $shelfnumber = $shelf->shelfnumber; + }; + if ($@) { + push @messages, { type => 'error', code => ref($@), msg => $@ }; + } elsif ( not $shelf ) { + push @messages, { type => 'error', code => 'error_on_insert' }; + } else { + push @messages, { type => 'message', code => 'success_on_insert' }; + $op = 'view'; + } } else { - push @messages, { type => 'message', code => 'success_on_insert' }; - $op = 'view'; + push @messages, { type => 'error', code => 'unauthorized_on_insert' }; + $op = 'list'; } } elsif ( $op eq 'edit' ) { $shelfnumber = $query->param('shelfnumber'); --