Here is a quick patch that will help to integrate the Webform module with the Webform Bonus Pack module. Last one includes Webform Digest submodule that allows to send personalized periodic digest of the submissions. The Webform Digest module reuses download submissions form and programmatically submit this form and then intercepts file:

  // Intercept download form submission, get file.
  $file_content = '';
  if (ob_start ()) {
  // Submit download form.
  drupal_execute('webform_results_download_form', $download_form_state, $node);
  $file_content = ob_get_contents();
  ob_end_clean();
}

However to make this happen we need to set $GLOBALS['webform_digest_send'] to true and to apply patch to the Webform module before. See patch in the attachment.

However it is a quick patch, we need to think hot to split up function webform_results_download() in two parts: first part will generate file contents and second one will push file to be downloaded.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dealancer’s picture

Status: Active » Needs review
kt-designs’s picture

2 questions:

1) Summary does not display all fieldsets
Is this the patch that will fix my Summary issue where not all fields are displayed on the summary review page?

I'm NOT using the Digest component at all (not enabled). The summary component displays all the form field results EXCEPT:

It only displays the 1st fieldset of 5 that is triggered by the select list of # of licences. (If a user chooses 3 licenses, 3 separate fieldsets are displayed on the form. But, the results of License 2 and License 3 fieldsets don't display on the summary page).

My form uses only the admin functions available with Webform & Webform Bonus Pak. No custom PHP has been added. In the Webform Summary configuration, all of these fields have been selected as fields to display.

The site is authenticated only, so I can't provide a link. Let me know if there is any other information I can provide.

2) Can I hide fields based on a Token Value?
Also, we have the a field that uses a Token ( %profile[profile_organization] ). If I'm understanding this correctly, I can only apply the conditions to hide/show based on a value chosen in a select field. If there is a way to hide a field based on Value of a previous field, please let me know. We simply need to show 3 specific fields for one particular user/organization. So, the extra 3 fields are hidden unless Organization B is filling out the form. And, no, I cannot change the field from a default value to a select list. The owner prefers the default vaule to be displayed.

Thank you in advance,
Kathy

quicksketch’s picture

Title: Integration with the Webform Bonus Pack module. Updating exporting mechanism. » Update the exporting mechanism to make it extendable by other modules
Priority: Major » Normal
Status: Needs review » Needs work

I'm all for making Webform more extensible/flexible, but this patch uses a questionable approach.

However to make this happen we need to set $GLOBALS['webform_digest_send'] to true and to apply patch to the Webform module before. See patch in the attachment.

This isn't going to be acceptable. We need to do this in a way that is not tied to any particular module.

However it is a quick patch, we need to think hot to split up function webform_results_download() in two parts: first part will generate file contents and second one will push file to be downloaded.

Yes, let's see a patch which takes that approach.

joelstein’s picture

Status: Needs work » Needs review
FileSize
1.95 KB

Here's a patch that renames webform_results_download to webform_results_export, and alters the function to receive a "download" option. If that option is TRUE, it will behave as before (setting the headers, downloading the file, and then deleting it). If FALSE, then it will simply return the file name.

quicksketch’s picture

Thanks joelstein! This looks like a good start, but it looks like a strange coupling between downloading and the webform_results_export() function. Ideally you should be able to call webform_results_export(), then call webform_results_download() on the result. Something sort of like this:

$file_info = webform_results_export($node, $format, $options);
if ($options['download']) {
  webform_results_download($file_info);
}

Having the same function either print something to the page or return a file name based on a parameter is messy business.

dealancer’s picture

@quicksketch, thanks for the guidelines.

Here is a patch that implements them, it also saves $export_info to the storage of the $form_state if the form was submitted programmatically, as it happens in webform_bonus module.

dealancer’s picture

The same as above patch with no spaces at the end of line.

quicksketch’s picture

Status: Needs review » Fixed
FileSize
3.43 KB

Thanks, this is a beautiful patch. I <3 it.

I modified it slightly to reorder the functions, which has the convenient side-effect of making the same patch work on D6 and D7. Committed to both branches. Committed to both branches.

joelstein’s picture

Thanks!

Fabianx’s picture

Indeed! Great patch! Thanks for commiting!

quicksketch’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.