diff options
author | fossee-dell | 2017-08-30 11:28:42 +0530 |
---|---|---|
committer | fossee-dell | 2017-08-30 11:28:42 +0530 |
commit | 31c85860d821af590b312740157c153040f98289 (patch) | |
tree | e3a3977fffaa25e016ea5c71f7d02bb20b4a931f /full_download.inc | |
parent | 1d1dcba8bbab9979009261148f89adcb4a8c6991 (diff) | |
download | esim_circuit_simulation_project_module-31c85860d821af590b312740157c153040f98289.tar.gz esim_circuit_simulation_project_module-31c85860d821af590b312740157c153040f98289.tar.bz2 esim_circuit_simulation_project_module-31c85860d821af590b312740157c153040f98289.zip |
Minor issues fixed
Diffstat (limited to 'full_download.inc')
-rwxr-xr-x | full_download.inc | 102 |
1 files changed, 52 insertions, 50 deletions
diff --git a/full_download.inc b/full_download.inc index 48ed080..932b4d7 100755 --- a/full_download.inc +++ b/full_download.inc @@ -1,45 +1,45 @@ <?php // $Id$ -function circuit_simulation_download_full_project() { +function circuit_simulation_download_full_project() +{ global $user; - $circuit_simulation_id = arg(3); + $id = arg(3); $root_path = circuit_simulation_path(); $query = db_select('esim_circuit_simulation_proposal'); $query->fields('esim_circuit_simulation_proposal'); - $query->condition('id', $circuit_simulation_id); + $query->condition('id', $id); $circuit_simulation_q = $query->execute(); $circuit_simulation_data = $circuit_simulation_q->fetchObject(); - $FLOWSHEET_PATH = $circuit_simulation_data->directory_name . '/'; - + $CIRCUITSIMULATION_PATH = $circuit_simulation_data->directory_name . '/'; /* zip filename */ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; /* creating zip archive on the server */ - //var_dump($zip_filename);die; $zip = new ZipArchive(); - //var_dump($zip);die; - $zip->open($zip_filename, ZipArchive::CREATE); + $zip->open($zip_filename, ZipArchive::CREATE); $query = db_select('esim_circuit_simulation_proposal'); $query->fields('esim_circuit_simulation_proposal'); - $query->condition('id', $circuit_simulation_id); + $query->condition('id', $id); $circuit_simulation_udc_q = $query->execute(); - while ($circuit_simulation_udc_row = $circuit_simulation_udc_q->fetchObject()) { - if ($circuit_simulation_udc_row->user_defined_compound_filepath || $circuit_simulation_udc_row->user_defined_compound_filepath != 'NULL') { - $USER_DEFINED_PATH = 'user_defined_compound/'; - - $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $circuit_simulation_udc_row->user_defined_compound_filepath, $USER_DEFINED_PATH . str_replace(' ', '_', basename($circuit_simulation_udc_row->user_defined_compound_filepath))); - } //$circuit_simulation_udc_row->user_defined_compound_filepath || $circuit_simulation_udc_row->user_defined_compound_filepath != 'NULL' - } //$circuit_simulation_udc_row = $circuit_simulation_udc_q->fetchObject() - $query = db_select('esim_circuit_simulation_submitted_abstracts_file'); - $query->fields('esim_circuit_simulation_submitted_abstracts_file'); - $query->condition('proposal_id', $circuit_simulation_id); - $circuit_simulation_f_q = $query->execute(); - while ($circuit_simulation_f_row = $circuit_simulation_f_q->fetchObject()) { - $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $circuit_simulation_f_row->filepath, str_replace(' ', '_', basename($circuit_simulation_f_row->filename))); - } //$circuit_simulation_f_row = $circuit_simulation_f_q->fetchObject() - $zip_file_count = $zip->numFiles; + if ($circuit_simulation_udc_row->samplefilepath != 'NULL') { + $REFERENCE_PATH = 'reference_file/'; + $str = substr($circuit_simulation_udc_row->samplefilepath,strrpos($circuit_simulation_udc_row->samplefilepath, '/')); + $resource_file =ltrim($str, '/'); + $zip->addFile($root_path . $CIRCUITSIMULATION_PATH . $resource_file , $REFERENCE_PATH . str_replace(' ', '_', basename($resource_file))); + } //$CIRCUITSIMULATION_udc_row->user_defined_compound_filepath || $CIRCUITSIMULATION_udc_row->user_defined_compound_filepath != 'NULL' + } //$CIRCUITSIMULATION_udc_row = $CIRCUITSIMULATION_udc_q->fetchObject() + $query = db_select('esim_circuit_simulation_proposal'); + $query->fields('esim_circuit_simulation_proposal'); + $query->condition('id', $id); + //$circuit_simulation_f_q = $query->execute(); + /*while ($circuit_simulation_data) { + $str = substr($circuit_simulation_data->samplefilepath,strrpos($circuit_simulation_data->samplefilepath, '/')); + $resource_file =ltrim($str, '/'); + $zip->addFile($root_path . $CIRCUITSIMULATION_PATH . $resource_file); + //var_dump($root_path . $CIRCUITSIMULATION_PATH . $resource_file);die; + } //$CIRCUITSIMULATION_f_row = $CIRCUITSIMULATION_f_q->fetchObject() + */$zip_file_count = $zip->numFiles; $zip->close(); - //var_dump($zip_file_count);die; if ($zip_file_count > 0) { if ($user->uid) { /* download zip file */ @@ -67,46 +67,49 @@ function circuit_simulation_download_full_project() { } } //$zip_file_count > 0 else { - drupal_set_message("There are circuit_simulation project in this proposal to download", 'error'); + drupal_set_message("There are no circuit simulation project in this proposal to download", 'error'); drupal_goto('circuit-simulation-project/full-download/project'); } } function circuit_simulation_download_completed_project() { - global $user; - $circuit_simulation_id = arg(3); + global $user; + $id = arg(3); $root_path = circuit_simulation_path(); $query = db_select('esim_circuit_simulation_proposal'); $query->fields('esim_circuit_simulation_proposal'); - $query->condition('id', $circuit_simulation_id); + $query->condition('id', $id); $circuit_simulation_q = $query->execute(); $circuit_simulation_data = $circuit_simulation_q->fetchObject(); - $FLOWSHEET_PATH = $circuit_simulation_data->directory_name . '/'; + $CIRCUITSIMULATION_PATH = $circuit_simulation_data->directory_name . '/'; /* zip filename */ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; /* creating zip archive on the server */ $zip = new ZipArchive(); - //var_dump($zip);die; $zip->open($zip_filename, ZipArchive::CREATE); - var_dump($zip);die; $query = db_select('esim_circuit_simulation_proposal'); $query->fields('esim_circuit_simulation_proposal'); - $query->condition('id', $circuit_simulation_id); + $query->condition('id', $id); $circuit_simulation_udc_q = $query->execute(); while ($circuit_simulation_udc_row = $circuit_simulation_udc_q->fetchObject()) { - if ($circuit_simulation_udc_row->user_defined_compound_filepath || $circuit_simulation_udc_row->user_defined_compound_filepath != 'NULL') { - $USER_DEFINED_PATH = 'user_defined_compound/'; - $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $circuit_simulation_udc_row->user_defined_compound_filepath, $USER_DEFINED_PATH . str_replace(' ', '_', basename($circuit_simulation_udc_row->user_defined_compound_filepath))); - } //$circuit_simulation_udc_row->user_defined_compound_filepath || $circuit_simulation_udc_row->user_defined_compound_filepath != 'NULL' - } //$circuit_simulation_udc_row = $circuit_simulation_udc_q->fetchObject() - $query = db_select('esim_circuit_simulation_submitted_abstracts_file'); - $query->fields('esim_circuit_simulation_submitted_abstracts_file'); - $query->condition('proposal_id', $circuit_simulation_id); - $circuit_simulation_f_q = $query->execute(); - while ($circuit_simulation_f_row = $circuit_simulation_f_q->fetchObject()) { - $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $circuit_simulation_f_row->filepath, str_replace(' ', '_', basename($circuit_simulation_f_row->filename))); - } //$circuit_simulation_f_row = $circuit_simulation_f_q->fetchObject() - $zip_file_count = $zip->numFiles; + if ($circuit_simulation_udc_row->samplefilepath != 'NULL') { + $REFERENCE_PATH = 'reference_file/'; + $str = substr($circuit_simulation_udc_row->samplefilepath,strrpos($circuit_simulation_udc_row->samplefilepath, '/')); + $resource_file =ltrim($str, '/'); + $zip->addFile($root_path . $CIRCUITSIMULATION_PATH . $resource_file , $REFERENCE_PATH . str_replace(' ', '_', basename($resource_file))); + } //$CIRCUITSIMULATION_udc_row->user_defined_compound_filepath || $CIRCUITSIMULATION_udc_row->user_defined_compound_filepath != 'NULL' + } //$CIRCUITSIMULATION_udc_row = $CIRCUITSIMULATION_udc_q->fetchObject() + $query = db_select('esim_circuit_simulation_proposal'); + $query->fields('esim_circuit_simulation_proposal'); + $query->condition('id', $id); + //$circuit_simulation_f_q = $query->execute(); + /*while ($circuit_simulation_data) { + $str = substr($circuit_simulation_data->samplefilepath,strrpos($circuit_simulation_data->samplefilepath, '/')); + $resource_file =ltrim($str, '/'); + $zip->addFile($root_path . $CIRCUITSIMULATION_PATH . $resource_file); + //var_dump($root_path . $CIRCUITSIMULATION_PATH . $resource_file);die; + } //$CIRCUITSIMULATION_f_row = $CIRCUITSIMULATION_f_q->fetchObject() + */$zip_file_count = $zip->numFiles; $zip->close(); if ($zip_file_count > 0) { if ($user->uid) { @@ -135,8 +138,7 @@ function circuit_simulation_download_completed_project() } } //$zip_file_count > 0 else { - drupal_set_message("There are circuit_simulation project in this proposal to download", 'error'); - drupal_goto('circuit-simulation-project/esim-circuit_simulation-run'); + drupal_set_message("There are circuit simulation project in this proposal to download", 'error'); + drupal_goto('circuit-simulation-project/full-download/project'); } -} - +}
\ No newline at end of file |