View | Details | Raw Unified | Return to bug 8015
Collapse All | Expand All

(-)a/C4/Koha.pm (-1 / +1 lines)
Lines 1500-1506 sub _isbn_cleanup { Link Here
1500
sub Log {
1500
sub Log {
1501
  my ($data) = @_;
1501
  my ($data) = @_;
1502
  warn $data;
1502
  warn $data;
1503
  open my $fh, '>>/tmp/koha.log';
1503
  open my $fh, '>>', '/tmp/koha.log';
1504
  print $fh "$data\n";
1504
  print $fh "$data\n";
1505
  close $fh;
1505
  close $fh;
1506
}
1506
}
(-)a/C4/MarcModificationTemplates.pm (-104 / +145 lines)
Lines 1-29 Link Here
1
package C4::MarcModificationTemplates;
1
package C4::MarcModificationTemplates;
2
2
3
# Copyright 2010 Kyle M Hall <kyle.m.hall@gmail.com>
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright 2010 Kyle M Hall <kyle.m.hall@gmail.com>
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 2 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
## NOTE:
20
## NOTE:
21
## Parts of this module are used from cgi scripts that are detached from apache before
21
## Parts of this module are used from cgi scripts that are detached from apache before
22
## execution. For this reason, the C4::Koha::Log function has been used to capture
22
## execution. For this reason, the C4::Koha::Log function has been used to capture
23
## output for debugging purposes.
23
## output for debugging purposes.
24
24
25
use strict;
25
use Modern::Perl;
26
use warnings;
27
26
28
use DateTime;
27
use DateTime;
29
28
Lines 128-134 sub AddModificationTemplate { Link Here
128
        $action->{'field_value'},
127
        $action->{'field_value'},
129
        $action->{'to_field'},
128
        $action->{'to_field'},
130
        $action->{'to_subfield'},
129
        $action->{'to_subfield'},
131
        $action->{'to_regex'},
130
        $action->{'to_regex_search'},
131
        $action->{'to_regex_replace'},
132
        $action->{'to_regex_modifiers'},
132
        $action->{'conditional'},
133
        $action->{'conditional'},
133
        $action->{'conditional_field'},
134
        $action->{'conditional_field'},
134
        $action->{'conditional_subfield'},
135
        $action->{'conditional_subfield'},
Lines 156-164 sub DelModificationTemplate { Link Here
156
  my $dbh = C4::Context->dbh;
157
  my $dbh = C4::Context->dbh;
157
  my $sth = $dbh->prepare("DELETE FROM marc_modification_templates WHERE template_id = ?");
158
  my $sth = $dbh->prepare("DELETE FROM marc_modification_templates WHERE template_id = ?");
158
  $sth->execute( $template_id );
159
  $sth->execute( $template_id );
159
160
  $sth = $dbh->prepare("DELETE FROM marc_modification_template_actions WHERE template_id = ?");
161
  $sth->execute( $template_id );
162
}
160
}
163
161
164
=head2
162
=head2
Lines 211-217 sub GetModificationTemplateActions { Link Here
211
  AddModificationTemplateAction(
209
  AddModificationTemplateAction(
212
    $template_id, $action, $field_number,
210
    $template_id, $action, $field_number,
213
    $from_field, $from_subfield, $field_value,
211
    $from_field, $from_subfield, $field_value,
214
    $to_field, $to_subfield, $to_regex,
212
    $to_field, $to_subfield, $to_regex_search, $to_regex_replace, $to_regex_modifiers
215
    $conditional, $conditional_field, $conditional_subfield,
213
    $conditional, $conditional_field, $conditional_subfield,
216
    $conditional_comparison, $conditional_value,
214
    $conditional_comparison, $conditional_value,
217
    $conditional_regex, $description
215
    $conditional_regex, $description
Lines 231-237 sub AddModificationTemplateAction { Link Here
231
    $field_value,
229
    $field_value,
232
    $to_field,
230
    $to_field,
233
    $to_subfield,
231
    $to_subfield,
234
    $to_regex,
232
    $to_regex_search,
233
    $to_regex_replace,
234
    $to_regex_modifiers,
235
    $conditional,
235
    $conditional,
236
    $conditional_field,
236
    $conditional_field,
237
    $conditional_subfield,
237
    $conditional_subfield,
Lines 243-253 sub AddModificationTemplateAction { Link Here
243
243
244
  C4::Koha::Log( "C4::MarcModificationTemplates::AddModificationTemplateAction( $template_id, $action,
244
  C4::Koha::Log( "C4::MarcModificationTemplates::AddModificationTemplateAction( $template_id, $action,
245
                    $field_number, $from_field, $from_subfield, $field_value, $to_field, $to_subfield,
245
                    $field_number, $from_field, $from_subfield, $field_value, $to_field, $to_subfield,
246
                    $to_regex, $conditional, $conditional_field, $conditional_subfield, $conditional_comparison,
246
                    $to_regex_search, $to_regex_replace, $to_regex_modifiers, $conditional, $conditional_field, $conditional_subfield, $conditional_comparison,
247
                    $conditional_value, $conditional_regex, $description )" ) if DEBUG;
247
                    $conditional_value, $conditional_regex, $description )" ) if DEBUG;
248
  warn( "C4::MarcModificationTemplates::AddModificationTemplateAction( $template_id, $action,
248
  warn( "C4::MarcModificationTemplates::AddModificationTemplateAction( $template_id, $action,
249
                    $field_number, $from_field, $from_subfield, $field_value, $to_field, $to_subfield,
249
                    $field_number, $from_field, $from_subfield, $field_value, $to_field, $to_subfield,
250
                    $to_regex, $conditional, $conditional_field, $conditional_subfield, $conditional_comparison,
250
                    $to_regex_search, $to_regex_replace, $to_regex_modifiers, $conditional, $conditional_field, $conditional_subfield, $conditional_comparison,
251
                    $conditional_value, $conditional_regex, $description )" ) if DEBUG;
251
                    $conditional_value, $conditional_regex, $description )" ) if DEBUG;
252
252
253
  $conditional_regex ||= '0';
253
  $conditional_regex ||= '0';
Lines 270-276 sub AddModificationTemplateAction { Link Here
270
  field_value,
270
  field_value,
271
  to_field,
271
  to_field,
272
  to_subfield,
272
  to_subfield,
273
  to_regex,
273
  to_regex_search,
274
  to_regex_replace,
275
  to_regex_modifiers,
274
  conditional,
276
  conditional,
275
  conditional_field,
277
  conditional_field,
276
  conditional_subfield,
278
  conditional_subfield,
Lines 279-285 sub AddModificationTemplateAction { Link Here
279
  conditional_regex,
281
  conditional_regex,
280
  description
282
  description
281
  )
283
  )
282
  VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
284
  VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
283
285
284
  $sth = $dbh->prepare( $query );
286
  $sth = $dbh->prepare( $query );
285
287
Lines 293-299 sub AddModificationTemplateAction { Link Here
293
    $field_value,
295
    $field_value,
294
    $to_field,
296
    $to_field,
295
    $to_subfield,
297
    $to_subfield,
296
    $to_regex,
298
    $to_regex_search,
299
    $to_regex_replace,
300
    $to_regex_modifiers,
297
    $conditional,
301
    $conditional,
298
    $conditional_field,
302
    $conditional_field,
299
    $conditional_subfield,
303
    $conditional_subfield,
Lines 310-316 sub AddModificationTemplateAction { Link Here
310
  ModModificationTemplateAction(
314
  ModModificationTemplateAction(
311
    $mmta_id, $action, $field_number, $from_field,
315
    $mmta_id, $action, $field_number, $from_field,
312
    $from_subfield, $field_value, $to_field,
316
    $from_subfield, $field_value, $to_field,
313
    $to_subfield, $to_regex, $conditional,
317
    $to_subfield, $to_regex_search, $to_regex_replace, $to_regex_modifiers, $conditional,
314
    $conditional_field, $conditional_subfield,
318
    $conditional_field, $conditional_subfield,
315
    $conditional_comparison, $conditional_value,
319
    $conditional_comparison, $conditional_value,
316
    $conditional_regex, $description
320
    $conditional_regex, $description
Lines 330-336 sub ModModificationTemplateAction { Link Here
330
    $field_value,
334
    $field_value,
331
    $to_field,
335
    $to_field,
332
    $to_subfield,
336
    $to_subfield,
333
    $to_regex,
337
    $to_regex_search,
338
    $to_regex_replace,
339
    $to_regex_modifiers,
334
    $conditional,
340
    $conditional,
335
    $conditional_field,
341
    $conditional_field,
336
    $conditional_subfield,
342
    $conditional_subfield,
Lines 351-357 sub ModModificationTemplateAction { Link Here
351
  field_value = ?,
357
  field_value = ?,
352
  to_field = ?,
358
  to_field = ?,
353
  to_subfield = ?,
359
  to_subfield = ?,
354
  to_regex = ?,
360
  to_regex_search = ?,
361
  to_regex_replace = ?,
362
  to_regex_modifiers = ?,
355
  conditional = ?,
363
  conditional = ?,
356
  conditional_field = ?,
364
  conditional_field = ?,
357
  conditional_subfield = ?,
365
  conditional_subfield = ?,
Lines 371-377 sub ModModificationTemplateAction { Link Here
371
    $field_value,
379
    $field_value,
372
    $to_field,
380
    $to_field,
373
    $to_subfield,
381
    $to_subfield,
374
    $to_regex,
382
    $to_regex_search,
383
    $to_regex_replace,
384
    $to_regex_modifiers,
375
    $conditional,
385
    $conditional,
376
    $conditional_field,
386
    $conditional_field,
377
    $conditional_subfield,
387
    $conditional_subfield,
Lines 493-574 sub ModifyRecordsWithTemplate { Link Here
493
=cut
503
=cut
494
504
495
sub ModifyRecordWithTemplate {
505
sub ModifyRecordWithTemplate {
496
  my ( $template_id, $record ) = @_;
506
    my ( $template_id, $record ) = @_;
497
  C4::Koha::Log( "C4::MarcModificationTemplates::ModifyRecordWithTemplate( $template_id, $record )" ) if DEBUG;
507
    C4::Koha::Log( "C4::MarcModificationTemplates::ModifyRecordWithTemplate( $template_id, $record )" ) if DEBUG;
498
  warn( "C4::MarcModificationTemplates::ModifyRecordWithTemplate( $template_id, $record )" ) if DEBUG;
508
    warn( "C4::MarcModificationTemplates::ModifyRecordWithTemplate( $template_id, $record )" ) if DEBUG;
499
  C4::Koha::Log( "Unmodified Record:\n" . $record->as_formatted() ) if DEBUG >= 10;
509
    C4::Koha::Log( "Unmodified Record:\n" . $record->as_formatted() ) if DEBUG >= 10;
500
  warn( "Unmodified Record:\n" . $record->as_formatted() ) if DEBUG >= 10;
510
    warn( "Unmodified Record:\n" . $record->as_formatted() ) if DEBUG >= 10;
501
511
502
  my $current_date = DateTime->now()->ymd();
512
    my $current_date = DateTime->now()->ymd();
503
  my $branchcode = C4::Context->userenv->{branch};
513
    my $branchcode = C4::Context->userenv->{branch};
504
514
505
  my @actions = GetModificationTemplateActions( $template_id );
515
    my @actions = GetModificationTemplateActions( $template_id );
506
516
507
  foreach my $a ( @actions ) {
517
    foreach my $a ( @actions ) {
508
    my $action = $a->{'action'};
518
        my $action = $a->{'action'};
509
    my $field_number = $a->{'field_number'};
519
        my $field_number = $a->{'field_number'};
510
    my $from_field = $a->{'from_field'};
520
        my $from_field = $a->{'from_field'};
511
    my $from_subfield = $a->{'from_subfield'};
521
        my $from_subfield = $a->{'from_subfield'};
512
    my $field_value = $a->{'field_value'};
522
        my $field_value = $a->{'field_value'};
513
    my $to_field = $a->{'to_field'};
523
        my $to_field = $a->{'to_field'};
514
    my $to_subfield = $a->{'to_subfield'};
524
        my $to_subfield = $a->{'to_subfield'};
515
    my $to_regex = $a->{'to_regex'};
525
        my $to_regex_search = $a->{'to_regex_search'};
516
    my $conditional = $a->{'conditional'};
526
        my $to_regex_replace = $a->{'to_regex_replace'};
517
    my $conditional_field = $a->{'conditional_field'};
527
        my $to_regex_modifiers = $a->{'to_regex_modifiers'};
518
    my $conditional_subfield = $a->{'conditional_subfield'};
528
        my $conditional = $a->{'conditional'};
519
    my $conditional_comparison = $a->{'conditional_comparison'};
529
        my $conditional_field = $a->{'conditional_field'};
520
    my $conditional_value = $a->{'conditional_value'};
530
        my $conditional_subfield = $a->{'conditional_subfield'};
521
    my $conditional_regex = $a->{'conditional_regex'};
531
        my $conditional_comparison = $a->{'conditional_comparison'};
522
532
        my $conditional_value = $a->{'conditional_value'};
523
    my $eval = "$action( \$record, '$from_field', '$from_subfield', ";
533
        my $conditional_regex = $a->{'conditional_regex'};
524
534
525
    if ( $field_value ) {
535
        if ( $field_value ) {
526
      C4::Koha::Log( "Field value before replacements: $field_value" ) if ( DEBUG >= 3 );
536
            $field_value =~ s/__CURRENTDATE__/$current_date/g;
527
      warn( "Field value before replacements: $field_value" ) if ( DEBUG >= 3 );
537
            $field_value =~ s/__BRANCHCODE__/$branchcode/g;
528
538
        }
529
      $field_value =~ s/__CURRENTDATE__/$current_date/g;
539
530
      $field_value =~ s/__BRANCHCODE__/$branchcode/g;
540
        my @params = ( $record, $from_field, $from_subfield );
531
541
        if ( $action eq 'update_field' ) {
532
      $eval .= " undef, " if ( $action eq 'update_field' );
542
            push @params,
533
      $eval .= " '$field_value' ";
543
                ( $field_value
534
544
                    ? ( undef, $field_value )
535
      C4::Koha::Log( "Field value after replacements: $field_value" ) if ( DEBUG >= 3 );
545
                    : ()
536
      warn( "Field value after replacements: $field_value" ) if ( DEBUG >= 3 );
546
                );
537
    } elsif ( $to_field ) {
547
        } else {
538
      $eval .= " '$to_field', '$to_subfield', '$to_regex' ";
548
            push @params,
539
    }
549
                ( $field_value
540
550
                    ? $field_value
541
    $eval .= ", '$field_number' " if ( $field_number );
551
                    : ()
542
    $eval .= ') ';
552
                );
543
553
        }
544
    if ( $conditional ) {
554
        push @params, (
545
      $eval .= " $conditional ( ";
555
                ( ( not $field_value and $to_field )
546
556
                    ? ( $to_field, $to_subfield, { search => $to_regex_search, replace => $to_regex_replace, modifiers => $to_regex_modifiers} )
547
      if ( $conditional_comparison eq 'exists' ) {
557
                    : () ),
548
        $eval .= "field_exists( \$record, '$conditional_field', '$conditional_subfield' )";
558
                ( $field_number
549
559
                    ? $field_number
550
      } elsif ( $conditional_comparison eq 'not_exists' ) {
560
                    : () )
551
        $eval .= "!field_exists( \$record, '$conditional_field', '$conditional_subfield' )";
561
        );
552
562
553
      } elsif ( $conditional_comparison eq 'equals' ) {
563
        my $do = 1;
554
        $eval .= "field_equals( \$record, '$conditional_value', '$conditional_field', '$conditional_subfield', '$conditional_regex' ) ";
564
        if ( $conditional ) {
555
565
            for ( $conditional_comparison ) {
556
      } elsif ( $conditional_comparison eq 'not_equals' ) {
566
                when ( /^exists$/ ) {
557
        $eval .= "!field_equals( \$record, '$conditional_value', '$conditional_field', '$conditional_subfield', '$conditional_regex' ) ";
567
                    my $exists = field_exists( $record, $conditional_field, $conditional_subfield );
558
      }
568
                    $do = $conditional eq 'if'
559
569
                        ? $exists
560
      $eval .= " )";
570
                        : not $exists;
571
                }
572
                when ( /^not_exists$/ ) {
573
                    my $exists = field_exists( $record, $conditional_field, $conditional_subfield );
574
                    $do = $conditional eq 'if'
575
                        ? not $exists
576
                        : $exists;
577
                }
578
                when ( /^equals$/ ) {
579
                    my $equals = field_equals( $record, $conditional_value, $conditional_field, $conditional_subfield, $conditional_regex );
580
                    $do = $conditional eq 'if'
581
                        ? $equals
582
                        : not $equals;
583
                }
584
                when ( /^not_equals$/ ) {
585
                    my $equals = field_equals( $record, $conditional_value, $conditional_field, $conditional_subfield, $conditional_regex );
586
                    $do = $conditional eq 'if'
587
                        ? not $equals
588
                        : $equals;
589
                }
590
            }
591
        }
592
593
        if ( $do ) {
594
            for ( $action ) {
595
                when ( /^copy_field$/ ) {
596
                    copy_field( @params );
597
                }
598
                when ( /^update_field$/ ) {
599
                    update_field( @params );
600
                }
601
                when ( /^move_field$/ ) {
602
                    move_field( @params );
603
                }
604
                when ( /^delete_field$/ ) {
605
                    delete_field( @params );
606
                }
607
            }
608
        }
609
610
        C4::Koha::Log( $record->as_formatted() ) if DEBUG >= 10;
611
        warn( $record->as_formatted() ) if DEBUG >= 10;
561
    }
612
    }
562
563
    $eval .= ";";
564
565
    C4::Koha::Log("eval $eval") if DEBUG >= 2;
566
    warn("eval $eval") if DEBUG >= 2;
567
    eval {$eval};
568
    C4::Koha::Log( $record->as_formatted() ) if DEBUG >= 10;
569
    warn( $record->as_formatted() ) if DEBUG >= 10;
570
571
  }
572
}
613
}
573
1;
614
1;
574
__END__
615
__END__
(-)a/Koha/SimpleMARC.pm (-58 / +34 lines)
Lines 2-9 package Koha::SimpleMARC; Link Here
2
2
3
# Copyright 2009 Kyle M. Hall <kyle.m.hall@gmail.com>
3
# Copyright 2009 Kyle M. Hall <kyle.m.hall@gmail.com>
4
4
5
use strict;
5
use Modern::Perl;
6
use warnings;
7
6
8
#use MARC::Record;
7
#use MARC::Record;
9
8
Lines 66-72 at your option, any later version of Perl 5 you may have available. Link Here
66
65
67
  Copies a value from one field to another. If a regular expression ( $regex ) is supplied,
66
  Copies a value from one field to another. If a regular expression ( $regex ) is supplied,
68
  the value will be transformed by the given regex before being copied into the new field.
67
  the value will be transformed by the given regex before being copied into the new field.
69
  Example: $regex = 's/Old Text/Replacement Text/'
68
  Example: $regex = { search => 'Old Text', replace => 'Replacement Text', modifiers => 'g' };
70
69
71
  If $n is passed, copy_field will only copy the Nth field of the list of fields.
70
  If $n is passed, copy_field will only copy the Nth field of the list of fields.
72
  E.g. $n = 1 will only use the first field's value, $n = 2 will use only the 2nd field's value.
71
  E.g. $n = 1 will only use the first field's value, $n = 2 will use only the 2nd field's value.
Lines 83-97 sub copy_field { Link Here
83
  @values = ( $values[$n-1] ) if ( $n );
82
  @values = ( $values[$n-1] ) if ( $n );
84
  C4::Koha::Log( "@values = read_field( $record, $fromFieldName, $fromSubfieldName )" ) if $debug >= 3;
83
  C4::Koha::Log( "@values = read_field( $record, $fromFieldName, $fromSubfieldName )" ) if $debug >= 3;
85
84
86
  if ( $regex ) {
85
  if ( $regex and $regex->{search} ) {
86
    $regex->{modifiers} //= q||;
87
    my @available_modifiers = qw( i g );
88
    my $modifiers = q||;
89
    for my $modifier ( split //, $regex->{modifiers} ) {
90
        $modifiers .= $modifier
91
            if grep {/$modifier/} @available_modifiers;
92
    }
87
    foreach my $value ( @values ) {
93
    foreach my $value ( @values ) {
88
      C4::Koha::Log( "\$value =~ s$regex" ) if ( $debug >= 3 );
94
      C4::Koha::Log( "\$value =~ s/$regex->{search}/$regex->{replace}/$modifiers" ) if ( $debug >= 3 );
89
      eval "\$value =~ s$regex";
95
        for ( $modifiers ) {
96
          when ( /^(ig|gi)$/ ) {
97
            $value =~ s/$regex->{search}/$regex->{replace}/ig;
98
          }
99
          when ( /^i$/ ) {
100
            $value =~ s/$regex->{search}/$regex->{replace}/i;
101
          }
102
          when ( /^g$/ ) {
103
            $value =~ s/$regex->{search}/$regex->{replace}/g;
104
          }
105
          default {
106
            $value =~ s/$regex->{search}/$regex->{replace}/;
107
          }
108
      }
90
    }
109
    }
91
  }
110
  }
92
93
  update_field( $record, $toFieldName, $toSubfieldName, $dont_erase, @values );
111
  update_field( $record, $toFieldName, $toSubfieldName, $dont_erase, @values );
94
95
}
112
}
96
113
97
=head2 update_field
114
=head2 update_field
Lines 114-134 sub update_field { Link Here
114
131
115
  if ( ! ( $record && $fieldName ) ) { return; }
132
  if ( ! ( $record && $fieldName ) ) { return; }
116
133
117
  if ( @values eq 1 ) {
118
    _update_repeatable_field_with_single_value( $record, $fieldName, $subfieldName, @values );
119
    return;
120
  }
121
122
  my $i = 0;
134
  my $i = 0;
123
  my $field;
135
  my $field;
124
  if ( $subfieldName ) {
136
  if ( $subfieldName ) {
125
    if ( my @fields = $record->field( $fieldName ) ) {
137
    if ( my @fields = $record->field( $fieldName ) ) {
126
      unless ( $dont_erase ) {
138
      unless ( $dont_erase ) {
139
        @values = ($values[0]) x scalar( @fields )
140
          if @values == 1;
127
        foreach my $field ( @fields ) {
141
        foreach my $field ( @fields ) {
128
          $field->update( "$subfieldName" => $values[$i++] );
142
          $field->update( "$subfieldName" => $values[$i++] );
129
        }
143
        }
130
      }
144
      }
131
      if ( $i <= scalar @values - 1 ) {
145
      if ( $i <= scalar ( @values ) - 1 ) {
132
        foreach my $field ( @fields ) {
146
        foreach my $field ( @fields ) {
133
          foreach my $j ( $i .. scalar( @values ) - 1) {
147
          foreach my $j ( $i .. scalar( @values ) - 1) {
134
            $field->add_subfields( "$subfieldName" => $values[$j] );
148
            $field->add_subfields( "$subfieldName" => $values[$j] );
Lines 144-149 sub update_field { Link Here
144
    }
158
    }
145
  } else { ## No subfield
159
  } else { ## No subfield
146
    if ( my @fields = $record->field( $fieldName ) ) {
160
    if ( my @fields = $record->field( $fieldName ) ) {
161
      @values = ($values[0]) x scalar( @fields )
162
        if @values == 1;
147
      foreach my $field ( @fields ) {
163
      foreach my $field ( @fields ) {
148
        $field->update( $values[$i++] );
164
        $field->update( $values[$i++] );
149
      }
165
      }
Lines 221-227 sub field_exists { Link Here
221
  Returns true if the field equals the given value, false otherwise.
237
  Returns true if the field equals the given value, false otherwise.
222
238
223
  If a regular expression ( $regex ) is supplied, the value will be compared using
239
  If a regular expression ( $regex ) is supplied, the value will be compared using
224
  the given regex. Example: $regex = 'm/sought_text/'
240
  the given regex. Example: $regex = 'sought_text'
225
241
226
  If $n is passed, the Nth field of a repeatable series will be used for comparison.
242
  If $n is passed, the Nth field of a repeatable series will be used for comparison.
227
  Set $n to 1 or leave empty for a non-repeatable field.
243
  Set $n to 1 or leave empty for a non-repeatable field.
Lines 239-246 sub field_equals { Link Here
239
  my $field_value = $field_values[$n-1];
255
  my $field_value = $field_values[$n-1];
240
256
241
  if ( $regex ) {
257
  if ( $regex ) {
242
    C4::Koha::Log( "Testing '$field_value' =~ m$value" ) if $debug >= 3;
258
    C4::Koha::Log( "Testing '$field_value' =~ m/$value/" ) if $debug >= 3;
243
    return eval "\$field_value =~ m$value";
259
    return $field_value =~ m/$value/;
244
  } else {
260
  } else {
245
    return $field_value eq $value;
261
    return $field_value eq $value;
246
  }
262
  }
Lines 262-268 sub field_equals { Link Here
262
sub move_field {
278
sub move_field {
263
  my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_;
279
  my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_;
264
  C4::Koha::Log( "C4::SimpleMARC::move_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug;
280
  C4::Koha::Log( "C4::SimpleMARC::move_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug;
265
  copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , 1);
281
  copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , 'dont_erase' );
266
  delete_field( $record, $fromFieldName, $fromSubfieldName, $n );
282
  delete_field( $record, $fromFieldName, $fromSubfieldName, $n );
267
}
283
}
268
284
Lines 296-340 sub delete_field { Link Here
296
  }
312
  }
297
}
313
}
298
314
299
=head2 _update_repeatable_field_with_single_value
300
301
  _update_repeatable_field_with_single_value( $record, $fieldName, $subfieldName, $value );
302
303
  Updates a repeatable field, giving all existing copies of that field the given value.
304
305
  This is an internal function, and thus is not exported.
306
307
=cut
308
309
sub _update_repeatable_field_with_single_value {
310
  my ( $record, $fieldName, $subfieldName, $value ) = @_;
311
  C4::Koha::Log( "C4::SimpleMARC::_update_repeatable_field_with_single_value( $record, $fieldName, $subfieldName, $value )" ) if $debug;
312
313
  if ( ! ( $record && $fieldName ) ) { return; }
314
315
  my $field;
316
  if ( $subfieldName ) {
317
    if ( my @fields = $record->field( $fieldName ) ) {
318
      foreach my $field ( @fields ) {
319
        $field->update( $subfieldName => $value );
320
      }
321
    } else {
322
      ## Field does not exist, create it.
323
      $field = MARC::Field->new( $fieldName, undef, undef, $subfieldName => $value );
324
      $record->append_fields( $field );
325
    }
326
  } else { ## No subfield
327
    if ( my @fields = $record->field( $fieldName ) ) {
328
      foreach my $field ( @fields ) {
329
        $field->update( $value );
330
      }
331
    } else {
332
      ## Field does not exists, create it
333
      $field = MARC::Field->new( $fieldName, $value );
334
      $record->append_fields( $field );
335
    }
336
  }
337
}
338
339
1;
315
1;
340
__END__
316
__END__
(-)a/installer/data/mysql/kohastructure.sql (-2 / +5 lines)
Lines 3300-3306 CREATE TABLE IF NOT EXISTS marc_modification_template_actions ( Link Here
3300
  field_value varchar(100) DEFAULT NULL,
3300
  field_value varchar(100) DEFAULT NULL,
3301
  to_field varchar(3) DEFAULT NULL,
3301
  to_field varchar(3) DEFAULT NULL,
3302
  to_subfield varchar(1) DEFAULT NULL,
3302
  to_subfield varchar(1) DEFAULT NULL,
3303
  to_regex text,
3303
  to_regex_search text,
3304
  to_regex_replace text,
3305
  to_regex_modifiers varchar(8) DEFAULT '',
3304
  conditional enum('if','unless') DEFAULT NULL,
3306
  conditional enum('if','unless') DEFAULT NULL,
3305
  conditional_field varchar(3) DEFAULT NULL,
3307
  conditional_field varchar(3) DEFAULT NULL,
3306
  conditional_subfield varchar(1) DEFAULT NULL,
3308
  conditional_subfield varchar(1) DEFAULT NULL,
Lines 3308-3314 CREATE TABLE IF NOT EXISTS marc_modification_template_actions ( Link Here
3308
  conditional_value text,
3310
  conditional_value text,
3309
  conditional_regex tinyint(1) NOT NULL DEFAULT '0',
3311
  conditional_regex tinyint(1) NOT NULL DEFAULT '0',
3310
  description text,
3312
  description text,
3311
  PRIMARY KEY (mmta_id)
3313
  PRIMARY KEY (mmta_id),
3314
  CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
3312
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3315
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3313
3316
3314
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3317
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +5 lines)
Lines 7327-7333 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
7327
      field_value varchar(100) default NULL,
7327
      field_value varchar(100) default NULL,
7328
      to_field varchar(3) default NULL,
7328
      to_field varchar(3) default NULL,
7329
      to_subfield varchar(1) default NULL,
7329
      to_subfield varchar(1) default NULL,
7330
      to_regex text,
7330
      to_regex_search text,
7331
      to_regex_replace text,
7332
      to_regex_modifiers varchar(8) default '',
7331
      conditional enum('if','unless') default NULL,
7333
      conditional enum('if','unless') default NULL,
7332
      conditional_field varchar(3) default NULL,
7334
      conditional_field varchar(3) default NULL,
7333
      conditional_subfield varchar(1) default NULL,
7335
      conditional_subfield varchar(1) default NULL,
Lines 7335-7341 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
7335
      conditional_value text,
7337
      conditional_value text,
7336
      conditional_regex tinyint(1) NOT NULL default '0',
7338
      conditional_regex tinyint(1) NOT NULL default '0',
7337
      description text,
7339
      description text,
7338
      PRIMARY KEY  (mmta_id)
7340
      PRIMARY KEY  (mmta_id),
7341
      CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
7339
      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
7342
      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
7340
    ");
7343
    ");
7341
7344
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt (-18 / +30 lines)
Lines 9-14 $(document).ready(function() { Link Here
9
    $('#select_template').change(function() {
9
    $('#select_template').change(function() {
10
        $('#select_template').submit();
10
        $('#select_template').submit();
11
    });
11
    });
12
    $("span.match_regex_prefix" ).hide();
13
    $("span.match_regex_suffix" ).hide();
12
});
14
});
13
//]]>
15
//]]>
14
</script>
16
</script>
Lines 97-105 function onToFieldRegexChange( checkboxObj ) { Link Here
97
99
98
function onConditionalRegexChange( checkboxObj ) {
100
function onConditionalRegexChange( checkboxObj ) {
99
    if ( checkboxObj.checked ) {
101
    if ( checkboxObj.checked ) {
100
        document.getElementById( 'match_regex_prefix' ).style.visibility='visible';
102
        $("span.match_regex_prefix" ).show();
103
        $("span.match_regex_suffix" ).show();
101
    } else {
104
    } else {
102
        document.getElementById( 'match_regex_prefix' ).style.visibility='hidden';
105
        $("span.match_regex_prefix" ).hide();
106
        $("span.match_regex_suffix" ).hide();
103
    }
107
    }
104
}
108
}
105
109
Lines 145-151 var modaction_legend_innerhtml; Link Here
145
var action_submit_value;
149
var action_submit_value;
146
150
147
function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
151
function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
148
    to_subfield, to_regex, conditional, conditional_field, conditional_subfield,
152
    to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
149
    conditional_comparison, conditional_value, conditional_regex, description
153
    conditional_comparison, conditional_value, conditional_regex, description
150
) {
154
) {
151
    document.getElementById('mmta_id').value = mmta_id;
155
    document.getElementById('mmta_id').value = mmta_id;
Lines 160-168 function editAction( mmta_id, ordering, action, field_number, from_field, from_s Link Here
160
    document.getElementById('field_value').value = field_value;
164
    document.getElementById('field_value').value = field_value;
161
    document.getElementById('to_field').value = to_field;
165
    document.getElementById('to_field').value = to_field;
162
    document.getElementById('to_subfield').value = to_subfield;
166
    document.getElementById('to_subfield').value = to_subfield;
163
    document.getElementById('to_regex').value = to_regex;
167
    $("#to_regex_search").val(to_regex_search);
168
    $("#to_regex_replace").val(to_regex_replace);
169
    $("#to_regex_modifiers").val(to_regex_modifiers);
164
170
165
    document.getElementById('to_field_regex').checked = to_regex.length;
171
    document.getElementById('to_field_regex').checked = conditional_regex.length;
166
    document.getElementById('to_field_regex').onchange();
172
    document.getElementById('to_field_regex').onchange();
167
173
168
    setSelectByValue( 'conditional', conditional );
174
    setSelectByValue( 'conditional', conditional );
Lines 200-206 function cancelEditAction() { Link Here
200
    document.getElementById('field_value').value = '';
206
    document.getElementById('field_value').value = '';
201
    document.getElementById('to_field').value = '';
207
    document.getElementById('to_field').value = '';
202
    document.getElementById('to_subfield').value = '';
208
    document.getElementById('to_subfield').value = '';
203
    document.getElementById('to_regex').value = '';
209
    $("#to_regex_search").val("");
210
    $("#to_regex_replace").val("");
211
    $("#to_regex_modifiers").val("");
204
212
205
    document.getElementById('to_field_regex').checked = false;
213
    document.getElementById('to_field_regex').checked = false;
206
    document.getElementById('to_field_regex').onchange();
214
    document.getElementById('to_field_regex').onchange();
Lines 245-250 function setSelectByValue( selectId, value ) { Link Here
245
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; MARC modification templates</div>
253
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; MARC modification templates</div>
246
254
247
<div id="doc3" class="yui-t2">
255
<div id="doc3" class="yui-t2">
256
  <div id="bd">
248
    <div id="yui-main">
257
    <div id="yui-main">
249
        <div class="yui-b">
258
        <div class="yui-b">
250
            <h2>MARC modification templates</h2>
259
            <h2>MARC modification templates</h2>
Lines 290-308 function setSelectByValue( selectId, value ) { Link Here
290
                            <tr>
299
                            <tr>
291
                                <td style="white-space:nowrap;">
300
                                <td style="white-space:nowrap;">
292
                                    <a title="Move Action Up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
301
                                    <a title="Move Action Up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
293
                                    <img src="/intranet-tmpl/[% theme %]/img/go-up.png" border="0" alt="Go up" />
302
                                    <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
294
                                        </a>
303
                                        </a>
295
304
296
                                <a title="Move Action To Top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
305
                                <a title="Move Action To Top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
297
                                    <img src="/intranet-tmpl/[% theme %]/img/go-top.png" border="0" alt="Go top" />
306
                                    <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
298
                                        </a>
307
                                        </a>
299
308
300
                                        <a title="Move Action To Bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
309
                                        <a title="Move Action To Bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
301
                                    <img src="/intranet-tmpl/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
310
                                    <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
302
                                        </a>
311
                                        </a>
303
312
304
                                        <a title="Move Action Down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
313
                                        <a title="Move Action Down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
305
                                    <img src="/intranet-tmpl/[% theme %]/img/go-down.png" border="0" alt="Go down" />
314
                                    <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
306
                                        </a>
315
                                        </a>
307
                                </td>
316
                                </td>
308
317
Lines 330-337 function setSelectByValue( selectId, value ) { Link Here
330
                                    [% IF ( ActionsLoo.to_field ) %]
339
                                    [% IF ( ActionsLoo.to_field ) %]
331
                                        to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
340
                                        to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
332
341
333
                                        [% IF ( ActionsLoo.to_regex ) %]
342
                                        [% IF ( ActionsLoo.to_regex_search ) %]
334
                                             using RegEx s<strong>[% ActionsLoo.to_regex %]</strong>
343
                                             using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
335
                                        [% END %]
344
                                        [% END %]
336
                                    [% END %]
345
                                    [% END %]
337
346
Lines 346-352 function setSelectByValue( selectId, value ) { Link Here
346
                                        [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
355
                                        [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
347
                                        [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
356
                                        [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
348
357
349
                                        [% IF ( ActionsLoo.conditional_regex ) %] RegEx m[% END %]<strong>[% ActionsLoo.conditional_value %]</strong>
358
                                        [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]<strong>[% ActionsLoo.conditional_value %]/</strong>
350
                                    [% END %]
359
                                    [% END %]
351
                                </td>
360
                                </td>
352
                                <td>[% ActionsLoo.description %]</td>
361
                                <td>[% ActionsLoo.description %]</td>
Lines 360-366 function setSelectByValue( selectId, value ) { Link Here
360
                                                    "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
369
                                                    "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
361
                                                    "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
370
                                                    "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
362
                                                    "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
371
                                                    "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
363
                                                    "[% ActionsLoo.to_regex |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
372
                                                    "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
373
                                                    "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
374
                                                    "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
364
                                                    "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
375
                                                    "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
365
                                                    "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
376
                                                    "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
366
                                                    "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
377
                                                    "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
Lines 411-417 function setSelectByValue( selectId, value ) { Link Here
411
                                    <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
422
                                    <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
412
423
413
                                    <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
424
                                    <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
414
                                        s<input type="text" name="to_regex" id="to_regex" />
425
                                        s/<input type="text" name="to_regex_search" id="to_regex_search" placeholder="regex pattern" />/<input type="text" name="to_regex_replace" id="to_regex_replace" placeholder="regex replacement" />/<input type="text" name="to_regex_modifiers" id="to_regex_modifiers" placeholder="ig" size="3" />
415
                                    </span>
426
                                    </span>
416
                                </sup>
427
                                </sup>
417
                            </span>
428
                            </span>
Lines 438-444 function setSelectByValue( selectId, value ) { Link Here
438
449
439
                            <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
450
                            <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
440
451
441
                                <span id="match_regex_prefix" style="visibility:hidden;">m</span><input type="text" id="conditional_value" name="conditional_value" />
452
                                <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
442
453
443
                                <sup>
454
                                <sup>
444
                                    <label for="conditional_regex">RegEx</label>
455
                                    <label for="conditional_regex">RegEx</label>
Lines 470-477 function setSelectByValue( selectId, value ) { Link Here
470
                <fieldset>
481
                <fieldset>
471
                    <legend>Create a new template</legend>
482
                    <legend>Create a new template</legend>
472
483
473
                    <label for="template_name">Name: </label>
484
                    <label for="template_name" class="required">Name: </label>
474
                    <input name="template_name" id="template_name" type="text" size="30" />
485
                    <input name="template_name" id="template_name" type="text" size="30" required="required" />
475
486
476
                    <input type="hidden" name="op" value="create_template" />
487
                    <input type="hidden" name="op" value="create_template" />
477
                    <input type="submit" value="Create template" />
488
                    <input type="submit" value="Create template" />
Lines 489-493 function setSelectByValue( selectId, value ) { Link Here
489
    <div class="yui-b">
500
    <div class="yui-b">
490
        [% INCLUDE 'tools-menu.inc' %]
501
        [% INCLUDE 'tools-menu.inc' %]
491
    </div>
502
    </div>
503
  </div>
492
</div>
504
</div>
493
[% INCLUDE 'intranet-bottom.inc' %]
505
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/t/SimpleMARC.t (+199 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
use Test::More tests => 37;
4
5
use_ok("MARC::Field");
6
use_ok("MARC::Record");
7
use_ok("Koha::SimpleMARC");
8
9
sub new_record {
10
    my $record = MARC::Record->new;
11
    $record->leader('03174nam a2200445 a 4500');
12
    my @fields = (
13
        MARC::Field->new(
14
            100, '1', ' ',
15
            a => 'Knuth, Donald Ervin',
16
            d => '1938',
17
        ),
18
        MARC::Field->new(
19
            245, '1', '4',
20
            a => 'The art of computer programming',
21
            c => 'Donald E. Knuth.',
22
        ),
23
        MARC::Field->new(
24
            650, ' ', '0',
25
            a => 'Computer programming.',
26
            9 => '462',
27
        ),
28
        MARC::Field->new(
29
            952, ' ', ' ',
30
            p => '3010023917',
31
            y => 'BK',
32
            c => 'GEN',
33
            d => '2001-06-25',
34
        ),
35
    );
36
    $record->append_fields(@fields);
37
    return $record;
38
}
39
40
my $record = new_record;
41
42
# field_exists
43
is( field_exists( $record, '650', 'a'), 'Computer programming.', '650$a exists' );
44
is( field_exists( $record, '650', 'b'), undef, '650$b does not exist' );
45
46
$record->append_fields(
47
    MARC::Field->new(
48
        650, ' ', '0',
49
        a => 'Computer algorithms.',
50
        9 => '463',
51
    )
52
);
53
54
is( field_exists( $record, '650', 'a'), 'Computer programming.', '650$a exists, field_exists returns the first one' );
55
56
# read_field
57
my @fields_650a = read_field( $record, '650', 'a');
58
is( $fields_650a[0], 'Computer programming.', 'first 650$a' );
59
is( $fields_650a[1], 'Computer algorithms.', 'second 650$a' );
60
is( read_field( $record, '650', 'a', 1 ), 'Computer programming.', 'first 650$a bis' );
61
is( read_field( $record, '650', 'a', 2 ), 'Computer algorithms.', 'second 650$a bis' );
62
is( read_field( $record, '650', 'a', 3 ), undef, 'There is no 3 650$a' );
63
64
# copy_field
65
copy_field( $record, '245', 'a', '246', 'a' );
66
is_deeply( read_field( $record, '245', 'a' ), 'The art of computer programming', 'After copy 245$a still exists' );
67
is_deeply( read_field( $record, '246', 'a' ), 'The art of computer programming', '246$a is a new field' );
68
delete_field( $record, '246' );
69
is( field_exists( $record, '246', 'a', '246$a does not exist anymore' ), undef );
70
71
copy_field( $record, '650', 'a', '651', 'a' );
72
my @fields_651a = read_field( $record, '651', 'a' );
73
is_deeply( \@fields_651a, ['Computer programming.', 'Computer algorithms.'], 'Copy multivalued field' );
74
delete_field( $record, '651' );
75
76
copy_field( $record, '650', 'a', '651', 'a', undef, 1 );
77
@fields_651a = read_field( $record, '651', 'a' );
78
is_deeply( read_field( $record, '651', 'a' ), 'Computer programming.', 'Copy first field 650$a' );
79
delete_field( $record, '651' );
80
81
copy_field( $record, '650', 'a', '651', 'a', undef, 2 );
82
@fields_651a = read_field( $record, '651', 'a' );
83
is_deeply( read_field( $record, '651', 'a' ), 'Computer algorithms.', 'Copy second field 650$a' );
84
delete_field( $record, '651' );
85
86
copy_field( $record, '650', 'a', '651', 'a', { search => 'Computer', replace => 'The art of' } );
87
@fields_651a = read_field( $record, '651', 'a' );
88
is_deeply( \@fields_651a, ['The art of programming.', 'The art of algorithms.'], 'Copy field using regex' );
89
90
copy_field( $record, '650', 'a', '651', 'a', { search => 'Computer', replace => 'The mistake of' } );
91
@fields_651a = read_field( $record, '651', 'a' );
92
is_deeply( \@fields_651a, ['The mistake of programming.', 'The mistake of algorithms.'], 'Copy fields using regex on existing fields' );
93
delete_field( $record, '651' );
94
95
copy_field( $record, '650', 'a', '651', 'a', { search => 'Computer', replace => 'The art of' } );
96
copy_field( $record, '650', 'a', '651', 'a', { search => 'Computer', replace => 'The mistake of' }, 1, "dont_erase" );
97
@fields_651a = read_field( $record, '651', 'a' );
98
is_deeply( \@fields_651a, [
99
    'The art of programming.',
100
    'The mistake of programming.',
101
    'The art of algorithms.',
102
    'The mistake of programming.'
103
], 'Copy first field using regex on existing fields without erase existing values' );
104
delete_field( $record, '651' );
105
106
copy_field( $record, '650', 'a', '651', 'a', { search => 'Computer', replace => 'The art of' } );
107
copy_field( $record, '650', 'a', '651', 'a', { search => 'Computer', replace => 'The mistake of' }, undef , "dont_erase" );
108
@fields_651a = read_field( $record, '651', 'a' );
109
is_deeply( \@fields_651a, [
110
    'The art of programming.',
111
    'The mistake of programming.',
112
    'The mistake of algorithms.',
113
    'The art of algorithms.',
114
    'The mistake of programming.',
115
    'The mistake of algorithms.'
116
], 'Copy fields using regex on existing fields without erase existing values' );
117
delete_field( $record, '651' );
118
119
# Copy with regex modifiers
120
copy_field( $record, '650', 'a', '652', 'a', { search => 'o', replace => 'foo' } );
121
my @fields_652a = read_field( $record, '652', 'a' );
122
is_deeply( \@fields_652a, ['Cfoomputer programming.', 'Cfoomputer algorithms.'], 'Copy field using regex' );
123
124
copy_field( $record, '650', 'a', '653', 'a', { search => 'o', replace => 'foo', modifiers => 'g' } );
125
my @fields_653a = read_field( $record, '653', 'a' );
126
is_deeply( \@fields_653a, ['Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.'], 'Copy field using regex' );
127
128
copy_field( $record, '650', 'a', '654', 'a', { search => 'O', replace => 'foo', modifiers => 'i' } );
129
my @fields_654a = read_field( $record, '654', 'a' );
130
is_deeply( \@fields_654a, ['Cfoomputer programming.', 'Cfoomputer algorithms.'], 'Copy field using regex' );
131
132
copy_field( $record, '650', 'a', '655', 'a', { search => 'O', replace => 'foo', modifiers => 'gi' } );
133
my @fields_655a = read_field( $record, '655', 'a' );
134
is_deeply( \@fields_655a, ['Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.'], 'Copy field using regex' );
135
136
# update_field
137
update_field( $record, '952', 'p', undef, '3010023918' );
138
is_deeply( read_field( $record, '952', 'p' ), '3010023918', 'update existing subfield 952$p' );
139
delete_field( $record, '952' );
140
update_field( $record, '952', 'p', undef, '3010023918' );
141
update_field( $record, '952', 'y', undef, 'BK' );
142
is_deeply( read_field( $record, '952', 'p' ), '3010023918', 'create subfield 952$p' );
143
is_deeply( read_field( $record, '952', 'y' ), 'BK', 'create subfield 952$k on existing 952 field' );
144
$record->append_fields(
145
    MARC::Field->new(
146
        952, ' ', ' ',
147
        p => '3010023917',
148
        y => 'BK',
149
    ),
150
);
151
update_field( $record, '952', 'p', undef, '3010023919' );
152
my @fields_952p = read_field( $record, '952', 'p' );
153
is_deeply( \@fields_952p, ['3010023919', '3010023919'], 'update all subfields 952$p with the same value' );
154
155
update_field( $record, '952', 'p', undef, ('3010023917', '3010023918') );
156
@fields_952p = read_field( $record, '952', 'p' );
157
is_deeply( \@fields_952p, ['3010023917', '3010023918'], 'update all subfields 952$p with the different values' );
158
159
# move_field
160
$record = new_record;
161
my ( @fields_952d, @fields_952c, @fields_954c, @fields_954p);
162
$record->append_fields(
163
    MARC::Field->new(
164
        952, ' ', ' ',
165
        p => '3010023917',
166
        y => 'BK',
167
    ),
168
);
169
copy_field( $record, '952', 'd', '952', 'd' );
170
@fields_952d = read_field( $record, '952', 'd' );
171
is_deeply( \@fields_952d, ['2001-06-25', '2001-06-25'], 'copy 952$d into others 952 field' );
172
173
move_field( $record, '952', 'c', '954', 'c' );
174
@fields_952c = read_field( $record, '952', 'c' );
175
@fields_954c = read_field( $record, '954', 'c' );
176
is_deeply( \@fields_952c, [], 'The 952$c has moved' );
177
is_deeply( \@fields_954c, ['GEN'], 'Now 954$c exists' );
178
179
move_field( $record, '952', 'p', '954', 'p', undef, 1 ); # Move the first field
180
@fields_952p = read_field( $record, '952', 'p' );
181
@fields_954p = read_field( $record, '954', 'p' );
182
is_deeply( \@fields_952p, ['3010023917'], 'One of 952$p has moved' );
183
is_deeply( \@fields_954p, ['3010023917'], 'Now 954$p exists' );
184
185
$record = new_record;
186
$record->append_fields(
187
    MARC::Field->new(
188
        952, ' ', ' ',
189
        p => '3010023917',
190
        y => 'BK',
191
    ),
192
);
193
194
move_field( $record, '952', 'p', '954', 'p' ); # Move all field
195
@fields_952p = read_field( $record, '952', 'p' );
196
@fields_954p = read_field( $record, '954', 'p' );
197
is_deeply( \@fields_952p, [], 'All 952$p have moved' );
198
is_deeply( \@fields_954p, ['3010023917', '3010023917'], 'Now 2 954$p exist' );
199
(-)a/t/db_dependent/MarcModificationTemplates.t (+262 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
use Test::More tests => 74;
4
5
use_ok("MARC::Field");
6
use_ok("MARC::Record");
7
use_ok("C4::MarcModificationTemplates");
8
9
my $dbh = C4::Context->dbh;
10
$dbh->{AutoCommit} = 0;
11
$dbh->{RaiseError} = 1;
12
13
$dbh->do(q|DELETE FROM marc_modification_templates|);
14
15
# Creation
16
my $template_id = AddModificationTemplate("template_name");
17
like( $template_id, qr|^\d+$|, "new template returns an id" );
18
19
is( AddModificationTemplateAction(
20
    $template_id, 'move_field', 1,
21
    '464', 'u', '', '464', '3',
22
    '', '', '',
23
    '', '', '', '', '', '',
24
    'move first 464$u to 464$3'
25
), 1, "Add first action");
26
27
is( AddModificationTemplateAction(
28
    $template_id, 'update_field', 0,
29
    '099', 't', 'LIV', '', '',
30
    '', '', '',
31
    'if', '200', 'b', 'equals', 'Text', '',
32
    'Update field 099$t with value LIV if 200$b matches "Text"'
33
), 1, "Add second action");
34
35
is( AddModificationTemplateAction(
36
    $template_id, 'copy_field', 0,
37
    '606', 'a', '', '607', 'a',
38
    '', '', '',
39
    'unless', '606', 'a', 'not_equals', '^AJAX', '1',
40
    'Copy field 606$a to 607$a unless 606$a matches RegEx m^AJAX'
41
), 1, "Add third action");
42
43
# Getter
44
my @actions = GetModificationTemplateActions( $template_id );
45
is( @actions, 3, "3 actions are insered");
46
47
for my $action ( @actions ) {
48
    isnt( GetModificationTemplateAction( $action->{mmta_id} ), undef, "action with id $action->{mmta_id} exists" );
49
}
50
51
my $first_action = $actions[0];
52
is( $first_action->{ordering}, 1, "test ordering for first action" );
53
is( $first_action->{action}, 'move_field', "test action for first action" );
54
is( $first_action->{from_field}, '464', "test from_field for first action" );
55
is( $first_action->{from_subfield}, 'u', "test from_subfield for first action" );
56
is( $first_action->{to_field}, '464', "test to_field for first action" );
57
is( $first_action->{to_subfield}, '3', "test to_subfield for first action" );
58
59
my $second_action = $actions[1];
60
is( $second_action->{ordering}, 2, "test ordering for second action" );
61
is( $second_action->{action}, 'update_field', "test action for second action" );
62
is( $second_action->{from_field}, '099',"test from_field for second action" );
63
is( $second_action->{from_subfield}, 't', "test from_subfield for second action" );
64
is( $second_action->{field_value}, 'LIV', "test firld_value for second action" );
65
is( $second_action->{to_field}, '', "test to_field for second action" );
66
is( $second_action->{to_subfield}, '', "test to_subfield for second action" );
67
is( $second_action->{conditional}, 'if', "test conditional for second action" );
68
is( $second_action->{conditional_field}, '200', "test conditional_field for second action" );
69
is( $second_action->{conditional_subfield}, 'b', "test conditional_subfield for second action" );
70
is( $second_action->{conditional_comparison}, 'equals', "test conditional_comparison for second action" );
71
72
my $third_action = $actions[2];
73
is( $third_action->{ordering}, 3, "test ordering for third action" );
74
is( $third_action->{action}, 'copy_field', "test  factionor third action" );
75
is( $third_action->{from_field}, '606', "test from_field for third action" );
76
is( $third_action->{from_subfield}, 'a', "test from_subfield for third action" );
77
is( $third_action->{to_field}, '607', "test to_field for third action" );
78
is( $third_action->{to_subfield}, 'a', "test to_subfield for third action" );
79
is( $third_action->{conditional}, 'unless', "test conditional for third action" );
80
is( $third_action->{conditional_field}, '606', "test conditional_field for third action" );
81
is( $third_action->{conditional_subfield}, 'a', "test conditional_subfield for third action" );
82
is( $third_action->{conditional_comparison}, 'not_equals', "test conditional_comparison for third action" );
83
is( $third_action->{conditional_value}, '^AJAX', "test conditional_value for third action" );
84
85
86
# Modifications
87
is( ModModificationTemplateAction(
88
    $actions[1]->{mmta_id}, 'update_field', 0,
89
    '100', 'u', 'LIV', '', '',
90
    '', '', '',
91
    'if', '200', 'c', 'equals', 'Text', '',
92
    'Update field 099$t with value LIV if 200$b matches "Text"'
93
), 1, "Modify second action");
94
95
$second_action = GetModificationTemplateAction( $actions[1]->{mmta_id} );
96
is( $second_action->{ordering}, 2, "test ordering for second action modified" );
97
is( $second_action->{action}, 'update_field', "test action for second action modified" );
98
is( $second_action->{from_field}, '100',"test from_field for second action modified" );
99
is( $second_action->{from_subfield}, 'u', "test from_subfield for second action modified" );
100
is( $second_action->{field_value}, 'LIV', "test firld_value for second action modified" );
101
is( $second_action->{to_field}, '', "test to_field for second action modified" );
102
is( $second_action->{to_subfield}, '', "test to_subfield for second action modified" );
103
is( $second_action->{conditional}, 'if', "test conditional for second action modified" );
104
is( $second_action->{conditional_field}, '200', "test conditional_field for second action modified" );
105
is( $second_action->{conditional_subfield}, 'c', "test conditional_subfield for second action modified" );
106
is( $second_action->{conditional_comparison}, 'equals', "test conditional_comparison for second action modified" );
107
108
# Up and down
109
is( MoveModificationTemplateAction( $actions[2]->{mmta_id}, 'top' ), '1', 'Move the third action on top' );
110
is( MoveModificationTemplateAction( $actions[0]->{mmta_id}, 'bottom' ), '1', 'Move the first action on bottom' );
111
112
is( GetModificationTemplateAction( $actions[0]->{mmta_id} )->{ordering}, '3', 'First becomes third' );
113
is( GetModificationTemplateAction( $actions[1]->{mmta_id} )->{ordering}, '2', 'Second stays second' );
114
is( GetModificationTemplateAction( $actions[2]->{mmta_id} )->{ordering}, '1', 'Third becomes first' );
115
116
is( MoveModificationTemplateAction( $actions[0]->{mmta_id}, 'up' ), '1', 'Move up the first action (was third)' );
117
is( MoveModificationTemplateAction( $actions[0]->{mmta_id}, 'up' ), '1', 'Move up the first action (was second)' );
118
is( MoveModificationTemplateAction( $actions[2]->{mmta_id}, 'down' ), '1', 'Move down the third action (was second)' );
119
120
is( GetModificationTemplateAction( $actions[0]->{mmta_id} )->{ordering}, '1', 'First becomes again first' );
121
is( GetModificationTemplateAction( $actions[1]->{mmta_id} )->{ordering}, '2', 'Second stays again second' );
122
is( GetModificationTemplateAction( $actions[2]->{mmta_id} )->{ordering}, '3', 'Third becomes again third' );
123
124
# Cleaning
125
is( DelModificationTemplateAction( $actions[0]->{mmta_id} ), 2, "Delete the first action, 2 others are reordered" );
126
is( GetModificationTemplateAction( $actions[0]->{mmta_id} ), undef, "first action does not exist anymore" );
127
128
is( DelModificationTemplate( $template_id ), 1, "The template has been deleted" );
129
130
is( GetModificationTemplateAction( $actions[1]->{mmta_id} ), undef, "second action does not exist anymore" );
131
is( GetModificationTemplateAction( $actions[2]->{mmta_id} ), undef, "third action does not exist anymore" );
132
133
is( GetModificationTemplateActions( $template_id ), 0, "There is no action for deleted template" );
134
135
# ModifyRecordWithTemplate
136
my @USERENV = (
137
    1,
138
    'test',
139
    'MASTERTEST',
140
    'Test',
141
    'Test',
142
    't',
143
    'Test',
144
    0,
145
);
146
C4::Context->_new_userenv ('DUMMY_SESSION_ID');
147
C4::Context->set_userenv ( @USERENV );
148
149
$template_id = AddModificationTemplate("template_name");
150
like( $template_id, qr|^\d+$|, "new template returns an id" );
151
152
is( AddModificationTemplateAction(
153
    $template_id, 'copy_field', 0,
154
    '245', 'a', '', '246', 'a',
155
    '', '', '',
156
    '', '', '', '', '', '',
157
    'copy field 245$a to 246$a'
158
), 1, 'Add first action: copy 245$a to 246$a');
159
160
is( AddModificationTemplateAction(
161
    $template_id, 'delete_field', 0,
162
    '650', 'a', '', '', '',
163
    '', '', '',
164
    'if', '650', '9', 'equals', '462', '',
165
    'Delete field 650$a if 650$9=462'
166
), 1, 'Add second action: delete field 650$a if 650$9=462');
167
168
is( AddModificationTemplateAction(
169
    $template_id, 'update_field', 0,
170
    '952', 'p', '3010023917_updated', '', '',
171
    '', '', '',
172
    'unless', '650', '9', 'equals', '42', '',
173
    'Update field 952$p with "3010023917_updated" if 650$9 != 42'
174
), 1, 'Add third action: update field 952$p with "3010023917_updated" if 650$9 != 42');
175
176
is( AddModificationTemplateAction(
177
    $template_id, 'move_field', 0,
178
    '952', 'd', '', '952', 'e', '',
179
    '', '', '',
180
    'if', '952', 'c', 'equals', '^GEN', '1',
181
    'Move field 952$d to 952$e if 952$c =~ /^GE/'
182
), 1, 'Add fourth action: move field 952$d to 952$e if 952$c =~ /^GE/');
183
184
my $record = new_record();
185
186
ModifyRecordWithTemplate( $template_id, $record );
187
188
my $expected_record = expected_record();
189
is_deeply( $record, $expected_record );
190
191
done_testing;
192
193
sub new_record {
194
    my $record = MARC::Record->new;
195
    $record->leader('03174nam a2200445 a 4500');
196
    my @fields = (
197
        MARC::Field->new(
198
            100, '1', ' ',
199
            a => 'Knuth, Donald Ervin',
200
            d => '1938',
201
        ),
202
        MARC::Field->new(
203
            245, '1', '4',
204
            a => 'The art of computer programming',
205
            c => 'Donald E. Knuth.',
206
        ),
207
        MARC::Field->new(
208
            650, ' ', '0',
209
            a => 'Computer programming.',
210
            9 => '462',
211
        ),
212
        MARC::Field->new(
213
            952, ' ', ' ',
214
            p => '3010023917',
215
            y => 'BK',
216
            c => 'GEN',
217
            d => '2001-06-25',
218
        ),
219
    );
220
    $record->append_fields(@fields);
221
    return $record;
222
}
223
224
sub expected_record {
225
    my $record = MARC::Record->new;
226
    $record->leader('03174nam a2200445 a 4500');
227
    my @fields = (
228
        MARC::Field->new(
229
            100, '1', ' ',
230
            a => 'Knuth, Donald Ervin',
231
            d => '1938',
232
        ),
233
        MARC::Field->new(
234
            245, '1', '4',
235
            a => 'The art of computer programming',
236
            c => 'Donald E. Knuth.',
237
        ),
238
        MARC::Field->new(
239
            650, ' ', '0',
240
            9 => '462',
241
        ),
242
        MARC::Field->new(
243
            952, ' ', ' ',
244
            p => '3010023917_updated',
245
            y => 'BK',
246
            c => 'GEN',
247
            e => '2001-06-25',
248
        ),
249
        MARC::Field->new(
250
            246, '', ' ',
251
            a => 'The art of computer programming',
252
        ),
253
    );
254
    $record->append_fields(@fields);
255
    return $record;
256
}
257
258
259
# C4::Context->userenv
260
sub Mock_userenv {
261
    return { branchcode => 'CPL' };
262
}
(-)a/tools/marc_modification_templates.pl (-19 / +23 lines)
Lines 1-23 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
# Copyright 2010 Kyle M Hall <kyle.m.hall@gmail.com>
3
#
4
# This file is part of Koha.
2
# This file is part of Koha.
5
#
3
#
6
# Koha is free software; you can redistribute it and/or modify it under the
4
# Copyright 2010 Kyle M Hall <kyle.m.hall@gmail.com>
7
# terms of the GNU General Public License as published by the Free Software
5
#
8
# Foundation; either version 2 of the License, or (at your option) any later
6
# Koha is free software; you can redistribute it and/or modify it
9
# version.
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# Koha is distributed in the hope that it will be useful, but
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
14
#
15
#
15
# You should have received a copy of the GNU General Public License along
16
# You should have received a copy of the GNU General Public License
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
18
19
use strict;
19
use Modern::Perl;
20
use warnings;
21
20
22
use CGI;
21
use CGI;
23
22
Lines 28-34 use C4::MarcModificationTemplates; Link Here
28
27
29
my $cgi = new CGI;
28
my $cgi = new CGI;
30
29
31
my $op = $cgi->param('op');
30
my $op = $cgi->param('op') || q{};
32
my $template_id = $cgi->param('template_id');
31
my $template_id = $cgi->param('template_id');
33
32
34
my ($template, $loggedinuser, $cookie)
33
my ($template, $loggedinuser, $cookie)
Lines 60-66 if ( $op eq "create_template" ) { Link Here
60
  my $field_value = $cgi->param('field_value');
59
  my $field_value = $cgi->param('field_value');
61
  my $to_field = $cgi->param('to_field');
60
  my $to_field = $cgi->param('to_field');
62
  my $to_subfield = $cgi->param('to_subfield');
61
  my $to_subfield = $cgi->param('to_subfield');
63
  my $to_regex = $cgi->param('to_regex');
62
  my $to_regex_search = $cgi->param('to_regex_search');
63
  my $to_regex_replace = $cgi->param('to_regex_replace');
64
  my $to_regex_modifiers = $cgi->param('to_regex_modifiers');
64
  my $conditional = $cgi->param('conditional');
65
  my $conditional = $cgi->param('conditional');
65
  my $conditional_field = $cgi->param('conditional_field');
66
  my $conditional_field = $cgi->param('conditional_field');
66
  my $conditional_subfield = $cgi->param('conditional_subfield');
67
  my $conditional_subfield = $cgi->param('conditional_subfield');
Lines 79-85 if ( $op eq "create_template" ) { Link Here
79
      $field_value,
80
      $field_value,
80
      $to_field,
81
      $to_field,
81
      $to_subfield,
82
      $to_subfield,
82
      $to_regex,
83
      $to_regex_search,
84
      $to_regex_replace,
85
      $to_regex_modifiers,
83
      $conditional,
86
      $conditional,
84
      $conditional_field,
87
      $conditional_field,
85
      $conditional_subfield,
88
      $conditional_subfield,
Lines 98-104 if ( $op eq "create_template" ) { Link Here
98
      $field_value,
101
      $field_value,
99
      $to_field,
102
      $to_field,
100
      $to_subfield,
103
      $to_subfield,
101
      $to_regex,
104
      $to_regex_search,
105
      $to_regex_replace,
106
      $to_regex_modifiers,
102
      $conditional,
107
      $conditional,
103
      $conditional_field,
108
      $conditional_field,
104
      $conditional_subfield,
109
      $conditional_subfield,
105
- 

Return to bug 8015