From 42cb6220712a783e70f6904b64e3cdb6d410f668 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 3 Mar 2014 09:55:43 +0100 Subject: [PATCH] Bug 8262: Special kohaadmin cannot create lists Content-Type: text/plain; charset=utf-8 Since kohaadmin has no borrower number, it cannot create lists. A database error is logged, but the user is not notified. This patch alerts the user (kohaadmin). In the incidental case that a normal user gets a database error, he is notified too that the list could not be created. Test plan: This patch should be applied on top of 9032 patches. Login as kohaadmin under opac and staff. Create a list in opac and staff. Check the message. --- C4/VirtualShelves.pm | 1 + C4/VirtualShelves/Page.pm | 6 ++++-- .../prog/en/modules/virtualshelves/shelves.tt | 1 + .../opac-tmpl/prog/en/modules/opac-shelves.tt | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index 116b614..9547d02 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -334,6 +334,7 @@ sub AddShelf { $hashref->{allow_add}//0, $hashref->{allow_delete_own}//1, $hashref->{allow_delete_other}//0 ); + return if $sth->err; my $shelfnumber = $dbh->{'mysql_insertid'}; return $shelfnumber; } diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index 609dcca..dd46e61 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -337,7 +337,7 @@ sub shelfpage { #Add a shelf if ( my $newshelf = $query->param('addshelf') ) { - # note: a user can always add a new shelf + # note: a user can always add a new shelf (except kohaadmin) my $shelfnumber = AddShelf( { shelfname => $newshelf, sortfield => $query->param('sortfield'), @@ -348,7 +348,9 @@ sub shelfpage { }, $query->param('owner') ); $stay = 1; - if ( $shelfnumber == -1 ) { #shelf already exists. + if( !$shelfnumber ) { + push @paramsloop, { kohaadmin => 1 }; + } elsif ( $shelfnumber == -1 ) { #shelf already exists. $showadd = 1; push @paramsloop, { already => $newshelf }; $template->param( shelfnumber => $shelfnumber ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index b2db5e4..2d406f9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -228,6 +228,7 @@ function placeHold () {
[% IF ( paramsloo.already ) %]
A List named [% paramsloo.already %] already exists!
[% END %] + [% IF ( paramsloo.kohaadmin ) %]
List could not be created. (Do not use the special administrator account.)
[% END %] [% IF ( paramsloo.status ) %]
[% paramsloo.string %]
[% END %] [% IF ( paramsloo.nobarcode ) %]
ERROR: No barcode given.
[% END %] [% IF ( paramsloo.noshelfnumber ) %]
ERROR: No shelfnumber given.
[% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt index 5bbebca..0db4293 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt @@ -261,6 +261,7 @@ $(document).ready(function() {
[% IF ( paramsloo.already ) %]
A list named [% paramsloo.already %] already exists!
[% END %] + [% IF ( paramsloo.kohaadmin ) %]
List could not be created. (Do not use the special administrator account.)
[% END %] [% IF ( paramsloo.status ) %]
[% paramsloo.string %]
[% END %] [% IF ( paramsloo.nobarcode ) %]
ERROR: No barcode given.
[% END %] [% IF ( paramsloo.noshelfnumber ) %]
ERROR: No shelfnumber given.
[% END %] -- 1.7.7.6