Bug 25078: Separate update "report" from its description
[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
25 use C4::Auth qw( get_template_and_user );
26 use C4::Context;
27 use C4::Output qw( output_html_with_http_headers );
28 use DBIx::Class::ResultClass::HashRefInflator;
29 use Koha::Database;
30 use Koha::MarcSubfieldStructures;
31 use Koha::BiblioFrameworks;
32 use Koha::KeyboardShortcuts;
33
34 my $input = CGI->new;
35
36 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37     {
38         template_name   => 'cataloguing/editor.tt',
39         query           => $input,
40         type            => 'intranet',
41         flagsrequired   => {
42             editcatalogue => {
43                 'edit_catalogue'  => 1,
44                 'advanced_editor' => 1
45             },
46         }
47     }
48 );
49
50 my $schema = Koha::Database->new->schema;
51
52 my @keyboard_shortcuts = Koha::KeyboardShortcuts->search();
53
54 # Keyboard shortcuts
55 $template->param(
56     shortcuts => \@keyboard_shortcuts,
57 );
58
59 # Available import batches
60 $template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->search(
61     {
62         batch_type => [ 'batch', 'webservice' ],
63         import_status => 'staged',
64     },
65     { result_class => 'DBIx::Class::ResultClass::HashRefInflator' },
66 ) ];
67
68 # Needed information for cataloging plugins
69 $template->{VARS}->{DefaultLanguageField008} = pack( 'A3', C4::Context->preference('DefaultLanguageField008') || 'eng' );
70 $template->{VARS}->{DefaultCountryField008} = pack( 'A3', C4::Context->preference('DefaultCountryField008') || '|||' );
71
72 my $authtags = Koha::MarcSubfieldStructures->search({ authtypecode => { '!=' => '' }, 'frameworkcode' => '' });
73 $template->{VARS}->{authtags} = $authtags;
74
75 my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
76 $template->{VARS}->{frameworks} = $frameworks;
77
78 # Z39.50 servers
79 my $dbh = C4::Context->dbh;
80 $template->{VARS}->{z3950_servers} = $dbh->selectall_arrayref( q{
81     SELECT * FROM z3950servers
82     WHERE recordtype != 'authority' AND servertype = 'zed'
83     ORDER BY rank,servername
84 }, { Slice => {} } );
85
86 output_html_with_http_headers $input, $cookie, $template->output;