You are here

function webform_submission_delete in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform_submissions.inc \webform_submission_delete()
  2. 6.3 includes/webform.submissions.inc \webform_submission_delete()
  3. 6.2 webform_submissions.inc \webform_submission_delete()
  4. 7.3 includes/webform.submissions.inc \webform_submission_delete()

Delete a single submission.

Parameters

$node: The node object containing the current webform.

$submission: The webform submission object to be deleted from the database.

2 calls to webform_submission_delete()
webform_results_clear in includes/webform.report.inc
Delete all submissions for a node.
webform_submission_delete_form_submit in includes/webform.submissions.inc
Form submit handler.

File

includes/webform.submissions.inc, line 197
Submission handling functions.

Code

function webform_submission_delete($node, $submission) {
  $transaction = db_transaction();

  // Iterate through all components and let each do cleanup if necessary.
  foreach ($node->webform['components'] as $cid => $component) {
    if (isset($submission->data[$cid])) {
      webform_component_invoke($component['type'], 'delete', $component, $submission->data[$cid]);
    }
  }

  // Delete any anonymous session information.
  if (isset($_SESSION['webform_submission'][$submission->sid])) {
    unset($_SESSION['webform_submission'][$submission->sid]);
  }
  db_delete('webform_submitted_data')
    ->condition('nid', $node->nid)
    ->condition('sid', $submission->sid)
    ->execute();
  db_delete('webform_submissions')
    ->condition('nid', $node->nid)
    ->condition('sid', $submission->sid)
    ->execute();
  module_invoke_all('webform_submission_delete', $node, $submission);
}