Commit Graph

296 Commits

Author SHA1 Message Date
Jonathan Druart 36606ea9d6
Bug 41674: Fix review issues - remove unused import, fix POD synopsis, remove unused variable
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-30 09:14:52 +00:00
Owen Leonard 797c1b352e
Bug 41674: Add template plugin for linking to system preferences based on user permission
This patch adds a new template plugin, LinkPref, for displaying system
preference names as links depending on the logged-in user's permission.

Syntax:

  [% "SYSTEM_PREFERENCE_NAME" | html | $LinkPref %]

For a user with 'CAN_user_parameters_manage_sysprefs' permission it
outputs:

  <a class="link_preference" href="admin/preferences.pl?op=search&amp;ok=Search&amp;searchfield=SYSTEM_PREFERENCE_NAME">SYSTEM_PREFERENCE_NAME</a>

For a user without permission it outputs:

  <span class="link_preference">SYSTEM_PREFERENCE_NAME</span>

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-30 09:14:45 +00:00
Olivia Reynolds fd24968eb2
Bug 41648: Handle parse errors in KohaDates
If dt_from_string throws an exception whilst trying to parse the input,
catch it and return an empty result.

Test plan:
1. Apply patch.
2. Prove t/db_dependent/Template/Plugin/KohaDates.t

Sponsored-by: Open Fifth
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-08-21 14:31:47 +00:00
David Cook 268863392e
Bug 42136: prevent cgi, directory, and file plugins from use in user-entered templates
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-04-28 15:48:20 -06:00
Martin Renvoize b18fbab806
Bug 39781: (QA follow-up) Fix crashes, dead code and add tests
- Fix potential crash when C4::Context->userenv returns undef:
  use the established ternary guard pattern used throughout other
  TT plugins (AuthorisedValues, Branches, Desks, etc.)
- Remove dead second argument passed to GetLettersAvailableForALibrary,
  which only accepts one argument; the group_by/columns/order_by
  hashref was silently dropped
- Fix typo "librries" -> "libraries" in GetByModuleForLibrary POD
- Update POD example to use 'add_message' module matching actual usage
- Add test coverage for GetByModuleForLibrary, verifying that a user
  logged in to a branch sees branch-specific and all-libraries notices,
  while users at other branches see only all-libraries notices

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
2026-03-24 15:38:09 +01:00
Andrew Fuerste Henry 5937d40a28
Bug 39781: Add POD coverage
Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
2026-03-24 15:38:09 +01:00
Andrew Fuerste Henry 3a1bd59197
Bug 39781: Allow limiting of custom message notices by library
To test
The following should work with either email or SMS notices sent from the Add Message button in a patron record
1 - create a notice in module Patrons (custom message) for all libraries
2 - create a notice in module Patrons (custom message) for Centerville
3 - while logged in at Centerville, confirm you can see and enqueue your all libraries message
4 - while logged in at Centerville, confirm you can see but cannot successfully enqueue your Centerville message
5 - while logged in at Fairfield, confirm you can see but cannot successfully enqueue your Centerville message

6 - apply patch, restart_all

7 - while logged in at Fairfield, confirm you can see and enqueue your all libraries message
8 - while logged in at Fairfield, confirm you cannot see your Centerville message
9 - while logged in at Centervielle, confirm you can see and enqueue your Centerville message

Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
2026-03-24 15:38:08 +01:00
Tomás Cohen Arazi f64051cddb
Bug 41107: (follow-up) Use Koha::Status in Koha::Template::Plugin::Koha
This patch makes the template plugin used for rendering the Koha version
use the introduced method.

I did this checks:

```shell
cd koha-tmpl
git grep Koha.Version
```

The places Koha.Version is used, it is used as:

* `Koha.Version.maintenance`
* `Koha.Version.release`
* Assigned to a variable like this `SET koha_version = Koha.Version`

All occurences of the `koha_version` template variable are:

* `koha_version.development`
* `koha_version.major`
* `koha_version.minor`

This implies the newly added `.version` attribute has no undesired side
effects in templates.

