Bug 17578 [QA Followup] - Update number of tests
[koha.git] / misc / devel / create_superlibrarian.pl
blob623a01ade59606d393de5447d2880eb16670335a
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Copyright 2016 Koha Development Team
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
21 use Getopt::Long;
22 use Pod::Usage;
24 use C4::Installer;
25 use C4::Context;
26 use C4::Members;
28 use Koha::DateUtils;
29 use Koha::Libraries;
30 use Koha::Patrons;
31 use Koha::Patron::Categories;
33 my $library = Koha::Libraries->search->next;
34 my $patron_category = Koha::Patron::Categories->search->next;
36 die
37 "Not enough data in the database, library and/or patron category does not exist"
38 unless $library and $patron_category;
40 die "A patron with userid 'koha' already exists"
41 if Koha::Patrons->find( { userid => 'koha' } );
42 die "A patron with cardnumber '42' already exists"
43 if Koha::Patrons->find( { cardnumber => 'koha' } );
45 my $userid = 'koha';
46 my $password = 'koha';
47 my $help;
49 GetOptions(
50 'help|?' => \$help,
51 'userid=s' => \$userid,
52 'password=s' => \$password
55 pod2usage(1) if $help;
57 AddMember(
58 surname => 'koha',
59 userid => $userid,
60 cardnumber => 42,
61 branchcode => $library->branchcode,
62 categorycode => $patron_category->categorycode,
63 password => $password,
64 flags => 1,
67 =head1 NAME
69 create_superlibrarian.pl - create a user in Koha with superlibrarian permissions
71 =head1 SYNOPSIS
73 create_superlibrarian.pl
74 [ --userid <userid> ] [ --password <password> ]
76 Options:
77 -?|--help brief help message
78 --userid specify the userid to be set (defaults to koha)
79 --password specify the password to be set (defaults to koha)
81 =head1 OPTIONS
83 =over 8
85 =item B<--help|-?>
87 Print a brief help message and exits
89 =item B<--userid>
91 Allows you to specify the userid to be set in the database
93 =item B<--password>
95 Allows you to specify the password to be set in the database
97 =back
99 =head1 DESCRIPTION
101 A simple script to create a user in the Koha database with superlibrarian permissions
103 =cut