From faa989913c1ba4e98635c66f697172e91695f321 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 29 May 2025 12:01:12 +0000 Subject: [PATCH] Bug 40026: Edit item metadata should present Standard form if AutoILLBackendPriority is in use When the AutoILLBackendPriority system preference is enabled, the form that was used is always the Standard form, regardless of which backend the request ends up on. It only makes sense that when editing an ILL request's item metadata, the form shown is also the Standard form if AutoILLBackendPriority is in use. Test plan, k-t-d, don't apply patch: 1) Enable ILLModule 2) Install an external backend, e.g. the libkey lending tool (IncDocs) backend plugin: https://github.com/openfifth/koha-ill-libkey-lending-tool/releases/tag/v2.0.3 3) Restart plack $ koha-plack --restart kohadev 4) Create a new IncDocs ILL request: /cgi-bin/koha/ill/ill-requests.pl?method=create&backend=IncDocs 5) Add a DOI '123', a cardnumber '42' and any library. Click 'Make request'. 6) Enable AutoILLBackendPriority system preference by ticking 'IncDocs'. This is only done now to simplify the test plan, as creating an 'IncDocs' request using AutoILLBackendPriority requires credentials configuration. 7) Back on the 'Manage request' page for the request created in step 5, click 'Edit item metadata'. Notice the form shown is not the 'Standard' form (its the IncDocs one). Edit any of the metadata values, click 'Save'. Verify the new metadata is saved correctly. 8) Apply patch. Repeat 7). Notice the form shown is the 'Standard' form now. Edit any of the metadata values, click "Save". Verify the new medata is saved correctly. --- Koha/ILL/Request.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 9b151e3924c..549cd5b587c 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -1189,6 +1189,8 @@ sub expand_template { $backend_tmpl = join "/", $backend_dir, $backend; } + ( $params, $backend_tmpl ) = _edititem_tmpl_override( $params, $backend_tmpl ); + my $intra_tmpl = join "/", $backend_tmpl, "intra-includes", ( $params->{method} // q{} ) . ".inc"; my $opac_tmpl = join "/", $backend_tmpl, "opac-includes", @@ -1202,6 +1204,29 @@ sub expand_template { return $params; } +=head3 _edititem_tmpl_override + + $backend_tmpl = _edititem_tmpl_override( $params, $backend_tmpl ); + +Overwrites template path and cwd (current working directory) with core Standard's to present the same +form when editing a request's item metadata using AutoILLBackendPriority mode, regardless of backend. + +=cut + +sub _edititem_tmpl_override { + my ( $params, $backend_tmpl ) = @_; + + return ( $params, $backend_tmpl ) + unless $params->{method} eq 'edititem' + && C4::Context->preference("AutoILLBackendPriority"); + + $backend_tmpl = dirname(__FILE__) . '/Backend'; + if ( exists $params->{cwd} ) { + $params->{cwd} = $backend_tmpl; + } + return ( $params, $backend_tmpl ); +} + #### Abstract Imports =head3 getLimits -- 2.39.5