Note: plugins-home.tt has a different use of a variable named the same,
which is unrelated.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/Koha_Template_Plugin_Koha.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
2026-03-23 09:33:54 +01:00
David Cook c8bfd03386
Bug 38365: Only get the nonce in templates if CSP is enabled
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:26 +01:00
David Cook a26a1f4dc7
Bug 38365: Fix nonce caching and add to framework plugin scripts
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:17 +01:00
Lari Taskula e750e6d1f5
Bug 38365: Add Koha::Template::Plugin::Koha::CSPNonce
This patch adds a new Template plugin method, Koha.CSPNonce, that can be used to
attach the Content Security Policy nonce into our templates.

To test:
1. prove t/Koha/Middleware/ContentSecurityPolicy.t
2. prove t/db_dependent/Koha/Template/Plugin/Koha.t

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:10 +01:00
Martin Renvoize aee1c8f7a5
Bug 40095: Add context to intranet_js plugin hook
The get_plugins_intranet_js method now passes the current script name
(controller) to plugins via a 'page' parameter, allowing plugins to
determine which page/controller is being displayed.

This will allow plugin authors to only return JS that's relevant to the
current page when they wish to do so.

Test plan:
1. Create a plugin with an intranet_js method that logs the received parameters
2. Navigate to different pages in the staff interface
3. Verify that the plugin receives the page parameter containing the script name
4. Confirm that the script name reflects the actual controller (e.g.,
   '/cgi-bin/koha/admin/admin-home.pl' when on the admin home page)
5. Run the test: prove t/db_dependent/Koha/Template/Plugin/KohaPlugins.t
6. Verify that the new test passes, confirming plugins receive the page parameter

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-06 15:17:36 -07:00
Imani Thomas 315f9a95af
Bug 39142: Add debug permission to allow user to toggle JS and CSS customizations on/off
To test:
1. Apply the patch
2. Use updatedatabase run to update your db
3. Add custom JS and CSS in the IntranetUserJS and IntranetUserCSS fields
4. With a superLibrarian account confirm you have 3 buttons at the bottom of
   your screen, Disable User JS, Disable User CSS, and load only default
   stylesheets
5. Clicking the buttons should reload the current page with a query to
   disable those things.
6. Log in as a user that is not a superlibrarian and does not have the
   debug UI permission enabled
7. Confirm the buttons are no longer visible
8. Add the debug UI permission to the user
9. Confirm the debug buttons are now visible for that user.

Signed-off-by: Lari Strand <lari.strand@koha-suomi.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-01-09 08:18:48 -07:00
Tomás Cohen Arazi 35fd016f88
Bug 37711: (follow-up) Fix AuthClient plugin database upgrade handling
The AuthClient template plugin was causing 500 errors during database
upgrades when the identity_providers schema was out of sync. The plugin
tried to query the new 'auto_register_opac' column before the database
schema was updated, creating a chicken-egg problem.

This patch wraps the database query in Try::Tiny to handle schema
mismatches gracefully during upgrades, allowing the upgrade process
to continue without crashing the authentication interface.

Test plan:
1. On main, apply all bug 37711 patches BUT THIS ONE
2. Simulate an upgrade by:

* Edit Koha.pm so it points to the next version
* Move the atomicupdate file to the right number in db_revs

3. Restart everything:
   $ ktd --shell
  k$ restart_all
4. Access http://kohadev-intra.localhost
=> FAIL: You get a 500! With a stack trace!
5. Apply this patch
6. Repeat 3 and 4
=> SUCCESS: No 500 error, redirects to installer
7. Proceed with the upgrade:
=> SUCCESS: It works as it should
8. Run tests:
  k$ prove -v t/db_dependent/Template/Plugin/AuthClient.t
=> SUCCESS: All tests pass
9. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-11-05 07:12:33 -07:00
Tomás Cohen Arazi 6b478e0da9
Bug 40163: (follow-up) Fix wrong GNU links and update test
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-09-24 09:25:04 -06:00
Tomas Cohen Arazi 1873d97c07
Bug 40163: Fix several http addresses in the code docs
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-09-23 16:21:29 -06:00
Matt Blenkinsop 4260c84cde
Bug 37115: Delete linked serial when deleting a single item
Test plan:
- Add a new subscription to a serial notice (with the option 'create an item record' selected)
- Receive one issue and create the linked item
- Return to the bibliographic record
- Edit item - Action - Delete
- Tick the box 'delete serial issues linked to item' and confirm
- The item should still be deleted correctly
- Back to subscription : the issue linked to the item doesn't exist any more

