From c5fbcf4aef16fc2a339c000a8223812ee066f131 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 27 Jul 2020 12:18:36 -0300 Subject: [PATCH] Bug 25826: Forbid changing the hidden attributes for biblionumber This patch tweaks the UI so it forbids changing the hidden values when they are correct (i.e. when they are not hidden in OPAC and intranet). To test: 1. Apply the first patch 2. Play with the hidden values of the subfield you have mapped to biblio.biblionumber in your picked framework. This is usually 999$c in MARC21, and 001 in UNIMARC. => SUCCESS: When you verify the about.pl, it mentions issues when you hide in some of the interfaces 3. Apply this patch and reload everything 4. Repeat 2 => SUCCESS: If your framework is 'ok', it prevents you from editing this values, otherwise you can change them. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens --- admin/marc_subfields_structure.pl | 28 ++++++++++++++++++++++ .../en/modules/admin/marc_subfields_structure.tt | 2 +- .../prog/js/marc_subfields_structure.js | 18 +++++++++++--- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 0dce186c6f..c02633a940 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -25,6 +25,7 @@ use C4::Context; use Koha::Authority::Types; use Koha::AuthorisedValueCategories; +use Koha::Filter::MARC::ViewPolicy; use List::MoreUtils qw( uniq ); @@ -192,6 +193,33 @@ if ( $op eq 'add_form' ) { $row_data{isurl} = $data->{isurl}; $row_data{row} = $i; $row_data{link} = $data->{'link'}; + + if ( defined $data->{kohafield} + and $data->{kohafield} eq 'biblio.biblionumber' ) + { + my $hidden_opac = Koha::Filter::MARC::ViewPolicy->should_hide_marc( + { + frameworkcode => $frameworkcode, + interface => "opac", + } + )->{biblionumber}; + + my $hidden_intranet = Koha::Filter::MARC::ViewPolicy->should_hide_marc( + { + frameworkcode => $frameworkcode, + interface => "intranet", + } + )->{biblionumber}; + + if ( $hidden_opac or $hidden_intranet ) { + # We should allow editing for fixing it + $row_data{hidden_protected} = 0; + } + else { + $row_data{hidden_protected} = 1; + } + } + push( @loop_data, \%row_data ); $i++; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt index 7736f1f248..81815e7803 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt @@ -129,7 +129,7 @@
  1. -
  2. +
  3. diff --git a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js b/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js index aa90be610a..081afd2484 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js @@ -70,7 +70,10 @@ function setHiddenValue() { hidden_value='8'; } - enable_cb(tab); + var hidden_protected = $('#hidden-'+ tab).attr('data-koha-protected'); + if ( hidden_protected != 1 ) { + enable_cb(tab); + } $('#hidden-' + tab).val(hidden_value); @@ -79,6 +82,7 @@ function setHiddenValue() { function populateHiddenCheckboxes(tab) { // read the serialized value var hidden_value = $('#hidden-' + tab).val(); + var hidden_protected = $('#hidden-'+ tab).attr('data-koha-protected'); // deafult to false var opac_checked = false; var intranet_checked = false; @@ -143,6 +147,14 @@ function populateHiddenCheckboxes(tab) { $("#hidden_collapsed_" + tab).prop('checked',collapsed_checked); $("#hidden_flagged_" + tab).prop('checked',flagged_checked); - enable_cb(tab); - + if ( hidden_protected == 1 ) { + $("#hidden_opac_" + tab).prop('disabled','disabled'); + $("#hidden_intranet_" + tab).prop('disabled','disabled'); + $("#hidden_editor_" + tab).prop('disabled','disabled'); + $("#hidden_collapsed_" + tab).prop('disabled','disabled'); + $("#hidden_flagged_" + tab).prop('disabled','disabled'); + } + else { + enable_cb(tab); + } } -- 2.11.0