Commit d7d9587d authored by webchick's avatar webchick

#892950 by reglogge, scor, McGo, brian_c, Volx, fago: Fixed No welcome mail...

#892950 by reglogge, scor, McGo, brian_c, Volx, fago: Fixed No welcome mail sent to new users after site administrator approval.
parent d665a2ce
......@@ -302,13 +302,19 @@ function user_profile_form_submit($form, &$form_state) {
// Remove unneeded values.
form_state_values_clean($form_state);
// Before updating the account entity, keep an unchanged copy for use with
// user_save() later. This is necessary for modules implementing the user
// hooks to be able to react on changes by comparing the values of $account
// and $edit.
$account_unchanged = clone $account;
entity_form_submit_build_entity('user', $account, $form, $form_state);
// Populate $edit with the properties of $account, which have been edited on
// this form by taking over all values, which appear in the form values too.
$edit = array_intersect_key((array) $account, $form_state['values']);
user_save($account, $edit, $category);
user_save($account_unchanged, $edit, $category);
$form_state['values']['uid'] = $account->uid;
if ($category == 'account' && !empty($edit['pass'])) {
......
......@@ -1084,6 +1084,26 @@ class UserAdminTestCase extends DrupalWebTestCase {
$this->drupalPost('admin/people', $edit, t('Update'));
$account = user_load($user_c->uid, TRUE);
$this->assertEqual($account->status, 0, 'User C blocked');
// Test unblocking of a user from /admin/people page and sending of activation mail
$editunblock = array();
$editunblock['operation'] = 'unblock';
$editunblock['accounts[' . $account->uid . ']'] = TRUE;
$this->drupalPost('admin/people', $editunblock, t('Update'));
$account = user_load($user_c->uid, TRUE);
$this->assertEqual($account->status, 1, 'User C unblocked');
$this->assertMail("to", $account->mail, "Activation mail sent to user C");
// Test blocking and unblocking another user from /user/[uid]/edit form and sending of activation mail
$user_d = $this->drupalCreateUser(array());
$account1 = user_load($user_d->uid, TRUE);
$this->drupalPost('user/' . $account1->uid . '/edit', array('status' => 0), t('Save'));
$account1 = user_load($user_d->uid, TRUE);
$this->assertEqual($account1->status, 0, 'User D blocked');
$this->drupalPost('user/' . $account1->uid . '/edit', array('status' => TRUE), t('Save'));
$account1 = user_load($user_d->uid, TRUE);
$this->assertEqual($account1->status, 1, 'User D unblocked');
$this->assertMail("to", $account1->mail, "Activation mail sent to user D");
}
}
......
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