diff options
author | ivan <ivan> | 2011-05-01 19:27:52 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-05-01 19:27:52 +0000 |
commit | 811c95da18776232da103fd445e2def019f98d5b (patch) | |
tree | 8aa6dae300f9717d7a9b0bbdd4cd07a77f8a900e /FS/FS/Record.pm | |
parent | ab1ec8c254827cee30244d79a3c4544bf6946abc (diff) |
cdr reimporting, RT#12181
Diffstat (limited to 'FS/FS/Record.pm')
-rw-r--r-- | FS/FS/Record.pm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 28d0d4f..3511fe7 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1633,6 +1633,8 @@ Class method for batch imports. Available params: =item fields - Alternate way to specify import, specifying import fields directly as a listref +=item preinsert_callback + =item postinsert_callback =item params @@ -1667,9 +1669,14 @@ sub batch_import { my( $type, $header, $sep_char, $fixedlength_format, $xml_format, $row_callback, @fields ); + my $postinsert_callback = ''; $postinsert_callback = $param->{'postinsert_callback'} if $param->{'postinsert_callback'}; + my $preinsert_callback = ''; + $preinsert_callback = $param->{'preinsert_callback'} + if $param->{'preinsert_callback'}; + if ( $param->{'format'} ) { my $format = $param->{'format'}; @@ -1917,6 +1924,16 @@ sub batch_import { } next if exists( $param->{skiprow} ); + if ( $preinsert_callback ) { + my $error = &{$postinsert_callback}($record, $param); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "preinsert_callback error". ( $line ? " for $line" : '' ). + ": $error"; + } + next if exists $param->{skiprow} && $param->{skiprow}; + } + my $error = $record->insert; if ( $error ) { |