Skip to content
Snippets Groups Projects
Commit 9646d4f9 authored by lkmorlan's avatar lkmorlan Committed by Liam Morland
Browse files

Issue #3041624 by Liam Morland: Create fillpdf_form_delete_template() and...

Issue #3041624 by Liam Morland: Create fillpdf_form_delete_template() and fillpdf_form_delete_file()
parent 5930d016
No related branches found
No related tags found
No related merge requests found
......@@ -645,17 +645,7 @@ function fillpdf_form_delete_confirm($form, &$form_state, $pdf_form) {
*/
function fillpdf_form_delete_confirm_submit($form, &$form_state) {
$fid = $form['#pdf_form']->fid;
db_delete('fillpdf_fields')
->condition('fid', $fid)
->execute();
$file = file_load($fid);
file_usage_delete($file, 'fillpdf', 'fillpdf_form', $fid, 0);
file_delete($file);
db_delete('fillpdf_forms')
->condition('fid', $fid)
->execute();
fillpdf_form_delete_template($fid);
drupal_set_message(t('Your form has been deleted.'));
$form_state['redirect'] = 'admin/structure/fillpdf';
}
......
......@@ -2121,3 +2121,37 @@ function fillpdf_file_usage($file) {
return FALSE;
}
/**
* Delete a FillPDF template and all database entries related to it.
*
* @param int $fid
* The {fillpdf_forms.fid} of the template.
*/
function fillpdf_form_delete_template($fid) {
$fid = (int) $fid;
db_delete('fillpdf_fields')
->condition('fid', $fid)
->execute();
fillpdf_form_delete_file($fid);
db_delete('fillpdf_forms')
->condition('fid', $fid)
->execute();
}
/**
* Delete a FillPDF template file.
*
* @param int $fid
* The {fillpdf_forms.fid} of the template.
*/
function fillpdf_form_delete_file($fid) {
$fid = (int) $fid;
$file = file_load($fid);
file_usage_delete($file, 'fillpdf', 'fillpdf_form', $fid, 0);
file_delete($file);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment