From 73b88b9738cf3116cb6a55126ae000b47e62dea8 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 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 Signed-off-by: Tomas Cohen Arazi --- Koha/Exceptions.pm | 4 ++++ Koha/Virtualshelf.pm | 4 ++++ .../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 f6534e050a..44092967cf 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 d80f2490a0..7ce2738a55 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 25159f1624..414342be2a 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 %] -- 2.39.5