summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashant2015-04-13 15:47:19 +0530
committerprashant2015-04-13 15:47:19 +0530
commitbe2b10d3633d00e0919bf96f7aa7e89004a21e11 (patch)
tree56ffa2d14f87e6f0d566df568f92afd391069148
parentadf9a307b718d13f5e9cad77e1dc7384df237928 (diff)
downloadDWSIM_textbook_companion-be2b10d3633d00e0919bf96f7aa7e89004a21e11.tar.gz
DWSIM_textbook_companion-be2b10d3633d00e0919bf96f7aa7e89004a21e11.tar.bz2
DWSIM_textbook_companion-be2b10d3633d00e0919bf96f7aa7e89004a21e11.zip
changed code for download chapters
-rwxr-xr-xdownload.inc13
1 files changed, 3 insertions, 10 deletions
diff --git a/download.inc b/download.inc
index c72526a..db9d5d8 100755
--- a/download.inc
+++ b/download.inc
@@ -81,7 +81,7 @@ function textbook_companion_download_example()
function textbook_companion_download_chapter()
{
- $chapter_id = arg(2);
+ $chapter_id = (int)arg(2);
$root_path = textbook_companion_path();
/* get example data */
@@ -101,18 +101,10 @@ function textbook_companion_download_chapter()
{
$EX_PATH = 'EX' . $example_row->number . '/';
$example_files_q = db_query("SELECT * FROM {textbook_companion_example_files} WHERE example_id = %d", $example_row->id);
- $example_dependency_files_q = db_query("SELECT * FROM {textbook_companion_example_dependency} WHERE example_id = %d", $example_row->id);
while ($example_files_row = db_fetch_object($example_files_q))
{
$zip->addFile($root_path . $example_files_row->filepath, $CH_PATH . $EX_PATH . $example_files_row->filename);
}
- /* dependency files */
- while ($example_dependency_files_row = db_fetch_object($example_dependency_files_q))
- {
- $dependency_file_data = db_fetch_object(db_query("SELECT * FROM {textbook_companion_dependency_files} WHERE id = %d LIMIT 1", $example_dependency_files_row->dependency_id));
- if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $CH_PATH . $EX_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
- }
}
$zip_file_count = $zip->numFiles;
$zip->close();
@@ -120,6 +112,7 @@ function textbook_companion_download_chapter()
if ($zip_file_count > 0)
{
/* download zip file */
+ ob_clean();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename="CH' . $chapter_data->number . '.zip"');
header('Content-Length: ' . filesize($zip_filename));
@@ -127,7 +120,7 @@ function textbook_companion_download_chapter()
unlink($zip_filename);
} else {
drupal_set_message("There are no examples in this chapter to download", 'error');
- drupal_goto('textbook_runs');
+ drupal_goto('textbook_run');
}
}