Remove user_id_to_login procedural API; set default values for non-select fields on bug form
parent
2b44c2da4f
commit
e50428a42b
|
@ -608,7 +608,7 @@ sub sendMail
|
|||
my @watchingrel = map { REL_NAMES->{$_} } @reasons_watch;
|
||||
push @headerrel, 'None' unless @headerrel;
|
||||
push @watchingrel, 'None' unless @watchingrel;
|
||||
push @watchingrel, map { user_id_to_login($_) } @{$args->{watch}};
|
||||
push @watchingrel, map { $_->login } @{ Bugzilla::User->new_from_list(@{$args->{watch}}) };
|
||||
|
||||
for my $change (@$new_diffs)
|
||||
{
|
||||
|
|
|
@ -192,16 +192,15 @@ sub update
|
|||
if ($self->max_votes_per_bug < $self->votes_per_user)
|
||||
{
|
||||
my $votes = $dbh->selectall_arrayref(
|
||||
'SELECT votes.who, votes.bug_id FROM votes'.
|
||||
' INNER JOIN bugs ON bugs.bug_id = votes.bug_id'.
|
||||
' WHERE bugs.product_id = ? AND votes.vote_count > ?',
|
||||
undef, ($self->id, $self->max_votes_per_bug)
|
||||
'SELECT votes.who, votes.bug_id, profiles.login_name FROM votes, bugs, profiles'.
|
||||
' WHERE bugs.product_id = ? AND votes.vote_count > ?'.
|
||||
' AND bugs.bug_id=votes.bug_id AND profiles.id=votes.who',
|
||||
undef, $self->id, $self->max_votes_per_bug
|
||||
);
|
||||
foreach my $vote (@$votes)
|
||||
{
|
||||
my ($who, $id) = (@$vote);
|
||||
my ($who, $id, $name) = (@$vote);
|
||||
Bugzilla::Bug::RemoveVotes($id, $who, 'votes_too_many_per_bug');
|
||||
my $name = Bugzilla::User::user_id_to_login($who);
|
||||
push @toomanyvotes_list, { id => $id, name => $name };
|
||||
}
|
||||
}
|
||||
|
@ -213,39 +212,37 @@ sub update
|
|||
# than maxvotesperbug). See Bugzilla::Bug::RemoveVotes().
|
||||
|
||||
my $votes = $dbh->selectall_arrayref(
|
||||
'SELECT votes.who, votes.vote_count FROM votes'.
|
||||
' INNER JOIN bugs ON bugs.bug_id = votes.bug_id'.
|
||||
' WHERE bugs.product_id = ?', undef, $self->id
|
||||
'SELECT votes.who, votes.vote_count, profiles.login_name FROM votes, bugs, profiles'.
|
||||
' WHERE bugs.product_id = ? AND bugs.bug_id = votes.bug_id AND profiles.userid=votes.who', undef, $self->id
|
||||
);
|
||||
|
||||
my %counts;
|
||||
foreach my $vote (@$votes)
|
||||
{
|
||||
my ($who, $count) = @$vote;
|
||||
my ($who, $count, $name) = @$vote;
|
||||
if (!defined $counts{$who})
|
||||
{
|
||||
$counts{$who} = $count;
|
||||
$counts{$who} = [ $count, $name ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$counts{$who} += $count;
|
||||
$counts{$who}[0] += $count;
|
||||
}
|
||||
}
|
||||
my @toomanytotalvotes_list = ();
|
||||
foreach my $who (keys(%counts))
|
||||
{
|
||||
if ($counts{$who} > $self->votes_per_user)
|
||||
if ($counts{$who}[0] > $self->votes_per_user)
|
||||
{
|
||||
my $name = $counts{$who}[1];
|
||||
my $bug_ids = $dbh->selectcol_arrayref(
|
||||
'SELECT votes.bug_id FROM votes'.
|
||||
' INNER JOIN bugs ON bugs.bug_id = votes.bug_id'.
|
||||
'SELECT votes.bug_id FROM votes, bugs'.
|
||||
' WHERE bugs.product_id = ? AND votes.who = ?',
|
||||
undef, ($self->id, $who)
|
||||
);
|
||||
foreach my $bug_id (@$bug_ids)
|
||||
{
|
||||
Bugzilla::Bug::RemoveVotes($bug_id, $who, 'votes_too_many_per_user');
|
||||
my $name = Bugzilla::User::user_id_to_login($who);
|
||||
push @toomanytotalvotes_list, {id => $bug_id, name => $name};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,10 +58,9 @@ use Storable qw(dclone);
|
|||
|
||||
use base qw(Bugzilla::Object Exporter);
|
||||
# FIXME Remove procedural APIs
|
||||
@Bugzilla::User::EXPORT = qw(is_available_username
|
||||
login_to_id user_id_to_login validate_password
|
||||
USER_MATCH_MULTIPLE USER_MATCH_FAILED USER_MATCH_SUCCESS
|
||||
MATCH_SKIP_CONFIRM
|
||||
@Bugzilla::User::EXPORT = qw(
|
||||
is_available_username login_to_id validate_password
|
||||
USER_MATCH_MULTIPLE USER_MATCH_FAILED USER_MATCH_SUCCESS MATCH_SKIP_CONFIRM
|
||||
);
|
||||
|
||||
#####################################################################
|
||||
|
@ -1962,17 +1961,6 @@ sub login_to_id
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub user_id_to_login {
|
||||
my $user_id = shift;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
|
||||
return '' unless ($user_id && detaint_natural($user_id));
|
||||
|
||||
my $login = $dbh->selectrow_array('SELECT login_name FROM profiles
|
||||
WHERE userid = ?', undef, $user_id);
|
||||
return $login || '';
|
||||
}
|
||||
|
||||
sub validate_password {
|
||||
my ($password, $matchpassword) = @_;
|
||||
|
||||
|
@ -1986,7 +1974,6 @@ sub validate_password {
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
|
@ -51,7 +51,6 @@ sub get
|
|||
{
|
||||
$params->{match} = [ $params->{match} ];
|
||||
}
|
||||
warn Dumper $params;
|
||||
|
||||
my @keyword_list;
|
||||
if ($params->{names})
|
||||
|
|
|
@ -50,7 +50,7 @@ Bugzilla->send_header(
|
|||
);
|
||||
|
||||
my $json = {};
|
||||
for (Bugzilla->get_fields({ is_select => 1, obsolete => 0 }))
|
||||
for (Bugzilla->get_fields({ obsolete => 0 }))
|
||||
{
|
||||
$json->{$_->name} = $_->json_visibility;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,10 @@ function initControllerField(i)
|
|||
// Select global default value before selecting dependent ones
|
||||
f._oldDefault = setFieldValue(f, field_metadata[i].default_value);
|
||||
}
|
||||
handleControllerField(document.forms['Create'] ? null : 'INITIAL', f);
|
||||
if (f.nodeName == 'SELECT')
|
||||
{
|
||||
handleControllerField(document.forms['Create'] ? null : 'INITIAL', f);
|
||||
}
|
||||
addListener(f, 'change', handleControllerField_this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue