Commit Graph

9261 Commits

Author SHA1 Message Date
Jonathan Druart 4f7d00eaed
Bug 39325: Tidy
Some files need to be tidy after the automatic commit

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:27 +02:00
Jonathan Druart 69b8341a8c
Bug 39325: Manual fixes
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:23 +02: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
Raphael Straub d1d9b24979
Bug 37418: delete_patrons.pl: Exclude patrons with restrictions
Add the option "--without_restriction_type" so that delete_patrons.pl
does not delete patrons with given restriction types.

To test:
1) Run
   misc/cronjobs/delete_patrons.pl --not_borrowed_since 2010-01-01
   and choose a borrowernumber that would be deleted.
2) In your browser go to
   /cgi-bin/koha/members/moremember.pl?borrowernumber=<borrowernumber>
   and add a manual restriction to this patron.
3) Apply the patch.
4) Run
   misc/cronjobs/delete_patrons.pl --not_borrowed_since 2010-01-01 \
       --without_restriction_type MANUAL
5) Check that the patron with the manual restriction would not be
   deleted.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-25 08:46:53 +02:00
Raphael Straub 936b5650c5
Bug 39405: (follow-up) Add the parameter borrowernumber to the overwrite_calc_fine plugin hook
This patch adds the borrowernumber as a parameter to the overwrite_calc_fine
plugin hook. E.g., the borrower is needed for calculating graduated fines.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-25 08:46:49 +02:00
Tomas Cohen Arazi 9345f6d784
Bug 39405: (follow-up) Simplify code for choosing the first fine values
This patch avoids the introduction of a `foreach` loop and a `return`
call inside of it, by using grep on the array assignment, and then just
returning the first element on it, if any.

No behavior change is expected.

The code becomes easier to read and spot what is doing.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-25 08:46:48 +02:00
Raphael Straub fa329e4a09
Bug 39405: Add hook overwrite_calc_fine to override CalcFine in Overdues.pm
This new hook allows to overwrite the koha standard calculation of fines.
This can be useful if your library has a fine policy with graduated fines
per overdue letter.

To test:
1) Apply patch.
2) Run prove -v t/db_dependent/Circulation/CalcFine.t
3) Run prove -v t/db_dependent/Koha/Plugins/Overdues.t
4) Sign off.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-25 08:46:47 +02:00
Matthias Meusburger 4dd5b2a891
Bug 38142: Choose language to report from authority to bibliographic record.
Currently, when reporting authority field to the bibliographic records,
the merge function uses the first matching authority field.

However, authorities can provide multiple versions of the same field, with
different languages, identified by a code in the $7 field.

French reference for languages codes for example, but any code system could be
used:
https://documentation.abes.fr/sudoc/formats/unmb/DonneesCodees/CodesZone104.htm#$d

This patch introduces the LanguageToReportOnMerge system preference, which
allows to specify a language code.

When set, if there is an authority field with the given language code, it will
be used to report to the bibliographic record.

If the system preference is not set, or there is no matching field, the default
behavior will apply: the first field will be used.

The $7 in the authority field can be in a short or long form:

 - the short form is 2 characters long. Example: ba
 - the long form is 8 characters long, with the short form in position 5 and 6
   (starting from 1). Example: ba0yba0y

Test plan:
----------

1) Edit the 'Personal Name' authority type framework to make the 100 field
repeatable

2) Add an authority with several languages, like this (the order is important):

100    _7ba0yda0y
       _a伊東豊雄
100    _7ba0yba0y
       _aItō

3) Add a bibliographic record linked to that authority.
(Click on the "tag editor" icon next to the 100$a field in the bibliographic record to
 search for the authority, then Search main heading ($a only): contains Itō)

Note that you can choose which version you want when searching for the
authority, under the "Get it!" column

For this example, choose the latin version: Itō

You should now have this in your bibliographic record:
100    _aItō
       _92646

4) Edit the authority, you don't have to change anything, just edit and save.
Note that your bibliographic record now looks like this:

100    _7ba0yda0y
       _a伊東豊雄
       _92646

