Revision e41671e0
Von Sven Schöling vor mehr als 10 Jahren hinzugefügt
SL/Controller/CsvImport/Base.pm | ||
---|---|---|
221 | 221 |
bool => 'bool_value' ); |
222 | 222 |
|
223 | 223 |
my @cvars; |
224 |
my %changed_cvars; |
|
224 | 225 |
foreach my $config (@{ $self->all_cvar_configs }) { |
225 | 226 |
next unless exists $entry->{raw_data}->{ "cvar_" . $config->name }; |
226 | 227 |
my $value = $entry->{raw_data}->{ "cvar_" . $config->name }; |
227 | 228 |
my $column = $type_to_column{ $config->type } || die "Program logic error: unknown custom variable storage type"; |
228 | 229 |
|
229 |
push @cvars, SL::DB::CustomVariable->new(config_id => $config->id, $column => $value, sub_module => ''); |
|
230 |
my $new_cvar = SL::DB::CustomVariable->new(config_id => $config->id, $column => $value, sub_module => ''); |
|
231 |
|
|
232 |
push @cvars, $new_cvar; |
|
233 |
$changed_cvars{$config->name} = $new_cvar; |
|
230 | 234 |
} |
231 | 235 |
|
232 |
$entry->{object}->custom_variables(\@cvars); |
|
236 |
# merge existing with new cvars. swap every existing with the imported one, push the rest |
|
237 |
if (@cvars) { |
|
238 |
my @orig_cvars = ($entry->{object_to_save} || $entry->{object})->custom_variables; |
|
239 |
for (@orig_cvars) { |
|
240 |
$_ = $changed_cvars{ $_->config->name } if $changed_cvars{ $_->config->name }; |
|
241 |
delete $changed_cvars{ $_->config->name }; |
|
242 |
} |
|
243 |
push @orig_cvars, values %changed_cvars; |
|
244 |
|
|
245 |
$entry->{object}->custom_variables(\@orig_cvars); |
|
246 |
} |
|
233 | 247 |
} |
234 | 248 |
|
235 | 249 |
sub init_profile { |
Auch abrufbar als: Unified diff
CsvImport: Bei Imports ohne cvars nicht die cvars klobbern.