function webform_submission_update in Webform 6.3
Same name and namespace in other branches
- 5.2 webform_submissions.inc \webform_submission_update()
- 6.2 webform_submissions.inc \webform_submission_update()
- 7.4 includes/webform.submissions.inc \webform_submission_update()
- 7.3 includes/webform.submissions.inc \webform_submission_update()
Update a webform submission entry in the database.
Parameters
$node: The node object containing the current webform.
$submission: The webform submission object to be saved into the database.
Return value
The existing submission SID.
1 call to webform_submission_update()
- webform_client_form_submit in ./
webform.module - Submit handler for saving the form values and sending e-mails.
File
- includes/
webform.submissions.inc, line 51 - This file is loaded when handling submissions, either submitting new, editing, or viewing. It also contains all CRUD functions for submissions.
Code
function webform_submission_update($node, $submission) {
// Allow other modules to modify the submission before saving.
foreach (module_implements('webform_submission_presave') as $module) {
$function = $module . '_webform_submission_presave';
$function($node, $submission);
}
// Update the main submission info.
drupal_write_record('webform_submissions', $submission, 'sid');
// If is draft, only delete data for components submitted, to
// preserve any data from form pages not visited in this submission.
if ($submission->is_draft) {
$submitted_cids = array_keys($submission->data);
if ($submitted_cids) {
$placeholders = db_placeholders($submitted_cids);
$arguments = array_merge(array(
$submission->sid,
), $submitted_cids);
db_query("DELETE FROM {webform_submitted_data} WHERE sid = %d AND cid IN (" . $placeholders . ")", $arguments);
}
}
else {
db_query("DELETE FROM {webform_submitted_data} WHERE sid = %d", $submission->sid);
}
// Then re-add submission data to the database.
$submission->is_new = FALSE;
webform_submission_insert($node, $submission);
module_invoke_all('webform_submission_update', $node, $submission);
return $submission->sid;
}