Bug 40262

Summary: ILL - Save the fact that copyright clearance has been confirmed by the patron
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: ILLAssignee: Pedro Amorim <pedro.amorim>
Status: Pushed to main --- QA Contact: Tomás Cohen Arazi (tcohen) <tomascohen>
Severity: enhancement    
Priority: P5 - low CC: david, lisette, martin.renvoize, n.halford-busby, pedro.amorim, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
This enhancement to copyright clearance for interlibrary loan requests: - records the copyright clearance in the database (it previously wasn't) - shows the message "Patron has confirmed copyright clearance for this request" on the request page (This requires text in the ILLModuleCopyrightClearance HTML customization.)
Version(s) released in:
25.11.00
Circulation function:
Bug Depends on:    
Bug Blocks: 40850    
Attachments: Bug 40262: Save and display copyrightclearance_confirmed
Bug 40262: Save and display copyrightclearance_confirmed
Bug 40262: (QA follow-up): Fix compatibility with ILLOpacUnauthenticatedRequest
Bug 40262: Save and display copyrightclearance_confirmed
Bug 40262: (QA follow-up): Fix compatibility with ILLOpacUnauthenticatedRequest
Bug 40262: (follow-up) Refactor copyright clearance to use dedicated methods
Bug 40262: (follow-up) Refactor copyright clearance to use dedicated methods

Description Pedro Amorim 2025-06-27 14:00:57 UTC
The current functionality of ILLModuleCopyrightClearance blocks the patron from creating an ILL request in the OPAC unless they click 'Yes'. This is working like this by design but nowhere in the database this fact is recorded.
Some libraries require this to be recorded in the database for legal and other purposes.
Comment 1 Pedro Amorim 2025-06-27 14:09:02 UTC
Created attachment 183607 [details] [review]
Bug 40262: Save and display copyrightclearance_confirmed

Test plan, k-t-d:
1) Enable ILLModule
2) Add a new HTML customization, visit:
<staff_url>/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=html_customizations&editmode=wysiwyg
3) Pick ILLModuleCopyrightClearance as the 'Display location'
4) Pick a 'Publication date' in the past
5) Add a title and content. Save.
6) Create a new ILL request in the OPAC, visit:
<opac_url>/cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=Standard
7) Notice the copyright clearance step is shown. Click 'Yes'.
8) Enter a 'type' and (optionally) some metadata. Click 'Create'.
9) Go back to the module in Staff UI and pick the request just created through the OPAC, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl
10) Notice the message 'Patron has confirmed copyright clearance for this request' is shown next to the patron in the the request details
Comment 2 David Nind 2025-06-30 21:57:10 UTC
Created attachment 183662 [details] [review]
Bug 40262: Save and display copyrightclearance_confirmed

Test plan, k-t-d:
1) Enable ILLModule
2) Add a new HTML customization, visit:
<staff_url>/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=html_customizations&editmode=wysiwyg
3) Pick ILLModuleCopyrightClearance as the 'Display location'
4) Pick a 'Publication date' in the past
5) Add a title and content. Save.
6) Create a new ILL request in the OPAC, visit:
<opac_url>/cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=Standard
7) Notice the copyright clearance step is shown. Click 'Yes'.
8) Enter a 'type' and (optionally) some metadata. Click 'Create'.
9) Go back to the module in Staff UI and pick the request just created through the OPAC, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl
10) Notice the message 'Patron has confirmed copyright clearance for this request' is shown next to the patron in the the request details

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Pedro Amorim 2025-08-04 12:08:21 UTC
Created attachment 185096 [details] [review]
Bug 40262: (QA follow-up): Fix compatibility with ILLOpacUnauthenticatedRequest

