From 55820d126e56904fee58a04be82548135683a5c1 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 21 Jan 2015 05:35:34 +0100 Subject: DefaultTo: Add TitleExistsCheck Add sub TitleExistsCheck to check if another DefaultTo entry exists with the given name. --- Kernel/System/DefaultTo.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Kernel/System/DefaultTo.pm b/Kernel/System/DefaultTo.pm index ef631cb..8ef9a1b 100644 --- a/Kernel/System/DefaultTo.pm +++ b/Kernel/System/DefaultTo.pm @@ -201,6 +201,27 @@ sub List { return %DefaultTo; } +sub TitleExistsCheck { + my ( $Self, %Param ) = @_; + + return if !$Self->{DBObject}->Prepare( + SQL => 'SELECT id FROM default_to WHERE title = ?', + Bind => [ \$Param{Title} ], + ); + + # fetch the result + my $Flag; + while ( my @Row = $Self->{DBObject}->FetchrowArray() ) { + if ( !$Param{ID} || $Param{ID} ne $Row[0] ) { + $Flag = 1; + } + } + if ($Flag) { + return 1; + } + return 0; +} + sub MappingAdd { my ( $Self, %Param ) = @_; -- cgit v1.2.3-1-g7c22