Bug 18508: Fix t/db_dependent/api/v1/swagger/definitions.t (follow-up of 6758)
[koha.git] / cataloguing / editor.pl
1 #!/usr/bin/perl
2 #
3 # Copyright 2013 ByWater
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19 #
20
21 use Modern::Perl;
22
23 use CGI;
24 use MARC::Record;
25
26 use C4::Auth;
27 use C4::Biblio;
28 use C4::Context;
29 use C4::Output;
30 use DBIx::Class::ResultClass::HashRefInflator;
31 use Koha::Database;
32
33 my $input = CGI->new;
34
35 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36     {
37         template_name   => 'cataloguing/editor.tt',
38         query           => $input,
39         type            => 'intranet',
40         authnotrequired => 0,
41         flagsrequired   => { editcatalogue => 'edit_catalogue' },
42     }
43 );
44
45 my $schema = Koha::Database->new->schema;
46
47 # Available import batches
48 $template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->search(
49     {
50         batch_type => [ 'batch', 'webservice' ],
51         import_status => 'staged',
52     },
53     { result_class => 'DBIx::Class::ResultClass::HashRefInflator' },
54 ) ];
55
56 # Needed information for cataloging plugins
57 $template->{VARS}->{DefaultLanguageField008} = pack( 'A3', C4::Context->preference('DefaultLanguageField008') || 'eng' );
58
59 # Z39.50 servers
60 my $dbh = C4::Context->dbh;
61 $template->{VARS}->{z3950_servers} = $dbh->selectall_arrayref( q{
62     SELECT * FROM z3950servers
63     WHERE recordtype != 'authority' AND servertype = 'zed'
64     ORDER BY servername
65 }, { Slice => {} } );
66
67 output_html_with_http_headers $input, $cookie, $template->output;