The first 100 field of the authority has been reported back to the bibliographic
record, regardless of what you chose when selecting the authority.

5) Apply the patch, set the LanguageToReportOnMerge system preference to: 'ba'

6) Edit the authority again, and check that your bibliographic record now looks
like this, according to the system preference:

100    _7ba0yba0y
       _aItō
       _92646

7) Edit the authority again, but set the $7 of the latin field to its short
form:

100    _7ba0yda0y
       _a伊東豊雄
100    _7ba
       _aItō

8) Check that the bibliographic record still has the latin field reported:

100    _7ba
       _aItō
       _92646

9) prove koha/t/db_dependent/Authority/Merge.t

10) Sign-off :)

Sponsored-by: ENSA

Works smoothly, both with UNIMARC/MARC21
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-25 08:46:38 +02:00
Jonathan Druart ff14f582de
Bug 39367: Replace tabs with spaces in POD
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-23 09:35:17 +02:00
Jonathan Druart 14e66bfe84
Bug 39367: Remove .pod files from C4/SIP
Include them into the pm instead.

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 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
Martin Renvoize 7da684a507
Bug 38646: (follow-up) Ensure consistent ordering of languages
We add an `ORDER BY` clause to the SQL statement to ensure we
consistently order accross databases by the iso code.

This fixes the failing test on MariaDB as it's default sort order
appears to differ from MySQL for this.

This also ensure we are consistently ordering which will lead to more
consistent and clear results for end users.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-17 15:11:22 +02:00
Aleisha Amohia 8a86f5e7cd
Bug 37784: Do not show forbidden columns in reports dictionary
This patch prevents forbidden columns from being selected using the reports dictionary.

To test:

1. Go to Reports -> View dictionary
2. Choose 'new dictionary'
3. After providing a name and description, select the 'patrons' table
4. Select the 'password' column and go Next
5. Notice it is possible to see a list of all the password hashes in the 'choose' selection box when asked to specify a value

6. Apply patch and restart services

7. Repeat steps 1-3
8. Notice the 'password' column and other forbidden columns are not available to be selected

9. Open the Inspector / developer tools in your browser and find the code for the columns selection
10. Change the value of one of the options in the code to "borrowers.password". So it may end up looking like this:

<option value="borrowers.password">Card number</option>

11. Choose that option from the dropdown and click Next.
12. Confirm you are redirected back to this page and warned about the column being used.

13. Ensure tests pass t/db_dependent/Reports/Guided.t

Sponsored-by: Reserve Bank of New Zealand
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-14 08:51:23 +02:00
Jonathan Druart 15a030bc76
Bug 39319: Fixes for Pod::Checker
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>
2025-04-14 08:51:21 +02:00
Janusz Kaczmarek c0fc7eae32
Bug 38729: Linker should consider diacritics
Currently, Koha linker does not pay attention to the diacritics while
linking--the decision about linking is taken based on the results of
search in the search engine (be it Zebra or Elasticsearch) which are
diacritics insensitive.  As a consequence, "Brückner, Karl" could be
erroneously linked to "Bruckner, Karl", in case when "Brückner, Karl"
did not exist in the authority file, or no link would be made in case
when both "Brückner, Karl" and "Bruckner, Karl" existed in the authority
file and LinkerModule is set to 'default'.

Test plan:
==========

1. Make sure that LinkerModule system preference is set to default.
2. Create an authority record of type PERSO_NAME with a name containing
   diacritics (e.g. "Brückner, Karl" , or "Rąkowski, Albin" etc.).
3. Edit an existing or create a new bibliographic record and put in a
   personal name field (100, 600, 700) that name without diacritics.
4. Click "Link authorities automatically" -- the two different names will
   be linked, which is wrong.
5. Create a second authority record with name form exactly from the
   bibliographic record (without diacritics).
6. Edit an existing or create a new bibliographic record and put in a
   personal name field (100, 600, 700) the name without diacritics.
7. Click "Link authorities automatically" -- you should get a message
   "More than one local match found. Possibly a duplicate authority!".
