3 # Copyright 2011 BibLibre SARL
4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
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.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
25 Define mappings for a given set.
26 Mappings are conditions that define which biblio is included in which set.
27 A condition is in the form 200$a = 'abc'.
28 Multiple conditions can be defined for a given set. In this case,
29 the OR operator will be applied.
36 use C4::Auth qw( get_template_and_user );
37 use C4::Output qw( output_html_with_http_headers );
38 use C4::OAI::Sets qw( GetOAISet GetOAISetMappings ModOAISetMappings );
42 my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
43 template_name => 'admin/oai_set_mappings.tt',
46 flagsrequired => { 'parameters' => 'manage_oai_sets' },
49 my $id = $input->param('id');
50 my $op = $input->param('op');
52 if($op && $op eq "save") {
53 my @marcfields = $input->multi_param('marcfield');
54 my @marcsubfields = $input->multi_param('marcsubfield');
55 my @operators = $input->multi_param('operator');
56 my @marcvalues = $input->multi_param('marcvalue');
57 my @ruleoperators = $input->multi_param('rule_operator');
58 my @ruleorders = $input->multi_param('rule_order');
62 while($i < @marcfields and $i < @marcsubfields and $i < @marcvalues) {
63 if($marcfields[$i] and $marcsubfields[$i]) {
65 marcfield => $marcfields[$i],
66 marcsubfield => $marcsubfields[$i],
67 operator => $operators[$i],
68 marcvalue => $marcvalues[$i],
69 rule_operator => $ruleoperators[$i],
75 $mappings[0]{'rule_operator'} = undef if (@mappings);
76 ModOAISetMappings($id, \@mappings);
77 $template->param(mappings_saved => 1);
80 my $set = GetOAISet($id);
81 my $mappings = GetOAISetMappings($id);
85 setName => $set->{'name'},
86 setSpec => $set->{'spec'},
87 mappings => $mappings,
90 output_html_with_http_headers $input, $cookie, $template->output;