X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=admin%2Fkoha2marclinks.pl;h=8ba6b1c36fc1bb0ff90da9eab766c251781aa522;hb=c0a52bb1981cea372033ccac02430cba761d3def;hp=4880421f50d62d7eb55949e01c62fcd4a64b782e;hpb=2c6765610856bd298cec045077a55296ae10abda;p=koha.git diff --git a/admin/koha2marclinks.pl b/admin/koha2marclinks.pl index 4880421f50..8ba6b1c36f 100755 --- a/admin/koha2marclinks.pl +++ b/admin/koha2marclinks.pl @@ -4,24 +4,24 @@ # # This file is part of Koha. # -# 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 2 of the License, or (at your option) any later -# version. +# 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. +# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use strict; use warnings; use C4::Output; use C4::Auth; -use CGI; +use CGI qw ( -utf8 ); use C4::Context; use C4::Biblio; @@ -35,11 +35,11 @@ my $script_name = 'koha2marclinks.pl'; my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( { - template_name => "admin/koha2marclinks.tmpl", + template_name => "admin/koha2marclinks.tt", query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => { parameters => 1 }, + flagsrequired => { parameters => 'parameters_remaining_permissions' }, debug => 1, } ); @@ -59,21 +59,25 @@ else { } my $dbh = C4::Context->dbh; +my $cache = Koha::Cache->get_instance(); ################## ADD_FORM ################################## # called by default. Used to create form to add or modify a record if ( $op eq 'add_form' ) { - my $sth = $dbh->prepare( -"select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where kohafield=?" - ); + my $data; + my $sth = + $dbh->prepare( +"select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where kohafield=? AND frameworkcode=''" + ); $sth->execute( $tablename . "." . $kohafield ); my ( $defaulttagfield, $defaulttagsubfield, $defaultliblibrarian ) = $sth->fetchrow; for ( my $i = 0 ; $i <= 9 ; $i++ ) { - my $sth2 = $dbh->prepare( -"select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where tagfield like ?" - ); + my $sth2 = + $dbh->prepare( +"select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where tagfield like ? AND frameworkcode=''" + ); $sth2->execute("$i%"); my @marcarray; push @marcarray, " "; @@ -82,14 +86,10 @@ if ( $op eq 'add_form' ) { { push @marcarray, "$field $tagsubfield - $liblibrarian"; } - my $marclist = CGI::scrolling_list( - -name => 'marc', - -values => \@marcarray, - -default => - "$defaulttagfield $defaulttagsubfield - $defaultliblibrarian", - -size => 1, - -multiple => 0, - ); + my $marclist = { + values => \@marcarray, + default => "$defaulttagfield $defaulttagsubfield - $defaultliblibrarian", + }; $template->param( "marclist$i" => $marclist ); } $template->param( @@ -113,8 +113,10 @@ elsif ( $op eq 'add_validate' ) { $dbh->do( "update marc_subfield_structure set kohafield='$tablename.$kohafield' where tagfield='$temp[0]' and tagsubfield='$temp[1]'" ); - print -"Content-Type: text/html\n\n"; + # We could get a list of all frameworks and do them one-by-one, or zap + # everything. + $cache->flush_all(); + print $input->redirect("/cgi-bin/koha/admin/koha2marclinks.pl?tablename=$tablename"); exit; # END $OP eq ADD_VALIDATE @@ -151,19 +153,13 @@ q|select tagfield,tagsubfield,liblibrarian,kohafield from marc_subfield_structur "$script_name?op=add_form&tablename=$tablename&kohafield=$field"; push( @loop_data, \%row_data ); } + my $tablenames = { + values => [ 'biblio', 'biblioitems', 'items' ], + default => $tablename, + }; $template->param( loop => \@loop_data, - tablename => CGI::scrolling_list( - -name => 'tablename', - -values => [ - 'biblio', - 'biblioitems', - 'items', - ], - -default => $tablename, - -size => 1, - -multiple => 0 - ) + tablename => $tablenames, ); } #---- END $OP eq DEFAULT output_html_with_http_headers $input, $cookie, $template->output;