8. Apply the patch ; updatedatabase ; restart_all
9. Set the LinkerConsiderDiacritics systempreference to 'Do'.
10. Choose another name pair with and without diacritics. Repeat p. 3-4.
    The bibliographic field should not be linked this time.
11. With the new pair, repeat p. 5.-7.  The bibliographic field should
    now be correctly linked.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-14 08:50:57 +02:00
Janusz Kaczmarek 317b70b7b6
Bug 34739: Linked biblios should not be merged (updated) when changes to an authority don't change the authorized heading
Currently, the function C4::AuthoritiesMarc::merge calls ModBiblio for
all bibliographic records linked to the modified authority record.  It
could seem a just behavior but we know that this could lead to
performance problems.  This is why AuthorityMergeLimit
systempreference with merge_authorities.pl was introduced (earlier:
dontmerge).

Although this partially solves the performance problems, for
moderately large and large catalogs (500+ K) and authority records
linked with a large number of bibliographic records, performance
problems still occur, even with overnight processing with
merge_authorities.pl.  This problem is particularly apparent when
updating authority records from central databases, whose modifications
are beyond our control.

It turns out, however, that many such modifications to authority
records involve fields other than the heading field (1XX in MARC 21),
so these updates in fact do not modify bibliographic records.
However, with the current merge function, every touch on an
authority record forces a call to the ModBiblio function.  The
number of relatively expensive ModBiblio calls could be
reduced by checking whether there has been an actual change in
the field associated with the authority record.

However, with IncludeSeeFromInSearches or IncludeSeeAlsoFromInSearches
preferences enabled, the record should be refreshed in the search
engine just in case (should the 4XX, 5XX fields have changed, which we
don't know at this point).

Test plan:
==========
1. Make sure to have CataloguingLog set to Log and
   IncludeSeeFromInSearches set to Include.
2. Have a bibliographic record with an authority record linked. Open
   the authority record in a separate tab, open it in the editor and
   save, without modifying it. Repeat this 2-3 times. In the
   bibliographic record tab open the Modification log and see a number of
   entries - for each “empty” modification of the linked authority
   record.
3. Apply the patch ; restart_all.
4. Repat p. 2. Note that there are no new entries in the log.
5. Edit the authority record again, this time putting in one of the
   proper 4XX $a subfield an uncommon word (but do not  touch the 1XX
   field). Save the authority record. In the bibliographic record
   tab control that there are no new entries in the modification log.
   Make a search for the word put in 4XX field. You should get the
   bibliographic record(s) linked to the edited authority record, even
   though the bibliographic record itself has not been modified.
6. Edit the authority record again, this time changing the 1XX field.
   Save the authority record. In the bibliographic record tab control
   that there are is new entry in the modification log.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-11 09:52:34 +02:00
Martin Renvoize cb71027f14
Bug 37171: Add serial note to serial claims screen
This patch adds the serial note field into the serials claims display
table.

Test plan:
1) Add a Serial
2) View the serial 'Serial collection'
3) Use the 'Edit serials' option to add a note to an expected, late
   serial issue.
4) View the serial claims for the Vendor of that serial
5) Note the new 'Serial notes' column in the display of claims
6) Signoff

Sponsored-by: Loughborough University <https://lboro.ac.uk/>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-19 11:55:31 +01:00
Lucas Gass 8c8c480db0
Bug 38615: Add ability to set hold cancellation request via SIP
To test:
1. APPLY PATCH, updatedatabase, restart_all
2. Search for the new system preference HoldCancellationRequestSIP, it should be set to 'Don't'. Leave it as is.
3. Make some holds, either in the staff client of via SIP.
    -/kohadevbox/koha/misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m hold --patron 23529000035676 --item 39999000001310 --hold-mode +

4. Mark the hold as waiting.
5. Cancel it via SIP:
    -/kohadevbox/koha/misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m hold --patron 23529000035676 --item 39999000001310 --hold-mode -

