|
Lines 17-24
Link Here
|
| 17 |
# You should have received a copy of the GNU General Public License |
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>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
19 |
|
| 20 |
|
|
|
| 21 |
use Modern::Perl; |
20 |
use Modern::Perl; |
|
|
21 |
use Getopt::Long; |
| 22 |
use Pod::Usage; |
| 22 |
|
23 |
|
| 23 |
use C4::Installer; |
24 |
use C4::Installer; |
| 24 |
use C4::Context; |
25 |
use C4::Context; |
|
Lines 32-49
use Koha::Patron::Categories;
Link Here
|
| 32 |
my $library = Koha::Libraries->search->next; |
33 |
my $library = Koha::Libraries->search->next; |
| 33 |
my $patron_category = Koha::Patron::Categories->search->next; |
34 |
my $patron_category = Koha::Patron::Categories->search->next; |
| 34 |
|
35 |
|
| 35 |
die "Not enough data in the database, library and/or patron category does not exist" |
36 |
die |
|
|
37 |
"Not enough data in the database, library and/or patron category does not exist" |
| 36 |
unless $library and $patron_category; |
38 |
unless $library and $patron_category; |
| 37 |
|
39 |
|
| 38 |
die "A patron with userid 'koha' already exists" if Koha::Patrons->find( { userid => 'koha' } ); |
40 |
die "A patron with userid 'koha' already exists" |
| 39 |
die "A patron with cardnumber '42' already exists" if Koha::Patrons->find( { cardnumber => 'koha' } ); |
41 |
if Koha::Patrons->find( { userid => 'koha' } ); |
|
|
42 |
die "A patron with cardnumber '42' already exists" |
| 43 |
if Koha::Patrons->find( { cardnumber => 'koha' } ); |
| 44 |
|
| 45 |
my $userid = 'koha'; |
| 46 |
my $password = 'koha'; |
| 47 |
my $help; |
| 48 |
|
| 49 |
GetOptions( |
| 50 |
'help|?' => \$help, |
| 51 |
'userid=s' => \$userid, |
| 52 |
'password=s' => \$password |
| 53 |
); |
| 54 |
|
| 55 |
pod2usage(1) if $help; |
| 40 |
|
56 |
|
| 41 |
AddMember( |
57 |
AddMember( |
| 42 |
surname => 'koha', |
58 |
surname => 'koha', |
| 43 |
userid => 'koha', |
59 |
userid => $userid, |
| 44 |
cardnumber => 42, |
60 |
cardnumber => 42, |
| 45 |
branchcode => $library->branchcode, |
61 |
branchcode => $library->branchcode, |
| 46 |
categorycode => $patron_category->categorycode, |
62 |
categorycode => $patron_category->categorycode, |
| 47 |
password => 'koha', |
63 |
password => $password, |
| 48 |
flags => 1, |
64 |
flags => 1, |
| 49 |
); |
65 |
); |
| 50 |
- |
66 |
|
|
|
67 |
=head1 NAME |
| 68 |
|
| 69 |
create_superlibrarian.pl - create a user in Koha with superlibrarian permissions |
| 70 |
|
| 71 |
=head1 SYNOPSIS |
| 72 |
|
| 73 |
create_superlibrarian.pl |
| 74 |
[ --userid <userid> ] [ --password <password> ] |
| 75 |
|
| 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) |
| 80 |
|
| 81 |
=head1 OPTIONS |
| 82 |
|
| 83 |
=over 8 |
| 84 |
|
| 85 |
=item B<--help|-?> |
| 86 |
|
| 87 |
Print a brief help message and exits |
| 88 |
|
| 89 |
=item B<--userid> |
| 90 |
|
| 91 |
Allows you to specify the userid to be set in the database |
| 92 |
|
| 93 |
=item B<--password> |
| 94 |
|
| 95 |
Allows you to specify the password to be set in the database |
| 96 |
|
| 97 |
=back |
| 98 |
|
| 99 |
=head1 DESCRIPTION |
| 100 |
|
| 101 |
A simple script to create a user in the Koha database with superlibrarian permissions |
| 102 |
|
| 103 |
=cut |