Bugzilla – Attachment 151989 Details for
Bug 32748
Library limitations will cause data loss when editing items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32748: Prevent data erasing when editing items
Bug-32748-Prevent-data-erasing-when-editing-items.patch (text/plain), 6.79 KB, created by
Thibaud Guillot
on 2023-06-05 13:05:27 UTC
(
hide
)
Description:
Bug 32748: Prevent data erasing when editing items
Filename:
MIME Type:
Creator:
Thibaud Guillot
Created:
2023-06-05 13:05:27 UTC
Size:
6.79 KB
patch
obsolete
>From 4608e67f77aaaddfb8e73a46428049e368b46d84 Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Thu, 6 Apr 2023 17:16:22 +0200 >Subject: [PATCH] Bug 32748: Prevent data erasing when editing items > >When we set an authorised value linked to one library, >users who do not belong to this library do not get the >value and can therefore overwrite it. > >This patch add current value to the dropdown list even if it comes from an authorized value of another library. > >Test plan : > >1) Edit an item with one of these fields has an authorized value from >another library. >2) See that you don't get this value on 'edit' >3) Apply this patch >4) Refresh and do step 1 >5) Now you have the value in dropdown list and a tooltip info >--- > C4/Koha.pm | 15 +++++++++++---- > Koha/UI/Form/Builder/Item.pm | 8 ++++++-- > .../prog/en/includes/html_helpers.inc | 11 +++++++++-- > 3 files changed, 26 insertions(+), 8 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 7132910adf..248b63dbab 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -486,32 +486,39 @@ C<$opac> If set to a true value, displays OPAC descriptions rather than normal o > sub GetAuthorisedValues { > my $category = shift // ''; # optional parameter > my $opac = shift ? 1 : 0; # normalise to be safe >+ my $options = shift // ''; >+ my $no_limit = $options->{'no_limit'} if $options; #optional paramater to ignore branch limitation > > # Is this cached already? > my $branch_limit = > C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; > my $cache_key = >- "AuthorisedValues-$category-$opac-$branch_limit"; >+ "AuthorisedValues-$category-$opac-$branch_limit-$no_limit"; > my $cache = Koha::Caches->get_instance(); > my $result = $cache->get_from_cache($cache_key); > return $result if $result; > > my @results; > my $dbh = C4::Context->dbh; >+ my $select_clause = 'SELECT av.*'; >+ my @where_args; >+ if ($branch_limit && $no_limit) { >+ $select_clause .= ', IF (branchcode = ? OR branchcode IS NULL, 0, 1) as restricted'; >+ push @where_args, $branch_limit; >+ } > my $query = qq{ >- SELECT DISTINCT av.* >+ $select_clause > FROM authorised_values av > }; > $query .= qq{ > LEFT JOIN authorised_values_branches ON ( id = av_id ) > } if $branch_limit; > my @where_strings; >- my @where_args; > if($category) { > push @where_strings, "category = ?"; > push @where_args, $category; > } >- if($branch_limit) { >+ if($branch_limit && !defined $no_limit) { > push @where_strings, "( branchcode = ? OR branchcode IS NULL )"; > push @where_args, $branch_limit; > } >diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm >index 3a478ee05e..180b6f8ba6 100644 >--- a/Koha/UI/Form/Builder/Item.pm >+++ b/Koha/UI/Form/Builder/Item.pm >@@ -174,6 +174,7 @@ sub generate_subfield_form { > if ( $subfield->{authorised_value} ) { > my @authorised_values; > my %authorised_lib; >+ my %authorised_restricted; > > # builds list, depending on authorised value... > if ( $subfield->{authorised_value} eq "LOST" ) { >@@ -251,10 +252,12 @@ sub generate_subfield_form { > } > else { > push @authorised_values, qq{}; >- my $av = GetAuthorisedValues( $subfield->{authorised_value} ); >+ my $av = GetAuthorisedValues( $subfield->{authorised_value}, undef, { 'no_limit' => 1 } ); > for my $r (@$av) { > push @authorised_values, $r->{authorised_value}; >- $authorised_lib{ $r->{authorised_value} } = $r->{lib}; >+ >+ $authorised_lib{ $r->{authorised_value} } = $r->{lib}; >+ $authorised_restricted{ $r->{authorised_value} } = $r->{restricted}; > } > } > >@@ -282,6 +285,7 @@ sub generate_subfield_form { > . $index_subfield, > values => \@authorised_values, > labels => \%authorised_lib, >+ restricted => \%authorised_restricted, > default => $value, > ( > ( >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index f0d695bc9c..ae32756224 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -113,12 +113,20 @@ > [% FOREACH aval IN mv.values %] > [% IF aval == mv.default %] > [% SET matched = 1 %] >- <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> >+ [% IF mv.restricted.$aval %] >+ <option value="[%- aval | html -%]" selected="selected" style="float:right" title="This value ([%- mv.labels.$aval | html -%]) is limited to other branches">[%- mv.labels.$aval | html -%] ⚠ >+ </option> >+ [% ELSE %] >+ <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> >+ [% END %] > [% ELSE %] > [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %] > <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option> > [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %] > <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option> >+ [% ELSIF mv.restricted.$aval %] >+ <option value="[%- aval | html -%]" style="float:right" title="This value ([%- mv.labels.$aval | html -%]) is limited to other branches">[%- mv.labels.$aval | html -%] ⚠ >+ </option> > [% ELSE %] > <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option> > [% END %] >@@ -210,7 +218,6 @@ > [% END %] > > <span class="hint" id="hint[% subfield.tag | html %][% subfield.subfield | html %][% subfield.random | html %]"></span> >- > </div> > </li> > [% END %] >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32748
:
148409
|
148491
|
150155
|
151989
|
154039
|
154040
|
154041
|
154042