6. The hold is cancelled like normal, the screen msg should be "Hold Cancelled."
7. Change HoldCancellationRequestSIP to 'Do'.
8. Do steps 3-5 again.
9. Now the screen message is 'Hold Cancellation Requested.'
10. Now check Holds awaiting pickup. In the "Holds with cancellation requests" tab you should now see the hold from step 8.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-17 08:21:26 +01:00
David Cook e223b17d68
Bug 39295: Prevent infinite loop on line wrapping
This change checks that the string width is larger than 0 before
attempting to perform line wrapping on the line.

Test plan:
0. Apply the patch and koha-plack --restart kohadev
1. Follow instructions at end of this message[1]
2. Note that the infinite loop does not happen and that a blank
card is created
3. Export the batch using the test layout and template that come
with koha-testing-docker
4. Note that the patron card is correctly created

[1]
To reproduce:

0. Change Koha test user's firstnameto "Firstname" and surname to "Lastname"

1. Create a template:
Units: PostScript Points
Page height: 60pt
Page width: 60pt
Card height: 60pt
Card with: 60pt

Top page margin: 10pt
Left page margin: 10pt
Number of columns: 1
Number of rows: 1
Gap between columns: 10pt
Gap between rows: 10pt

2. Create a layout:
Units: US inches

Field 1:
Text: Library Name
Font: Times-Roman
Font size: 12 pt
Text alignment: Left
Lower left X coordinate: 100in
Lower left Y coordinate: 100in

Field 2:
Text: <firstname> <surname>
Font: Times-Roman
Font size: 10pt
Text alignment: Left
Lower left X coordinate: 5in
Lower left Y coordinate: 5in

3. Create a batch for borrowernumber 51 (if using "koha" test user in ktd)

4. Export using the above template and layout

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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-17 08:21:22 +01:00
Aleisha Amohia 2b770e5e77
Bug 39313: Make OpacTrustedCheckout self-checkout modal accept valid barcode
This patch fixes a regression introduced by Bug 38505.

To test:

1. Enabled OpacTrustedCheckout system preference
2. Search for an item and get the barcode
3. Go to the OPAC
4. Click the Self-checkout button at the top
5. Enter the barcode and submit
6. Notice you are given an error UNKNOWN_BARCODE and the item is not checked out

7. Apply the patch and restart services

8. Repeat steps 4-6 and confirm you are able to successfully check out the item
9. Test submitting the modal with no barcode entered - confirm you are shown an appropriate error
10. Test with a fake barcode that does not exist - confirm you are shown an appropriate error

11. Run tests to confirm no regressions
prove t/db_dependent/Circulation*
prove t/db_dependent/DecreaseLoanHighHolds.t
prove t/db_dependent/rollingloans.t
prove t/db_dependent/api/v1/checkouts.t
prove t/db_dependent/Patron/Borrower_PrevCheckout.t
prove t/db_dependent/Koha/ILL/Requests.t

Sponsored-by: Reserve Bank of New Zealand
Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised, including the tests.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-17 08:21:18 +01:00
Julian Maurice 1f0eb3e1dd
Bug 39299: Fix cataloguing plugins in serial item editor
Some CSS classes were missing, causing the corresponding event listener
to not be called.

Adding the missing CSS classes caused the tag editor button to be moved
to the left of the input, because of 'float: left' for .tag_editor
It seems that float:left is useless now, at least in cataloguing where
we use 'display: flex' for those elements, so this patch removes it.

Test plan:
1. Set 'cn_browser.pl' as a plugin for one of the item subfields (e.g.
   952$o)
2. Go to the serial edition page and click on "Add item". This should
   show an item form
3. Click on the tag editor button, the cn_browser.pl popup should appear

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-13 10:29:18 +01:00
Marcel de Rooy 9b927e7923
Bug 36431: Add screen message for NeedsTransfer when AutomaticItemReturn is off
Test plan:
Pick an item (without holds) with homebranch A and holdingbranch B.
(My SIP examples use RMA for A, NRD for B.)
Enable AutomaticItemReturn.
Check in this item at branch B via SIP.
* 09N20240422    10000020240422    160000APNRD|AONRD|ABperl01|
You should see something like:
* 101YNY20240422    105736AONRD|ABperl01|AQRMA|AJLearning Perl /|CSH|CTRMA|CV04|
Verify too that a transfer was started.
Now disable AutomaticItemReturn. Remove the transfer.
Check in this item at branch B via SIP.
You should see now something like:
101YNY20240422    105515AONRD|ABperl01|AQRMA|AJLearning Perl /|CSH|CTRMA|CV04|AFThis item must still be transferred to RMA branch.|
Verify that no transfer was started.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-07 18:02:58 +01:00
David Cook 465d473b5d
Bug 39159: Remove useless autouse line
This patch removes a useless autouse line.

