diff --git a/C4/Koha.pm b/C4/Koha.pm index 28ac1aa3b7..bb3efc7bc5 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -1486,9 +1486,7 @@ sub _isbn_cleanup { return; } -=head2 - - Log( $message ); +=head2 Log( $message ); Writes data to /tmp/koha.log. @@ -1499,9 +1497,10 @@ sub _isbn_cleanup { sub Log { my ($data) = @_; - open (MYFILE, '>>/tmp/koha.log'); - print MYFILE "$data\n"; - close (MYFILE); + warn $data; + open my $fh, '>>/tmp/koha.log'; + print $fh "$data\n"; + close $fh; } 1; diff --git a/C4/MarcModificationTemplates.pm b/C4/MarcModificationTemplates.pm index 2c8bbafe3b..8c9212f13c 100644 --- a/C4/MarcModificationTemplates.pm +++ b/C4/MarcModificationTemplates.pm @@ -35,24 +35,24 @@ use vars qw($VERSION @ISA @EXPORT); use constant DEBUG => 0; BEGIN { - $VERSION = 1.00; # set the version for version checking - @ISA = qw(Exporter); - @EXPORT = qw( - &GetModificationTemplates - &AddModificationTemplate - &DelModificationTemplate + $VERSION = 1.00; # set the version for version checking + @ISA = qw(Exporter); + @EXPORT = qw( + &GetModificationTemplates + &AddModificationTemplate + &DelModificationTemplate - &GetModificationTemplateAction - &GetModificationTemplateActions + &GetModificationTemplateAction + &GetModificationTemplateActions - &AddModificationTemplateAction - &ModModificationTemplateAction - &DelModificationTemplateAction - &MoveModificationTemplateAction + &AddModificationTemplateAction + &ModModificationTemplateAction + &DelModificationTemplateAction + &MoveModificationTemplateAction - &ModifyRecordsWithTemplate - &ModifyRecordWithTemplate - ); + &ModifyRecordsWithTemplate + &ModifyRecordWithTemplate + ); } @@ -529,6 +529,7 @@ sub ModifyRecordWithTemplate { $field_value =~ s/__CURRENTDATE__/$current_date/g; $field_value =~ s/__BRANCHCODE__/$branchcode/g; + $eval .= " undef, " if ( $action eq 'update_field' ); $eval .= " '$field_value' "; C4::Koha::Log( "Field value after replacements: $field_value" ) if ( DEBUG >= 3 ); @@ -563,7 +564,7 @@ sub ModifyRecordWithTemplate { C4::Koha::Log("eval $eval") if DEBUG >= 2; warn("eval $eval") if DEBUG >= 2; - eval $eval; + eval {$eval}; C4::Koha::Log( $record->as_formatted() ) if DEBUG >= 10; warn( $record->as_formatted() ) if DEBUG >= 10; diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm index 82abe00461..f72fc2f54c 100644 --- a/Koha/SimpleMARC.pm +++ b/Koha/SimpleMARC.pm @@ -60,7 +60,7 @@ at your option, any later version of Perl 5 you may have available. =head1 FUNCTIONS -=head2 +=head2 copy_field copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName[, $regex[, $n ] ] ); @@ -90,13 +90,13 @@ sub copy_field { } } - update_field( $record, $toFieldName, $toSubfieldName, @values, $dont_erase ); + update_field( $record, $toFieldName, $toSubfieldName, $dont_erase, @values ); } -=head2 +=head2 update_field - update_field( $record, $fieldName, $subfieldName, $value[, $value,[ $value ... ] ] ); + update_field( $record, $fieldName, $subfieldName, $dont_erase, $value[, $value,[ $value ... ] ] ); Updates a field with the given value, creating it if neccessary. @@ -109,8 +109,8 @@ sub copy_field { =cut sub update_field { - my ( $record, $fieldName, $subfieldName, @values, $dont_erase ) = @_; - C4::Koha::Log( "C4::SimpleMARC::update_field( $record, $fieldName, $subfieldName, @values )" ) if $debug; + my ( $record, $fieldName, $subfieldName, $dont_erase, @values ) = @_; + C4::Koha::Log( "C4::SimpleMARC::update_field( $record, $fieldName, $subfieldName, $dont_erase, @values )" ) if $debug; if ( ! ( $record && $fieldName ) ) { return; } @@ -157,7 +157,7 @@ sub update_field { } } -=head2 +=head2 read_field my @values = read_field( $record, $fieldName[, $subfieldName, [, $n ] ] ); @@ -174,7 +174,7 @@ sub read_field { my @fields = $record->field( $fieldName ); - return @fields unless $subfieldName; + return map { $_->data() } @fields unless $subfieldName; my @subfields; foreach my $field ( @fields ) { @@ -189,7 +189,7 @@ sub read_field { } } -=head2 +=head2 field_exists $bool = field_exists( $record, $fieldName[, $subfieldName ]); @@ -214,7 +214,7 @@ sub field_exists { return $return; } -=head2 +=head2 field_equals $bool = field_equals( $record, $value, $fieldName[, $subfieldName[, $regex [, $n ] ] ]); @@ -246,7 +246,7 @@ sub field_equals { } } -=head2 +=head2 move_field move_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName[, $regex [, $n ] ] ); @@ -262,11 +262,11 @@ sub field_equals { sub move_field { my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_; C4::Koha::Log( "C4::SimpleMARC::move_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug; - copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , "don't_erase"); + copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , 1); delete_field( $record, $fromFieldName, $fromSubfieldName, $n ); } -=head2 +=head2 delete_field delete_field( $record, $fieldName[, $subfieldName [, $n ] ] ); @@ -296,7 +296,7 @@ sub delete_field { } } -=head2 +=head2 _update_repeatable_field_with_single_value _update_repeatable_field_with_single_value( $record, $fieldName, $subfieldName, $value ); @@ -316,11 +316,11 @@ sub _update_repeatable_field_with_single_value { if ( $subfieldName ) { if ( my @fields = $record->field( $fieldName ) ) { foreach my $field ( @fields ) { - $field->update( "$subfieldName" => $value ); + $field->update( $subfieldName => $value ); } } else { ## Field does not exist, create it. - $field = MARC::Field->new( $fieldName, '', '', "$subfieldName" => $value ); + $field = MARC::Field->new( $fieldName, undef, undef, $subfieldName => $value ); $record->append_fields( $field ); } } else { ## No subfield diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc index 871803e7ca..45d9b4e2bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -72,7 +72,7 @@ [% END %] --> [% IF ( CAN_user_tools_marc_modification_templates ) %] -
| Change Order | -Order | -Action | -Description | -  | -  | -||
|---|---|---|---|---|---|---|---|
| Change Order | +Order | +Action | +Description | +  | +  | +||
-
-
-
+ [% FOREACH ActionsLoo IN ActionsLoop %]
+ | |||||||
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
- |
+
+ [% ActionsLoo.ordering %] | -- [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %] - [% IF ( ActionsLoo.action_update_field ) %] Update [% END %] - [% IF ( ActionsLoo.action_move_field ) %] Move [% END %] - [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %] + | [% ActionsLoo.ordering %] | ++ [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %] + [% IF ( ActionsLoo.action_update_field ) %] Update [% END %] + [% IF ( ActionsLoo.action_move_field ) %] Move [% END %] + [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %] - [% UNLESS ( ActionsLoo.action_update_field ) %] - [% IF ( ActionsLoo.field_number ) %] - 1st - [% END %] - [% END %] + [% UNLESS ( ActionsLoo.action_update_field ) %] + [% IF ( ActionsLoo.field_number ) %] + 1st + [% END %] + [% END %] - field + field - [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %] + [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %] - [% IF ( ActionsLoo.field_value ) %] - with value [% ActionsLoo.field_value %] - [% END %] + [% IF ( ActionsLoo.field_value ) %] + with value [% ActionsLoo.field_value %] + [% END %] - [% IF ( ActionsLoo.to_field ) %] - to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %] + [% IF ( ActionsLoo.to_field ) %] + to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %] - [% IF ( ActionsLoo.to_regex ) %] - using RegEx s[% ActionsLoo.to_regex %] - [% END %] - [% END %] + [% IF ( ActionsLoo.to_regex ) %] + using RegEx s[% ActionsLoo.to_regex %] + [% END %] + [% END %] - [% IF ( ActionsLoo.conditional ) %] - [% IF ( ActionsLoo.conditional_if ) %] if [% END %] - [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %] + [% IF ( ActionsLoo.conditional ) %] + [% IF ( ActionsLoo.conditional_if ) %] if [% END %] + [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %] - [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %] + [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %] - [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %] - [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %] - [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %] - [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %] + [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %] + [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %] + [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %] + [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %] - [% IF ( ActionsLoo.conditional_regex ) %] RegEx m[% END %][% ActionsLoo.conditional_value %] - [% END %] - | -[% ActionsLoo.description %] | -Edit | -Delete | -