function webform_file_usage_adjust in Webform 7.4
Same name and namespace in other branches
- 7.3 components/file.inc \webform_file_usage_adjust()
Given a submission with file_usage set, add or remove file usage entries.
2 calls to webform_file_usage_adjust()
- webform_webform_submission_insert in ./
webform.module - Implements hook_webform_submission_insert().
- webform_webform_submission_update in ./
webform.module - Implements hook_webform_submission_update().
File
- components/
file.inc, line 600 - Webform module file component.
Code
function webform_file_usage_adjust($submission) {
if (isset($submission->file_usage)) {
$files = file_load_multiple($submission->file_usage['added_fids']);
foreach ($files as $file) {
$file->status = 1;
file_save($file);
file_usage_add($file, 'webform', 'submission', $submission->sid);
}
$files = file_load_multiple($submission->file_usage['deleted_fids']);
foreach ($files as $file) {
file_usage_delete($file, 'webform', 'submission', $submission->sid);
file_delete($file);
}
}
}