Test plan:
0. Apply the patch
1. koha-plack --restart kohadev
2. Go to http://localhost:8081/cgi-bin/koha/mainpage.pl
3. Nothing blows up

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Followed the test plan, works as advertised.
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-07 15:41:16 +01:00
Marcel de Rooy f63feea8c6
Bug 29410: Resolve warn on numeric ne for two dates
Simply, remove the !=0 test. Test for true.

Test plan:
Restart SIP.
Ask item info (SIP 17) on a waiting hold. It must have a
hold pickup date.
Check that warn disappears with this patch.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-07 15:41:15 +01:00
Jonathan Druart 5e7b3167fd
Bug 38829: Sanitize GetLateOrMissingIssues inputs
Signed-off-by: Magnus Enger <magnus@libriotech.no>
The new test fails without this patch, and passes
when it is applied.

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:47 +01:00
David Cook 4b401010fb
Bug 38467: Make uri and url filters rfc3986 when using C4::Template
This change invokes Template::Filters->use_rfc3986 in the C4::Template
module.

Test plan:
0. Apply the patch
1. Note that "uri" and "url" filters now escape single quotes

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-06 13:54:42 +01:00
Marcel de Rooy abb2fc36d3
Bug 37816: (QA follow-up) Avoid repetition, typo and pipe test
Combining three regexes into one. Typo replcing.
Adding a test with pipe in pwd.

Test plan:
Run t/SIP/Sip.t

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:40 +01:00
Magnus Enger cb9c2146db
Bug 37816: Stop SIP2 from logging passwords
Koha's SIP2 server does a lot of logging, including all incoming
requests, in full. This means that passwords are logged, both for
the user the SIP2 client uses for logging into Koha, as well as
for the end users who provide a password to e.g. check something
out. This patch replaces passwords with three asterisks in
log strings, before they are written to the log.

To test, in ktd:
- Run the new tests:
  $ prove t/db_dependent/SIP/Sip.t
- Tail the SIP2 logs:
  $ sudo tail -f /var/log/koha/kohadev/sip*.log
- Telnet into the SIP2 server:
  $ telnet localhost 6001
- Try logging in by pasting this into the telnet session:
  "9300CNterm1|COmypassword|CPCPL|"
- Verify that "mypassword" is replaced by "***" in the logs
- Try different values for the password, including the correct password
  which is "term1" in ktd
- Try other SIP2 messages that include password fields (AC, AD, CO)

Update 2024-12-03: Fix issues pointed out by QA.

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

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:40 +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
Julian Maurice f000278b32
Bug 30975: Use event delegation for framework plugins
This is to avoid using private jQuery method _data.
Here's what jQuery 1.8.0 release notes says about it:
"this is not a supported public interface; the actual data structures
may change incompatibly from version to version."
So we should not rely on it.

What this patch does is use event delegation [1].
Events are bound to a parent container, so when elements are added
dynamically inside that container, we don't need to re-attach event
handlers manually

This patch also comes with a bit of cleanup, and introduce "breaking
changes" (they are breaking changes only if you happen to have custom
framework plugins):
1) 'mouseover', 'mousemove', 'keypress' events are no longer listened to
   'mouseover' and 'mousemove' are not used and would trigger too much
   events.
   'keypress' is also not used, and is deprecated
2) Event handlers now takes a single parameter that is an Event object
   It just makes the code a lot less complicated.
3) Event handlers do not pollute the global scope anymore

[1] https://learn.jquery.com/events/event-delegation/

Test plan:
- Go to every page that has a MARC editor and verify that plugins still
  work. This includes addbiblio.pl, additem.pl, authorities.pl,
  neworderempty.pl, orderreceive.pl
