Bug 2774 - Path to theme is hard-coded in many places
[koha.git] / admin / oai_set_mappings.pl
blobfb4ee281e5987bb68f10e9fb18d2ff6b4d734fb7
1 #!/usr/bin/perl
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 under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
9 # version.
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with Koha; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 =head1 NAME
21 oai_set_mappings.pl
23 =head1 DESCRIPTION
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.
31 =cut
33 use Modern::Perl;
35 use CGI;
36 use C4::Auth;
37 use C4::Output;
38 use C4::OAI::Sets;
40 use Data::Dumper;
42 my $input = new CGI;
43 my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
44 template_name => 'admin/oai_set_mappings.tt',
45 query => $input,
46 type => 'intranet',
47 authnotrequired => 0,
48 flagsrequired => { 'parameters' => 'parameters_remaining_permissions' },
49 debug => 1,
50 } );
52 my $id = $input->param('id');
53 my $op = $input->param('op');
55 if($op && $op eq "save") {
56 my @marcfields = $input->param('marcfield');
57 my @marcsubfields = $input->param('marcsubfield');
58 my @marcvalues = $input->param('marcvalue');
60 my @mappings;
61 my $i = 0;
62 while($i < @marcfields and $i < @marcsubfields and $i < @marcvalues) {
63 if($marcfields[$i] and $marcsubfields[$i]) {
64 push @mappings, {
65 marcfield => $marcfields[$i],
66 marcsubfield => $marcsubfields[$i],
67 marcvalue => $marcvalues[$i]
70 $i++;
72 ModOAISetMappings($id, \@mappings);
73 $template->param(mappings_saved => 1);
76 my $set = GetOAISet($id);
77 my $mappings = GetOAISetMappings($id);
79 $template->param(
80 id => $id,
81 setName => $set->{'name'},
82 setSpec => $set->{'spec'},
83 mappings => $mappings,
86 output_html_with_http_headers $input, $cookie, $template->output;