From 85a71bad4e1e97d75c852abe4da7f1d8ca15743c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 27 Jan 2014 14:27:51 +0100 Subject: [PATCH] Beim CSV-Import die Session-Id der "auftraggebenden" Sitzung verwenden. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Damit kann der CSV-Import via Task-Server auch von Benutzern verwendet werden, die den Task-Server nicht in ihrer Sitzung gestartet haben. Es bleibt das Problem, dass der Import nicht ausgeführt werden kann, wenn sie sich abmelden. Behebt #2198. --- SL/BackgroundJob/CsvImport.pm | 5 +++-- SL/Controller/CsvImport.pm | 14 +++++++------- SL/SessionFile.pm | 4 ++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/SL/BackgroundJob/CsvImport.pm b/SL/BackgroundJob/CsvImport.pm index 7df8b9b47..b5e6f2908 100644 --- a/SL/BackgroundJob/CsvImport.pm +++ b/SL/BackgroundJob/CsvImport.pm @@ -82,8 +82,9 @@ sub do_import { ); $c->add_progress_tracker($self); + my $session_id = $job->data_as_hash->{session_id}; - $c->test_and_import(test => $test, session_id => $job->data_as_hash->{session_id}); + $c->test_and_import(test => $test, session_id => $session_id); if ($c->errors) { $job->set_data( @@ -91,7 +92,7 @@ sub do_import { )->save; } else { - my $report_id = $c->save_report; + my $report_id = $c->save_report(session_id => $session_id); $job->set_data(report_id => $report_id)->save; $c->track_progress(finished => 1); diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index 50b5e4d05..58715d308 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -414,17 +414,17 @@ sub char_map { } sub save_report { - my ($self, $report_id) = @_; + my ($self, %params) = @_; if ($self->worker->is_multiplexed) { - return $self->save_report_multi($report_id); + return $self->save_report_multi(%params); } else { - return $self->save_report_single($report_id); + return $self->save_report_single(%params); } } sub save_report_single { - my ($self, $report_id) = @_; + my ($self, %params) = @_; $self->track_progress(phase => 'building report', progress => 0); @@ -432,7 +432,7 @@ sub save_report_single { $clone_profile->save; # weird bug. if this isn't saved before adding it to the report, it will default back to the last profile. my $report = SL::DB::CsvImportReport->new( - session_id => $::auth->create_or_refresh_session, + session_id => $params{session_id}, profile => $clone_profile, type => $self->type, file => '', @@ -494,7 +494,7 @@ sub save_report_single { } sub save_report_multi { - my ($self, $report_id) = @_; + my ($self, %params) = @_; $self->track_progress(phase => 'building report', progress => 0); @@ -502,7 +502,7 @@ sub save_report_multi { $clone_profile->save; # weird bug. if this isn't saved before adding it to the report, it will default back to the last profile. my $report = SL::DB::CsvImportReport->new( - session_id => $::auth->create_or_refresh_session, + session_id => $params{session_id}, profile => $clone_profile, type => $self->type, file => '', diff --git a/SL/SessionFile.pm b/SL/SessionFile.pm index 08f905bc8..bf6c313dc 100644 --- a/SL/SessionFile.pm +++ b/SL/SessionFile.pm @@ -21,6 +21,10 @@ sub new { my $self = $class->SUPER::new; + if ($params{session_id}) { + $self->session_id($params{session_id}) + } + my $path = $self->prepare_path; $file_name =~ s:.*/::g; $file_name = "${path}/${file_name}"; -- 2.20.1