diff options
-rwxr-xr-x | download.inc | 284 | ||||
-rwxr-xr-x | flowsheet_details.inc | 8 | ||||
-rwxr-xr-x | om_flowsheet.module | 4 | ||||
-rwxr-xr-x | run.inc | 5 |
4 files changed, 42 insertions, 259 deletions
diff --git a/download.inc b/download.inc index fa1fdd1..f3e315c 100755 --- a/download.inc +++ b/download.inc @@ -17,254 +17,36 @@ function om_flowsheet_download_user_defined_compound() ob_clean(); readfile($root_path . $om_flowsheet_user_compund_data->directory_name . '/' . $om_flowsheet_user_compund_data->user_defined_compound_filepath); } -function om_flowsheet_download_solution_file() -{ - $solution_file_id = arg(3); - $root_path = om_flowsheet_path(); - // $solution_files_q = db_query("SELECT * FROM {om_flowsheet_solution_files} WHERE id = %d LIMIT 1", $solution_file_id); - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id LIMIT 1", array( - ':solution_id' => $solution_file_id - )); - $solution_file_data = $solution_files_q->fetchObject(); - header('Content-Type: ' . $solution_file_data->filemime); - //header('Content-Type: application/octet-stram'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($solution_file_data->filename)) . '"'); - header('Content-Length: ' . filesize($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath)); - readfile($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath); -} -function om_flowsheet_download_dependency_file() -{ - $dependency_file_id = arg(3); - $root_path = om_flowsheet_path(); - $query = db_select('om_flowsheet_dependency_files'); - $query->fields('om_flowsheet_dependency_files'); - $query->condition('id', $dependency_file_id); - $query->range(0, 1); - $dependency_files_q = $query->execute(); - $dependency_file_data = $dependency_files_q->fetchObject(); - header('Content-Type: ' . $dependency_file_data->filemime); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($dependency_file_data->filename)) . '"'); - header('Content-Length: ' . filesize($root_path . $dependency_file_data->filepath)); - readfile($root_path . $dependency_file_data->filepath); -} -function om_flowsheet_download_solution() -{ - $solution_id = arg(3); - $root_path = om_flowsheet_path(); - $query = db_select('om_flowsheet_solution'); - $query->fields('om_flowsheet_solution'); - $query->condition('id', $solution_id); - $solution_q = $query->execute(); - $solution_data = $solution_q->fetchObject(); - $query = db_select('om_flowsheet_experiment'); - $query->fields('om_flowsheet_experiment'); - $query->condition('id', $solution_data->experiment_id); - $experiment_q = $query->execute(); - $experiment_data = $experiment_q->fetchObject(); - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array( - ':solution_id' => $solution_id - )); - $query = db_select('om_flowsheet_solution_dependency'); - $query->fields('om_flowsheet_solution_dependency'); - $query->condition('solution_id', $solution_id); - $solution_dependency_files_q = $query->execute(); - $CODE_PATH = 'CODE' . $solution_data->code_number . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive; - $zip->open($zip_filename, ZipArchive::CREATE); - while ($solution_files_row = $solution_files_q->fetchObject()) - { - $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); - } - /* dependency files */ - while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) - { - $query = db_select('om_flowsheet_dependency_files'); - $query->fields('om_flowsheet_dependency_files'); - $query->condition('id', $solution_dependency_files_row->dependency_id); - $query->range(0, 1); - $dependency_file_data = $query->execute()->fetchObject(); - if ($dependency_file_data) - $zip->addFile($root_path . $dependency_file_data->filepath, $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); - } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject() - $zip_file_count = $zip->numFiles; - $zip->close(); - if ($zip_file_count > 0) - { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="CODE' . $solution_data->code_number . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } //$zip_file_count > 0 - else - { - drupal_set_message("There are no files in this solutions to download", 'error'); - drupal_goto('lab-migration/lab-migration-run'); - } -} -function om_flowsheet_download_experiment() -{ - $experiment_id = (int) arg(3); - $root_path = om_flowsheet_path(); - /* get solution data */ - $query = db_select('om_flowsheet_experiment'); - $query->fields('om_flowsheet_experiment'); - $query->condition('id', $experiment_id); - $experiment_q = $query->execute(); - $experiment_data = $experiment_q->fetchObject(); - $EXP_PATH = 'EXP' . $experiment_data->number . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive; - $zip->open($zip_filename, ZipArchive::CREATE); - $query = db_select('om_flowsheet_solution'); - $query->fields('om_flowsheet_solution'); - $query->condition('experiment_id', $experiment_id); - $query->condition('approval_status', 1); - $solution_q = $query->execute(); - while ($solution_row = $solution_q->fetchObject()) - { - $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.solution_id = :solution_id", array( - ':solution_id' => $solution_row->id - )); - while ($solution_files_row = $solution_files_q->fetchObject()) - { - $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); - } //$solution_files_row = $solution_files_q->fetchObject() - /* dependency files */ - $query = db_select('om_flowsheet_solution_dependency'); - $query->fields('om_flowsheet_solution_dependency'); - $query->condition('solution_id', $solution_row->id); - $solution_dependency_files_q = $query->execute(); - while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) - { - $query = db_select('om_flowsheet_dependency_files'); - $query->fields('om_flowsheet_dependency_files'); - $query->condition('id', $solution_dependency_files_row->dependency_id); - $query->range(0, 1); - $dependency_file_data = $query->execute()->fetchObject(); - if ($dependency_file_data) - $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); - } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject() - } //$solution_row = $solution_q->fetchObject() - $zip_file_count = $zip->numFiles; - $zip->close(); - if ($zip_file_count > 0) - { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } //$zip_file_count > 0 - else - { - drupal_set_message("There are no solutions in this experiment to download", 'error'); - drupal_goto('lab-migration/lab-migration-run'); - } -} -function om_flowsheet_download_lab() -{ - global $user; - $lab_id = arg(3); - $root_path = om_flowsheet_path(); - /* get solution data */ - $query = db_select('om_flowsheet_proposal'); - $query->fields('om_flowsheet_proposal'); - $query->condition('id', $lab_id); - $lab_q = $query->execute(); - $lab_data = $lab_q->fetchObject(); - $LAB_PATH = $lab_data->lab_title . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive(); - $zip->open($zip_filename, ZipArchive::CREATE); - $query = db_select('om_flowsheet_experiment'); - $query->fields('om_flowsheet_experiment'); - $query->condition('proposal_id', $lab_id); - $experiment_q = $query->execute(); - while ($experiment_row = $experiment_q->fetchObject()) - { - $EXP_PATH = 'EXP' . $experiment_row->number . '/'; - $query = db_select('om_flowsheet_solution'); - $query->fields('om_flowsheet_solution'); - $query->condition('experiment_id', $experiment_row->id); - $query->condition('approval_status', 1); - $solution_q = $query->execute(); - while ($solution_row = $solution_q->fetchObject()) - { - $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array( - ':solution_id' => $solution_row->id - )); - $query = db_select('om_flowsheet_solution_dependency'); - $query->fields('om_flowsheet_solution_dependency'); - $query->condition('solution_id', $solution_row->id); - $solution_dependency_files_q = $query->execute(); - while ($solution_files_row = $solution_files_q->fetchObject()) - { - $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); - //var_dump($zip->numFiles); - } //$solution_files_row = $solution_files_q->fetchObject() - // die; - /* dependency files */ - while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) - { - $query = db_select('om_flowsheet_dependency_files'); - $query->fields('om_flowsheet_dependency_files'); - $query->condition('id', $solution_dependency_files_row->dependency_id); - $query->range(0, 1); - $dependency_file_data = $query->execute()->fetchObject(); - if ($dependency_file_data) - $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); - } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject() - } //$solution_row = $solution_q->fetchObject() - } //$experiment_row = $experiment_q->fetchObject() - $zip_file_count = $zip->numFiles; - $zip->close(); - if ($zip_file_count > 0) - { - if ($user->uid) - { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } //$user->uid - else - { - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - header("Content-Transfer-Encoding: binary"); - header('Expires: 0'); - header('Pragma: no-cache'); - ob_end_flush(); - ob_clean(); - flush(); - readfile($zip_filename); - unlink($zip_filename); - } - } //$zip_file_count > 0 - else - { - drupal_set_message("There are no solutions in this Lab to download", 'error'); - drupal_goto('lab-migration/lab-migration-run'); - } -} +function om_flowsheet_download_abstract_file() { + $proposal_id = arg(4); + $root_path = om_flowsheet_document_path(); + $query = db_select('om_flowsheet_submitted_abstracts_file'); + $query->fields('om_flowsheet_submitted_abstracts_file'); + $query->condition('proposal_id', $proposal_id); + $query->condition('filetype', A); + $result = $query->execute(); + $om_pssp_project_files = $result->fetchObject(); + //var_dump($om_pssp_project_files);die; + $query1 = db_select('om_flowsheet_proposal'); + $query1->fields('om_flowsheet_proposal'); + $query1->condition('id', $proposal_id); + $result1 = $query1->execute(); + $om_pssp = $result1->fetchObject(); + $directory_name = $om_pssp->directory_name . '/'; + $samplecodename = $om_pssp_project_files->filename; + ob_clean(); + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: public"); + header("Content-Description: File Transfer"); + header("Content-Type: application/pdf"); + header('Content-disposition: attachment; filename="' . $samplecodename . '"'); + header("Content-Length: " . filesize($root_path . $directory_name . $samplecodename)); + header("Content-Transfer-Encoding: binary"); + header("Expires: 0"); + header("Pragma: no-cache"); + readfile($root_path . $directory_name . $samplecodename); + ob_end_flush(); + ob_clean(); +}
\ No newline at end of file diff --git a/flowsheet_details.inc b/flowsheet_details.inc index c4e00ad..184be3a 100755 --- a/flowsheet_details.inc +++ b/flowsheet_details.inc @@ -6,7 +6,7 @@ function om_flowsheet_completed_proposals_all() $query = db_select('om_flowsheet_proposal'); $query->fields('om_flowsheet_proposal'); $query->condition('approval_status', 3); - $query->orderBy('actual_completion_date', 'ASC'); + $query->orderBy('actual_completion_date', 'DESC'); $result = $query->execute(); if ($result->rowCount() == 0) { @@ -34,8 +34,8 @@ function om_flowsheet_completed_proposals_all() 'No', 'Flowsheet Project', 'Contributor Name', - 'Institution', - 'Year' + 'University / Institute', + 'Year of Completion' ); $output .= theme('table', array( 'header' => $preference_header, @@ -78,7 +78,7 @@ function om_flowsheet_progress_all() 'No', 'Flowsheet Project', 'Contributor Name', - 'Institution', + 'University / Institute', 'Year' ); $page_content .= theme('table', array( diff --git a/om_flowsheet.module b/om_flowsheet.module index bab1740..85e8756 100755 --- a/om_flowsheet.module +++ b/om_flowsheet.module @@ -249,10 +249,10 @@ function om_flowsheet_menu() 'file' => 'upload_code_delete.inc' ); /* CODE DOWNLOADS */ - $items['chemical/flowsheeting-project/download/file'] = array( + $items['chemical/flowsheeting-project/download/abstract-file'] = array( 'title' => 'Code Download', 'description' => 'Code Download', - 'page callback' => 'om_flowsheet_download_solution_file', + 'page callback' => 'om_flowsheet_download_abstract_file', 'access arguments' => array( 'om flowsheet download code' ), @@ -44,7 +44,8 @@ function om_flowsheet_run_form($form, &$form_state) ); $form['selected_flowsheet'] = array( '#type' => 'item', - '#markup' => '<div id="ajax_selected_flowsheet">' . l('Download Flowsheet', 'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a mo file which is the OpenModelica flowsheet which is to be viewed by right clicking on the file and opening with OpenModelica.'))) . '</div><hr><p style="color:red;">Note: This flowsheet is compatible with the simulator version mentioned above. To simulate the flowsheet in OpenModelica, it must be opened with the above Simulator version.<br>To download the Simulator, click on the Simulator version mentioned above.</p>' + '#markup' => '<div id="ajax_selected_flowsheet">' . l('Download Abstract', "chemical/flowsheeting-project/download/abstract-file/" . $flowsheet_default_value) + . '<br>' . l('Download Flowsheet', 'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a mo file which is the OpenModelica flowsheet which is to be viewed by right clicking on the file and opening with OpenModelica.'))) . '</div><hr><p style="color:red;">Note: This flowsheet is compatible with the simulator version mentioned above. To simulate the flowsheet in OpenModelica, it must be opened with the above Simulator version.<br>To download the Simulator, click on the Simulator version mentioned above.</p>' ); } return $form; @@ -58,7 +59,7 @@ function om_flowsheet_project_details_callback($form, $form_state) $flowsheet_details = _flowsheet_information($flowsheet_default_value); $provider = user_load($flowsheet_details->uid); if ($flowsheet_details->uid > 0) { - $commands[] = ajax_command_html('#ajax_selected_flowsheet', l('Download Flowsheet', 'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))) . '<hr><p style="color:red;">Note: This flowsheet is compatible with the simulator version mentioned above. To simulate the flowsheet in OpenModelica, it must be opened with the above Simulator version.<br>To download the Simulator, click on the Simulator version mentioned above.</p>'); + $commands[] = ajax_command_html('#ajax_selected_flowsheet', l('Download Abstract', "chemical/flowsheeting-project/download/abstract-file/" . $flowsheet_default_value) . '<br>' . l('Download Flowsheet', 'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))) . '<hr><p style="color:red;">Note: This flowsheet is compatible with the simulator version mentioned above. To simulate the flowsheet in OpenModelica, it must be opened with the above Simulator version.<br>To download the Simulator, click on the Simulator version mentioned above.</p>'); } //$flowsheet_details->uid > 0 else { $commands[] = ajax_command_html('#ajax_selected_flowsheet', ''); |