Bug 25416 - Add information about anonymous session for XSLT use
Summary: Add information about anonymous session for XSLT use
Status: Pushed to stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Nick Clemens
URL:
Keywords:
Depends on:
Blocks: 24458
  Show dependency treegraph
 
Reported: 2020-05-07 13:56 UTC by Tomás Cohen Arazi
Modified: 2020-05-20 20:51 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.06


Attachments
Bug 25416: Sample usage for testing purposes [DO NOT PUSH] (2.16 KB, patch)
2020-05-07 18:21 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 25416: Let OPAC XSLTs know if the context is an anonymous session (6.86 KB, patch)
2020-05-07 18:21 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 25416: Unit tests (1.63 KB, patch)
2020-05-11 11:42 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24458: Regression tests (2.89 KB, patch)
2020-05-11 13:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24458: Use the ViewPolicy filter on search results (2.24 KB, patch)
2020-05-11 13:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 25416: Sample usage for testing purposes [DO NOT PUSH] (2.21 KB, patch)
2020-05-11 21:09 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 25416: Let OPAC XSLTs know if the context is an anonymous session (6.92 KB, patch)
2020-05-11 21:09 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 25416: Unit tests (1.68 KB, patch)
2020-05-11 21:09 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 25416: (follow-up) Remove useless use statement (876 bytes, patch)
2020-05-12 12:09 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 25416: Sample usage for testing purposes [DO NOT PUSH] (2.34 KB, patch)
2020-05-12 12:36 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 25416: Let OPAC XSLTs know if the context is an anonymous session (7.03 KB, patch)
2020-05-12 12:36 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 25416: Unit tests (1.79 KB, patch)
2020-05-12 12:36 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 25416: (follow-up) Remove useless use statement (988 bytes, patch)
2020-05-12 12:36 UTC, Nick Clemens
Details | Diff | Splinter Review
[19.11.x] Bug 25416: Let OPAC XSLTs know if the context is an anonymous session (7.00 KB, patch)
2020-05-20 18:54 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
[19.11.x] Bug 25416: Unit tests (1.73 KB, patch)
2020-05-20 18:54 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2020-05-07 13:56:00 UTC
For building different UI elements based on whether the patron is logged or not in the OPAC, it would be handy to add such information to the variables that are added to the MARCXML so the XSLT can take advantage of it.
Comment 1 Tomás Cohen Arazi 2020-05-07 18:21:19 UTC
Created attachment 104533 [details] [review]
Bug 25416: Sample usage for testing purposes [DO NOT PUSH]
Comment 2 Tomás Cohen Arazi 2020-05-07 18:21:25 UTC
Created attachment 104534 [details] [review]
Bug 25416: Let OPAC XSLTs know if the context is an anonymous session

This patch makes use of the 'variables' parameter in XSLTParse4Display
method in the different places that it is used in the OPAC. It does by
passing this parameter with

    anonymous_session => 1|0

