Bug 8612: Use CSV profile for exporting basket
[srvgit] / tools / batch_record_modification.pl
index 3aec4f7..6ea0317 100755 (executable)
@@ -25,11 +25,11 @@ use List::MoreUtils qw( uniq );
 
 use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
-use C4::AuthoritiesMarc qw( BuildSummary GetAuthTypeCode ModAuthority );
+use C4::AuthoritiesMarc qw( BuildSummary ModAuthority );
 use C4::BackgroundJob;
 use C4::Biblio qw( GetMarcBiblio ModBiblio );
 use C4::MarcModificationTemplates qw( GetModificationTemplateActions GetModificationTemplates ModifyRecordWithTemplate );
-use Koha::Authority;
+use Koha::MetadataRecord::Authority;
 
 my $input = new CGI;
 our $dbh = C4::Context->dbh;
@@ -44,7 +44,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
         query => $input,
         type => "intranet",
         authnotrequired => 0,
-        flagsrequired => { tools => 'biblio_batchmod' },
+        flagsrequired => { tools => 'records_batchmod' },
 });
 
 
@@ -128,7 +128,7 @@ if ( $op eq 'form' ) {
             push @records, $biblio;
         } else {
             # Retrieve authority information
-            my $authority = Koha::Authority->get_from_authid( $record_id );
+            my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id );
             unless ( $authority ) {
                 push @messages, {
                     type => 'warning',
@@ -151,7 +151,7 @@ if ( $op eq 'form' ) {
     );
 } elsif ( $op eq 'modify' ) {
     # We want to modify selected records!
-    my @record_ids = $input->param('record_id');
+    my @record_ids = $input->multi_param('record_id');
 
     my ( $job );
     if ( $runinbackground ) {
@@ -167,7 +167,6 @@ if ( $op eq 'form' ) {
             exit 0;
         } elsif (defined $pid) {
             close STDOUT;
-            close STDERR;
         } else {
             warn "fork failed while attempting to run tools/batch_record_modification.pl as a background job";
             exit 0;
@@ -214,10 +213,10 @@ if ( $op eq 'form' ) {
             # Authorities
             my $authid = $record_id;
             my $error = eval {
-                my $authority = Koha::Authority->get_from_authid( $authid );
+                my $authority = Koha::MetadataRecord::Authority->get_from_authid( $authid );
                 my $record = $authority->record;
                 ModifyRecordWithTemplate( $mmtid, $record );
-                ModAuthority( $authid, $record, GetAuthTypeCode( $authid ) );
+                ModAuthority( $authid, $record, $authority->authtypecode );
             };
             if ( $error and $error != $authid or $@ ) {
                 push @messages, {