Signed-off-by: Boubacar OUATTARA <boubacar.ouattara@biblibre.com>
Signed-off-by: Nathalie <nathalie.savarit@univ-amu.fr>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-08-01 13:22:53 -06:00
Marcel de Rooy 64b78fe3c4
Bug 40132: Remove POD for get_opac_news_by_id
We are removing a wrong method name at the same time ;)

Test plan:
Read the patch. Just removing a few outdated POD lines.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-28 16:26:36 -06:00
Jonathan Druart 1d844a7d2f
Bug 39325: Automatic fix
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-28 18:51:22 +02:00
Jonathan Druart b40ceb1cf5
Bug 39367: Manual changes
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-23 09:35:15 +02:00
Jonathan Druart 9fbff51f0a
Bug 39367: Automatic changes
Added head2 right before sub with missing POD

Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-23 09:35:14 +02:00
David Cook 31ff6b69df
Bug 38488: Add Template::Toolkit filter for C4::Scrubber
This change adds a Template::Toolkit filter which is invoked
via " | scrub_html type => 'note' ".

Test plan:
0. Apply the patch
1. prove t/Koha/Plugins/HtmlScrubber.t

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-06 13:54:45 +01:00
Jonathan Druart ddc0e07bab
Bug 36081: Use multivalue_preference
C4::Context->multivalue_preference is not used so far and split on |
However the values of "multiple" sysprefs are separated by... comma!

Let support both here.

This patch also removes silly JS code in the template.

Signed-off-by: Magnus Enger <magnus@libriotech.no>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-06 13:54:36 +01:00
Andreas Jonsson 208a7cc3a4
Bug 36025: Incorrect clause in patron search
This patch removes the search clause for
extended_attributes when there is no patron
attribute types which are searchable by default.

The clause was incorrectly added because the array
extended_attribute_types was rendered as [""]

This seems to be an issue with get_columns from DBIX Class and how that is cast when forcing an array
in the template. It returns an empty string for nothing, a scalar for a single value, and an array for multiple
values.

This patch now checks if the variable is set and has content, and wraps as an array if so. In the case of two attributes,
we do double the array, but this was true before as we always cast the return as an array.

Test plan:

* Make sure that no borrower attribute type is set to "searched by default"
  in Koha administration -> Patron attribute types.
* Enable the network monitring in the developer tools in your web browser
  (Ctrl + Shift + E in firefox or Ctrl + Shift + I and select the "Network"
  tab).
* Go to the patrons view members-home.pl (click patrons in top menu bar).
* Search for a string that will match multiple borrowers (to not be automatically
  redirected)
* Examine the ajax-request and make sure that "extended_attributes.code" is NOT
  part of the query.
* Also, in koha-testing-docker with selenium enabled,
  run 'perl t/db_dependent/selenium/patrons_search.t'
* Now set one patro attribute to searchable and searched by default and add a value for a patron, confirm search works
* Set a second patron attribute to searchable and searched by default and confirm searching works

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised. Did not run the selenium tests, as they have
been obsoleted.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-17 15:06:01 +01:00
Koha Development Team d659526b5a
Bug 38664: Tidy the whole codebase
This commit is generated using:
  % perl misc/devel/tidy.pl
*within* ktd, to get the same version of perltidy than what will be used
by our CI (currently v20230309).

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:24 +01:00
Katrin Fischer 7d2f41adee
Revert "Bug 36025: Incorrect clause in patron search"
This reverts commit 79085c4723.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-07 15:47:54 +01:00
Andreas Jonsson 79085c4723
Bug 36025: Incorrect clause in patron search
This patch removes the search clause for
extended_attributes when there is no patron
attribute types which are searchable by default.

