Bug 338793: Remove DBID_to_name() from globals.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=vladd a=justdave
git-svn-id: svn://10.0.0.236/trunk@200326 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -186,10 +186,10 @@ sub ProcessOneBug {
|
||||
# Convert to names, for later display
|
||||
$values{'changer'} = $changer;
|
||||
$values{'changername'} = Bugzilla::User->new_from_login($changer)->name;
|
||||
$values{'assigned_to'} = &::DBID_to_name($values{'assigned_to'});
|
||||
$values{'reporter'} = &::DBID_to_name($values{'reporter'});
|
||||
$values{'assigned_to'} = user_id_to_login($values{'assigned_to'});
|
||||
$values{'reporter'} = user_id_to_login($values{'reporter'});
|
||||
if ($values{'qa_contact'}) {
|
||||
$values{'qa_contact'} = &::DBID_to_name($values{'qa_contact'});
|
||||
$values{'qa_contact'} = user_id_to_login($values{'qa_contact'});
|
||||
}
|
||||
$values{'cc'} = join(', ', @cc_login_names);
|
||||
$values{'estimated_time'} = format_time_decimal($values{'estimated_time'});
|
||||
@@ -635,7 +635,7 @@ sub sendMail {
|
||||
}
|
||||
push @headerrel, 'None' if !scalar(@headerrel);
|
||||
push @watchingrel, 'None' if !scalar(@watchingrel);
|
||||
push @watchingrel, map { &::DBID_to_name($_) } @$watchingRef;
|
||||
push @watchingrel, map { user_id_to_login($_) } @$watchingRef;
|
||||
$substs{"reasonsheader"} = join(" ", @headerrel);
|
||||
$substs{"reasonswatchheader"} = join(" ", @watchingrel);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ use Bugzilla::Field;
|
||||
|
||||
use base qw(Exporter);
|
||||
@Bugzilla::User::EXPORT = qw(insert_new_user is_available_username
|
||||
login_to_id validate_password
|
||||
login_to_id user_id_to_login validate_password
|
||||
UserInGroup
|
||||
USER_MATCH_MULTIPLE USER_MATCH_FAILED USER_MATCH_SUCCESS
|
||||
MATCH_SKIP_CONFIRM
|
||||
@@ -1416,6 +1416,17 @@ sub login_to_id {
|
||||
}
|
||||
}
|
||||
|
||||
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) = @_;
|
||||
|
||||
@@ -1841,6 +1852,12 @@ of a user, but you don't want the full weight of Bugzilla::User.
|
||||
However, consider using a Bugzilla::User object instead of this function
|
||||
if you need more information about the user than just their ID.
|
||||
|
||||
=item C<user_id_to_login($user_id)>
|
||||
|
||||
Returns the login name of the user account for the given user ID. If no
|
||||
valid user ID is given or the user has no entry in the profiles table,
|
||||
we return an empty string.
|
||||
|
||||
=item C<validate_password($passwd1, $passwd2)>
|
||||
|
||||
Returns true if a password is valid (i.e. meets Bugzilla's
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#
|
||||
# You need to work with bug_email.pl the MIME::Parser installed.
|
||||
#
|
||||
# $Id: bug_email.pl,v 1.40 2006-06-19 16:25:02 vladd%bugzilla.org Exp $
|
||||
# $Id: bug_email.pl,v 1.41 2006-06-19 17:30:24 lpsolit%gmail.com Exp $
|
||||
###############################################################
|
||||
|
||||
# 02/12/2000 (SML)
|
||||
@@ -1081,7 +1081,7 @@ END
|
||||
|
||||
$val = $Control{ $field };
|
||||
|
||||
$val = DBID_to_name( $val ) if( $field =~ /reporter|assigned_to|qa_contact/ );
|
||||
$val = user_id_to_login( $val ) if( $field =~ /reporter|assigned_to|qa_contact/ );
|
||||
|
||||
$tmp_reply .= sprintf( " \@%-15s = %-15s\n", $field, $val );
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ use Bugzilla::Product;
|
||||
use Bugzilla::Classification;
|
||||
use Bugzilla::Milestone;
|
||||
use Bugzilla::Group;
|
||||
use Bugzilla::User;
|
||||
|
||||
# Shut up misguided -w warnings about "used only once". "use vars" just
|
||||
# doesn't work for me.
|
||||
@@ -907,7 +908,7 @@ if ($action eq 'update') {
|
||||
foreach my $msg (@$msgs) {
|
||||
MessageToMTA($msg);
|
||||
}
|
||||
my $name = DBID_to_name($who);
|
||||
my $name = user_id_to_login($who);
|
||||
|
||||
push(@toomanyvotes_list,
|
||||
{id => $id, name => $name});
|
||||
@@ -960,7 +961,7 @@ if ($action eq 'update') {
|
||||
foreach my $msg (@$msgs) {
|
||||
MessageToMTA($msg);
|
||||
}
|
||||
my $name = DBID_to_name($who);
|
||||
my $name = user_id_to_login($who);
|
||||
|
||||
push(@toomanytotalvotes_list,
|
||||
{id => $bug_id, name => $name});
|
||||
|
||||
@@ -138,28 +138,6 @@ sub GetVersionTable {
|
||||
$::VersionTableLoaded = 1;
|
||||
}
|
||||
|
||||
sub DBID_to_name {
|
||||
my ($id) = (@_);
|
||||
return "__UNKNOWN__" if !defined $id;
|
||||
# $id should always be a positive integer
|
||||
if ($id =~ m/^([1-9][0-9]*)$/) {
|
||||
$id = $1;
|
||||
} else {
|
||||
$::cachedNameArray{$id} = "__UNKNOWN__";
|
||||
}
|
||||
if (!defined $::cachedNameArray{$id}) {
|
||||
PushGlobalSQLState();
|
||||
SendSQL("SELECT login_name FROM profiles WHERE userid = $id");
|
||||
my $r = FetchOneColumn();
|
||||
PopGlobalSQLState();
|
||||
if (!defined $r || $r eq "") {
|
||||
$r = "__UNKNOWN__";
|
||||
}
|
||||
$::cachedNameArray{$id} = $r;
|
||||
}
|
||||
return $::cachedNameArray{$id};
|
||||
}
|
||||
|
||||
# Returns a list of all the legal values for a field that has a
|
||||
# list of legal values, like rep_platform or resolution.
|
||||
sub get_legal_field_values {
|
||||
|
||||
@@ -1587,8 +1587,8 @@ foreach my $id (@idlist) {
|
||||
$vars->{'field'} = 'component';
|
||||
} elsif ($col eq 'assigned_to' || $col eq 'qa_contact') {
|
||||
# Display the assignee or QA contact email address
|
||||
$vars->{'oldvalue'} = DBID_to_name($oldhash{$col});
|
||||
$vars->{'newvalue'} = DBID_to_name($formhash{$col});
|
||||
$vars->{'oldvalue'} = user_id_to_login($oldhash{$col});
|
||||
$vars->{'newvalue'} = user_id_to_login($formhash{$col});
|
||||
$vars->{'field'} = $col;
|
||||
} else {
|
||||
$vars->{'oldvalue'} = $oldhash{$col};
|
||||
@@ -2085,16 +2085,16 @@ foreach my $id (@idlist) {
|
||||
# the old assignee can be notified
|
||||
#
|
||||
if ($col eq 'assigned_to') {
|
||||
$old = ($old) ? DBID_to_name($old) : "";
|
||||
$new = ($new) ? DBID_to_name($new) : "";
|
||||
$old = ($old) ? user_id_to_login($old) : "";
|
||||
$new = ($new) ? user_id_to_login($new) : "";
|
||||
$origOwner = $old;
|
||||
}
|
||||
|
||||
# ditto for the old qa contact
|
||||
#
|
||||
if ($col eq 'qa_contact') {
|
||||
$old = ($old) ? DBID_to_name($old) : "";
|
||||
$new = ($new) ? DBID_to_name($new) : "";
|
||||
$old = ($old) ? user_id_to_login($old) : "";
|
||||
$new = ($new) ? user_id_to_login($new) : "";
|
||||
$origQaContact = $old;
|
||||
}
|
||||
|
||||
@@ -2154,7 +2154,7 @@ foreach my $id (@idlist) {
|
||||
|| !$cgi->param('confirm_add_duplicate')) {
|
||||
# The reporter is oblivious to the existence of the new bug and is permitted access
|
||||
# ... add 'em to the cc (and record activity)
|
||||
LogActivityEntry($duplicate,"cc","",DBID_to_name($reporter),
|
||||
LogActivityEntry($duplicate,"cc","",user_id_to_login($reporter),
|
||||
$whoid,$timestamp);
|
||||
$dbh->do(q{INSERT INTO cc (who, bug_id) VALUES (?, ?)},
|
||||
undef, $reporter, $duplicate);
|
||||
|
||||
Reference in New Issue
Block a user