Koha/svc/cataloguing/framework
Nick Clemens f8813f8d37 Bug 28750: (bug 17600 follow-up) Use full path for subroutines
Throughout the file we call methods with the module
Following suit rather than importing the methods

To test:
1 - Attempt to load advanced cataloging editor
2 - it fails
3 - http://localhost:8081/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=define
4 - Undefined subroutine &CGI::Compile::ROOT::kohadevbox_koha_svc_cataloguing_framework::GetMarcStructure called at /kohadevbox/koha/svc/cataloguing/framework line 18
5 - Apply patch
6 - Cataloging editor loads!
7 - Link in #3 loads!

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-07-26 16:28:52 +02:00

62 lines
2 KiB
Perl
Executable file

#!/usr/bin/perl
use Modern::Perl '2009';
use CGI;
use C4::ClassSource;
use C4::Context;
use C4::Biblio;
use C4::Koha;
use C4::Service;
use Koha::Database;
use Koha::Libraries;
my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' );
my $frameworkcode = $query->param( 'frameworkcode' ) // '';
my $tagslib = C4::Biblio::GetMarcStructure( 1, $frameworkcode );
my @tags;
foreach my $tag ( sort keys %$tagslib ) {
my $taglib = $tagslib->{$tag};
my $taginfo = { map { $_, $taglib->{$_} } grep { length $_ > 1 } keys %$taglib };
$taginfo->{subfields} = [ map { [ $_, $taglib->{$_} ] } grep { length $_ == 1 } sort keys %$taglib ];
push @tags, [ $tag, $taginfo ];
}
my $schema = Koha::Database->new->schema;
my $authorised_values = {};
my $branches = { map { $_->branchcode => $_->branchname } Koha::Libraries->search_filtered };
$authorised_values->{branches} = [];
foreach my $thisbranch ( sort keys %$branches ) {
push @{ $authorised_values->{branches} }, { value => $thisbranch, lib => $branches->{$thisbranch} };
}
$authorised_values->{itemtypes} = [ $schema->resultset( "Itemtype" )->search( undef, {
columns => [ { value => 'itemtype' }, { lib => "description" } ],
order_by => "description",
result_class => 'DBIx::Class::ResultClass::HashRefInflator'
} ) ];
my $class_sources = C4::ClassSource::GetClassSources();
my $default_source = C4::Context->preference("DefaultClassificationSource");
foreach my $class_source (sort keys %$class_sources) {
next unless $class_sources->{$class_source}->{'used'} or
($class_source eq $default_source);
push @{ $authorised_values->{cn_source} }, { value => $class_source, lib => $class_sources->{$class_source}->{'description'} };
}
my $avs = C4::Koha::GetAuthorisedValues();
for my $av ( @$avs ) {
push @{ $authorised_values->{$av->{category}} }, { value => $av->{authorised_value}, lib => $av->{lib} };
}
$response->param( framework => \@tags, authorised_values => $authorised_values );
C4::Service->return_success( $response );