You are here

function advuser_multiple_email_confirm_submit in Advanced User 7.3

Same name and namespace in other branches
  1. 5.2 advuser.module \advuser_multiple_email_confirm_submit()
  2. 5 advuser.module \advuser_multiple_email_confirm_submit()
  3. 6.3 forms/advuser_multiple_email_confirm.inc \advuser_multiple_email_confirm_submit()
  4. 6.2 advuser.module \advuser_multiple_email_confirm_submit()

The submit handler for the Email button.

File

forms/advuser_multiple_email_confirm.inc, line 118

Code

function advuser_multiple_email_confirm_submit($form, &$form_state) {
  $advuser =& $_SESSION['advuser'];
  $accounts =& $advuser['accounts'];
  if ($form_state['values']['confirm']) {
    foreach ($accounts as $uid => $value) {
      $account = user_load((int) $uid);
      $from = $form_state['values']['mailfrom'];
      $types = array(
        'user' => $account,
      );
      $mail_subject = token_replace($form_state['values']['mailsubject'], $types);
      $mail_body = token_replace($form_state['values']['mailbody'], $types);
      drupal_mail('advuser', 'advuser-mail', $account->mail, user_preferred_language($account), array(
        'subject' => $mail_subject,
        'body' => array(
          $mail_body,
        ),
      ), $from, TRUE);
    }
    drupal_set_message(t('The users have been mailed.'));
  }
  $form_state['redirect'] = 'admin/people/advuser';
  advuser_reset_variables();
}