The value will depend on the output from get_template_and_user (i.e. if
there's a returned borrowernumber).

A special case takes place in search results, as the call to
XSLTParse4Display happens in C4::Search::searchResults. So a new
parameter 'xslt_variables' is added to it.

To test:
1. Apply the [DO NOT PUSH] patch
2. Open the OPAC in your browser
3. Try detail pages, search results, tags and shelves pages with or
   without an active session
=> FAIL: It always says (somewhere) 'Anonymous session: Yes'
4. Apply this patch, restart_all
5. Repeat 3
=> SUCCESS: It will tell the Yes/No correctly regarding anonymous
sessions!
6. Sign off :-D

Sponsored-by: Universidad ORT Uruguay
Comment 3 Katrin Fischer 2020-05-09 22:26:49 UTC
I've been curious about this one as I have been wondering about a similar feature that would require some configuration information to the the XSLT. We have some similar features for passing XSLT variables (system preferences, authorised value descriptions) to MARCXML in XSLT.pm, but this patch doesn't touch the file. Is there a reason? Also missing tests :)
Comment 4 Tomás Cohen Arazi 2020-05-09 22:59:11 UTC
(In reply to Katrin Fischer from comment #3)
> I've been curious about this one as I have been wondering about a similar
> feature that would require some configuration information to the the XSLT.
> We have some similar features for passing XSLT variables (system
> preferences, authorised value descriptions) to MARCXML in XSLT.pm, but this
> patch doesn't touch the file. Is there a reason? Also missing tests :)

This uses a feature already present (that $variables parameter in XSLTTransform...
Comment 5 Tomás Cohen Arazi 2020-05-09 23:02:51 UTC
(In reply to Katrin Fischer from comment #3)
> I've been curious about this one as I have been wondering about a similar
> feature that would require some configuration information to the the XSLT.
> We have some similar features for passing XSLT variables (system
> preferences, authorised value descriptions) to MARCXML in XSLT.pm, but this
> patch doesn't touch the file. Is there a reason? Also missing tests :)

It is totally related to injecting sysprefs, as it happens in the same method. It is just an extra variable Julian seems to have added a while ago, and this patch is just making use of it.
Comment 6 Tomás Cohen Arazi 2020-05-11 01:29:52 UTC
(In reply to Katrin Fischer from comment #3)
> I've been curious about this one as I have been wondering about a similar
> feature that would require some configuration information to the the XSLT.
> We have some similar features for passing XSLT variables (system
> preferences, authorised value descriptions) to MARCXML in XSLT.pm, but this
> patch doesn't touch the file. Is there a reason? Also missing tests :)

I will add tests. I wanted your opinion on the feature first, as the tests are the most difficult bit here. Specially on this area
Comment 7 Tomás Cohen Arazi 2020-05-11 11:42:45 UTC
Created attachment 104689 [details] [review]
Bug 25416: Unit tests

This patch adds tests for the new 'feature': i.e. searchResults passes
the added $xslt_variables to the XSLTParse4Display method.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 8 Tomás Cohen Arazi 2020-05-11 11:45:19 UTC
(In reply to Katrin Fischer from comment #3)
> Also missing tests :)

Done :-D
Comment 9 Tomás Cohen Arazi 2020-05-11 13:16:46 UTC Comment hidden (obsolete)
Comment 10 Tomás Cohen Arazi 2020-05-11 13:16:50 UTC Comment hidden (obsolete)
Comment 11 Victor Grousset/tuxayo 2020-05-11 21:09:49 UTC
Created attachment 104718 [details] [review]
Bug 25416: Sample usage for testing purposes [DO NOT PUSH]

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 12 Victor Grousset/tuxayo 2020-05-11 21:09:53 UTC
Created attachment 104719 [details] [review]
Bug 25416: Let OPAC XSLTs know if the context is an anonymous session

This patch makes use of the 'variables' parameter in XSLTParse4Display
method in the different places that it is used in the OPAC. It does by
passing this parameter with

    anonymous_session => 1|0

The value will depend on the output from get_template_and_user (i.e. if
there's a returned borrowernumber).

A special case takes place in search results, as the call to
XSLTParse4Display happens in C4::Search::searchResults. So a new
parameter 'xslt_variables' is added to it.

To test:
1. Apply the [DO NOT PUSH] patch
2. Open the OPAC in your browser
3. Try detail pages, search results, tags and lists/shelves pages with
   or without an active session
=> FAIL: It always says (somewhere) 'Anonymous session: Yes'
4. Apply this patch, restart_all
5. Repeat 3
=> SUCCESS: It will tell the Yes/No correctly regarding anonymous
sessions!
6. Sign off :-D

Sponsored-by: Universidad ORT Uruguay

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 13 Victor Grousset/tuxayo 2020-05-11 21:09:57 UTC
Created attachment 104720 [details] [review]
Bug 25416: Unit tests

This patch adds tests for the new 'feature': i.e. searchResults passes
the added $xslt_variables to the XSLTParse4Display method.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 14 Tomás Cohen Arazi 2020-05-12 12:09:58 UTC
Created attachment 104764 [details] [review]
Bug 25416: (follow-up) Remove useless use statement

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 15 Nick Clemens 2020-05-12 12:36:35 UTC
Created attachment 104767 [details] [review]
Bug 25416: Sample usage for testing purposes [DO NOT PUSH]

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

https://bugs.koha-community.org/show_bug.cgi?id=24516
Comment 16 Nick Clemens 2020-05-12 12:36:38 UTC
Created attachment 104768 [details] [review]
Bug 25416: Let OPAC XSLTs know if the context is an anonymous session

This patch makes use of the 'variables' parameter in XSLTParse4Display
method in the different places that it is used in the OPAC. It does by
passing this parameter with

    anonymous_session => 1|0

The value will depend on the output from get_template_and_user (i.e. if
there's a returned borrowernumber).

A special case takes place in search results, as the call to
XSLTParse4Display happens in C4::Search::searchResults. So a new
parameter 'xslt_variables' is added to it.

To test:
1. Apply the [DO NOT PUSH] patch
2. Open the OPAC in your browser
3. Try detail pages, search results, tags and lists/shelves pages with
   or without an active session
=> FAIL: It always says (somewhere) 'Anonymous session: Yes'
4. Apply this patch, restart_all
5. Repeat 3
=> SUCCESS: It will tell the Yes/No correctly regarding anonymous
sessions!
6. Sign off :-D

Sponsored-by: Universidad ORT Uruguay

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

https://bugs.koha-community.org/show_bug.cgi?id=24516
Comment 17 Nick Clemens 2020-05-12 12:36:42 UTC
Created attachment 104769 [details] [review]
Bug 25416: Unit tests

This patch adds tests for the new 'feature': i.e. searchResults passes
the added $xslt_variables to the XSLTParse4Display method.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

https://bugs.koha-community.org/show_bug.cgi?id=24516
Comment 18 Nick Clemens 2020-05-12 12:36:46 UTC
Created attachment 104770 [details] [review]
Bug 25416: (follow-up) Remove useless use statement

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

https://bugs.koha-community.org/show_bug.cgi?id=24516
Comment 19 Katrin Fischer 2020-05-12 21:47:13 UTC
the others were faster :)
Comment 20 Martin Renvoize 2020-05-15 08:58:27 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 21 Joy Nelson 2020-05-19 21:55:53 UTC
enhancement not backported to 19.11.x
Comment 22 Tomás Cohen Arazi 2020-05-19 22:04:48 UTC
(In reply to Joy Nelson from comment #21)
> enhancement not backported to 19.11.x

Why not? :-D
Comment 23 Tomás Cohen Arazi 2020-05-20 18:54:47 UTC
Created attachment 105160 [details] [review]
[19.11.x] Bug 25416: Let OPAC XSLTs know if the context is an anonymous session

This patch makes use of the 'variables' parameter in XSLTParse4Display
method in the different places that it is used in the OPAC. It does by
passing this parameter with

    anonymous_session => 1|0

The value will depend on the output from get_template_and_user (i.e. if
there's a returned borrowernumber).

A special case takes place in search results, as the call to
XSLTParse4Display happens in C4::Search::searchResults. So a new
parameter 'xslt_variables' is added to it.

To test:
1. Apply the [DO NOT PUSH] patch
2. Open the OPAC in your browser
3. Try detail pages, search results, tags and lists/shelves pages with
   or without an active session
=> FAIL: It always says (somewhere) 'Anonymous session: Yes'
4. Apply this patch, restart_all
5. Repeat 3
=> SUCCESS: It will tell the Yes/No correctly regarding anonymous
sessions!
6. Sign off :-D

Sponsored-by: Universidad ORT Uruguay

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 24 Tomás Cohen Arazi 2020-05-20 18:54:55 UTC
Created attachment 105161 [details] [review]
[19.11.x] Bug 25416: Unit tests

This patch adds tests for the new 'feature': i.e. searchResults passes
the added $xslt_variables to the XSLTParse4Display method.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 25 Tomás Cohen Arazi 2020-05-20 18:56:34 UTC
(In reply to Joy Nelson from comment #21)
> enhancement not backported to 19.11.x

Just in case you would reconsider it, I submitted the 19.11 version, which is just adjusting the name of the XSLT class (Koha::XSLT_handler vs Koha::XSLT::Base) and the tests count (removal of QueryParser in master).
Comment 26 Joy Nelson 2020-05-20 20:51:31 UTC
Pushed to 19.11.x for 19.11.06