From 9bcb57e720d16810aa1d872ca5ab5bd792f2847b 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 (for prog and bootstrap): This patch should be applied on top of 9032 patches. Login as kohaadmin. Create a list in opac and staff. Check the message. Login as a normal user. Force a database error on list creation (I renamed category in the table with alter table change column..) You should have a different error message. Signed-off-by: Marcel de Rooy --- C4/VirtualShelves.pm | 1 + C4/VirtualShelves/Page.pm | 6 ++++-- .../prog/en/modules/virtualshelves/shelves.tt | 1 + .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 1 + .../opac-tmpl/prog/en/modules/opac-shelves.tt | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index f5a6758..863ca37 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..559bb15 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, { addshelf_failed => 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..4d8253e 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.addshelf_failed ) %]
List could not be created. [% IF loggedinuser==0 %](Do not use the database administrator account.)[% END %]
[% 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/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index d5ce5d7..fa20932 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -109,6 +109,7 @@ [% IF ( paramsloop ) %] [% FOREACH paramsloo IN paramsloop %] [% IF ( paramsloo.already ) %]
A list named [% paramsloo.already %] already exists!
[% END %] + [% IF ( paramsloo.addshelf_failed ) %]
List could not be created. [% IF loggedinuser==0 %](Do not use the database administrator account.)[% END %]
[% 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..658fe4e 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.addshelf_failed ) %]
List could not be created. [% IF loggedinuser==0 %](Do not use the database administrator account.)[% END %]
[% 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