Do not export anything from Bugzilla::User

hinted-selects
Vitaliy Filippov 2014-10-13 19:45:17 +04:00
parent 5a400911bb
commit cfd8911bdc
14 changed files with 31 additions and 32 deletions

View File

@ -48,7 +48,7 @@ sub create_or_update_user {
# A passed-in user_id always overrides anything else, for determining
# what account we should return.
if (!$user_id) {
my $username_user_id = login_to_id($username || '');
my $username_user_id = Bugzilla::User::login_to_id($username || '');
my $extern_user_id;
if ($extern_id) {
trick_taint($extern_id);

View File

@ -123,7 +123,7 @@ sub check_credentials {
# Cycle through the adresses and check if they're Bugzilla logins.
# Use the first one that returns a valid id.
foreach my $email (@emails) {
if ( login_to_id($email) ) {
if ( Bugzilla::User::login_to_id($email) ) {
$params->{bz_username} = $email;
last;
}

View File

@ -235,19 +235,19 @@ sub Send
my $changer = $forced->{changer};
if ($forced->{owner})
{
push @assignees, login_to_id($forced->{owner}, THROW_ERROR);
push @assignees, Bugzilla::User::login_to_id($forced->{owner}, THROW_ERROR);
}
if ($forced->{qacontact})
{
push @qa_contacts, login_to_id($forced->{qacontact}, THROW_ERROR);
push @qa_contacts, Bugzilla::User::login_to_id($forced->{qacontact}, THROW_ERROR);
}
if ($forced->{cc})
{
foreach my $cc (@{$forced->{cc}})
{
push @ccs, login_to_id($cc, THROW_ERROR);
push @ccs, Bugzilla::User::login_to_id($cc, THROW_ERROR);
}
}
@ -429,18 +429,18 @@ sub Send
{
foreach my $cc_user (split(/[\s,]+/, $diff->{removed}))
{
my $uid = login_to_id($cc_user);
my $uid = Bugzilla::User::login_to_id($cc_user);
$recipients{$uid}->{+REL_CC} = BIT_DIRECT if $uid;
}
}
elsif ($diff->{fielddesc} eq "QAContact")
{
my $uid = login_to_id($diff->{removed});
my $uid = Bugzilla::User::login_to_id($diff->{removed});
$recipients{$uid}->{+REL_QA} = BIT_DIRECT if $uid;
}
elsif ($diff->{fielddesc} eq "AssignedTo")
{
my $uid = login_to_id($diff->{removed});
my $uid = Bugzilla::User::login_to_id($diff->{removed});
$recipients{$uid}->{+REL_ASSIGNEE} = BIT_DIRECT if $uid;
}
}
@ -470,7 +470,7 @@ sub Send
my @watchers = split(/[,\s]+/, Bugzilla->params->{globalwatchers});
foreach (@watchers)
{
my $watcher_id = login_to_id($_);
my $watcher_id = Bugzilla::User::login_to_id($_);
next unless $watcher_id;
$recipients{$watcher_id}->{+REL_GLOBAL_WATCHER} = BIT_DIRECT;
}

View File

@ -289,7 +289,7 @@ sub _check_cc_list
my %cc_ids;
foreach my $cc (@$cc_list)
{
my $id = login_to_id($cc, THROW_ERROR);
my $id = Bugzilla::User::login_to_id($cc, THROW_ERROR);
$cc_ids{$id} = 1;
}
return [ keys %cc_ids ];

View File

@ -1028,7 +1028,7 @@ sub show_flag_reminders
$flag = Bugzilla::Flag->new({ id => $2 });
$flag->{status} = $ARGS->{$_};
if (($login = trim($ARGS->{"requestee-".$flag->{id}})) &&
($login = login_to_id($login)))
($login = Bugzilla::User::login_to_id($login)))
{
$flag->{requestee_id} = $login;
}

View File

@ -285,8 +285,7 @@ sub make_admin {
my ($user) = @_;
my $dbh = Bugzilla->dbh;
$user = ref($user) ? $user
: new Bugzilla::User(login_to_id($user, THROW_ERROR));
$user = ref($user) ? $user : Bugzilla::User->check($user);
my $admin_group = new Bugzilla::Group({ name => 'admin' });

View File

@ -1251,7 +1251,7 @@ sub init
foreach my $name (@guessed)
{
$name = trim($name);
if ($name && lc $name ne '%user%' && !login_to_id($name))
if ($name && lc $name ne '%user%' && !Bugzilla::User::login_to_id($name))
{
# Do a match on user login or name
my $u = Bugzilla::User::match_name($name, 1)->[0];
@ -2296,7 +2296,7 @@ sub _cc_nonchanged
sub _long_desc_changedby
{
my $self = shift;
my $id = login_to_id($self->{value}, THROW_ERROR);
my $id = Bugzilla::User::login_to_id($self->{value}, THROW_ERROR);
my @priv = $self->{user}->is_insider ? () : "longdescs.isprivate=0";
$self->{term} = {
base_table => "longdescs",
@ -2494,7 +2494,7 @@ sub _longdescs_isprivate
sub _work_time_changedby
{
my $self = shift;
my $id = login_to_id($self->{value}, THROW_ERROR);
my $id = Bugzilla::User::login_to_id($self->{value}, THROW_ERROR);
my @priv = $self->{user}->is_insider ? () : "longdescs.isprivate=0";
$self->{term} = {
base_table => "longdescs",
@ -3034,7 +3034,7 @@ sub _changedby
ThrowUserError("invalid_activity_field", { field => $self->{field} });
}
$fieldid = $fieldid->id;
my $id = login_to_id($self->{value}, THROW_ERROR);
my $id = Bugzilla::User::login_to_id($self->{value}, THROW_ERROR);
$self->{term} = {
base_table => 'bugs_activity',
where => [ "bugs_activity.fieldid = $fieldid",
@ -3053,7 +3053,7 @@ sub _in_search_results
{
# Allow to match on shared searches via 'SearchName <user@domain.com>' syntax
$v = $1;
$sharer = login_to_id(trim($2), THROW_ERROR);
$sharer = Bugzilla::User::login_to_id(trim($2), THROW_ERROR);
}
my $query = Bugzilla::Search::Saved->check({
name => trim($v),

View File

@ -55,7 +55,7 @@ use DateTime::TimeZone;
use Scalar::Util qw(blessed);
use Storable qw(dclone);
use base qw(Bugzilla::Object Exporter);
use base qw(Bugzilla::Object);
# FIXME Remove procedural APIs
@Bugzilla::User::EXPORT = qw(
is_available_username login_to_id validate_password

View File

@ -56,7 +56,7 @@ if ($changer !~ /$match/) {
print STDERR "Changer \"$changer\" doesn't match email regular expression.\n";
usage();
}
if(!login_to_id($changer)) {
if(!Bugzilla::User::login_to_id($changer)) {
print STDERR "\"$changer\" is not a login ID.\n";
usage();
}

View File

@ -151,7 +151,7 @@ if ($action eq 'save' && $current_module)
# can not use Bugzilla::User
foreach my $watcher (split(/[,\s]+/, $value))
{
unless (login_to_id($watcher))
unless (Bugzilla::User::login_to_id($watcher))
{
ThrowUserError('invalid_parameter', { name => $name, err => "no such user $watcher" });
}

View File

@ -189,7 +189,7 @@ if ($ARGS->{update})
{
if ($mailto_type == MAILTO_USER)
{
$mailto_id = login_to_id($mailto);
$mailto_id = Bugzilla::User::login_to_id($mailto);
}
elsif ($mailto_type == MAILTO_GROUP)
{

View File

@ -254,7 +254,7 @@ sub email_in_after_parse {
my $dbh = Bugzilla->dbh;
# No other check needed if this is a valid regular user.
return if login_to_id($reporter);
return if Bugzilla::User::login_to_id($reporter);
# The reporter is not a regular user. We create an account for him,
# but he can only comment on existing bugs.

View File

@ -201,7 +201,7 @@ sub changePassword
my $password = delete $ARGS->{password};
my $matchpassword = delete $ARGS->{matchpassword};
defined $password && defined $matchpassword || ThrowUserError('require_new_password');
validate_password($password, $matchpassword);
Bugzilla::User::validate_password($password, $matchpassword);
my $dbh = Bugzilla->dbh;
@ -250,7 +250,7 @@ sub changeEmail
}
# The new email address should be available as this was
# confirmed initially so cancel token if it is not still available
if (!is_available_username($new_email, $old_email))
if (!Bugzilla::User::is_available_username($new_email, $old_email))
{
$vars->{email} = $new_email; # Needed for Bugzilla::Token::Cancel's mail
Bugzilla::Token::Cancel($token, "account_exists", $vars);
@ -349,7 +349,7 @@ sub confirm_create_account
my (undef, undef, $login_name) = Bugzilla::Token::GetTokenData($token);
my $password = delete $ARGS->{passwd1} || '';
validate_password($password, delete $ARGS->{passwd2} || '');
Bugzilla::User::validate_password($password, delete $ARGS->{passwd2} || '');
my $otheruser = Bugzilla::User->create({
login_name => $login_name,

View File

@ -100,7 +100,7 @@ sub SaveAccount
if ($pwd1 ne "" || $pwd2 ne "")
{
$pwd1 || ThrowUserError("new_password_missing");
validate_password($pwd1, $pwd2);
Bugzilla::User::validate_password($pwd1, $pwd2);
if ($oldpassword ne $pwd1)
{
@ -130,7 +130,7 @@ sub SaveAccount
# Before changing an email address, confirm one does not exist.
validate_email_syntax($new_login_name)
|| ThrowUserError('illegal_email_address', { addr => $new_login_name });
is_available_username($new_login_name)
Bugzilla::User::is_available_username($new_login_name)
|| ThrowUserError("account_exists", { email => $new_login_name });
Bugzilla::Token::IssueEmailChangeToken($user, $old_login_name, $new_login_name);
@ -321,13 +321,13 @@ sub SaveEmail
# New watched users
push @$add_wdwr,
map { [ login_to_id(trim($_), THROW_ERROR), $userid ] }
map { [ Bugzilla::User::login_to_id(trim($_), THROW_ERROR), $userid ] }
split /[,\s]+/,
join(',', $ARGS->{new_watchedusers}) || '';
# New watchers
push @$add_wdwr,
map { [ $userid, login_to_id(trim($_), THROW_ERROR) ] }
map { [ $userid, Bugzilla::User::login_to_id(trim($_), THROW_ERROR) ] }
split /[,\s]+/,
join(',', $ARGS->{new_watchers}) || '';
@ -335,7 +335,7 @@ sub SaveEmail
{
# User wants to remove selected watched users
push @$del_wdwr,
map { [ login_to_id(trim($_), THROW_ERROR), $userid ] }
map { [ Bugzilla::User::login_to_id(trim($_), THROW_ERROR), $userid ] }
$ARGS->{watched_by_you};
}
@ -343,7 +343,7 @@ sub SaveEmail
{
# User wants to remove selected watchers
push @$del_wdwr,
map { [ $userid, login_to_id(trim($_), THROW_ERROR) ] }
map { [ $userid, Bugzilla::User::login_to_id(trim($_), THROW_ERROR) ] }
$ARGS->{watchers};
}