summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2006-06-20 02:30:23 +0200
committerlpsolit%gmail.com <>2006-06-20 02:30:23 +0200
commita97d48ec24e5e7d931bd8a0dc39c597ce758d106 (patch)
tree286ae60acc70da143f2c662a4949dd144120263d /Bugzilla
parent5510427a679157e889aa1bb170e2b9254aed6c49 (diff)
downloadbugzilla-a97d48ec24e5e7d931bd8a0dc39c597ce758d106.tar.gz
bugzilla-a97d48ec24e5e7d931bd8a0dc39c597ce758d106.tar.xz
Bug 338793: Remove DBID_to_name() from globals.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=vladd a=justdave
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/BugMail.pm8
-rw-r--r--Bugzilla/User.pm19
2 files changed, 22 insertions, 5 deletions
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index af0bf9027..2c6f6af3e 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -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);
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 7bafd688a..c26f64332 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -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