From d5cbf2cd4c28d6db0a620b9f3f875c50ea591bfd Mon Sep 17 00:00:00 2001 From: Martin Stenberg Date: Mon, 26 Oct 2015 18:28:17 +0100 Subject: [PATCH] Bug 14957: Add filters to relevant scripts Add MARCPermissions filters in scripts which modifies MARC records to enable the permission system for these scripts. --- cataloguing/addbiblio.pl | 10 +++++++++- .../intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt | 2 ++ misc/migration_tools/bulkmarcimport.pl | 3 ++- misc/migration_tools/import_lexile.pl | 2 +- tools/batch_record_modification.pl | 13 ++++++++++--- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 4615998..fec551e 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -838,7 +838,14 @@ if ( $op eq "addbiblio" ) { } if ( $is_a_modif ) { ModBiblioframework( $biblionumber, $frameworkcode ); - ModBiblio( $record, $biblionumber, $frameworkcode ); + my ($member) = C4::Members::GetMember('borrowernumber' => $loggedinuser); + ModBiblio( $record, $biblionumber, $frameworkcode, + { + source => $z3950 ? 'z39.50' : 'intranet', + category => $member->{'category_type'}, + borrower => $loggedinuser + } + ); } else { ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); @@ -931,6 +938,7 @@ elsif ( $op eq "delete" ) { $template->param( biblionumberdata => $biblionumber, op => $op, + z3950 => $z3950 ); if ( $op eq "duplicate" ) { $biblionumber = ""; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 1aa98ed..922657f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -544,7 +544,9 @@ function Changefwk() { [% END %] + + diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index d007d29..93db2fa 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -417,7 +417,8 @@ RECORD: while ( ) { if ($biblionumber) { eval{$biblioitemnumber=GetBiblioData($biblionumber)->{biblioitemnumber};}; if ($update) { - eval { ( $biblionumber, $biblioitemnumber ) = ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber) ) }; + eval { ( $biblionumber, $biblioitemnumber ) = ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber), + { source => 'bulkmarcimport' }) }; if ($@) { warn "ERROR: Edit biblio $biblionumber failed: $@\n"; printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile); diff --git a/misc/migration_tools/import_lexile.pl b/misc/migration_tools/import_lexile.pl index e9fad46..a261e53 100755 --- a/misc/migration_tools/import_lexile.pl +++ b/misc/migration_tools/import_lexile.pl @@ -200,7 +200,7 @@ while ( my $row = $csv->getline_hr($fh) ) { $record->append_fields($field); } - ModBiblio( $record, $biblionumber ) unless ( $test ); + ModBiblio( $record, $biblionumber, {source => 'import_lexile'} ) unless ( $test ); } } diff --git a/tools/batch_record_modification.pl b/tools/batch_record_modification.pl index 6ea0317..9f31527 100755 --- a/tools/batch_record_modification.pl +++ b/tools/batch_record_modification.pl @@ -156,7 +156,7 @@ if ( $op eq 'form' ) { my ( $job ); if ( $runinbackground ) { my $job_size = scalar( @record_ids ); - $job = C4::BackgroundJob->new( $sessionID, "FIXME", '/cgi-bin/koha/tools/batch_record_modification.pl', $job_size ); + $job = C4::BackgroundJob->new( $sessionID, "FIXME", $ENV{SCRIPT_NAME}, $job_size ); my $job_id = $job->id; if (my $pid = fork) { $dbh->{InactiveDestroy} = 1; @@ -168,7 +168,7 @@ if ( $op eq 'form' ) { } elsif (defined $pid) { close STDOUT; } else { - warn "fork failed while attempting to run tools/batch_record_modification.pl as a background job"; + warn "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job"; exit 0; } } @@ -192,7 +192,14 @@ if ( $op eq 'form' ) { my $record = GetMarcBiblio( $biblionumber ); ModifyRecordWithTemplate( $mmtid, $record ); my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); - ModBiblio( $record, $biblionumber, $frameworkcode ); + my ($member) = C4::Members::GetMember('borrowernumber' => $loggedinuser); + ModBiblio( $record, $biblionumber, $frameworkcode, + { + source => 'batchmod', + category => $member->{'category_type'}, + borrower => $loggedinuser + } + ); }; if ( $error and $error != 1 or $@ ) { # ModBiblio returns 1 if everything as gone well push @messages, { -- 2.1.4