[otrs-cvs] ITSMConfigurationManagement/Kernel/Modules AgentITSMConfigItemEdit.pm, 1.32.2.1, 1.32.2.2
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/ITSMConfigurationManagement/Kernel/Modules
In directory lancelot:/tmp/cvs-serv31550/Kernel/Modules
Modified Files:
Tag: rel-3_1
AgentITSMConfigItemEdit.pm
Log Message:
Added new optional sysconfig option to check if config item names are unique.
Author: ub
Index: AgentITSMConfigItemEdit.pm
===================================================================
RCS file: /home/cvs/ITSMConfigurationManagement/Kernel/Modules/AgentITSMConfigItemEdit.pm,v
retrieving revision 1.32.2.1
retrieving revision 1.32.2.2
diff -2 -u -d -r1.32.2.1 -r1.32.2.2
--- AgentITSMConfigItemEdit.pm 30 Nov 2012 17:07:56 -0000 1.32.2.1
+++ AgentITSMConfigItemEdit.pm 30 Nov 2012 19:47:44 -0000 1.32.2.2
@@ -18,4 +18,5 @@
use Kernel::System::GeneralCatalog;
use Kernel::System::Web::UploadCache;
+use Kernel::System::VariableCheck qw(:all);
use vars qw($VERSION);
@@ -184,4 +185,5 @@
# get xml data
my $Version = {};
+ my $NameDuplicates;
if ( $Self->{Subaction} eq 'VersionSave' ) {
@@ -236,4 +238,42 @@
);
+ # check, whether the feature to check for a unique name is enabled
+ if (
+ IsStringWithData( $Version->{Name} )
+ && $Self->{ConfigObject}->Get('UniqueCIName::EnableUniquenessCheck')
+ )
+ {
+
+ if ( $Self->{ConfigObject}->{Debug} > 0 ) {
+ $Self->{LogObject}->Log(
+ Priority => 'debug',
+ Message => "Checking for duplicate names (ClassID: $ConfigItem->{ClassID}, "
+ . "Name: $Version->{Name}, ConfigItemID: $ConfigItem->{ConfigItemID})",
+ );
+ }
+
+ $NameDuplicates = $Self->{ConfigItemObject}->UniqueNameCheck(
+ ConfigItemID => $ConfigItem->{ConfigItemID},
+ ClassID => $ConfigItem->{ClassID},
+ Name => $Version->{Name},
+ );
+
+ # stop processing if the name is not unique
+ if ( IsArrayRefWithData($NameDuplicates) ) {
+
+ $AllRequired = 0;
+
+ # build a string of all duplicate IDs
+ my $NameDuplicatesString = join ', ', @{$NameDuplicates};
+
+ $Self->{LogObject}->Log(
+ Priority => 'error',
+ Message =>
+ "The name $Version->{Name} is already in use by the ConfigItemID(s): "
+ . $NameDuplicatesString,
+ );
+ }
+ }
+
# save version to database
if ( $SubmitSave && $AllRequired ) {
@@ -384,4 +424,9 @@
}
+ # check for name duplicates
+ if ( IsArrayRefWithData($NameDuplicates) ) {
+ $RowNameInvalid = 'ServerError';
+ }
+
# output name block
$Self->{LayoutObject}->Block(
@@ -393,4 +438,36 @@
);
+ if ( IsStringWithData($RowNameInvalid) && !IsArrayRefWithData($NameDuplicates) ) {
+
+ if ( $Self->{ConfigObject}->{Debug} > 0 ) {
+ $Self->{LogObject}->Log(
+ Priority => 'debug',
+ Message => "Rendering default error block",
+ );
+ }
+
+ $Self->{LayoutObject}->Block(
+ Name => 'RowNameErrorDefault',
+ );
+ }
+ elsif ( IsArrayRefWithData($NameDuplicates) ) {
+
+ my $DuplicateString = join ', ', @{$NameDuplicates};
+
+ if ( $Self->{ConfigObject}->{Debug} > 0 ) {
+ $Self->{LogObject}->Log(
+ Priority => 'debug',
+ Message => "Rendering block for duplicates (IDs: $DuplicateString) error message",
+ );
+ }
+
+ $Self->{LayoutObject}->Block(
+ Name => 'RowNameErrorDuplicates',
+ Data => {
+ Duplicates => $DuplicateString,
+ },
+ );
+ }
+
# get deployment state list
my $DeplStateList = $Self->{GeneralCatalogObject}->ItemList(
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log