Bug 36654

Summary: Add template toolkit function to get arbitrary Koha::Objects
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: TemplatesAssignee: Kyle M Hall (khall) <kyle>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: julian.maurice, lucas, pedro.amorim
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 36654: Add template toolkit function to get arbitrary Koha::Objects
Bug 36654: Add template toolkit function to get arbitrary Koha::Objects
Bug 36654: Add template toolkit function to get arbitrary Koha::Objects

Description Kyle M Hall (khall) 2024-04-19 18:25:44 UTC
A lot of older notice data includes ids but not the objects themselves. We should have a helper TT plugin to make getting those objects easy.
Comment 1 Kyle M Hall (khall) 2024-04-19 18:28:27 UTC
In particular, the data for overdues is difficult to access.
Comment 2 Kyle M Hall (khall) 2024-04-19 18:30:21 UTC
Created attachment 165227 [details] [review]
Bug 36654: Add template toolkit function to get arbitrary Koha::Objects

A lot of older notice data include identifiers but not the objects themselves.
We should have a helper TT plugin to make getting those objects easy.

Test Plan:
1) prove t/db_dependent/Koha/Template/Plugin/Koha.t
2) Set the CHECKOUT notice to:

[% USE Koha %]
[% SET b = Koha.GetObjectById('Koha::Biblios', b.biblionumber );
[% b.title %]

3) Note the notice contains the checkout title
Comment 3 Matt Blenkinsop 2024-05-07 14:18:19 UTC
Created attachment 166293 [details] [review]
Bug 36654: Add template toolkit function to get arbitrary Koha::Objects

A lot of older notice data include identifiers but not the objects themselves.
We should have a helper TT plugin to make getting those objects easy.

Test Plan:
1) prove t/db_dependent/Koha/Template/Plugin/Koha.t
2) Set the CHECKOUT notice to:

[% USE Koha %]
[% SET b = Koha.GetObjectById('Koha::Biblios', bblio.biblionumber ); %]
[% b.title %]

3) Note the notice contains the checkout title

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Comment 4 Matt Blenkinsop 2024-05-07 14:19:43 UTC
Created attachment 166294 [details] [review]
Bug 36654: Add template toolkit function to get arbitrary Koha::Objects

A lot of older notice data include identifiers but not the objects themselves.
We should have a helper TT plugin to make getting those objects easy.

Test Plan:
1) prove t/db_dependent/Koha/Template/Plugin/Koha.t
2) Set the CHECKOUT notice to:

[% USE Koha %]
[% SET b = Koha.GetObjectById('Koha::Biblios', biblio.biblionumber ); %]
[% b.title %]

3) Note the notice contains the checkout title

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Comment 5 Julian Maurice 2024-09-20 12:49:32 UTC
I think this has security implications as anyone with "edit_notices" permission could fetch any object from the database.

In the CHECKOUT notice the biblio object is available so the example given could  be rewritten simply as:

[% biblio.title %]

Can you provide another example where GetObjectById would be required ?