You are here

function webform_results_batch_results in Webform 7.4

Batch API callback; Set the $_SESSION variables used to download the file.

Because we want the user to be returned to the main form first, we have to temporarily store information about the created file, send the user to the form, then use JavaScript to request node/x/webform-results/download-file, which will execute webform_results_download_file().

1 string reference to 'webform_results_batch_results'
webform_results_export_batch in includes/webform.report.inc
Return a Batch API array of commands that will generate an export.

File

includes/webform.report.inc, line 1592
This file includes helper functions for creating reports for webform.module.

Code

function webform_results_batch_results($node, $format, $options, &$context) {
  $export_info = array(
    'format' => $format,
    'options' => $options,
    'file_name' => $context['results']['file_name'],
    'row_count' => $context['results']['row_count'],
    'last_sid' => $context['results']['last_sid'],
  );
  if (isset($_SESSION)) {

    // UI exection. Defer resetting last-downloaded sid until download page. Set
    // a session variable containing the information referencing the exported
    // file. A cookie is also set to allow the browser to ensure the redirect to
    // the file only happens one time.
    $_SESSION['webform_export_info'] = $export_info;
    $params = session_get_cookie_params();
    setcookie('webform_export_info', '1', REQUEST_TIME + 120, $params['path'], $params['domain'], $params['secure'], FALSE);
  }
  else {

    // Drush execution of wfx command. Reset last-downloaded sid now. $_SESSION
    // is not supported for command line execution.
    webform_results_export_success($node, $export_info);
  }
}