Commit fb4c2220 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 312935: User Account Log should start with a creation date - Patch by…

Bug 312935: User Account Log should start with a creation date - Patch by Frédéric Buclin <LpSolit@gmail.com> r=bkor, r=wicked a=myk
parent 63fd6840
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
# Lance Larsh <lance.larsh@oracle.com> # Lance Larsh <lance.larsh@oracle.com>
# Justin C. De Vries <judevries@novell.com> # Justin C. De Vries <judevries@novell.com>
# Dennis Melentyev <dennis.melentyev@infopulse.com.ua> # Dennis Melentyev <dennis.melentyev@infopulse.com.ua>
# Frédéric Buclin <LpSolit@gmail.com>
################################################################################ ################################################################################
# Module Initialization # Module Initialization
...@@ -46,6 +47,7 @@ use Bugzilla::Constants; ...@@ -46,6 +47,7 @@ use Bugzilla::Constants;
use Bugzilla::User::Setting; use Bugzilla::User::Setting;
use Bugzilla::Product; use Bugzilla::Product;
use Bugzilla::Classification; use Bugzilla::Classification;
use Bugzilla::Field;
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::User::EXPORT = qw(insert_new_user is_available_username @Bugzilla::User::EXPORT = qw(insert_new_user is_available_username
...@@ -1321,7 +1323,7 @@ sub insert_new_user { ...@@ -1321,7 +1323,7 @@ sub insert_new_user {
($username, $realname, $cryptpassword, $disabledtext)); ($username, $realname, $cryptpassword, $disabledtext));
# Turn on all email for the new user # Turn on all email for the new user
my $userid = $dbh->bz_last_key('profiles', 'userid'); my $new_userid = $dbh->bz_last_key('profiles', 'userid');
foreach my $rel (RELATIONSHIPS) { foreach my $rel (RELATIONSHIPS) {
foreach my $event (POS_EVENTS, NEG_EVENTS) { foreach my $event (POS_EVENTS, NEG_EVENTS) {
...@@ -1333,18 +1335,28 @@ sub insert_new_user { ...@@ -1333,18 +1335,28 @@ sub insert_new_user {
next if (($event == EVT_CC) && ($rel != REL_REPORTER)); next if (($event == EVT_CC) && ($rel != REL_REPORTER));
$dbh->do('INSERT INTO email_setting (user_id, relationship, event) $dbh->do('INSERT INTO email_setting (user_id, relationship, event)
VALUES (?, ?, ?)', undef, ($userid, $rel, $event)); VALUES (?, ?, ?)', undef, ($new_userid, $rel, $event));
} }
} }
foreach my $event (GLOBAL_EVENTS) { foreach my $event (GLOBAL_EVENTS) {
$dbh->do('INSERT INTO email_setting (user_id, relationship, event) $dbh->do('INSERT INTO email_setting (user_id, relationship, event)
VALUES (?, ?, ?)', undef, ($userid, REL_ANY, $event)); VALUES (?, ?, ?)', undef, ($new_userid, REL_ANY, $event));
} }
my $user = new Bugzilla::User($userid); my $user = new Bugzilla::User($new_userid);
$user->derive_regexp_groups(); $user->derive_regexp_groups();
# Add the creation date to the profiles_activity table.
# $who is the user who created the new user account, i.e. either an
# admin or the new user himself.
my $who = Bugzilla->user->id || $user->id;
my $creation_date_fieldid = get_field_id('creation_ts');
$dbh->do('INSERT INTO profiles_activity
(userid, who, profiles_when, fieldid, newvalue)
VALUES (?, ?, NOW(), ?, NOW())',
undef, ($user->id, $who, $creation_date_fieldid));
# Return the password to the calling code so it can be included # Return the password to the calling code so it can be included
# in an email sent to the user. # in an email sent to the user.
......
...@@ -69,9 +69,9 @@ if (defined($login)) { ...@@ -69,9 +69,9 @@ if (defined($login)) {
$vars->{'login'} = $login; $vars->{'login'} = $login;
$dbh->bz_lock_tables('profiles WRITE', 'groups READ', $dbh->bz_lock_tables('profiles WRITE', 'profiles_activity WRITE',
'user_group_map WRITE', 'email_setting WRITE', 'user_group_map WRITE', 'email_setting WRITE',
'tokens READ'); 'groups READ', 'tokens READ', 'fielddefs READ');
if (!is_available_username($login)) { if (!is_available_username($login)) {
# Account already exists # Account already exists
......
...@@ -199,9 +199,9 @@ if ($action eq 'search') { ...@@ -199,9 +199,9 @@ if ($action eq 'search') {
my $disabledtext = trim($cgi->param('disabledtext') || ''); my $disabledtext = trim($cgi->param('disabledtext') || '');
# Lock tables during the check+creation session. # Lock tables during the check+creation session.
$dbh->bz_lock_tables('profiles WRITE', 'email_setting WRITE', $dbh->bz_lock_tables('profiles WRITE', 'profiles_activity WRITE',
'user_group_map WRITE', 'groups READ', 'email_setting WRITE', 'user_group_map WRITE',
'tokens READ'); 'groups READ', 'tokens READ', 'fielddefs READ');
# Validity checks # Validity checks
$login || ThrowUserError('user_login_required'); $login || ThrowUserError('user_login_required');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment