"Fossies" - the Fresh Open Source Software Archive

Member "koha-19.11.15/admin/oai_set_mappings.pl" (23 Feb 2021, 2504 Bytes) of package /linux/misc/koha-19.11.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "oai_set_mappings.pl" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 20.05.06_vs_20.11.00.

    1 #!/usr/bin/perl
    2 
    3 # Copyright 2011 BibLibre SARL
    4 # This file is part of Koha.
    5 #
    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.
   10 #
   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.
   15 #
   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>.
   18 
   19 =head1 NAME
   20 
   21 oai_set_mappings.pl
   22 
   23 =head1 DESCRIPTION
   24 
   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.
   30 
   31 =cut
   32 
   33 use Modern::Perl;
   34 
   35 use CGI qw ( -utf8 );
   36 use C4::Auth;
   37 use C4::Output;
   38 use C4::OAI::Sets;
   39 
   40 use Data::Dumper;
   41 
   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     flagsrequired   => { 'parameters' => 'manage_oai_sets' },
   48     debug           => 1,
   49 } );
   50 
   51 my $id = $input->param('id');
   52 my $op = $input->param('op');
   53 
   54 if($op && $op eq "save") {
   55     my @marcfields = $input->multi_param('marcfield');
   56     my @marcsubfields = $input->multi_param('marcsubfield');
   57     my @operators = $input->multi_param('operator');
   58     my @marcvalues = $input->multi_param('marcvalue');
   59 
   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                 operator     => $operators[$i],
   68                 marcvalue    => $marcvalues[$i]
   69             };
   70         }
   71         $i++;
   72     }
   73     ModOAISetMappings($id, \@mappings);
   74     $template->param(mappings_saved => 1);
   75 }
   76 
   77 my $set = GetOAISet($id);
   78 my $mappings = GetOAISetMappings($id);
   79 
   80 $template->param(
   81     id => $id,
   82     setName => $set->{'name'},
   83     setSpec => $set->{'spec'},
   84     mappings => $mappings,
   85 );
   86 
   87 output_html_with_http_headers $input, $cookie, $template->output;