From 12a4b4ba504ad5c5772cf0bb12f49156c9c24a25 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Fri, 10 Feb 2023 15:39:32 +0000
Subject: [PATCH] Bug 29822: Database and Preference description updates

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 .../data/mysql/atomicupdate/bug_29822.pl      | 20 +++++++++++++++++++
 installer/data/mysql/mandatory/sysprefs.sql   |  2 +-
 .../en/modules/admin/preferences/patrons.pref |  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100755 installer/data/mysql/atomicupdate/bug_29822.pl

diff --git a/installer/data/mysql/atomicupdate/bug_29822.pl b/installer/data/mysql/atomicupdate/bug_29822.pl
new file mode 100755
index 0000000000..73c0dfdfea
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_29822.pl
@@ -0,0 +1,20 @@
+use Modern::Perl;
+
+return {
+    bug_number  => "29822",
+    description => "Convert DefaultPatronSeachFields from csv to psv",
+    up          => sub {
+        my ($args) = @_;
+        my ( $dbh, $out ) = @$args{qw(dbh out)};
+
+        # Do you stuffs here
+        $dbh->do(q{
+            UPDATE systempreferences
+            SET
+              value = REPLACE( value, ',', '|' )
+            WHERE
+              variable = 'DefaultPatronSearchFields'
+        });
+        say $out "Updated system preference 'DefaultPatronSearchFields";
+    },
+};
diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql
index 38a756f817..c483b39aa5 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -183,7 +183,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
 ('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
 ('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
-('DefaultPatronSearchFields',    'firstname,middle_name,surname,othernames,cardnumber,userid',NULL,'Comma separated list defining the default fields to be used during a patron search using the "standard" option. If empty Koha will default to "firstname,surname,othernames,cardnumber,userid". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page.','free'),
+('DefaultPatronSearchFields',    'firstname|middle_name|surname|othernames|cardnumber|userid',NULL,'Pipe separated list defining the default fields to be used during a patron search using the "standard" option. If empty Koha will default to "firstname|surname|othernames|cardnumber|userid". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page.','free'),
 ('DefaultPatronSearchMethod','starts_with','Choose which search method to use by default when searching with PatronAutoComplete','starts_with|contains','Choice'),
 ('DefaultSaveRecordFileID','biblionumber','biblionumber|controlnumber','Defines whether the advanced cataloging editor will use the bibliographic record number or control number field to populate the name of the save file','Choice'),
 ('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
index 52eef0e462..c73fc27b67 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
@@ -61,7 +61,7 @@ Patrons:
            type: modalselect
            source: borrowers
            exclusions: anonymized|auth_method|autorenew_checkouts|date_renewed|dateenrolled|dateexpiry|lang|lastseen|login_attempts|overdrive_auth_token|password|password_expiration_date|primary_contact_method|gonenoaddress|lost|debarred|debarredcomment|branchcode|categorycode|flags|guarantorid|relationship|privacy|privacy_guarantor_checkouts|privacy_guarantor_fines|pronouns|secret|sms_provider_id|updated_on|checkprevcheckout
-         - "If empty Koha will default to \"firstname,middle_name,surname,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page."
+         - "If empty Koha will default to \"firstname|middle_name|surname|othernames|cardnumber|userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page."
      -
          - pref: DefaultPatronSearchMethod
            choices:
-- 
2.41.0