The clause was incorrectly added because the array
extended_attribute_types was rendered as [""] in
the template patron-search.inc most likely due to
a bug in DBIx::Class.

Test plan:

* Make sure that no borrower attribute type is set to "searched by default"
  in Koha administration -> Patron attribute types.
* Enable the network monitring in the developer tools in your web browser
  (Ctrl + Shift + E in firefox or Ctrl + Shift + I and select the "Network"
  tab).
* Go to the patrons view members-home.pl (click patrons in top menu bar).
* Search for a string that will match multiple borrowers (to not be automatically
  redirected)
* Examine the ajax-request and make sure that "extended_attributes.code" is NOT
  part of the query.
* Also, in koha-testing-docker with selenium enabled,
  run 'perl t/db_dependent/selenium/patrons_search.t'

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-12-30 15:12:47 +01:00
Marcel de Rooy 57c886f9ba
Bug 38758: Add strftime as TT virtual method
Test plan:
Try things like [% borrower.dateexpiry.strftime('%d-%m-%y') %] in
a notice. Also test datetime fields like borrower.lastseen.
Add locale support with strftime('%d %B', 'nl_NL') etc.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-12-23 13:36:24 +01:00
Jonathan Druart 827126e316
Bug 38594: Remove unused TablesSettings.GetColumns
This is no longer used, and should not.

Test plan:
  git grep TablesSettings.GetColumns
should not return any results

  git grep GetColumns
should not return results related to this method

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-12-03 17:34:05 +01:00
David Cook e8e00cfeb3
Bug 22223: Add filter to make item URLs safe in template output
This change adds a "safe_url" filter which takes a text input and
returns a Perl URL object which stringifies to a safe URL.

This change is only needed in the OPAC as the staff interface
handles the item URL display using Javascript not Template Toolkit.

0. Apply patch and koha-plack --restart kohadev
1. Create an item for a record using the following URL
https://koha-community.org?url=https%3A%2F%2Fkoha-community.org
2. Go to the OPAC for that record and verify that the URL is
not double-escaped
3. Create a malicious payload (talk to QA/security team for this if necessary)
4. Note that the malicious payload is escaped
5. prove t/Koha/Plugins/SafeURL.t
6. Celebrate!

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-11-07 16:29:18 +01:00
CJ Lynce fc002aa0aa
Bug 38043: Add unit tests for KohaTimes TT filter
This adds units tests for the new KohaTimes TT filter.
This also corrects a minor issue with a wrong comparitor operation in
    KohaTimes.pm causing a WARN to be thrown.

To test
1. Apply patch
2. prove t/db_dependent/Template/Plugin/KohaTimes.t
3. Verify 5 Tests PASS

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-10-11 11:13:54 +02:00
CJ Lynce aecfaa5911
Bug 36594: Library hours in koha/admin/branches.pl now adhere to selected time and calendar system preferences.
-Newly created or edited libraries no longer display 'null' for undefined
	open and close times.
-Libraries without any defined hours will state such instead of displaying the
	hours table.
-The CalendarFirstDayOfWeek system preferences is now respected when viewing
	a library with defined hours.
-Time displays and inputs now follow the TimeFormat system preference.
-Times are no longer displayed with seconds.

As part of this patch, a new Template Filter, KohaTimes, has been added to
	allow for proper formatting of time strings based on systems preferences.

To Test:
1. Login to staff interface
2. Go to Koha administration > Basic parameters > Libraries
3. Edit any library or create a new library. Do not set hours.
4. Save the library.
	*Note that on the library list, in the hours column, all days are displayed
	with 'null'.
5. Edit or create a 2nd library.
6. Try to manually enter a time (not using the flatpickr modal)
	*Note that the mask wants a date format, not a time format.
7. Set some hours for the library, leaving at least one
	day without hours. Save.
	*Note that in the library list, in the hours column, defined times are in
	the format HH:MM:SS.
7. Edit the system preference CalendarFirstDayOfWeek to set a day other
	than Sunday as the first day of the week.
8. Return to Koha administration > Basic parameters > Libraries
9. Click on the name of a specific library with hours to view details.
	*Note that the order of the calendar weeek still starts with Sunday.
