Bug 16699: Remove requirement from borrowernumberQueryParam
[koha.git] / authorities / blinddetail-biblio-search.pl
blobcab9c744563d52c2accdf8d8411b5ec87f82a27f
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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.
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.
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>.
20 =head1 NAME
22 blinddetail-biblio-search.pl : script to show an authority in MARC format
24 =head1 SYNOPSIS
26 =cut
28 =head1 DESCRIPTION
30 This script needs an authid
32 It shows the authority in a (nice) MARC format depending on authority MARC
33 parameters tables.
35 =head1 FUNCTIONS
37 =cut
39 use strict;
40 use warnings;
42 use C4::AuthoritiesMarc;
43 use C4::Auth;
44 use C4::Context;
45 use C4::Output;
46 use CGI qw ( -utf8 );
47 use MARC::Record;
48 use C4::Koha;
50 use Koha::Authorities;
51 use Koha::Authority::Types;
53 my $query = new CGI;
55 my $dbh = C4::Context->dbh;
57 my $authid = $query->param('authid');
58 my $index = $query->param('index');
59 my $tagid = $query->param('tagid');
60 my $relationship = $query->param('relationship');
61 my $authtypecode = Koha::Authorities->find($authid)->authtypecode;
62 my $tagslib = &GetTagsLabels( 1, $authtypecode );
64 my $auth_type = Koha::Authority::Types->find($authtypecode);
65 my $record;
66 if ($authid) {
67 $record = GetAuthority($authid);
70 # open template
71 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
73 template_name => "authorities/blinddetail-biblio-search.tt",
74 query => $query,
75 type => "intranet",
76 authnotrequired => 0,
77 flagsrequired => { editcatalogue => 'edit_catalogue' },
81 # fill arrays
82 my @subfield_loop;
83 my ($indicator1, $indicator2);
84 if ($authid) {
85 my @fields = $record->field( $auth_type->auth_tag_to_report );
86 my $repet = ($query->param('repet') || 1) - 1;
87 my $field = $fields[$repet];
89 # Get all values for each distinct subfield
90 my %subfields;
91 for ( $field->subfields ) {
92 next if $_->[0] eq '9'; # $9 will be set with authid value
93 my $letter = $_->[0];
94 next if defined $subfields{$letter};
95 my @values = $field->subfield($letter);
96 $subfields{$letter} = \@values;
99 # Add all subfields to the subfield_loop
100 for( keys %subfields ) {
101 my $letter = $_ || '@';
102 push( @subfield_loop, {marc_subfield => $letter, marc_values => $subfields{$_}} );
105 push( @subfield_loop, { marc_subfield => 'w', marc_values => $relationship } ) if ( $relationship );
106 if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
107 $indicator1 = $field->indicator('1');
108 $indicator2 = $field->indicator('2');
109 } elsif (C4::Context->preference('marcflavour') eq 'MARC21') {
110 my $tag_from = $auth_type->auth_tag_to_report;
111 my $tag_to = $index;
112 $tag_to =~ s/^tag_(\d*)_.*$/$1/;
113 if ($tag_to =~ /^6/) { # subject heading
114 my %thes_mapping = qw / a 0
124 | 4 /;
125 my $thes_008_11 = '';
126 $thes_008_11 = substr($record->field('008')->data(), 11, 1) if $record->field('008')->data();
127 $indicator2 = defined $thes_mapping{$thes_008_11} ? $thes_mapping{$thes_008_11} : $thes_008_11;
128 if ($indicator2 eq '7') {
129 if ($thes_008_11 eq 'r') {
130 $subfields{'2'} = ['aat'];
131 } elsif ($thes_008_11 eq 's') {
132 $subfields{'2'} = ['sears'];
136 if ($tag_from eq '130') { # unified title -- the special case
137 if ($tag_to eq '830' || $tag_to eq '240') {
138 $indicator2 = $field->indicator('2');
139 } else {
140 $indicator1 = $field->indicator('2');
142 } else {
143 $indicator1 = $field->indicator('1');
147 else {
148 # authid is empty => the user want to empty the entry.
149 $template->param( "clear" => 1 );
152 # Extract the tag number from the index
153 my $tag_number = $index;
154 $tag_number =~ s/^tag_(\d*)_.*$/$1/;
156 # Remove spaces in indicators
157 $indicator1 =~ s/\s//g;
158 $indicator2 =~ s/\s//g;
160 $template->param(
161 authid => $authid ? $authid : "",
162 index => $index,
163 tagid => $tagid,
164 indicator1 => $indicator1,
165 indicator2 => $indicator2,
166 SUBFIELD_LOOP => \@subfield_loop,
167 tag_number => $tag_number,
170 output_html_with_http_headers $query, $cookie, $template->output;