summaryrefslogtreecommitdiffstats
path: root/Bugzilla/API/1_0
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/API/1_0')
-rw-r--r--Bugzilla/API/1_0/Resource/Bug.pm21
-rw-r--r--Bugzilla/API/1_0/Resource/Bugzilla.pm4
-rw-r--r--Bugzilla/API/1_0/Resource/Group.pm10
-rw-r--r--Bugzilla/API/1_0/Resource/Product.pm4
-rw-r--r--Bugzilla/API/1_0/Resource/User.pm34
-rw-r--r--Bugzilla/API/1_0/Util.pm37
6 files changed, 65 insertions, 45 deletions
diff --git a/Bugzilla/API/1_0/Resource/Bug.pm b/Bugzilla/API/1_0/Resource/Bug.pm
index 781ac3176..b0182a5e3 100644
--- a/Bugzilla/API/1_0/Resource/Bug.pm
+++ b/Bugzilla/API/1_0/Resource/Bug.pm
@@ -509,7 +509,7 @@ sub _translate_comment {
my $comment_hash = {
id => as_int($comment->id),
bug_id => as_int($comment->bug_id),
- creator => as_email($comment->author->login),
+ creator => as_login($comment->author->login),
time => as_datetime($comment->creation_ts),
creation_time => as_datetime($comment->creation_ts),
is_private => as_boolean($comment->is_private),
@@ -1431,7 +1431,7 @@ sub _bug_to_hash {
$item{alias} = as_string_array($bug->alias);
}
if (filter_wants $params, 'assigned_to') {
- $item{'assigned_to'} = as_email($bug->assigned_to->login);
+ $item{'assigned_to'} = as_login($bug->assigned_to->login);
$item{'assigned_to_detail'} = $self->_user_to_hash($bug->assigned_to, $params, undef, 'assigned_to');
}
if (filter_wants $params, 'blocks') {
@@ -1444,14 +1444,14 @@ sub _bug_to_hash {
$item{component} = as_string($bug->component);
}
if (filter_wants $params, 'cc') {
- $item{'cc'} = as_email_array($bug->cc);
+ $item{'cc'} = as_login_array($bug->cc);
$item{'cc_detail'} = [ map { $self->_user_to_hash($_, $params, undef, 'cc') } @{ $bug->cc_users } ];
}
if (filter_wants $params, 'creation_time') {
$item{'creation_time'} = as_datetime($bug->creation_ts);
}
if (filter_wants $params, 'creator') {
- $item{'creator'} = as_email($bug->reporter->login);
+ $item{'creator'} = as_login($bug->reporter->login);
$item{'creator_detail'} = $self->_user_to_hash($bug->reporter, $params, undef, 'creator');
}
if (filter_wants $params, 'depends_on') {
@@ -1477,7 +1477,7 @@ sub _bug_to_hash {
}
if (filter_wants $params, 'qa_contact') {
my $qa_login = $bug->qa_contact ? $bug->qa_contact->login : '';
- $item{'qa_contact'} = as_email($qa_login);
+ $item{'qa_contact'} = as_login($qa_login);
if ($bug->qa_contact) {
$item{'qa_contact_detail'} = $self->_user_to_hash($bug->qa_contact, $params, undef, 'qa_contact');
}
@@ -1546,8 +1546,7 @@ sub _user_to_hash {
my $item = filter $filters, {
id => as_int($user->id),
real_name => as_string($user->name),
- name => as_email($user->login),
- email => as_email($user->email),
+ name => as_login($user->login),
}, $types, $prefix;
return $item;
}
@@ -1571,7 +1570,7 @@ sub _attachment_to_hash {
# creator requires an extra lookup, so we only send them if
# the filter wants them.
if (filter_wants $filters, 'creator', $types, $prefix) {
- $item->{'creator'} = as_email($attach->attacher->login);
+ $item->{'creator'} = as_login($attach->attacher->login);
}
if (filter_wants $filters, 'data', $types, $prefix) {
@@ -1603,7 +1602,7 @@ sub _flag_to_hash {
foreach my $field (qw(setter requestee)) {
my $field_id = $field . "_id";
- $item->{$field} = as_email($flag->$field->login)
+ $item->{$field} = as_login($flag->$field->login)
if $flag->$field_id;
}
@@ -2672,10 +2671,6 @@ C<string> The 'real' name for this user, if any.
C<string> The user's Bugzilla login.
-=item C<email>
-
-C<string> The user's email address. Currently this is the same value as the name.
-
=back
=back
diff --git a/Bugzilla/API/1_0/Resource/Bugzilla.pm b/Bugzilla/API/1_0/Resource/Bugzilla.pm
index f5bb2f417..fc2e15e90 100644
--- a/Bugzilla/API/1_0/Resource/Bugzilla.pm
+++ b/Bugzilla/API/1_0/Resource/Bugzilla.pm
@@ -69,7 +69,6 @@ use constant PARAMETERS_LOGGED_IN => qw(
defaultseverity
duplicate_or_move_bug_status
emailregexpdesc
- emailsuffix
letsubmitterchoosemilestone
letsubmitterchoosepriority
mailfrom
@@ -82,6 +81,7 @@ use constant PARAMETERS_LOGGED_IN => qw(
requirelogin
search_allow_no_criteria
urlbase
+ use_email_as_login
use_see_also
useclassification
usemenuforusers
@@ -449,7 +449,6 @@ A logged-in user can access the following parameters (listed alphabetically):
C<defaultseverity>,
C<duplicate_or_move_bug_status>,
C<emailregexpdesc>,
- C<emailsuffix>,
C<letsubmitterchoosemilestone>,
C<letsubmitterchoosepriority>,
C<mailfrom>,
@@ -462,6 +461,7 @@ A logged-in user can access the following parameters (listed alphabetically):
C<requirelogin>,
C<search_allow_no_criteria>,
C<urlbase>,
+ C<use_email_as_login>,
C<use_see_also>,
C<useclassification>,
C<usemenuforusers>,
diff --git a/Bugzilla/API/1_0/Resource/Group.pm b/Bugzilla/API/1_0/Resource/Group.pm
index 43a2521fb..f3b55b3fd 100644
--- a/Bugzilla/API/1_0/Resource/Group.pm
+++ b/Bugzilla/API/1_0/Resource/Group.pm
@@ -247,8 +247,8 @@ sub _get_group_membership {
map {{
id => as_int($_->id),
real_name => as_string($_->name),
- name => as_string($_->login),
- email => as_string($_->email),
+ name => as_login($_->login),
+ email => as_email($_->email),
can_login => as_boolean($_->is_enabled),
email_enabled => as_boolean($_->email_enabled),
login_denied_text => as_string($_->disabledtext),
@@ -571,12 +571,12 @@ C<string> The actual name of the user.
=item email
-C<string> The email address of the user.
+C<string> If you are in the editusers group, returns the email address of the
+user, else returns nothing.
=item name
-C<string> The login name of the user. Note that in some situations this is
-different than their email.
+C<string> The login name of the user.
=item can_login
diff --git a/Bugzilla/API/1_0/Resource/Product.pm b/Bugzilla/API/1_0/Resource/Product.pm
index d3576a734..02581b0ed 100644
--- a/Bugzilla/API/1_0/Resource/Product.pm
+++ b/Bugzilla/API/1_0/Resource/Product.pm
@@ -322,9 +322,9 @@ sub _component_to_hash {
name => as_string($component->name),
description => as_string($component->description),
default_assigned_to =>
- as_email($component->default_assignee->login),
+ as_login($component->default_assignee->login),
default_qa_contact =>
- as_email($component->default_qa_contact ?
+ as_login($component->default_qa_contact ?
$component->default_qa_contact->login : ""),
sort_key => 0, # sort_key is returned to match Bug.fields
is_active => as_boolean($component->is_active),
diff --git a/Bugzilla/API/1_0/Resource/User.pm b/Bugzilla/API/1_0/Resource/User.pm
index a214bd81f..101a70529 100644
--- a/Bugzilla/API/1_0/Resource/User.pm
+++ b/Bugzilla/API/1_0/Resource/User.pm
@@ -53,13 +53,11 @@ use constant PUBLIC_METHODS => qw(
);
use constant MAPPED_FIELDS => {
- email => 'login',
full_name => 'name',
login_denied_text => 'disabledtext',
};
use constant MAPPED_RETURNS => {
- login_name => 'email',
realname => 'full_name',
disabledtext => 'login_denied_text',
};
@@ -158,8 +156,11 @@ sub offer_account_by_email {
my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' });
+ my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
+ $login or ThrowCodeError('param_required', { param => 'login' });
+
Bugzilla->user->check_account_creation_enabled;
- Bugzilla->user->check_and_send_account_creation_confirmation($email);
+ Bugzilla->user->check_and_send_account_creation_confirmation($login, $email);
return undef;
}
@@ -174,11 +175,16 @@ sub create {
my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' });
+
+ my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
+ $login or ThrowCodeError('param_required', { param => 'login' });
+
my $realname = trim($params->{full_name});
my $password = trim($params->{password}) || '*';
my $user = Bugzilla::User->create({
- login_name => $email,
+ login_name => $login,
+ email => $email,
realname => $realname,
cryptpassword => $password
});
@@ -225,7 +231,7 @@ sub get {
@users = map { filter $params, {
id => as_int($_->id),
real_name => as_string($_->name),
- name => as_email($_->login),
+ name => as_login($_->login),
} } @$in_group;
return { users => \@users };
@@ -277,12 +283,12 @@ sub get {
my $user_info = filter $params, {
id => as_int($user->id),
real_name => as_string($user->name),
- name => as_email($user->login),
- email => as_email($user->email),
+ name => as_login($user->login),
can_login => as_boolean($user->is_enabled ? 1 : 0),
};
if (Bugzilla->user->in_group('editusers')) {
+ $user_info->{email} = as_email($user->email),
$user_info->{email_enabled} = as_boolean($user->email_enabled);
$user_info->{login_denied_text} = as_string($user->disabledtext);
}
@@ -651,6 +657,8 @@ This is the recommended way to create a Bugzilla account.
=item C<email> (string) - the email to send the offer to.
+=item C<login> (string) - the login of the user account.
+
=back
=item B<Returns> (nothing)
@@ -699,6 +707,11 @@ are the same as below.
=item C<email> (string) - The email address for the new user.
+=item C<login> (string) - The login name for the new user.
+If the installation has the C<use_email_as_login> parameter switched on, then
+this parameter is ignored, and the value of the C<email> parameter will
+be used as the login name for the new account.
+
=item C<full_name> (string) B<Optional> - The user's full name. Will
be set to empty if not specified.
@@ -768,7 +781,7 @@ C<array> Contains ids of user to update.
=item C<names>
-C<array> Contains email/login of user to update.
+C<array> Contains login of user to update.
=item C<full_name>
@@ -996,8 +1009,7 @@ C<string> The email address of the user.
=item name
-C<string> The login name of the user. Note that in some situations this is
-different than their email.
+C<string> The login name of the user.
=item can_login
@@ -1083,7 +1095,7 @@ C<string> The CGI parameters for the saved report.
B<Note>: If you are not logged in to Bugzilla when you call this function, you
will only be returned the C<id>, C<name>, and C<real_name> items. If you are
logged in and not in editusers group, you will only be returned the C<id>, C<name>,
-C<real_name>, C<email>, C<can_login>, and C<groups> items. The groups returned are
+C<real_name>, C<can_login>, and C<groups> items. The groups returned are
filtered based on your permission to bless each group.
The C<saved_searches> and C<saved_reports> items are only returned if you are
querying your own account, even if you are in the editusers group.
diff --git a/Bugzilla/API/1_0/Util.pm b/Bugzilla/API/1_0/Util.pm
index ce4487c1f..13c3eebac 100644
--- a/Bugzilla/API/1_0/Util.pm
+++ b/Bugzilla/API/1_0/Util.pm
@@ -33,9 +33,10 @@ our @EXPORT = qw(
as_datetime
as_double
as_email
- as_email_array
as_int
as_int_array
+ as_login
+ as_login_array
as_name_array
as_string
as_string_array
@@ -367,8 +368,8 @@ sub as_string { defined $_[0] ? $_[0] . '' : JSON::null }
# array types
-sub as_email_array { [ map { as_email($_) } @{ $_[0] // [] } ] }
sub as_int_array { [ map { as_int($_) } @{ $_[0] // [] } ] }
+sub as_login_array { [ map { as_login($_) } @{ $_[0] // [] } ] }
sub as_name_array { [ map { as_string($_->name) } @{ $_[0] // [] } ] }
sub as_string_array { [ map { as_string($_) } @{ $_[0] // [] } ] }
@@ -380,10 +381,14 @@ sub as_datetime {
: JSON::null;
}
-sub as_email {
+sub as_login {
defined $_[0]
- ? ( Bugzilla->params->{webservice_email_filter} ? email_filter($_[0]) : $_[0] . '' )
- : JSON::null
+ ? ( Bugzilla->params->{use_email_as_login} ? email_filter($_[0]) : $_[0] . '' )
+ : JSON::null;
+}
+
+sub as_email {
+ defined($_[0]) && Bugzilla->user->in_group('editusers') ? $_[0] . '' : JSON::null;
}
sub as_base64 {
@@ -496,13 +501,9 @@ double value. If parameter is undefined, returns JSON::null.
=head2 as_email
-Takes an email address as a parameter if filters it if C<webservice_email_filter> is
-enabled in the system settings. If parameter is undefined, returns JSON::null.
-
-=head2 as_email_array
-
-Similar to C<as_email>, but takes an array reference to a list of values and
-returns an array reference with the converted values.
+Takes an email address as a parameter. If the user is in the editusers group,
+it returns the email address, unchanged. If the parameter is undefined or the
+user is not in the editusers group, it returns JSON::null.
=head2 as_int
@@ -514,6 +515,18 @@ value. If parameter is undefined, returns JSON::null.
Similar to C<as_int>, but takes an array reference to a list of values and
returns an array reference with the converted values.
+=head2 as_login
+
+Takes a login name as a parameter. If C<use_email_as_login> is enabled and the
+user is logged out, it returns the local part of the email address (the part
+before '@'). Else it returns the full login name. If parameter is undefined,
+returns JSON::null.
+
+=head2 as_login_array
+
+Similar to C<as_login>, but takes an array reference to a list of values and
+returns an array reference with the converted values.
+
=head2 as_name_array
Takes a list of L<Bugzilla::Object> values and returns an array of new values