diff options
author | Sashi20 | 2020-08-10 20:06:50 +0530 |
---|---|---|
committer | GitHub | 2020-08-10 20:06:50 +0530 |
commit | 8fff84c30a9218ba49877babe4c3fc8e3a7b8d47 (patch) | |
tree | c787da0aeefae768b022c7eebede01b1f3d9c9b4 | |
parent | 3f7a749f39f656c46e08fef8c001025183af3ae0 (diff) | |
parent | 9fdf3f392432e51434566feccc8315c0f1b7c6b6 (diff) | |
download | r_textbook_companion-8fff84c30a9218ba49877babe4c3fc8e3a7b8d47.tar.gz r_textbook_companion-8fff84c30a9218ba49877babe4c3fc8e3a7b8d47.tar.bz2 r_textbook_companion-8fff84c30a9218ba49877babe4c3fc8e3a7b8d47.zip |
Merge pull request #40 from Sashi20/drupal_7.x
Modify regenerate pdf function to delete pdf
-rwxr-xr-x | latex.inc | 6 | ||||
-rwxr-xr-x | textbook_companion.module | 7 |
2 files changed, 9 insertions, 4 deletions
@@ -43,7 +43,7 @@ function _latex_generate_files($preference_id, $full_book = FALSE) del_book_pdf($preference_data->id); /* check if book already generated */ //var_dump(file_exists($dir_path . "book_" . $preference_data->id . ".pdf"));die; - if (file_exists($dir_path . "book_" . $preference_data->id . ".pdf")) + if (file_exists($dir_path . "book_" . $preference_data->directory_name . ".pdf")) { /* download PDF file */ ob_clean(); @@ -54,14 +54,14 @@ function _latex_generate_files($preference_id, $full_book = FALSE) header("Content-Description: File Transfer"); header('Content-Type: application/pdf'); header('Content-disposition: attachment; filename="' . $preference_data->book . '_' . $preference_data->author . '.pdf"'); - header('Content-Length: ' . filesize($dir_path . "book_" . $preference_data->id . ".pdf")); + header('Content-Length: ' . filesize($dir_path . "book_" . $preference_data->directory_name . ".pdf")); //header("Content-Transfer-Encoding: binary"); //header('Expires: 0'); //header('Pragma: no-cache'); //ob_end_flush(); //ob_clean(); //flush(); - readfile($dir_path . "book_" . $preference_data->id . ".pdf"); + readfile($dir_path . "book_" . $preference_data->directory_name . ".pdf"); return; } //file_exists($dir_path . "book_" . $preference_data->id . ".pdf") $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = :id", array( diff --git a/textbook_companion.module b/textbook_companion.module index 3fb1f79..2fc97e6 100755 --- a/textbook_companion.module +++ b/textbook_companion.module @@ -3688,7 +3688,12 @@ function del_book_pdf($book_id) { $root_path = textbook_companion_path(); $dir_path = $root_path . "latex/"; - $pdf_filename = "book_" . $book_id . ".pdf"; + $query = db_select('textbook_companion_preference'); + $query->fields('textbook_companion_preference'); + $query->condition('id', $book_id); + $query_pre_data = $query->execute(); + $result = $query_pre_data->fetchObject(); + $pdf_filename = "book_" . $result->directory_name . ".pdf"; if (file_exists($dir_path . $pdf_filename)) unlink($dir_path . $pdf_filename); } |