Lines 23-29
Link Here
|
23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
24 |
use CGI qw ( -utf8 ); |
24 |
use CGI qw ( -utf8 ); |
25 |
use C4::Context; |
25 |
use C4::Context; |
26 |
use C4::Auth qw( get_template_and_user ); |
26 |
use C4::Auth qw( get_template_and_user ); |
27 |
use C4::Output qw( output_html_with_http_headers ); |
27 |
use C4::Output qw( output_html_with_http_headers ); |
28 |
use Koha::Database; |
28 |
use Koha::Database; |
29 |
use Koha::OaiServers; |
29 |
use Koha::OaiServers; |
Lines 31-38
use Koha::OaiServers;
Link Here
|
31 |
# Initialize CGI, template, database |
31 |
# Initialize CGI, template, database |
32 |
|
32 |
|
33 |
my $input = CGI->new; |
33 |
my $input = CGI->new; |
34 |
my $op = $input->param('op') || 'list'; |
34 |
my $op = $input->param('op') || 'list'; |
35 |
my $id = $input->param('id') || 0; |
35 |
my $id = $input->param('id') || 0; |
36 |
my $type = $input->param('type') || ''; |
36 |
my $type = $input->param('type') || ''; |
37 |
my $searchfield = ''; |
37 |
my $searchfield = ''; |
38 |
|
38 |
|
Lines 54-60
my $schema = Koha::Database->new()->schema();
Link Here
|
54 |
# Main code |
54 |
# Main code |
55 |
# First process a confirmed delete, or save a validated record |
55 |
# First process a confirmed delete, or save a validated record |
56 |
|
56 |
|
57 |
if ( $op eq 'delete_confirmed' && $id ) { |
57 |
if ( $op eq 'cud-delete_confirmed' && $id ) { |
58 |
my $server = Koha::OaiServers->find($id); |
58 |
my $server = Koha::OaiServers->find($id); |
59 |
if ($server) { |
59 |
if ($server) { |
60 |
$server->delete; |
60 |
$server->delete; |
Lines 63-69
if ( $op eq 'delete_confirmed' && $id ) {
Link Here
|
63 |
$template->param( msg_notfound => 1, msg_add => $id ); |
63 |
$template->param( msg_notfound => 1, msg_add => $id ); |
64 |
} |
64 |
} |
65 |
$id = 0; |
65 |
$id = 0; |
66 |
} elsif ( $op eq 'add_validated' ) { |
66 |
} elsif ( $op eq 'cud-add_validated' ) { |
67 |
my @fields = qw/endpoint oai_set dataformat |
67 |
my @fields = qw/endpoint oai_set dataformat |
68 |
recordtype servername |
68 |
recordtype servername |
69 |
add_xslt/; |
69 |
add_xslt/; |
Lines 81-87
if ( $op eq 'delete_confirmed' && $id ) {
Link Here
|
81 |
Koha::OaiServer->new($formdata)->store; |
81 |
Koha::OaiServer->new($formdata)->store; |
82 |
$template->param( msg_added => 1, msg_add => $formdata->{servername} ); |
82 |
$template->param( msg_added => 1, msg_add => $formdata->{servername} ); |
83 |
} |
83 |
} |
84 |
} else { |
84 |
} elsif ( $op eq 'search' ) { |
85 |
|
85 |
|
86 |
#use searchfield only in remaining operations |
86 |
#use searchfield only in remaining operations |
87 |
$searchfield = $input->param('searchfield') || ''; |
87 |
$searchfield = $input->param('searchfield') || ''; |
Lines 92-98
if ( $op eq 'delete_confirmed' && $id ) {
Link Here
|
92 |
my $data = []; |
92 |
my $data = []; |
93 |
if ( $op eq 'add' || $op eq 'edit' ) { |
93 |
if ( $op eq 'add' || $op eq 'edit' ) { |
94 |
$data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id; |
94 |
$data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id; |
95 |
delete $data->[0]->{id} if @$data && $op eq 'add'; #cloning record |
95 |
delete $data->[0]->{id} if @$data && $op eq 'add'; #cloning record |
96 |
$template->param( |
96 |
$template->param( |
97 |
add_form => 1, server => @$data ? $data->[0] : undef, |
97 |
add_form => 1, server => @$data ? $data->[0] : undef, |
98 |
op => $op, type => $op eq 'add' ? lc $type : '' |
98 |
op => $op, type => $op eq 'add' ? lc $type : '' |