From 080c05eee2ca6ab6df250c7dd51e9ed3ac4b7684 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 3 Mar 2014 09:55:43 +0100 Subject: [PATCH] Bug 8262: explicitly warn that database admin account cannot create lists 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. In the incidental case that a normal user gets a database error, they are 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 as the database admin user * 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 Signed-off-by: Jesse Maseto Signed-off-by: Katrin Fischer Works as described, passes tests and QA script. Signed-off-by: Galen Charlton --- C4/VirtualShelves.pm | 1 + C4/VirtualShelves/Page.pm | 6 ++++-- .../intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt | 1 + koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 1 + koha-tmpl/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 e44f1f2206..70dc965755 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 609dcca48b..559bb1557f 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 4d2ffee185..453f108ba9 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 list number 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 8f2e1e2279..87223bb0cd 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 bb9b366e5c..359d81a65a 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 %] -- 2.39.5