Skip to content

Export forms on delete

theo lem requested to merge export-forms-on-delete into master

Motivation

The forms in Framaforms have a limited lifetime, the goal being to fight ever-growing databases. This can often cause user confusion, because of user mistakes or forgetfulness. As mentioned in #113 (closed), being able to send form submissions post-deletion can help soften an accidental form loss.

What this MR changes

This MR adds a hook_node_delete implementation that exports form submissions as CSV files before deletion. The CSV files are save withing the private_file_path of the Drupal installation (framaforms_submissions_backup subfolder), and are not web-accessible.

The files are named after the following model : '[Plain form title, with spaces]-[userid]-results.csv'

This MR additionally adds an option to the admin panel to activate/deactivate the automatic export, for installations with limited disk space.

This is adapted from the original code of the drush command.

The original Webform functions make use of the Drupal 7 Batch API to avoid slowdown of the user interface. If this change causes too many slowdowns, this MR's mechanism can be improved by putting all the webform function calls in a batch_set.

TODO :

  • periodical deletion of old csv files => to set up via crontab
  • save CSV files in subfolder of the private path
  • create private directory on module installation
Edited by theo lem

Merge request reports