You are here

function pet_user_form_submit in Previewable email templates 7

Same name and namespace in other branches
  1. 6 pet.admin.inc \pet_user_form_submit()

Form submission. Take action on step 2 (confirmation of the populated templates).

File

includes/pet.admin.inc, line 361
Contains pages for creating, editing, and deleting previewable email templates (PETs).

Code

function pet_user_form_submit($form, &$form_state) {
  $step = empty($form_state['storage']['step']) ? 1 : $form_state['storage']['step'];
  $form_state['storage']['step'] = $step;
  switch ($step) {
    case 1:
      $form_state['rebuild'] = TRUE;
      $form_state['storage']['recipients_raw'] = $form_state['values']['recipients'];
      $form_state['storage']['subject'] = $form_state['values']['subject'];
      $form_state['storage']['mail_body'] = pet_isset_or($form_state['values']['mail_body']);
      $form_state['storage']['mail_body_plain'] = pet_isset_or($form_state['values']['mail_body_plain']);
      $form_state['storage']['cc'] = $form_state['values']['cc'];
      $form_state['storage']['bcc'] = $form_state['values']['bcc'];
      pet_make_preview($form_state);
      break;
    case 2:
      $form_state['rebuild'] = TRUE;
      $name = $form_state['storage']['pet']->name;
      $recipients = $form_state['storage']['recipients'];
      $options = array(
        'nid' => $form_state['storage']['nid'],
        'subject' => $form_state['storage']['subject'],
        'body' => $form_state['storage']['mail_body'],
        'body_plain' => $form_state['storage']['mail_body_plain'],
        'from' => NULL,
        'cc' => $form_state['storage']['cc'],
        'bcc' => $form_state['storage']['bcc'],
      );
      pet_send_mail($name, $recipients, $options);
      break;
  }
  $form_state['storage']['step']++;
}