@@ -, +, @@ --- C4/ImportBatch.pm | 12 +++++++++++- Koha/BackgroundJob/BatchUpdateBiblio.pm | 17 +++++------------ tools/batch_record_modification.pl | 9 +++++++-- 3 files changed, 23 insertions(+), 15 deletions(-) --- a/C4/ImportBatch.pm +++ a/C4/ImportBatch.pm @@ -591,6 +591,10 @@ sub BatchCommitRecords { WHERE import_batch_id = ?"); $sth->execute($batch_id); my $marcflavour = C4::Context->preference('marcflavour'); + + my $userenv = C4::Context->userenv; + my $logged_in_patron = Koha::Patrons->find( $userenv->{number} ); + my $rec_num = 0; while (my $rowref = $sth->fetchrow_hashref) { $record_type = $rowref->{'record_type'}; @@ -664,7 +668,13 @@ sub BatchCommitRecords { } $oldxml = $old_marc->as_xml($marc_type); - ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode, {context => {source => 'batchimport'}}); + ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode, { + context => { + source => 'batchimport', + categorycode => $logged_in_patron->categorycode, + userid => $logged_in_patron->userid + }, + }); $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead if ($item_result eq 'create_new' || $item_result eq 'replace') { --- a/Koha/BackgroundJob/BatchUpdateBiblio.pm +++ a/Koha/BackgroundJob/BatchUpdateBiblio.pm @@ -88,13 +88,9 @@ sub process { my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); C4::MarcModificationTemplates::ModifyRecordWithTemplate( $mmtid, $record ); my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); - C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, - { - source => $args->{source}, - categorycode => $args->{categorycode}, - userid => $args->{userid}, - } - ); + C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, { + context => $args->{context}, + }); }; if ( $error and $error != 1 or $@ ) { # ModBiblio returns 1 if everything as gone well push @messages, { @@ -137,12 +133,9 @@ sub enqueue { return unless exists $args->{mmtid}; return unless exists $args->{record_ids}; - my $mmtid = $args->{mmtid}; - my @record_ids = @{ $args->{record_ids} }; - $self->SUPER::enqueue({ - job_size => scalar @record_ids, - job_args => {mmtid => $mmtid, record_ids => \@record_ids,} + job_size => scalar @{$args->{record_ids}}, + job_args => $args, }); } --- a/tools/batch_record_modification.pl +++ a/tools/batch_record_modification.pl @@ -150,15 +150,20 @@ if ( $op eq 'form' ) { my @record_ids = $input->multi_param('record_id'); try { + my $patron = Koha::Patrons->find( $loggedinuser ); my $params = { mmtid => $mmtid, record_ids => \@record_ids, + context => { + source => 'batchmod', + categorycode => $patron->categorycode, + userid => $patron->userid + } }; - my $patron = Koha::Patrons->find( $loggedinuser ); my $job_id = $recordtype eq 'biblio' - ? Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue($params, { source => 'batchmod', categorycode => $patron->categorycode, userid => $patron->userid }) + ? Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue($params) : Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue($params); $template->param( --