From 398c36213970eac3f2f3f14d8e36d794920664ee Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 11 Sep 2025 00:25:48 +0000 Subject: [PATCH] Bug 38549: Provide surname for create_superlibrarian.pl Interestingly this script already had a $surname variable, just never accepted a parameter for it. This enhancement enables the user to supply a surname parameter when creating a superlibrarian user via the commandline create_superlibrarian.pl script. Koha patrons MUST have a name, so if no surname is provided, the userid will be used for the surname instead. To test: 1. Apply the patch and restart services 2. Attempt to create a superlibrarian with no surname provided. In KTD: misc/devel/create_superlibrarian.pl --userid test --cardnumber test --password XXXX --branchcode CPL --categorycode S 3. Search for your patron in Koha. Confirm the surname was automatically set to the userid 'test' 4. Attempt to create a superlibrarian, this time provide a surname that is different from the userid so easy to tell apart. In KTD: misc/devel/create_superlibrarian.pl --userid test1 --cardnumber test1 --password XXXX --branchcode CPL --categorycode S --surname testsurname 5. Search for your patron in Koha. Confirm the surname was set correctly using the given surname. Sponsored-by: Catalyst IT --- misc/devel/create_superlibrarian.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/misc/devel/create_superlibrarian.pl b/misc/devel/create_superlibrarian.pl index dadf98ea045..94bedf36707 100755 --- a/misc/devel/create_superlibrarian.pl +++ b/misc/devel/create_superlibrarian.pl @@ -39,6 +39,7 @@ GetOptions( 'branchcode=s' => \$branchcode, 'categorycode=s' => \$categorycode, 'cardnumber=s' => \$cardnumber, + 'surname=s' => \$surname, ); pod2usage(1) if $help; @@ -62,6 +63,10 @@ try { Koha::Exceptions::Object::DuplicateID->throw( duplicate_id => 'cardnumber' ) if Koha::Patrons->find( { cardnumber => $cardnumber } ); + unless ($surname) { + $surname = $userid; + } + my $patron = Koha::Patron->new( { surname => $surname, @@ -115,7 +120,7 @@ create_superlibrarian.pl - create a user in Koha with superlibrarian permissions =head1 SYNOPSIS create_superlibrarian.pl - --userid --password --branchcode --categorycode --cardnumber + --userid --password --branchcode --categorycode --cardnumber --surname Options: -?|--help brief help message @@ -124,6 +129,7 @@ create_superlibrarian.pl --branchcode specify the library code --categorycode specify the patron category code --cardnumber specify the cardnumber to be set + --surname specify the surname to be set =head1 OPTIONS @@ -153,6 +159,10 @@ Patron category's code Patron's cardnumber +=item B<--surname> + +Patron's surname. If not provided, the given userid will be used. + =back =head1 DESCRIPTION -- 2.39.5