This patch fixes the copyrightclearance_confirmed not saving if submitting an unauthenticated ILL request.
Comment 4 Tomás Cohen Arazi (tcohen) 2025-09-22 14:49:37 UTC
I understand where this is coming from. But I'm now comfortable with this not being baked into a library and tested. Would you agree with a follow-up patch adding a dedicated method in `Koha::ILL::Request` to be called from the controller?
Comment 5 Pedro Amorim 2025-09-22 15:01:47 UTC
(In reply to Tomás Cohen Arazi (tcohen) from comment #4)
> I understand where this is coming from. But I'm now comfortable with this
> not being baked into a library and tested. Would you agree with a follow-up
> patch adding a dedicated method in `Koha::ILL::Request` to be called from
> the controller?

Yes, of course.
Comment 6 Tomás Cohen Arazi (tcohen) 2025-09-22 15:25:53 UTC
Created attachment 186729 [details] [review]
Bug 40262: Save and display copyrightclearance_confirmed

Test plan, k-t-d:
1) Enable ILLModule
2) Add a new HTML customization, visit:
<staff_url>/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=html_customizations&editmode=wysiwyg
3) Pick ILLModuleCopyrightClearance as the 'Display location'
4) Pick a 'Publication date' in the past
5) Add a title and content. Save.
6) Create a new ILL request in the OPAC, visit:
<opac_url>/cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=Standard
7) Notice the copyright clearance step is shown. Click 'Yes'.
8) Enter a 'type' and (optionally) some metadata. Click 'Create'.
9) Go back to the module in Staff UI and pick the request just created through the OPAC, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl
10) Notice the message 'Patron has confirmed copyright clearance for this request' is shown next to the patron in the the request details

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Comment 7 Tomás Cohen Arazi (tcohen) 2025-09-22 15:25:57 UTC
Created attachment 186730 [details] [review]
Bug 40262: (QA follow-up): Fix compatibility with ILLOpacUnauthenticatedRequest

This patch fixes the copyrightclearance_confirmed not saving if submitting an unauthenticated ILL request.

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Comment 8 Tomás Cohen Arazi (tcohen) 2025-09-22 15:26:00 UTC
Created attachment 186731 [details] [review]
Bug 40262: (follow-up) Refactor copyright clearance to use dedicated methods

This patch refactors the copyright clearance confirmation functionality
to follow proper separation of concerns by moving business logic from
the controller to the model.

Changes:
- Add set_copyright_clearance_confirmed() method to Koha::ILL::Request
- Add get_copyright_clearance_confirmed() method to Koha::ILL::Request
- Update controller to use dedicated method instead of direct attribute manipulation
- Update staff template to use the new dedicated accessor method
- Add comprehensive test coverage for both methods

Benefits:
- Improved separation of concerns (business logic in model)
- Consistency with existing patterns (get_type, get_type_disclaimer_value)
- Better reusability and testability
- Centralized attribute name management

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/ILL/Request/CopyrightClearance.t
=> SUCCESS: Tests pass! New methods work correctly
3. Test ILL copyright clearance workflow still works:
   - Enable ILLModule
   - Create HTML customization for ILLModuleCopyrightClearance
   - Create OPAC ILL request with copyright clearance
   - Verify confirmation is saved and displayed in staff interface
4. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Comment 9 Tomás Cohen Arazi (tcohen) 2025-09-22 15:26:46 UTC
Please confirm if you agree with the follow-up patch.
Comment 10 Pedro Amorim 2025-09-23 15:40:58 UTC
Created attachment 186824 [details] [review]
Bug 40262: (follow-up) Refactor copyright clearance to use dedicated methods

This patch refactors the copyright clearance confirmation functionality
to follow proper separation of concerns by moving business logic from
the controller to the model.

Changes:
- Add set_copyright_clearance_confirmed() method to Koha::ILL::Request
- Add get_copyright_clearance_confirmed() method to Koha::ILL::Request
- Update controller to use dedicated method instead of direct attribute manipulation
- Update staff template to use the new dedicated accessor method
- Add comprehensive test coverage for both methods

Benefits:
- Improved separation of concerns (business logic in model)
- Consistency with existing patterns (get_type, get_type_disclaimer_value)
- Better reusability and testability
- Centralized attribute name management

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/ILL/Request.t
=> SUCCESS: Tests pass! New methods work correctly
3. Test ILL copyright clearance workflow still works:
   - Enable ILLModule
   - Create HTML customization for ILLModuleCopyrightClearance
   - Create OPAC ILL request with copyright clearance
   - Verify confirmation is saved and displayed in staff interface
4. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>

PA amended: Test file name in commit message

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
Comment 11 Lucas Gass (lukeg) 2025-09-23 22:24:26 UTC
Nice work everyone!

Pushed to main for 25.11