- Test plugins that use 'focus' event (for instance barcode.pl), 'blur'
  event (callnumber.pl) and 'click' event (almost all the others)
- Test that plugins work on cloned fields/subfields

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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-27 17:32:33 +01:00
Lisette Scheer a524d94abb
Bug 37989: Add template toolkit to problem_report notice
This patch adds the ability to use template toolkit in the PROBLEM_REPORT notice

Test plan:
1. Turn on OPACReportProblem in the system preferences.
2. In the staff interface, create the following report:
  SELECT * FROM message_queue WHERE letter_id='PROBLEM_REPORT'
3. Log into the OPAC
4. Edit the PROBLEM_REPORT notice to include [% problemreport.username %] after the bespoke syntax for the username.
5. Report a problem
6. Run the report you created.
7. Observe the data. (Bug 37991, the title doesn't store properly)
8. Apply the patch
9. Restart all services (restart_all on command line Restart Services in sandbox options)
10. File a new OPAC problem report
11. Run your report. 2 usernames should now show.

Signed-off-by: Olivier V <olivier.vezina@inLibro.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-26 13:45:47 +01:00
Matthias Meusburger 47c3527af3
Bug 38658: Display message for expired patrons in SIP when NotifyBorrowerDeparture is disabled
This patch restores the behavior that existed in SIP before Bug 25813 - Enhance patron expiration in SIP display:
Always consider an expired patron as expired, even if NotifyBorrowerDeparture is set to 0 (disabled) or unset.

Test plan:

 - Set NotifyBorrowerDeparture to 0

 - Set a patron's expiry date to be in the past

 - Use misc/sip_cli_emulator.pl to display patron information:
   perl misc/sip_cli_emulator.pl -a localhost -p 6001 -su term1 -sp term1 -l CPL -t CR --patron <cardnumber> -m patron_information

 - Check that you have the following message (AF field):
 "Greetings from Koha. Your account has expired as of <expired date>"

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-21 16:41:28 +01:00
Marcel de Rooy ad45e5650b
Bug 30888: Copy info to deleted table
Test plan:
Delete an authority from the interface.
Check presence in the table deletedauth_header, verify that
the correct authid and authtype have been inserted.
Bonus: Check leader position 05 in deleted table.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-21 10:41:46 +01:00
David Cook 8d0f1b3a18
Bug 26684: Remove marc from auth_header for new installs
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-21 10:41:41 +01:00
Martin Renvoize 006485a036
Bug 38375: Use perl 5.10+ \R
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-19 17:05:29 +01:00
Lari Strand 3407dc28a3
Bug 38375: Splitting SIP2SortBinMapping syspref does not support all operating systems' line endings
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-19 17:05:29 +01:00
Owen Leonard 85d9861fb3
Bug 28453: (follow-up) Make pagination labels translatable
This patch moves the English strings out of Output.pm and adds classes
to the pagination markup which can be used as hooks for JavaScript. The
global JS include is modified to look for these hooks and add text
labels to the links.

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-18 10:55:30 +01:00
Owen Leonard 2685ac2c6c
Bug 28453: Update pagination subroutine to generate Bootstrap markup
This patch modifies Output.pm to change the HTML it generates when
creating pagination bars. The changes allow the pagination menu to be
styled like Bootstrap pagination, making them consistent with the
pagination on catalog search results.

To test, apply the patch and rebuild the staff interface CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

 - Test pages where the pagination_bar subroutine is called:
 - Authorities -> Authority search results.
 - Cataloging -> Cataloging search results.
 - Cataloging -> MARC Editor -> Edit tag which is configured to use the
   unimarc_field_210c value builder.
 - Reports -> Saved SQL reports -> Results.
 - Tools -> Comments.
 - Lists -> List contents.

The pagination bar markup was removed from the templates for these pages
because it wasn't being used:

 - Administration -> Patron attribute types.
 - Administration -> Record matching rules.
 - Tools -> Tags.

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: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-18 10:55:30 +01:00
William Lavoie db067d48ee
Bug 19113: Barcode value builder not working with numeric branchcode
The regexp for the value builder 'hbyymmincr' doesn't allow for numerics in the branchcode,
so the nextnum found is always 0 and multiple Add always generate the same barcode.
This simply allow for numerics within the regex.

Test
- It's a bit complicated.  You need
   - all your branchcodes to be numerics (01,02,71...)
   - all barcodes to already be a bunch of numbers
- Modify the syspref 'autobarcode' to hbyymmincr, the home branch + date one.
- Find an item in the pro-search,
- New -> New Item
- Click on the 'p' to have the value builder create the next barcode.
   - Without the patch, the query won't have found anything, so it'll suggest xxxxxx0001
- Click Add.  It reprensent the form to enter another one.
   - Click on the 'p' edit box, it'll offer you again xxxxxx0001
With the patch, it'll offer valid ones everytime.

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

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:03 +01:00
Nick Clemens d73e3399ca
Bug 39070: Don't request facets when searching for recrod matches
This patch adds a new option to Elasticsearch to skip facets in build_query and
build_query_compat.

There should be no behavior change, however, queries to ES should be simpler

To test:
1 - Export some record from Koha
2 - Stage the records for import, matching on 999c
3 - Confirm expected matches
4 - Switch batch to use ISBN for matching
5 - Confirm expected matches
6 - Apply patches, restart all
7 - Switch batch to use 999c
8 - Confirm matches
9 - Switch batch to use ISBN
10 - Confirm matches

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-13 16:17:58 +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
Jonathan Druart 10a41979e6
Bug 38838: Clean C4::Reports::Guided->get_columns
reports/dictionary.tt and reports/guided_reports_start.tt display a list
of the columns available using optgroup to group the columns per table.

The template code is quite ugly because of the perl structure choose in
C4::Reports::Guided->get_columns

This patch removes $cgi and the 'first' variable that were not used.
Now we have an usual structure with the table names as keys and column
info in an arrayref.

Test plan:
Create a report and a new dictionary definition.
At step 3 you should see the list of the columns.
Note that they are now identical. The list when you create a dictionary
now show the description of the columns.

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>
2025-02-11 14:55:52 +01:00
David Cook e72ee54eb5
Bug 36008: Use notice_email_address instead of email for SendAlerts issue type
This change makes Koha use "notice_email_address" instead of "email" for
SendAlerts with a type of "issue". This brings SendAlerts more in line with
the rest of Koha

Test plan:
0. Apply the patch
1. Create a subscription
- Go to http://localhost:8081/cgi-bin/koha/serials/serials-home.pl
- Click "New subscription" and follow the prompts / fill out
required fields
- On the first screen, ensure "Patron notification" says "New serial issue"
(You can edit this after creating the subscription if necessary)
2. Click "subscribers" next to "Patron notification: SERIAL_ALERT"
3. Log into the OPAC, go to the bib record for that subscription, click "Subscriptions",
and click "Subscribe to email notification on new issues" and click "Yes" on the subsequent
screen
4. Edit your patron record and make sure you have an email in "Secondary email" and not "Primary email"
5. Set up a SMTP server for your Koha or some other email delivery mechanism
6. Go to the "Serial collection" for your subscription
e.g. http://localhost:8081/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=1
7. Click "Receive"
8. Mark the serial as "Arrived"
9. Click "Save"
10. Note that you receive an email using your Koha user's "Secondary Email" address

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-30 18:55:21 +01:00
Jonathan Druart 835c7131e3
Bug 38713: labels/label-edit-batch.tt
The first row is the headers for thead, then the other rows are the
tbody.

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-30 18:05:53 +01:00
Marcel de Rooy 1f6e409871
Bug 38630: (QA follow-up) Fixing few calls of getTranslatedLanguages
The fourth parameter is now removed and was never used.
Also replacing the 'both' interface by passing no interface to make
it consistent with call in additional-contents.
Resolving warn for empty interface or theme on Languages.pm L128.

Test plan:
Run t/db_dependent/Languages.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-30 18:05:25 +01:00
Marcel de Rooy d84f06ebab
Bug 38630: (QA follow-up) Two typos
Prefered and chose.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-30 18:05:25 +01:00
Julian Maurice ca5db9ffb7
Bug 38630: Make the REST API respect KohaOpacLanguage cookie
The REST API can return translated strings to the opac or staff
interface, so it should respect the KohaOpacLanguage cookie and return
translations in the same language than the interface.

Test plan:
1. Do not apply patch yet
2. Log in to koha staff interface
3. Use the browser's devtools to get the value of CGISESSID cookie
4. Make sure you have at least 2 languages installed ('en' + another
   one - I'll use 'fr-FR' as an example in this test plan)
5. Find an item and note its itemnumber and itemtype
6. Go translate this itemtype's description (admin » item types » edit
   item type » translate). Add a translation for 'en' and another one
   for your language.
7. Close your browser tab (do not logout) and restart Koha to flush the
   memory cache.
8. Execute the following commands (replace variables by the correct
   value):

    curl -sSL "$KOHA_URL/api/v1/items/$ITEMNUMBER" \
        -H 'x-koha-embed: +strings' \
        -H "Cookie: KohaOpacLanguage=en; CGISESSID=$CGISESSID" \
        | jq -r '._strings.item_type_id.str'

   If you do not have jq, it can be found in most distributions
   packages. Or you could inspect the JSON manually at the path
   /_strings/item_type_id/str

   Restart Koha again, and execute the same command but with your
   language set in KohaOpacLanguage cookie:

    curl -sSL "$KOHA_URL/api/v1/items/$ITEMNUMBER" \
        -H 'x-koha-embed: +strings' \
        -H "Cookie: KohaOpacLanguage=fr-FR; CGISESSID=$CGISESSID" \
        | jq -r '._strings.item_type_id.str'

   Depending on how Koha sort the languages (not sure how it's done),
   you should get either the 'en' one or the 'fr-FR' one, but the
   important thing is you should get the same translation, no matter
   what the value of KohaOpacLanguage is, which is the issue this patch
   is trying to fix.
9. Apply the patch and restart Koha
10. Repeat step 8. This time you should get the translation
    corresponding to the language set in KohaOpacLanguage cookie

Side note:
* The need to restart Koha before each request is due to a bug (see bug
  38454). If already pushed when you're testing this one, you don't have
  to restart.

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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-30 18:05:24 +01:00
Jonathan Druart c26a989c64
Bug 38104: Always update when hea cronjob is run
If the cronjob is configured to run every month we don't need to add
another test on the delay in the script itself.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-24 16:14:31 +01:00
Baptiste Wojtkowski b7ed38413a
Bug 8425: Increment the barcode on each call of set_barcode()
Duplicate barcodes are generated when placing an Order in Acquisitions when AcqCreateItem = "placing an order" and Autobarcode is turned on.

The problem is that you can accidentally attach 3 items to an order, but only 1 will be saved to the database. When you go to receive your order, you can only receive 1 item as the other two were never made, since the barcode wasn't unique.

In 3.8.0, a software error comes up which prevent any item creation, I believe, but master (3.9.x) doesn't throw any warnings or errors.

Yes.. This tries and solve a bug from 3.8.0 /o/

Test plan:
1 - set syspref "autoBarcode" to generated in the form <branchcode> yymm001
2 - set the barcode field to "barcode.pl" in marc structure
3 - create a new basket
4 - add one item to this basket
5 - click on the barcode field -> it should have a barcode
6 - click on add item and click on the new barcode fiels, it should have
 the same value
 APPLY PATCH:
7 - click on the barcode field -> it should have a barcode
8 - click on add item and click on the new barcode fields, it should have
  an higher barcode.

Note : The barcode is incremented each time the barcode with an empty
value is clicked on. Therefore, if the
librarian removes the value from barcode and click again, they could get
another barcode. I do not know if it is an issue.
Note: This patch is not splitted in two parts anymore

Signed-off-by: Sam Sowanick <sam.sowanick@corvallisoregon.gov>
Signed-off-by: Magnus Enger <magnus@libriotech.no>
Followed the test plan, works as advertised.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-24 12:02:15 +01:00