You are here

function webform_results_download_callback in Webform 7.4

Menu callback; Download an exported file.

This callabck requires that an export file be already generated by a batch process. The $_SESSION settings are usually put in place by the webform_results_export_results() function.

Parameters

$node: The webform $node whose export file is being downloaded.

Return value

null|string Either an export file is downloaded with the appropriate HTTP headers set, or an error page is shown if now export is available to download.

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

File

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

Code

function webform_results_download_callback($node) {
  if (isset($_SESSION['webform_export_info'])) {
    module_load_include('inc', 'webform', 'includes/webform.export');
    $export_info = $_SESSION['webform_export_info'];
    $export_info['exporter'] = webform_export_create_handler($export_info['format'], $export_info['options']);
    unset($_SESSION['webform_export_info']);
    if (isset($_COOKIE['webform_export_info'])) {
      unset($_COOKIE['webform_export_info']);
      $params = session_get_cookie_params();
      setcookie('webform_export_info', '', -1, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
    }
    webform_results_download($node, $export_info);
  }
  else {
    return t('No export file ready for download. The file may have already been downloaded by your browser. Visit the <a href="!href">download export form</a> to create a new export.', array(
      '!href' => url('node/' . $node->nid . '/webform-results/download'),
    ));
  }
}