Bugzilla – Attachment 74244 Details for
Bug 20580
create_superlibrarian.pl should accept parameters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20580: Make create_superlibrarian.pl accept parameters
Bug-20580-Make-createsuperlibrarianpl-accept-param.patch (text/plain), 4.16 KB, created by
Jonathan Druart
on 2018-04-16 15:34:36 UTC
(
hide
)
Description:
Bug 20580: Make create_superlibrarian.pl accept parameters
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-04-16 15:34:36 UTC
Size:
4.16 KB
patch
obsolete
>From 0a4a15a33f3508259115595e4edcebe8f5d9ed47 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Apr 2018 12:31:22 -0300 >Subject: [PATCH] Bug 20580: Make create_superlibrarian.pl accept parameters > >So far this script does not accept parameters and create a koha/koha >superlibrarian >This patch makes it accept parameters to create a customized >superlibrarian patrons. > >Test plan: >Use the script with valid and invalid paramters and confirm that it >works as expected. > >Note: A cryptic "Invalid parameter passed" error is raised when the >categorycode is not valid. Better error handling must be provided but >Koha::Exceptions seems to be enhancement (see related bug reports). >--- > misc/devel/create_superlibrarian.pl | 75 +++++++++++++++++++------------------ > 1 file changed, 38 insertions(+), 37 deletions(-) > >diff --git a/misc/devel/create_superlibrarian.pl b/misc/devel/create_superlibrarian.pl >index 623a01ade5..9a8d0ff984 100755 >--- a/misc/devel/create_superlibrarian.pl >+++ b/misc/devel/create_superlibrarian.pl >@@ -21,45 +21,31 @@ use Modern::Perl; > use Getopt::Long; > use Pod::Usage; > >-use C4::Installer; >-use C4::Context; > use C4::Members; > >-use Koha::DateUtils; >-use Koha::Libraries; >-use Koha::Patrons; >-use Koha::Patron::Categories; >- >-my $library = Koha::Libraries->search->next; >-my $patron_category = Koha::Patron::Categories->search->next; >- >-die >-"Not enough data in the database, library and/or patron category does not exist" >- unless $library and $patron_category; >- >-die "A patron with userid 'koha' already exists" >- if Koha::Patrons->find( { userid => 'koha' } ); >-die "A patron with cardnumber '42' already exists" >- if Koha::Patrons->find( { cardnumber => 'koha' } ); >- >-my $userid = 'koha'; >-my $password = 'koha'; >-my $help; >- >+my ( $help, $surname, $userid, $password, $branchcode, $categorycode, $cardnumber ); > GetOptions( >- 'help|?' => \$help, >- 'userid=s' => \$userid, >- 'password=s' => \$password >+ 'help|?' => \$help, >+ 'userid=s' => \$userid, >+ 'password=s' => \$password, >+ 'branchcode=s' => \$branchcode, >+ 'categorycode=s' => \$categorycode, >+ 'cardnumber=s' => \$cardnumber, > ); > > pod2usage(1) if $help; >- >-AddMember( >- surname => 'koha', >+pod2usage("userid is mandatory") unless $userid; >+pod2usage("password is mandatory") unless $password; >+pod2usage("branchcode is mandatory") unless $branchcode; >+pod2usage("categorycode is mandatory") unless $categorycode; >+pod2usage("cardnumber is mandatory") unless $cardnumber; >+ >+C4::Members::AddMember( >+ surname => $surname, > userid => $userid, >- cardnumber => 42, >- branchcode => $library->branchcode, >- categorycode => $patron_category->categorycode, >+ cardnumber => $cardnumber, >+ branchcode => $branchcode, >+ categorycode => $categorycode, > password => $password, > flags => 1, > ); >@@ -71,12 +57,15 @@ create_superlibrarian.pl - create a user in Koha with superlibrarian permissions > =head1 SYNOPSIS > > create_superlibrarian.pl >- [ --userid <userid> ] [ --password <password> ] >+ --userid <userid> --password <password> --branchcode <branchcode> --categorycode <categorycode> --cardnumber <cardnumber> > > Options: > -?|--help brief help message >- --userid specify the userid to be set (defaults to koha) >- --password specify the password to be set (defaults to koha) >+ --userid specify the userid to be set >+ --password specify the password to be set >+ --branchcode specify the library code >+ --categorycode specify the patron category code >+ --cardnumber specify the cardnumber to be set > > =head1 OPTIONS > >@@ -88,11 +77,23 @@ Print a brief help message and exits > > =item B<--userid> > >-Allows you to specify the userid to be set in the database >+To specify the userid to be set in the database > > =item B<--password> > >-Allows you to specify the password to be set in the database >+To specify the password to be set in the database >+ >+=item B<--branchcode> >+ >+Library code >+ >+=item B<--categorycode> >+ >+Patron category's code >+ >+=item B<--cardnumber> >+ >+Patron's cardnumber > > =back > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20580
:
74244
|
74597