Skip to content

Commit

Permalink
Issue #2842: Introduce ACLs in Sets first stub.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven committed Feb 15, 2024
1 parent cf63b8d commit 62fd037
Show file tree
Hide file tree
Showing 3 changed files with 502 additions and 303 deletions.
62 changes: 62 additions & 0 deletions Kernel/Modules/AgentTicketPhone.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@ sub Run {
my %DynFieldStates = (
Visibility => {},
Fields => {},
Sets => {},
);

until ( $Convergence{Fields} ) {
Expand Down Expand Up @@ -2217,6 +2218,10 @@ sub Run {
%{ $DynFieldStates{Visibility} },
%{ $CurFieldStates{Visibility} },
};
$DynFieldStates{Sets} = {
%{ $DynFieldStates{Sets} },
%{ $CurFieldStates{Sets} },
};

# store new values
$GetParam{DynamicField} = {
Expand Down Expand Up @@ -2293,6 +2298,63 @@ sub Run {
};
}

for my $SetField ( values $DynFieldStates{Sets}->%* ) {
my $DynamicFieldConfig = $SetField->{DynamicFieldConfig};

# the frontend name is the name of the inner field including its index or the '_Template' suffix
DYNAMICFIELD:
for my $FrontendName ( keys $SetField->{FieldStates}->%* ) {

if ( $DynamicFieldConfig->{Config}{MultiValue} && ref $SetField->{Values}{$FrontendName} eq 'ARRAY' ) {
for my $i ( 0 .. $#{ $SetField->{Values}{$FrontendName} } ) {
my $DataValues = $SetField->{FieldStates}{$FrontendName}{NotACLReducible}
? $SetField->{Values}{$FrontendName}[$i]
:
(
$DynamicFieldBackendObject->BuildSelectionDataGet(
DynamicFieldConfig => $DynamicFieldConfig,
PossibleValues => $SetField->{FieldStates}{$FrontendName}{PossibleValues},
Value => [ $SetField->{Values}{$FrontendName}[$i] ],
)
|| $SetField->{FieldStates}{$FrontendName}{PossibleValues}
);

# add dynamic field to the list of fields to update
push @DynamicFieldAJAX, {
Name => 'DynamicField_' . $FrontendName . "_$i",
Data => $DataValues,
SelectedID => $SetField->{Values}{$FrontendName}[$i],
Translation => $DynamicFieldConfig->{Config}->{TranslatableValues} || 0,
Max => 100,
};
}

next DYNAMICFIELD;
}

my $DataValues = $SetField->{FieldStates}{$FrontendName}{NotACLReducible}
? $SetField->{Values}{$FrontendName}
:
(
$DynamicFieldBackendObject->BuildSelectionDataGet(
DynamicFieldConfig => $DynamicFieldConfig,
PossibleValues => $SetField->{FieldStates}{$FrontendName}{PossibleValues},
Value => $SetField->{Values}{$FrontendName},
)
|| $SetField->{FieldStates}{$FrontendName}{PossibleValues}
);

# add dynamic field to the list of fields to update
push @DynamicFieldAJAX, {
Name => 'DynamicField_' . $FrontendName,
Data => $DataValues,
SelectedID => $SetField->{Values}{$FrontendName},
Translation => $DynamicFieldConfig->{Config}->{TranslatableValues} || 0,
Max => 100,
};
}
}

if ( IsHashRefWithData( $DynFieldStates{Visibility} ) ) {
push @DynamicFieldAJAX, {
Name => 'Restrictions_Visibility',
Expand Down
Loading

0 comments on commit 62fd037

Please sign in to comment.