BZ::Client::User - Creates and edits user accounts in Bugzilla
This class provides methods for accessing information about the Bugzilla servers installation.
my $client = BZ::Client->new( url => $url, user => $user, password => $password ); my $ok = BZ::Client::User->offer_account_by_email( $client, 'email@address' ); my $users = BZ::Client::User->get( $client, \%params ); my $id = BZ::Client::User->create( $client, \%params ); my $users = BZ::Client::User->update( $client, \%params );
This section lists the class methods, which are available in this module.
my $ok = BZ::Client::User->offer_account_by_email( $client, 'email@address' ); my $ok = BZ::Client::User->offer_account_by_email( $client, \%params );
Sends an email to the user, offering to create an account. The user will have to click on a URL in the email, and choose their password and real name.
This is the recommended way to create a Bugzilla account.
email (string) The email address to send the offer to.
Note: email can be provided as the single option as a scalar as shown above.
nothing if successful
The email parameter was not provided.
An account with that email address already exists in Bugzilla.
This Bugzilla does not allow you to create accounts with the format of email address you specified. Account creation may be entirely disabled.
my $users = BZ::Client::User->get( $client, \%params );
Gets information about user accounts in Bugzilla.
Added in Bugzilla 3.4
Note: Users will only appear once in the returned list, even if that user is matched by more than one search argument.
An array of integers, representing user ID's.
Logged-out users cannot pass this parameter to this function. If they try, they will get an error. Logged-in users will get an error if they specify the ID of a user they cannot see.
An array of login names (strings).
An array of strings. This works just like "user matching" in Bugzilla itself. Users will be returned whose real name or login name contains any one of the specified strings. Users that you cannot see will not be included in the returned list.
Most installations have a limit on how many matches are returned for each string, which defaults to
1000 but can be changed by the Bugzilla administrator.
Logged-out users cannot use this argument, and an error will be thrown if they try. (This is to make it harder for spammers to harvest email addresses from Bugzilla, and also to enforce the user visibility restrictions that are implemented on some Bugzillas.)
Limit the number of users matched by the "match" parameter. If value is greater than the system limit, the system limit will be used. This parameter is only used when user matching using the "match" parameter is being performed.
group_ids is an array of numeric ids for groups that a user can be in. If this is specified, it limits the return value to users who are in any of the groups specified.
Added in Bugzilla 4.0
groups is an array of names of groups that a user can be in. If this is specified, it limits the return value to users who are in any of the groups specified.
Added in Bugzilla 4.0
By default, when using the "match" parameter, disabled users are excluded from the returned results unless their full username is identical to the match string. Setting "include_disabled" to
true will include disabled users in the returned results even if their username doesn't fully match the input string.
Added in Bugzilla 4.0, default behaviour for "match" was then changed to exclude disabled users.
A hash containing one item,
users, that is an array of hashes. Each hash describes a user, and has the following items:
id (int) The unique integer ID that Bugzilla uses to represent this user. Even if the user's login name changes, this will not change.
real_name (string) The actual name of the user. May be blank.
email (string) The email address of the user.
name (string) The login name of the user. Note that in some situations this is different than their email.
can_login (boolean) A boolean value to indicate if the user can login into bugzilla.
email_enabled (boolean) A boolean value to indicate if bug-related mail will be sent to the user or not.
login_denied_text (string) A text field that holds the reason for disabling a user from logging into bugzilla, if empty then the user account is enabled. Otherwise it is disabled/closed.
groups (array) An array of group hashes the user is a member of. If the currently logged in user is querying his own account or is a member of the
editusers group, the array will contain all the groups that the user is a member of. Otherwise, the array will only contain groups that the logged in user can bless. Each hash describes the group and contains the following items:
Added in Bugzilla 4.4
saved_searches (array) An array of hashes, each of which represents a user's saved search and has the following keys:
Added in Bugzilla 4.4
saved_reports (array) An array of hashes, each of which represents a user's saved report and has the following keys:
Added in Bugzilla 4.4
id (int) An integer ID uniquely identifying the saved report.
name (string) The name of the saved report.
query (string) The CGI parameters for the saved report.
Note: If you are not logged in to Bugzilla when you call this function, you will only be returned the
real_name items. If you are logged in and not in
editusers group, you will only be returned the
groups items. The
groups returned are filtered based on your permission to bless each group. The "saved_searches" and "saved_reports" items are only returned if you are querying your own account, even if you are in the
The value used must be an integer greater then zero.
You are logged in, but you are not authorized to see one of the users you wanted to get information about by user ID.
Logged-out users cannot use the
match arguments to this function.
You passed a group name in the
groups argument which either does not exist or you do not belong to it.
Added in Bugzilla 4.0.9 and 4.2.4, when it also became illegal to pass a group name you don't belong to.
my $user = BZ::Client::User->new( id => $id );
Creates a new instance with the given ID.
my $id = BZ::Client::User->create( $client, \%params );
Creates a user account directly in Bugzilla, password and all. Instead of this, you should use "offer_account_by_email" when possible, because that makes sure that the email address specified can actually receive an email. This function does not check that.
You must be logged in and have the
editusers privilege in order to call this function.
email (string) - The email address for the new user.
full_name (string) The user's full name. Will be set to empty if not specified.
password (string) The password for the new user account, in plain text. It will be stripped of leading and trailing whitespace. If blank or not specified, the newly created account will exist in Bugzilla, but will not be allowed to log in using DB authentication until a password is set either by the user (through resetting their password) or by the administrator.
The numeric ID of the user that was created.
The same as "offer_account_by_email". If a password is specified, the function may also throw:
The password specified is too short. (Usually, this means the password is under three characters.)
Removed in Bugzilla 3.6
my $users = BZ::Client::User->update( $client, \%params );
Updates user accounts in Bugzilla.
array Contains ID's of user to update.
array Contains email/login of user to update.
full_name (string) The new name of the user.
email (string) The email of the user. Note that email used to login to bugzilla. Also note that you can only update one user at a time when changing the login name / email. (An error will be thrown if you try to update this field for multiple users at once.)
password (string) The password of the user.
email_enabled (boolean) A boolean value to enable/disable sending bug-related mail to the user.
login_denied_text (string) A text field that holds the reason for disabling a user from logging into Bugzilla, if empty then the user account is enabled otherwise it is disabled/closed.
An array of hashes with the following fields:
id (int) The ID of the user that was updated.
changes (hash) The changes that were actually done on this user. The keys are the names of the fields that were changed, and the values are a hash with two keys:
added (string) The values that were added to this field, possibly a comma-and-space-separated list if multiple values were added.
removed (string) The values that were removed from this field, possibly a comma-and-space-separated list if multiple values were removed.
You passed an invalid login name in the
Logged-in users are not authorized to edit other users.
This software is copyright (c) 2017 by Dean Hamstad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.