10. The order of the calendar week still starts with Sunday.
11. Edit the system preference TimeFormat and set to 12-hours.
12. Return to Koha administration > Basic parameters > Libraries.
	*Note that the time format on the branches list is not in 12-hour format.
13. Click on the name of a specific library with hours to view details.
	*Note that the time format in the branch details screen is not in 12-hour
	format.

14. Apply Patch.

15. Return to Koha administration > Basic parameters > Libraries
16. Verify that your library with all undefined times shows "Library hours
	not set".
17. Verify that your library with defined hours is showing times in	HH:MM
	format, and days without defined hours are blank.
18. Verify that your library with defined hours is respecting the TimeFormat
	preferences.
19. Click on the name of a library with hours to view details.
20. Verify that the hours respect the CalendarFirstDayOfWeek and TimeFormat
	preferences.
21. Click on the name of another library without hours to view details.
	Verify these libraries show as "No opening hours have been set"
	in the branch detail view.
22. Edit a library's hours. When inputing, try to manually enter a time (not
	using the flatpickr modal). Verify that you can enter time in the proper
	(12 or 24 hours) format.

Sponsored-by: Westlake Porter Public Library
Signed-off-by: Olivier V <olivier.vezina@inLibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2024-09-30 15:28:15 +01:00
Jonathan Druart 8830cd7eff
Bug 37628: (follow-up) Remove get_opac_news_by_id
Keep the same behaviour, but wondering why we don't return 'content'
when there is no match.

ie.
+    is( $additional_contents, undef );
should certainly be
+    is( $additional_contents->{content}->count, 0 );

WNC amended patch - tidied

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-08-16 17:33:51 +02:00
Matt Blenkinsop 132b22bbfa
Bug 28924: (QA follow-up): Remove unnecessary template method
Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-07-18 18:25:56 +02:00
Matt Blenkinsop f215fe5370
Bug 28924: Add a template method and update template usages
This patch adds a method to be used in the template where currently the Koha.Preference('noissuescharge') method is used. This currently does not take into account the new patron category level limits and so needs to be updated to its own method to handle these.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-07-18 18:25:53 +02:00
Nick Clemens 492645a9d2
Bug 36941: Limit login branch list when IP restriction enabled
This patch adds a new 'ip_limit' option to Koha::Template:Plugin::Branches

To test:
1 - Set some branches in the system to have random IPs
2 - Set one branch to have your IP
    To find the IP in KTD I:
    Enabled ILS-DI
    Set ILS-DI:AuthorizedIPs to 1.1.1.1
    Visit:
    http://localhost:8080/cgi-bin/koha/ilsdi.pl?service=GetAvailability&id=248&id_type=biblio
    And note the unauthorized IP listed
3 - Log out, confirm all branches are listed
4 - Log in, enable StaffLoginRestrictLibraryByIP
5 - Log out, confirm branches with IPs are removed
6 - Confirm branch matching your IP is listed
7 - Choose any of the branches and login
8 - Confirm login works

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-06-28 13:49:26 +02:00
Marcel de Rooy e4bb59683f
Bug 36700: Fix underscore in CSRF header
Also change the cache key in template plugin. And the X- header
that had an underscore in svc script.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2024-05-01 13:40:12 +01:00
Julian Maurice edefd14f23
Bug 29393: Prevent SQL errors when SQL strict mode is set
Signed-off-by: Matthias Le Gac <matthias.le-gac@inlibro.com>
Signed-off-by: Phan Tung Bui <phan-tung.bui@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 17:38:00 +02:00
Alex Arnaud 748091798a
Bug 29393: Sort notice templates by name
Signed-off-by: Matthias Le Gac <matthias.le-gac@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 17:37:59 +02:00
Alex Arnaud f6b5ed8ee9
Bug 29393: Don't show notice templates for each language
Signed-off-by: Matthias Le Gac <matthias.le-gac@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 17:37:58 +02:00
Alex Arnaud ba3f704493
Bug 29393: Ability to send emails from patron details page
Test plan
  - apply Bug 12802
  - go to a patron's details page
  - click on "Add message" in tools bar
  - choose "Email" in "Add a message for"
  - Select a notice (module members) or manualy fill the message
  - Save
  - Check the message is saved in message_queue table

