Bug 11319: Template modifications
[koha.git] / admin / oai_sets.pl
blobc923e8732273f918e445d21782fbe3fca35f5138
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_sets.pl
23 =head1 DESCRIPTION
25 Admin page to describe OAI SETs
27 =cut
29 use Modern::Perl;
31 use CGI;
32 use C4::Auth;
33 use C4::Output;
34 use C4::OAI::Sets;
36 use Data::Dumper;
38 my $input = new CGI;
39 my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
40 template_name => 'admin/oai_sets.tt',
41 query => $input,
42 type => 'intranet',
43 authnotrequired => 0,
44 flagsrequired => { 'parameters' => 'parameters_remaining_permissions' },
45 debug => 1,
46 } );
48 my $op = $input->param('op');
50 if($op && $op eq "new") {
51 $template->param( op_new => 1 );
52 } elsif($op && $op eq "savenew") {
53 my $spec = $input->param('spec');
54 my $name = $input->param('name');
55 my @descriptions = $input->param('description');
56 AddOAISet({
57 spec => $spec,
58 name => $name,
59 descriptions => \@descriptions
60 });
61 } elsif($op && $op eq "mod") {
62 my $id = $input->param('id');
63 my $set = GetOAISet($id);
64 $template->param(
65 op_mod => 1,
66 id => $set->{'id'},
67 spec => $set->{'spec'},
68 name => $set->{'name'},
69 descriptions => [ map { {description => $_} } @{ $set->{'descriptions'} } ],
71 } elsif($op && $op eq "savemod") {
72 my $id = $input->param('id');
73 my $spec = $input->param('spec');
74 my $name = $input->param('name');
75 my @descriptions = $input->param('description');
76 ModOAISet({
77 id => $id,
78 spec => $spec,
79 name => $name,
80 descriptions => \@descriptions
81 });
82 } elsif($op && $op eq "del") {
83 my $id = $input->param('id');
84 DelOAISet($id);
87 my $OAISets = GetOAISets;
88 my @sets_loop;
89 foreach(@$OAISets) {
90 push @sets_loop, {
91 id => $_->{'id'},
92 spec => $_->{'spec'},
93 name => $_->{'name'},
94 descriptions => [ map { {description => $_} } @{ $_->{'descriptions'} } ]
98 $template->param(
99 sets_loop => \@sets_loop,
102 output_html_with_http_headers $input, $cookie, $template->output;