Koha/svc/cataloguing/framework
Jesse Weaver edd64d3018 Bug 11559: Rancor: advanced cataloging interface
Full test plan is posted on bug. Test plan for system preference:

  1. Apply patch, clear cookies.
  2. Go to "Cataloging."
  3. Add new record, verify that basic editor is used.
  4. Navigate to existing record, click on "Edit record", verify that
     basic editor is used.
  5. Inside basic editor, verify that no button appears to switch to the
     advanced editor.
  6. Enable the "EnableAdvancedCatalogingEditor" syspref.
  7. Repeat above steps, should still go to basic editor, but button
     should appear to switch to the advanced editor; click it.
  8. Now, adding new records and editing existing records should go to
     the advanced editor.

Signed-off-by: Nick Clemens <nick@quecheelibrary.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2015-10-27 12:17:39 -03:00

77 lines
2.6 KiB
Perl
Executable file

#!/usr/bin/perl
use Modern::Perl '2009';
use CGI;
use C4::Branch;
use C4::ClassSource;
use C4::Context;
use C4::Biblio;
use C4::Service;
use Koha::Database;
my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' );
my $frameworkcode = $query->param( 'frameworkcode' ) // '';
my $tagslib = 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 = {};
$authorised_values->{branches} = [];
my $onlymine=C4::Context->preference('IndependentBranches') &&
C4::Context->userenv &&
C4::Context->userenv->{flags} % 2 == 0 &&
C4::Context->userenv->{branch};
my $branches = GetBranches($onlymine);
foreach my $thisbranch ( sort keys %$branches ) {
push @{ $authorised_values->{branches} }, { value => $thisbranch, lib => $branches->{$thisbranch}->{'branchname'} };
}
$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 = 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 $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
my $results;
if( $branch_limit ) {
$results = $schema->resultset( "AuthorisedValue" )->search(
{ "authorised_values_branches.branchcode" => { "=", [ $branch_limit, undef ] } },
{ join => "authorised_values_branches", order_by => "lib" } );
} else {
$results = $schema->resultset( "AuthorisedValue" )->search(
undef,
{ order_by => "lib" } );
}
foreach my $result ( $results->all ) {
$authorised_values->{$result->category} ||= [];
push @{ $authorised_values->{$result->category} }, { value => $result->authorised_value, lib => $result->lib };
}
$response->param( framework => \@tags, authorised_values => $authorised_values );
C4::Service->return_success( $response );