You are here

function webform_submission_resend in Webform 6.3

Same name and namespace in other branches
  1. 7.4 includes/webform.submissions.inc \webform_submission_resend()
  2. 7.3 includes/webform.submissions.inc \webform_submission_resend()

Form to resend specific e-mails associated with a submission.

1 string reference to 'webform_submission_resend'
webform_menu in ./webform.module
Implements hook_menu().

File

includes/webform.submissions.inc, line 420
This file is loaded when handling submissions, either submitting new, editing, or viewing. It also contains all CRUD functions for submissions.

Code

function webform_submission_resend($form_state, $node, $submission) {

  // Render the admin UI breadcrumb.
  webform_set_breadcrumb($node, $submission);
  $form['#tree'] = TRUE;
  $form['#node'] = $node;
  $form['#submission'] = $submission;
  foreach ($node->webform['emails'] as $eid => $email) {
    $email_addresses = array_filter(explode(',', check_plain($email['email'])));
    foreach ($email_addresses as $key => $email_address) {
      $email_addresses[$key] = webform_format_email_address($email_address, NULL, $node, $submission, FALSE);
    }
    $valid_email = !empty($email_addresses[0]) && valid_email_address($email_addresses[0]);
    $form['resend'][$eid] = array(
      '#type' => 'checkbox',
      '#default_value' => $valid_email ? TRUE : FALSE,
      '#disabled' => $valid_email ? FALSE : TRUE,
    );
    $form['emails'][$eid]['email'] = array(
      '#value' => implode('<br />', $email_addresses),
    );
    if (!$valid_email) {
      $form['emails'][$eid]['email']['#value'] .= ' (' . t('empty') . ')';
    }
    $form['emails'][$eid]['subject'] = array(
      '#value' => check_plain(webform_format_email_subject($email['subject'], $node, $submission)),
    );
    $form['actions'] = array(
      '#type' => 'markup',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Resend e-mails'),
    );
    $form['actions']['cancel'] = array(
      '#type' => 'markup',
      '#value' => l(t('Cancel'), isset($_GET['destination']) ? $_GET['destination'] : 'node/' . $node->nid . '/submission/' . $submission->sid),
    );
  }
  return $form;
}