Koha/svc/records/preview
Jonathan Druart 22ce6a4bac Bug 11395: New service to preview a record.
The main patch adds the ability to preview a record. This is done using
an AJAX way. The preview record is processed on the server side.

Note: I don't think an authentification check is necessary here.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-03-05 15:27:03 +01:00

53 lines
1.7 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright (C) 2013 BibLibre
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI;
use C4::Auth qw( get_template_and_user );
use C4::Biblio qw( GetMarcBiblio );
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate );
use C4::Output qw( output_html_with_http_headers );
use Koha::Authority;
my $query = CGI->new();
my $record_id = $query->param('record_id');
my $record_type = $query->param('record_type') || 'biblio';
my $mmtid = $query->param('mmtid'); # Marc modification template id
my $record;
if ( $record_type eq 'biblio' ) {
$record = GetMarcBiblio( $record_id );
} else {
my $authority = Koha::Authority->get_from_authid( $record_id );
$record = $authority->record;
}
if ( $mmtid ) {
ModifyRecordWithTemplate( $mmtid, $record );
}
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
template_name => "catalogue/showmarc.tt",
query => $query,
type => "intranet",
authnotrequired => 1,
});
$template->param( MARC_FORMATTED => $record->as_formatted );
output_html_with_http_headers $query, $cookie, $template->output;