Signed-off-by: Matthias Le Gac <matthias.le-gac@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 17:37:56 +02:00
Jonathan Druart 385048f27c
Bug 33568: Status
FIXME We need tests here!

See the FIXME in the code, we are losing the ability to search on the status,
but this is really impossible to implement if we are not storing the
status (DB or search engine).

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-05 15:34:48 +02:00
Jonathan Druart b23996ee7a
Bug 35790: Remove Koha::Template::Plugin::Biblio::CanArticleRequest
It is no longer used anywhere.

Test plan:
  % git grep CanArticleRequest
should not return any results

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-22 12:26:45 +01:00
Jonathan Druart b19ff6f4c7
Bug 35793: Remove Koha::Template::Plugin::Cache
Introduced in 2011 by bug 7387 but has never been used.
Removing it.

Test plan:
 git grep Cache **/*.tt **/*.inc
should not return relevant results.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-22 12:26:44 +01:00
Jonathan Druart ea80d2f140
Bug 35789: Remove Koha::Template::Plugin::Biblio::ArticleRequestsActiveCount
Can be replaced with biblio.article_requests.filter_by_current.count

Test plan:
Turn on article requests (syspref + circ rule)
Request an article (detail page of a bib record)
On the left you see "Article requests" tab with the number of current
article requests.

It should show the correct number (same as before this patch).

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-22 12:26:44 +01:00
Jonathan Druart 1a780ddcf0
Bug 35783: Replace TT plugin's method Biblio::RecallsCount
We can use biblio.recalls.search( completed => 0 ).count instead.

Test plan:
1. Go to the biblio detail view, click on the different entries in the menu
on the left. Confirm that the "Recalls" tab always has the correct number
of current recalls display in the parenthesis.

2. Run a search and confirm that the number of current recalls are still displayed
for each result.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-22 10:35:29 +01:00
Jonathan Druart 93b1cbd69a
Bug 35788: Remove Koha::Template::Plugin::Biblio::BookingsCount
We need a new method filter_by_future in Koha::Bookings.

Additionally this TT plugin's method was not covered by tests. Neither
is the whole Koha::Booking[s] objects btw.

Test plan:
Confirm that the number of bookings is displayed in the "Bookings" tab
in the left menu of the bibliographic record detail page.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-15 09:38:42 +01:00
Jonathan Druart bd987c7046
Bug 35787: Remove Koha::Template::Plugin::Biblio::CanBook
We can replace it with biblio.items.filter_by_bookable, no need to have this TT method.

Additionally there was no test for it.

Test plan:
Make sure the Bookings tab on the left of the biblio detail page is
displayed when needed.

Note that there is also a "Place booking" button that should appear in
the toolbar.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-15 09:38:41 +01:00
Jonathan Druart 06c09e15fd
Bug 35782: Replace TT plugin's method Biblio::HoldsCount
We can use biblio.holds.count instead.

The main idea here is to make sure we are passing a Koha::Biblio object
as 'biblio' to all the templates including biblio-view-menu.inc

Test plan:
1. Go to the biblio detail view, click on the different entries in the menu
on the left. Confirm that the "Holds" tab always has the correct number
of Holds display in the parenthesis.

2. Run a search and confirm that the number of holds are still displayed
for each result.

QA:
git grep biblio-view-menu.inc
notice the tt list, open the corresponding perl controllers and confirm
that 'biblio' is passed and that it is a Koha::Biblio object.
The only missing place I found was in viewlog.
Note that we are not removing the TT method yet, we are marking it as
deprecated and also display a warning during the update DB process in
case one of the notice templates is using it.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-15 09:38:39 +01:00
David Cook 108c955eac
Bug 35955: Cache CSRF token in template plugin
This change uses the Koha::Cache::Memory::Lite cache to
cache the CSRF token, so that it is only generated once,
and is re-used by the Koha::Template::Plugin::Koha object
throughout the entire template processing for the HTTP request.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 10:55:52 +01:00