return !$invalid;
}
+sub custom_variables_validity_by_trans_id {
+ $main::lxdebug->enter_sub(2);
+
+ my $self = shift;
+ my %params = @_;
+
+ return sub { 0 } unless $params{trans_id};
+
+ my $myconfig = \%main::myconfig;
+ my $form = $main::form;
+
+ my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
+
+ my $query = qq|SELECT config_id, COUNT(*) FROM custom_variables_validity WHERE trans_id = ? GROUP BY config_id|;
+
+ my %invalids = selectall_as_map($form, $dbh, $query, 'config_id', 'count', $params{trans_id});
+
+ $main::lxdebug->leave_sub(2);
+
+ return sub { !$invalids{+shift} };
+}
+
1;
__END__
my $form = $main::form;
$form->{CVAR_CONFIGS} ||= { };
- $form->{CVAR_CONFIGS}->{IC} = CVar->get_configs(module => 'IC');
+ $form->{CVAR_CONFIGS}->{IC} ||= CVar->get_configs(module => 'IC');
$main::lxdebug->leave_sub();
}
return;
}
+ my $valid = CVar->custom_variables_validity_by_trans_id(trans_id => $params{part_id});
+
my $num_visible_cvars = 0;
foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) {
- $cvar->{valid} = $params{part_id} &&
- CVar->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{part_id});
+ $cvar->{valid} = $params{part_id} && $valid->($cvar->{id});
my $description = '';
if ($cvar->{flag_editable} && $cvar->{valid}) {