Skip to content

Commit

Permalink
Added ability to accept multiple articles in generic interface operat…
Browse files Browse the repository at this point in the history
…ions TicketCreate and TicketUpdate.
  • Loading branch information
Matthias Bethke committed Jun 19, 2024
1 parent 031c67d commit 6fb9f93
Show file tree
Hide file tree
Showing 6 changed files with 1,514 additions and 621 deletions.
2 changes: 1 addition & 1 deletion Kernel/GenericInterface/Operation/Ticket/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ sub SetDynamicFieldValue {
if ( !$ObjectID ) {
return {
Success => 0,
ErrorMessage => "SetDynamicFieldValue() Could not set $ObjectID!",
ErrorMessage => "SetDynamicFieldValue() Could not set ObjectID!",
};
}

Expand Down
62 changes: 13 additions & 49 deletions Kernel/GenericInterface/Operation/Ticket/TicketCreate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -512,39 +512,21 @@ sub Run {
}

# isolate Article parameter
my @Article;
my @Articles;
if ( IsHashRefWithData( $Param{Data}->{Article} ) ) {
push @Article, $Param{Data}->{Article};
push @Articles, $Param{Data}->{Article};
}
if ( IsArrayRefWithData( $Param{Data}->{Article} ) ) {
@Article = @{ $Param{Data}->{Article} };
else {
@Articles = @{ $Param{Data}->{Article} };
}

for my $Article (@Article) {
for my $Article (@Articles) {
$Article->{UserType} = $UserType;

# remove leading and trailing spaces
for my $Attribute ( sort keys %{$Article} ) {
if ( ref $Attribute ne 'HASH' && ref $Attribute ne 'ARRAY' ) {

#remove leading spaces
$Article->{$Attribute} =~ s{\A\s+}{};

#remove trailing spaces
$Article->{$Attribute} =~ s{\s+\z}{};
}
}
s{ (?: \A\s+ | \s+\z ) }{}gx for values %$Article;
if ( IsHashRefWithData( $Article->{OrigHeader} ) ) {
for my $Attribute ( sort keys %{ $Article->{OrigHeader} } ) {
if ( ref $Attribute ne 'HASH' && ref $Attribute ne 'ARRAY' ) {

#remove leading spaces
$Article->{OrigHeader}->{$Attribute} =~ s{\A\s+}{};

#remove trailing spaces
$Article->{OrigHeader}->{$Attribute} =~ s{\s+\z}{};
}
}
s{ (?: \A\s+ | \s+\z ) }{}gx for values %{ $Article->{OrigHeader} };
}

# Check attributes that can be set by sysconfig.
Expand Down Expand Up @@ -592,11 +574,11 @@ sub Run {
$DynamicField = $Param{Data}->{DynamicField};

# homogenate input to array
if ( ref $DynamicField eq 'HASH' ) {
push @DynamicFieldList, $DynamicField;
if ( ref $DynamicField eq 'ARRAY' ) {
@DynamicFieldList = @{$DynamicField};
}
else {
@DynamicFieldList = @{$DynamicField};
push @DynamicFieldList, $DynamicField;
}

# check DynamicField internal structure
Expand All @@ -610,16 +592,7 @@ sub Run {
}

# remove leading and trailing spaces
for my $Attribute ( sort keys %{$DynamicFieldItem} ) {
if ( ref $Attribute ne 'HASH' && ref $Attribute ne 'ARRAY' ) {

#remove leading spaces
$DynamicFieldItem->{$Attribute} =~ s{\A\s+}{};

#remove trailing spaces
$DynamicFieldItem->{$Attribute} =~ s{\s+\z}{};
}
}
s{ (?: \A\s+ | \s+\z ) }{}gx for values %{$DynamicFieldItem};

# check DynamicField attribute values
my $DynamicFieldCheck = $Self->_CheckDynamicField( DynamicField => $DynamicFieldItem );
Expand Down Expand Up @@ -657,16 +630,7 @@ sub Run {
}

# remove leading and trailing spaces
for my $Attribute ( sort keys %{$AttachmentItem} ) {
if ( ref $Attribute ne 'HASH' && ref $Attribute ne 'ARRAY' ) {

#remove leading spaces
$AttachmentItem->{$Attribute} =~ s{\A\s+}{};

#remove trailing spaces
$AttachmentItem->{$Attribute} =~ s{\s+\z}{};
}
}
s{ (?: \A\s+ | \s+\z ) }{}gx for values %{$AttachmentItem};

# check Attachment attribute values
my $AttachmentCheck = $Self->_CheckAttachment( Attachment => $AttachmentItem );
Expand All @@ -679,7 +643,7 @@ sub Run {

return $Self->_TicketCreate(
Ticket => $Ticket,
Article => \@Article,
Article => \@Articles,
DynamicFieldList => \@DynamicFieldList,
AttachmentList => \@AttachmentList,
UserID => $UserID,
Expand Down
Loading

0 comments on commit 6fb9f93

Please sign in to comment.