View | Details | Raw Unified | Return to bug 20580
Collapse All | Expand All

(-)a/misc/devel/create_superlibrarian.pl (-38 / +38 lines)
Lines 21-65 use Modern::Perl; Link Here
21
use Getopt::Long;
21
use Getopt::Long;
22
use Pod::Usage;
22
use Pod::Usage;
23
23
24
use C4::Installer;
25
use C4::Context;
26
use C4::Members;
24
use C4::Members;
27
25
28
use Koha::DateUtils;
26
my ( $help, $surname, $userid, $password, $branchcode, $categorycode, $cardnumber );
29
use Koha::Libraries;
30
use Koha::Patrons;
31
use Koha::Patron::Categories;
32
33
my $library         = Koha::Libraries->search->next;
34
my $patron_category = Koha::Patron::Categories->search->next;
35
36
die
37
"Not enough data in the database, library and/or patron category does not exist"
38
  unless $library and $patron_category;
39
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' } );
44
45
my $userid   = 'koha';
46
my $password = 'koha';
47
my $help;
48
49
GetOptions(
27
GetOptions(
50
    'help|?'   => \$help,
28
    'help|?'         => \$help,
51
    'userid=s'   => \$userid,
29
    'userid=s'       => \$userid,
52
    'password=s' => \$password
30
    'password=s'     => \$password,
31
    'branchcode=s'   => \$branchcode,
32
    'categorycode=s' => \$categorycode,
33
    'cardnumber=s'   => \$cardnumber,
53
);
34
);
54
35
55
pod2usage(1) if $help;
36
pod2usage(1) if $help;
56
37
pod2usage("userid is mandatory")       unless $userid;
57
AddMember(
38
pod2usage("password is mandatory")     unless $password;
58
    surname      => 'koha',
39
pod2usage("branchcode is mandatory")   unless $branchcode;
40
pod2usage("categorycode is mandatory") unless $categorycode;
41
pod2usage("cardnumber is mandatory")   unless $cardnumber;
42
43
C4::Members::AddMember(
44
    surname      => $surname,
59
    userid       => $userid,
45
    userid       => $userid,
60
    cardnumber   => 42,
46
    cardnumber   => $cardnumber,
61
    branchcode   => $library->branchcode,
47
    branchcode   => $branchcode,
62
    categorycode => $patron_category->categorycode,
48
    categorycode => $categorycode,
63
    password     => $password,
49
    password     => $password,
64
    flags        => 1,
50
    flags        => 1,
65
);
51
);
Lines 71-82 create_superlibrarian.pl - create a user in Koha with superlibrarian permissions Link Here
71
=head1 SYNOPSIS
57
=head1 SYNOPSIS
72
58
73
create_superlibrarian.pl
59
create_superlibrarian.pl
74
  [ --userid <userid> ] [ --password <password> ]
60
  --userid <userid> --password <password> --branchcode <branchcode> --categorycode <categorycode> --cardnumber <cardnumber>
75
61
76
 Options:
62
 Options:
77
   -?|--help        brief help message
63
   -?|--help        brief help message
78
   --userid         specify the userid to be set (defaults to koha)
64
   --userid         specify the userid to be set
79
   --password       specify the password to be set (defaults to koha)
65
   --password       specify the password to be set
66
   --branchcode     specify the library code
67
   --categorycode   specify the patron category code
68
   --cardnumber     specify the cardnumber to be set
80
69
81
=head1 OPTIONS
70
=head1 OPTIONS
82
71
Lines 88-98 Print a brief help message and exits Link Here
88
77
89
=item B<--userid>
78
=item B<--userid>
90
79
91
Allows you to specify the userid to be set in the database
80
To specify the userid to be set in the database
92
81
93
=item B<--password>
82
=item B<--password>
94
83
95
Allows you to specify the password to be set in the database
84
To specify the password to be set in the database
85
86
=item B<--branchcode>
87
88
Library code
89
90
=item B<--categorycode>
91
92
Patron category's code
93
94
=item B<--cardnumber>
95
96
Patron's cardnumber
96
97
97
=back
98
=back
98
99
99
- 

Return to bug 20580