From fad828e9741a1a5e2ac6149b3572e55239271070 Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Wed, 2 Sep 2015 10:04:04 +0200 Subject: [PATCH] Bug 14544 - Handle database error when creating a shelf with DB admin account Content-Type: text/plain; charset=utf-8 Signed-off-by: Jonathan Druart I don't think this is useful, it will be a mess if we have to check this case everywhere. But it works! I let the cut to the QAer or RM. Signed-off-by: Marcel de Rooy --- Koha/Exceptions.pm | 4 ++++ Koha/Virtualshelf.pm | 4 ++++ koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt | 2 ++ 3 files changed, 10 insertions(+) diff --git a/Koha/Exceptions.pm b/Koha/Exceptions.pm index f6534e0..4409296 100644 --- a/Koha/Exceptions.pm +++ b/Koha/Exceptions.pm @@ -28,6 +28,10 @@ use Exception::Class ( 'Koha::Exceptions::Virtualshelves::ShareHasExpired' => { isa => 'Koha::Exceptions::Exception', description=> 'Cannot share this shelf, the share has expired', + }, + 'Koha::Exceptions::Virtualshelves::UseDbAdminAccount' => { + isa => 'Koha::Exceptions::Exception', + description => "Invalid use of database administrator account", } ); diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm index d80f249..7ce2738 100644 --- a/Koha/Virtualshelf.pm +++ b/Koha/Virtualshelf.pm @@ -51,6 +51,10 @@ our $PUBLIC = 2; sub store { my ( $self ) = @_; + unless ( $self->owner ) { + Koha::Exceptions::Virtualshelves::UseDbAdminAccount->throw; + } + unless ( $self->is_shelfname_valid ) { Koha::Exceptions::Virtualshelves::DuplicateObject->throw; } 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 44a2dae..546f4fa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -351,6 +351,8 @@ function placeHold () { No biblio has been removed. [% CASE 'Koha::Exceptions::Virtualshelves::DuplicateObject' %] An error occurred when inserting this list. The name already [% shelfname %] exists. + [% CASE 'Koha::Exceptions::Virtualshelves::UseDbAdminAccount' %] + List could not be created. (Do not use the database administrator account.). [% CASE 'DBIx::Class::Exception' %] [% m.msg %] [% CASE %] -- 1.7.10.4