Bug 11592: Applying filtering to opac interface.
Applying the filtering and then... Debugging opac/opac-detail.pl filtering Debugging opac/opac-ISBDdetail.pl more Debugging opac/opac-export.pl Tweak opac/opac-export.pl fix variable declarations, conditional assignments Debugging opac/opac-showmarc.pl https://bugs.koha-community.org/show_bug.cgi?id=11592 Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
dd8352bb8b
commit
6cbae9c3cb
|
|
@ -54,6 +54,7 @@ use C4::Review;
|
|||
use C4::Serials; # uses getsubscriptionfrom biblionumber
|
||||
use C4::Koha;
|
||||
use C4::Members; # GetMember
|
||||
use Koha::RecordProcessor;
|
||||
|
||||
my $query = CGI->new();
|
||||
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
|
|
@ -91,11 +92,15 @@ if (scalar @items >= 1) {
|
|||
}
|
||||
}
|
||||
|
||||
my $record = GetMarcBiblio($biblionumber);
|
||||
if ( ! $record ) {
|
||||
my $record_unfiltered = GetMarcBiblio($biblionumber);
|
||||
if ( ! $record_unfiltered ) {
|
||||
print $query->redirect("/cgi-bin/koha/errors/404.pl");
|
||||
exit;
|
||||
}
|
||||
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
|
||||
my $record_filtered = $record_unfiltered->clone();
|
||||
my $record = $record_processor->process($record_filtered);
|
||||
|
||||
# some useful variables for enhanced content;
|
||||
# in each case, we're grabbing the first value we find in
|
||||
# the record and normalizing it
|
||||
|
|
@ -112,7 +117,7 @@ $template->param(
|
|||
normalized_ean => $ean,
|
||||
normalized_oclc => $oclc,
|
||||
normalized_isbn => $isbn,
|
||||
content_identifier_exists => $content_identifier_exists,
|
||||
content_identifier_exists => $content_identifier_exists,
|
||||
);
|
||||
|
||||
#coping with subscriptions
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ use C4::Images;
|
|||
use Koha::DateUtils;
|
||||
use C4::HTML5Media;
|
||||
use C4::CourseReserves qw(GetItemCourseReservesInfo);
|
||||
|
||||
use Koha::RecordProcessor;
|
||||
use Koha::Virtualshelves;
|
||||
|
||||
BEGIN {
|
||||
|
|
@ -84,11 +84,14 @@ if (scalar @all_items >= 1) {
|
|||
}
|
||||
}
|
||||
|
||||
my $record = GetMarcBiblio($biblionumber);
|
||||
if ( ! $record ) {
|
||||
my $record_unfiltered = GetMarcBiblio($biblionumber);
|
||||
if ( ! $record_unfiltered ) {
|
||||
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
|
||||
exit;
|
||||
}
|
||||
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
|
||||
my $record_filtered = $record_unfiltered->clone();
|
||||
my $record = $record_processor->process($record_filtered);
|
||||
|
||||
# redirect if opacsuppression is enabled and biblio is suppressed
|
||||
if (C4::Context->preference('OpacSuppression')) {
|
||||
|
|
@ -524,6 +527,11 @@ if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
|
|||
}
|
||||
|
||||
my $dat = &GetBiblioData($biblionumber);
|
||||
my $HideMARC = $record_processor->filters->[0]->should_hide_marc(
|
||||
{
|
||||
frameworkcode => $dat->{'frameworkcode'},
|
||||
interface => 'opac',
|
||||
} );
|
||||
|
||||
my $itemtypes = GetItemTypes();
|
||||
# imageurl:
|
||||
|
|
@ -762,7 +770,9 @@ if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
|
|||
);
|
||||
}
|
||||
|
||||
# FIXME: The template uses this hash directly. Need to filter.
|
||||
foreach ( keys %{$dat} ) {
|
||||
next if ( $HideMARC->{$_} );
|
||||
$template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,20 +26,33 @@ use C4::Biblio;
|
|||
use CGI qw ( -utf8 );
|
||||
use C4::Auth;
|
||||
use C4::Ris;
|
||||
use Koha::RecordProcessor;
|
||||
|
||||
my $query = new CGI;
|
||||
my $query = CGI->new;
|
||||
my $op=$query->param("op")||''; #op=export is currently the only use
|
||||
my $format=$query->param("format")||'utf8';
|
||||
my $biblionumber = $query->param("bib")||0;
|
||||
$biblionumber = int($biblionumber);
|
||||
my ($marc, $error)= ('','');
|
||||
my $error = q{};
|
||||
|
||||
$marc = GetMarcBiblio($biblionumber, 1) if $biblionumber;
|
||||
if(!$marc) {
|
||||
my $marc_unfiltered;
|
||||
$marc_unfiltered = GetMarcBiblio($biblionumber, 1) if $biblionumber;
|
||||
if(!$marc_unfiltered) {
|
||||
print $query->redirect("/cgi-bin/koha/errors/404.pl");
|
||||
exit;
|
||||
}
|
||||
elsif ($format =~ /endnote/) {
|
||||
|
||||
# ASSERT: There is a biblionumber, because GetMarcBiblio returned something.
|
||||
|
||||
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
|
||||
my $marc_filtered = $marc_unfiltered->clone();
|
||||
my $marc = $record_processor->process($marc_filtered);
|
||||
|
||||
my $marc_noitems_unfiltered = GetMarcBiblio($biblionumber);
|
||||
my $marc_noitems_filtered = $marc_noitems_unfiltered->clone();
|
||||
my $marc_noitems = $record_processor->process($marc_noitems_filtered);
|
||||
|
||||
if ($format =~ /endnote/) {
|
||||
$marc = marc2endnote($marc);
|
||||
$format = 'endnote';
|
||||
}
|
||||
|
|
@ -56,11 +69,12 @@ elsif ($format =~ /ris/) {
|
|||
$format = 'ris';
|
||||
}
|
||||
elsif ($format =~ /bibtex/) {
|
||||
$marc = marc2bibtex(C4::Biblio::GetMarcBiblio($biblionumber),$biblionumber);
|
||||
$marc = marc2bibtex($marc_noitems,$biblionumber);
|
||||
$format = 'bibtex';
|
||||
}
|
||||
elsif ($format =~ /dc$/) {
|
||||
$marc = marc2dcxml(undef, undef, $biblionumber, $format);
|
||||
# TODO: Dublin Core leaks fields marked hidden by framework.
|
||||
$marc = marc2dcxml($marc, undef, $biblionumber, $format);
|
||||
$format = "dublin-core.xml";
|
||||
}
|
||||
elsif ($format =~ /marc8/) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ use C4::Biblio;
|
|||
use C4::ImportBatch;
|
||||
use C4::XSLT ();
|
||||
use C4::Templates;
|
||||
use Koha::RecordProcessor;
|
||||
|
||||
my $input = new CGI;
|
||||
my $biblionumber = $input->param('id');
|
||||
|
|
@ -38,21 +39,33 @@ $biblionumber = int($biblionumber);
|
|||
my $importid= $input->param('importid');
|
||||
my $view= $input->param('viewas') || 'marc';
|
||||
|
||||
my $record;
|
||||
my $record_unfiltered;
|
||||
if ($importid) {
|
||||
my ($marc) = GetImportRecordMarc($importid);
|
||||
$record = MARC::Record->new_from_usmarc($marc);
|
||||
$record_unfiltered = MARC::Record->new_from_usmarc($marc);
|
||||
}
|
||||
else {
|
||||
$record =GetMarcBiblio($biblionumber);
|
||||
$record_unfiltered = GetMarcBiblio($biblionumber);
|
||||
}
|
||||
if(!ref $record) {
|
||||
if(!ref $record_unfiltered) {
|
||||
print $input->redirect("/cgi-bin/koha/errors/404.pl");
|
||||
exit;
|
||||
}
|
||||
|
||||
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
|
||||
my $record_filtered = $record_unfiltered->clone();
|
||||
my $record = $record_processor->process($record_filtered);
|
||||
|
||||
if ($view eq 'card' || $view eq 'html') {
|
||||
# FIXME: GetXmlBiblio needs filtering later.
|
||||
my $xml = $importid ? $record->as_xml(): GetXmlBiblio($biblionumber);
|
||||
if (!$importid && $view eq 'html') {
|
||||
my $unfiltered_record = MARC::Record->new_from_xml($xml);
|
||||
my $frameworkcode = GetFrameworkCode($biblionumber);
|
||||
$record_processor->options({ frameworkcode => $frameworkcode});
|
||||
my $filtered_record = $record_processor->process($unfiltered_record);
|
||||
$xml = $filtered_record->as_xml();
|
||||
}
|
||||
my $xsl = $view eq 'card' ? 'compact.xsl' : 'plainMARC.xsl';
|
||||
my $htdocs = C4::Context->config('opachtdocs');
|
||||
my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $xsl, 'opac', $input);
|
||||
|
|
|
|||
Loading…
Reference in New Issue