summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdownload.inc301
-rwxr-xr-xdwsim_flowsheet.module1512
-rwxr-xr-xemail.inc397
-rwxr-xr-xfull_download.inc241
-rw-r--r--manage_proposal.inc1245
-rwxr-xr-xproposal.inc988
-rwxr-xr-xsettings.inc186
-rwxr-xr-xupload_code.inc317
-rwxr-xr-xupload_code_delete.inc95
9 files changed, 3603 insertions, 1679 deletions
diff --git a/download.inc b/download.inc
new file mode 100755
index 0000000..c409063
--- /dev/null
+++ b/download.inc
@@ -0,0 +1,301 @@
+<?php
+// $Id$
+
+function dwsim_flowsheet_download_user_defined_compound()
+{
+ $proposal_id = arg(3);
+ $root_path = dwsim_flowsheet_document_path();
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $dwsim_flowsheet_user_compund_data = $result->fetchObject();
+ $samplecodename = substr($dwsim_flowsheet_user_compund_data->user_defined_compound_filepath, strrpos($dwsim_flowsheet_user_compund_data->user_defined_compound_filepath, '/') + 1);
+ header('Content-Type: txt/zip');
+ header('Content-disposition: attachment; filename="' . $samplecodename . '"');
+ header('Content-Length: ' . filesize($root_path . $dwsim_flowsheet_user_compund_data->directory_name. '/'. $dwsim_flowsheet_user_compund_data->user_defined_compound_filepath));
+ ob_clean();
+ readfile($root_path . $dwsim_flowsheet_user_compund_data->directory_name. '/'.$dwsim_flowsheet_user_compund_data->user_defined_compound_filepath);
+}
+
+function dwsim_flowsheet_download_solution_file()
+ {
+ $solution_file_id = arg(3);
+ $root_path = dwsim_flowsheet_path();
+ // $solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE id = %d LIMIT 1", $solution_file_id);
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_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));
+ /*$query = db_select('dwsim_flowsheet_solution_files');
+ $query->fields('dwsim_flowsheet_solution_files');
+ $query->condition('id', $solution_file_id);
+ $query->range(0, 1);
+ $solution_files_q = $query->execute();*/
+ $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 dwsim_flowsheet_download_dependency_file()
+ {
+ $dependency_file_id = arg(3);
+ $root_path = dwsim_flowsheet_path();
+ //$dependency_file_q = db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $dependency_file_id);
+ $query = db_select('dwsim_flowsheet_dependency_files');
+ $query->fields('dwsim_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 dwsim_flowsheet_download_solution()
+ {
+ $solution_id = arg(3);
+ $root_path = dwsim_flowsheet_path();
+ /* get solution data */
+ //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE id = %d", $solution_id);
+ $query = db_select('dwsim_flowsheet_solution');
+ $query->fields('dwsim_flowsheet_solution');
+ $query->condition('id', $solution_id);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $solution_data->experiment_id);
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ //$solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_id);
+ /*$query = db_select('dwsim_flowsheet_solution_files');
+ $query->fields('dwsim_flowsheet_solution_files');
+ $query->condition('solution_id', $solution_id);
+ $solution_files_q = $query->execute();*/
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_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));
+ //$solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_id);
+ $query = db_select('dwsim_flowsheet_solution_dependency');
+ $query->fields('dwsim_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())
+ {
+ //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $query = db_select('dwsim_flowsheet_dependency_files');
+ $query->fields('dwsim_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)));
+ }
+ $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);
+ }
+ else
+ {
+ drupal_set_message("There are no files in this solutions to download", 'error');
+ drupal_goto('lab-migration/lab-migration-run');
+ }
+ }
+function dwsim_flowsheet_download_experiment()
+ {
+ $experiment_id = (int)arg(3);
+
+ $root_path = dwsim_flowsheet_path();
+ /* get solution data */
+ //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $experiment_id);
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_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);
+ //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id);
+ $query = db_select('dwsim_flowsheet_solution');
+ $query->fields('dwsim_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 * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_row->id);
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_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));
+ /* $query = db_select('dwsim_flowsheet_solution_files');
+ $query->fields('dwsim_flowsheet_solution_files');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_files_q = $query->execute();*/
+ // $solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $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)));
+ }
+ /* dependency files */
+ $query = db_select('dwsim_flowsheet_solution_dependency');
+ $query->fields('dwsim_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())
+ {
+ //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $query = db_select('dwsim_flowsheet_dependency_files');
+ $query->fields('dwsim_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)));
+ }
+ }
+ $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);
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this experiment to download", 'error');
+ drupal_goto('lab-migration/lab-migration-run');
+ }
+ }
+function dwsim_flowsheet_download_lab()
+ {
+ global $user;
+ $lab_id = arg(3);
+ $root_path = dwsim_flowsheet_path();
+ /* get solution data */
+ //$lab_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $lab_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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);
+ //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $lab_id);
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $lab_id);
+ $experiment_q = $query->execute();
+ while ($experiment_row = $experiment_q->fetchObject())
+ {
+ $EXP_PATH = 'EXP' . $experiment_row->number . '/';
+ //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id);
+ $query = db_select('dwsim_flowsheet_solution');
+ $query->fields('dwsim_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 * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_row->id);
+
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_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('dwsim_flowsheet_solution_files');
+ $query->fields('dwsim_flowsheet_solution_files');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_files_q = $query->execute();*/
+ //$solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_row->id);
+ $query = db_select('dwsim_flowsheet_solution_dependency');
+ $query->fields('dwsim_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);
+ }
+ // die;
+ /* dependency files */
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $query = db_select('dwsim_flowsheet_dependency_files');
+ $query->fields('dwsim_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)));
+ }
+ }
+ }
+ $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);
+ }
+ 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);
+ }
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this Lab to download", 'error');
+ drupal_goto('lab-migration/lab-migration-run');
+ }
+ }
diff --git a/dwsim_flowsheet.module b/dwsim_flowsheet.module
index 9e135ab..9ebbcfe 100755
--- a/dwsim_flowsheet.module
+++ b/dwsim_flowsheet.module
@@ -6,771 +6,783 @@ require_once('email.inc');
* Implementation of hook_menu().
*/
function dwsim_flowsheet_menu()
- {
- $items = array();
- /* PROPOSAL */
- $items['dwsim-flowsheet/proposal'] = array(
- 'title' => 'Flowsheet Proposal Form',
- 'description' => 'Flowsheet Proposal Form Proposal Form',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_proposal_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet create proposal'
- ),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal'] = array(
- 'title' => 'Manage Flowsheet Proposals',
- 'description' => 'Manage Flowsheet Proposals',
- 'page callback' => 'dwsim_flowsheet_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/pending'] = array(
- 'title' => 'Pending Proposals',
- 'description' => 'Pending dwsim flowsheet Proposals Queue',
- 'page callback' => 'dwsim_flowsheet_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/pending-solution-proposal'] = array(
- 'title' => 'Pending Solution Proposals',
- 'description' => 'Pending dwsim flowsheet Solution Proposals Queue',
- 'page callback' => 'dwsim_flowsheet_solution_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'manage_solution_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/pending-solution'] = array(
- 'title' => 'Pending Solution',
- 'description' => 'Pending dwsim flowsheet Solution',
- 'page callback' => 'dwsim_flowsheet_proposal_pending_solution',
- 'access callback' => 'user_access',
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3,
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/all'] = array(
- 'title' => 'All Proposals',
- 'description' => 'All Proposals',
- 'page callback' => 'dwsim_flowsheet_proposal_all',
- 'access callback' => 'user_access',
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 4,
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/category'] = array(
- 'title' => 'Category',
- 'description' => 'Category',
- 'page callback' => 'dwsim_flowsheet_category_all',
- 'access callback' => 'user_access',
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 5,
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/category/edit'] = array(
- 'title' => 'Edit Category',
- 'description' => 'Edit category',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_category_edit_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet edit proposal'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/approve'] = array(
- 'title' => 'Approve Proposal',
- 'description' => 'Approve Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_proposal_approval_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/solution-proposal-approve'] = array(
- 'title' => 'Approve Solution Proposal',
- 'description' => 'Approve Solution Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_solution_proposal_approval_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_solution_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/edit'] = array(
- 'title' => 'Edit Proposal',
- 'description' => 'Edit Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_proposal_edit_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet manage proposal'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc'
- );
- $items['dwsim-flowsheet/manage-proposal/status'] = array(
- 'title' => 'Proposal Status',
- 'description' => 'Proposal Status',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_proposal_status_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet approve proposal'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc'
- );
- /* SOLUTION PROPOSAL */
- $items['dwsim-flowsheet/open-proposal'] = array(
- 'title' => 'dwsim flowsheet Solve',
- 'description' => 'dwsim flowsheet Proposal Open For Solution',
- 'page callback' => 'dwsim_flowsheet_proposal_open',
- 'access arguments' => array(
- 'dwsim flowsheet propose solution'
- ),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'solution_proposal.inc'
- );
- $items['dwsim-flowsheet/show-proposal'] = array(
- 'title' => 'dwsim flowsheet Solution Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_solution_proposal_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet propose solution'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'solution_proposal.inc'
- );
- /* CODE REVIEW */
- $items['dwsim-flowsheet/code-approval'] = array(
- 'title' => 'LM Manage Code Approval',
- 'description' => 'Manage Code Approval',
- 'page callback' => 'dwsim_flowsheet_code_approval',
- 'access arguments' => array(
- 'dwsim flowsheet approve code'
- ),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'code_approval.inc'
- );
- $items['dwsim-flowsheet/code-approval/approve'] = array(
- 'title' => 'Code Approval',
- 'description' => 'Code Approval',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_code_approval_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet approve code'
- ),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'code_approval.inc'
- );
- $items['dwsim-flowsheet/code-approval/bulk'] = array(
- 'title' => 'Bulk Manage',
- 'description' => 'Bulk Mangage',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_bulk_approval_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
- ),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'bulk_approval.inc'
- );
- $items['dwsim-flowsheet/code-approval/bulk'] = array(
- 'title' => 'Bulk Manage',
- 'description' => 'Bulk Mangage',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_bulk_approval_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
- ),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'bulk_approval.inc'
- );
- /*$items['dwsim_flowsheet/code_approval/dependency'] = array(
- 'title' => 'Dependency',
- 'description' => 'Dependency Mangage',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('dwsim_flowsheet_dependency_approval_form'),
- 'access arguments' => array('dwsim flowsheet bulk manage code'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3,
- 'file' => 'dependency_approval.inc',
- );*/
- $items['dwsim-flowsheet/code-approval/upload'] = array(
- 'title' => 'Upload Code',
- 'description' => 'Admin Upload',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_bulk_upload_code_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
- ),
- 'type' => MENU_CALLBACK,
- 'weight' => 4,
- 'file' => 'bulk_upload_code.inc'
- );
- $items['dwsim-flowsheet/code-approval/notes'] = array(
- 'title' => 'Notes for Reviewers',
- 'description' => 'Notes for Reviewers',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_lab_notes_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
- ),
- 'type' => MENU_CALLBACK,
- 'weight' => 4,
- 'file' => 'notes.inc'
- );
- /* CODE UPLOAD */
- $items['dwsim-flowsheet/code'] = array(
- 'title' => 'Code Submission',
- 'description' => 'Code Submission',
- 'page callback' => 'dwsim_flowsheet_list_experiments',
- 'access callback' => 'user_access',
- 'access arguments' => array(
- 'dwsim flowsheet upload code'
- ),
- 'file' => 'upload_code.inc'
- );
- $items['dwsim-flowsheet/code/list-experiments'] = array(
- 'title' => 'List Experiments',
- 'description' => 'List Experiments',
- 'page callback' => 'dwsim_flowsheet_list_experiments',
- 'access arguments' => array(
- 'dwsim flowsheet upload code'
- ),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'file' => 'upload_code.inc',
- 'weight' => 1
- );
- $items['dwsim-flowsheet/code/upload'] = array(
- 'title' => 'Code Submission',
- 'description' => 'Code Submission',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_upload_code_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet upload code'
- ),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'upload_code.inc',
- 'weight' => 2
- );
- /* $items['dwsim_flowsheet/code/upload_dep'] = array(
- 'title' => 'Upload Dependency',
- 'description' => 'Upload Dependency Files',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('dwsim_flowsheet_upload_dependency_form'),
- 'access arguments' => array('dwsim flowsheet upload code'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'dependency.inc',
- 'weight' => 3,
- );*/
- $items['dwsim-flowsheet/code/delete'] = array(
- 'title' => 'Delete Solution',
- 'description' => 'Delete Solution',
- 'page callback' => 'dwsim_flowsheet_upload_code_delete',
- 'access arguments' => array(
- 'dwsim flowsheet upload code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'upload_code_delete.inc'
- );
- /* CODE DOWNLOADS */
- $items['dwsim-flowsheet/download/file'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_solution_file',
- 'access arguments' => array(
- 'dwsim flowsheet download code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc'
- );
- /*$items['dwsim_flowsheet/download/dependency'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_dependency_file',
- 'access arguments' => array('dwsim flowsheet download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );*/
- $items['dwsim-flowsheet/download/solution'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_solution',
- 'access arguments' => array(
- 'dwsim flowsheet download code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc'
- );
- $items['dwsim-flowsheet/download/experiment'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_experiment',
- 'access arguments' => array(
- 'dwsim flowsheet download code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc'
- );
- $items['dwsim-flowsheet/download/lab'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_lab',
- 'access arguments' => array(
- 'dwsim flowsheet download code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc'
- );
- $items['dwsim-flowsheet/full-download/experiment'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_full_experiment',
- 'access arguments' => array(
- 'dwsim flowsheet approve code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc'
- );
- $items['dwsim-flowsheet/full-download/lab'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_full_lab',
- 'access arguments' => array(
- 'dwsim flowsheet approve code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc'
- );
- /* COMPLETED dwsim flowsheetS */
- $items['dwsim-flowsheet/completed-labs'] = array(
- 'title' => 'Completed Labs',
- 'page callback' => 'dwsim_flowsheet_completed_labs_all',
- 'access arguments' => array(
- 'dwsim flowsheet download code'
- ),
- 'file' => 'lab_details.inc'
- );
- /* LABS IN PROGRESS */
- $items['dwsim-flowsheet/labs-progress'] = array(
- 'title' => 'Labs in Progress',
- 'page callback' => 'dwsim_flowsheet_labs_progress_all',
- 'access arguments' => array(
- 'dwsim flowsheet download code'
- ),
- 'file' => 'lab_details.inc'
- );
- /* DOWNLOAD FOR EVERYONE */
- $items['dwsim-flowsheet/dwsim-flowsheet-run'] = array(
- 'title' => 'Download Codes',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_run_form'
- ),
- 'access arguments' => array(
- 'dwsim flowsheet download code'
- ),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'run.inc'
- );
- /*$items['dwsim_flowsheet_run'] = array(
- 'title' => 'Download Codes',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('dwsim_flowsheet_run_form_ajax'),
- 'access arguments' => array('access content'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'run.inc',
- );
- $items['dwsim_flowsheet_run_ajax'] = array(
- 'page callback' => 'dwsim_flowsheet_run_ajax',
- 'access callback' => TRUE,
- 'file' => 'run.inc',
- );
- $items['download_codes'] = array(
- 'title' => 'Download Codes',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('dwsim_flowsheet_run_form_ajax'),
- 'access arguments' => array('access content'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'run.inc',
- );*/
- /* LATEX SCRIPT */
- $items['dwsim-flowsheet/generate-lab'] = array(
- 'title' => 'Generate Lab',
- 'description' => 'Generate Lab From Latex Script',
- 'page callback' => 'dwsim_flowsheet_download_lab_pdf',
- 'access arguments' => array(
- 'dwsim flowsheet generate lab'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'latex.inc'
- );
- $items['dwsim-flowsheet/delete-lab'] = array(
- 'title' => 'Delete Lab PDF',
- 'description' => 'Delete Lab PDF',
- 'page callback' => 'dwsim_flowsheet_delete_lab_pdf',
- 'access arguments' => array(
- 'dwsim flowsheet approve code'
- ),
- 'type' => MENU_CALLBACK,
- 'file' => 'latex.inc'
- );
- /* ADMIN SETTINGS */
- $items['admin/settings/dwsim-flowsheet'] = array(
- 'title' => 'dwsim flowsheet Settings',
- 'description' => 'dwsim flowsheet Settings',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array(
- 'dwsim_flowsheet_settings_form'
- ),
- 'access arguments' => array(
- 'administer dwsim flowsheet'
- ),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'settings.inc'
- );
- /* AJAX REQUEST */
- $items["lab-bulk-manage-exp/ajax"] = array(
- "title" => "Ajax callbacks",
- "page callback" => "lab_bulk_manage_exp_ajax",
- "access arguments" => array(
- "dwsim flowsheet bulk manage code"
- ),
- "type" => MENU_CALLBACK,
- 'file' => 'bulk_approval.inc'
- );
- /* $items["dwsim_flowsheet/code_approval/dependency/ajax"] = array(
- "title" => "Ajax callbacks",
- "page callback" => "dwsim_flowsheet_dependency_approval_ajax",
- "access arguments" => array("dwsim flowsheet bulk manage code"),
- "type" => MENU_CALLBACK,
- 'file' => 'dependency_approval.inc',
- );*/
- return $items;
- }
+{
+ $items = array();
+ /* PROPOSAL */
+ $items['flowsheeting-project/proposal'] = array(
+ 'title' => 'Flowsheet Proposal Form',
+ 'description' => 'Flowsheet Proposal Form Proposal Form',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_proposal_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet create proposal'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal'] = array(
+ 'title' => 'Manage Flowsheet Proposals',
+ 'description' => 'Manage Flowsheet Proposals',
+ 'page callback' => 'dwsim_flowsheet_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'dwsim flowsheet manage proposal'
+ ),
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/pending'] = array(
+ 'title' => 'Pending Proposals',
+ 'description' => 'Pending dwsim flowsheet Proposals Queue',
+ 'page callback' => 'dwsim_flowsheet_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'dwsim flowsheet manage proposal'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/all'] = array(
+ 'title' => 'All Proposals',
+ 'description' => 'All Proposals',
+ 'page callback' => 'dwsim_flowsheet_proposal_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'dwsim flowsheet manage proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/approve'] = array(
+ 'title' => 'Approve Proposal',
+ 'description' => 'Approve Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_proposal_approval_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/solution-proposal-approve'] = array(
+ 'title' => 'Approve Solution Proposal',
+ 'description' => 'Approve Solution Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_solution_proposal_approval_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_solution_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/edit'] = array(
+ 'title' => 'Edit Proposal',
+ 'description' => 'Edit Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_proposal_edit_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/status'] = array(
+ 'title' => 'Proposal Status',
+ 'description' => 'Proposal Status',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_proposal_status_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet approve proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/show-proposal'] = array(
+ 'title' => 'dwsim flowsheet Solution Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_solution_proposal_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet propose solution'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'solution_proposal.inc'
+ );
+ /* CODE REVIEW */
+ $items['flowsheeting-project/code-approval'] = array(
+ 'title' => 'LM Manage Code Approval',
+ 'description' => 'Manage Code Approval',
+ 'page callback' => 'dwsim_flowsheet_code_approval',
+ 'access arguments' => array(
+ 'dwsim flowsheet approve code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'code_approval.inc'
+ );
+ $items['flowsheeting-project/code-approval/approve'] = array(
+ 'title' => 'Code Approval',
+ 'description' => 'Code Approval',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_code_approval_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet approve code'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'code_approval.inc'
+ );
+ $items['flowsheeting-project/code-approval/bulk'] = array(
+ 'title' => 'Bulk Manage',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_bulk_approval_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet bulk manage code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'bulk_approval.inc'
+ );
+ $items['flowsheeting-project/code-approval/bulk'] = array(
+ 'title' => 'Bulk Manage',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_bulk_approval_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet bulk manage code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'bulk_approval.inc'
+ );
+ /*$items['dwsim_flowsheet/code_approval/dependency'] = array(
+ 'title' => 'Dependency',
+ 'description' => 'Dependency Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('dwsim_flowsheet_dependency_approval_form'),
+ 'access arguments' => array('dwsim flowsheet bulk manage code'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 3,
+ 'file' => 'dependency_approval.inc',
+ );*/
+ $items['flowsheeting-project/code-approval/upload'] = array(
+ 'title' => 'Upload Code',
+ 'description' => 'Admin Upload',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_bulk_upload_code_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet bulk manage code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'weight' => 4,
+ 'file' => 'bulk_upload_code.inc'
+ );
+ $items['flowsheeting-project/code-approval/notes'] = array(
+ 'title' => 'Notes for Reviewers',
+ 'description' => 'Notes for Reviewers',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_lab_notes_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet bulk manage code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'weight' => 4,
+ 'file' => 'notes.inc'
+ );
+ /* CODE UPLOAD */
+ $items['flowsheeting-project/abstract-code'] = array(
+ 'title' => 'Abstract Submission',
+ 'description' => 'Abstract Submission',
+ 'page callback' => 'dwsim_flowsheet_abstract',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'dwsim flowsheet upload code'
+ ),
+ 'file' => 'upload_code.inc'
+ );
+ $items['flowsheeting-project/abstract-code/flowsheet-project-list'] = array(
+ 'title' => 'Flowsheet project',
+ 'description' => 'List Experiments',
+ 'page callback' => 'dwsim_flowsheet_abstract',
+ 'access arguments' => array(
+ 'dwsim flowsheet upload code'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 1
+ );
+ $items['flowsheeting-project/abstract-code/upload'] = array(
+ 'title' => 'Code Submission',
+ 'description' => 'Code Submission',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_upload_abstract_code_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet upload code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 2
+ );
+ /* $items['dwsim_flowsheet/code/upload_dep'] = array(
+ 'title' => 'Upload Dependency',
+ 'description' => 'Upload Dependency Files',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('dwsim_flowsheet_upload_dependency_form'),
+ 'access arguments' => array('dwsim flowsheet upload code'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'dependency.inc',
+ 'weight' => 3,
+ );*/
+ $items['flowsheeting-project/abstract-code/delete'] = array(
+ 'title' => 'Delete Solution',
+ 'description' => 'Delete Solution',
+ 'page callback' => 'dwsim_flowsheet_upload_code_delete',
+ 'access arguments' => array(
+ 'dwsim flowsheet upload code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'upload_code_delete.inc'
+ );
+ /* CODE DOWNLOADS */
+ $items['flowsheeting-project/download/file'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'dwsim_flowsheet_download_solution_file',
+ 'access arguments' => array(
+ 'dwsim flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ /*$items['dwsim_flowsheet/download/dependency'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'dwsim_flowsheet_download_dependency_file',
+ 'access arguments' => array('dwsim flowsheet download code'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc',
+ );*/
+ $items['flowsheeting-project/download/solution'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'dwsim_flowsheet_download_solution',
+ 'access arguments' => array(
+ 'dwsim flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['flowsheeting-project/download/experiment'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'dwsim_flowsheet_download_experiment',
+ 'access arguments' => array(
+ 'dwsim flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['flowsheeting-project/download/lab'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'dwsim_flowsheet_download_lab',
+ 'access arguments' => array(
+ 'dwsim flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['flowsheeting-project/full-download/experiment'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'dwsim_flowsheet_download_full_experiment',
+ 'access arguments' => array(
+ 'dwsim flowsheet approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ $items['flowsheeting-project/full-download/lab'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'dwsim_flowsheet_download_full_lab',
+ 'access arguments' => array(
+ 'dwsim flowsheet approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ /* COMPLETED dwsim flowsheetS */
+ $items['flowsheeting-project/completed-labs'] = array(
+ 'title' => 'Completed Labs',
+ 'page callback' => 'dwsim_flowsheet_completed_labs_all',
+ 'access arguments' => array(
+ 'dwsim flowsheet download code'
+ ),
+ 'file' => 'lab_details.inc'
+ );
+ /* LABS IN PROGRESS */
+ $items['flowsheeting-project/labs-progress'] = array(
+ 'title' => 'Labs in Progress',
+ 'page callback' => 'dwsim_flowsheet_labs_progress_all',
+ 'access arguments' => array(
+ 'dwsim flowsheet download code'
+ ),
+ 'file' => 'lab_details.inc'
+ );
+ /* DOWNLOAD FOR EVERYONE */
+ $items['flowsheeting-project/dwsim-flowsheet-run'] = array(
+ 'title' => 'Download Codes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_run_form'
+ ),
+ 'access arguments' => array(
+ 'dwsim flowsheet download code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'run.inc'
+ );
+ $items['flowsheeting-project/download/user-defined-compound-file'] = array(
+ 'title' => 'Download user defined compound file',
+ 'description' => 'Download user defined compound',
+ 'page callback' => 'dwsim_flowsheet_download_user_defined_compound',
+ 'access arguments' => array(
+ 'download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ /*$items['dwsim_flowsheet_run'] = array(
+ 'title' => 'Download Codes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('dwsim_flowsheet_run_form_ajax'),
+ 'access arguments' => array('access content'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'run.inc',
+ );
+ $items['dwsim_flowsheet_run_ajax'] = array(
+ 'page callback' => 'dwsim_flowsheet_run_ajax',
+ 'access callback' => TRUE,
+ 'file' => 'run.inc',
+ );
+ $items['download_codes'] = array(
+ 'title' => 'Download Codes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('dwsim_flowsheet_run_form_ajax'),
+ 'access arguments' => array('access content'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'run.inc',
+ );*/
+ /* LATEX SCRIPT */
+ $items['flowsheeting-project/generate-lab'] = array(
+ 'title' => 'Generate Lab',
+ 'description' => 'Generate Lab From Latex Script',
+ 'page callback' => 'dwsim_flowsheet_download_lab_pdf',
+ 'access arguments' => array(
+ 'dwsim flowsheet generate lab'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'latex.inc'
+ );
+ $items['flowsheeting-project/delete-lab'] = array(
+ 'title' => 'Delete Lab PDF',
+ 'description' => 'Delete Lab PDF',
+ 'page callback' => 'dwsim_flowsheet_delete_lab_pdf',
+ 'access arguments' => array(
+ 'dwsim flowsheet approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'latex.inc'
+ );
+ /* ADMIN SETTINGS */
+ $items['admin/settings/dwsim-flowsheet'] = array(
+ 'title' => 'dwsim flowsheet Settings',
+ 'description' => 'dwsim flowsheet Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'dwsim_flowsheet_settings_form'
+ ),
+ 'access arguments' => array(
+ 'administer dwsim flowsheet'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'settings.inc'
+ );
+ /* AJAX REQUEST */
+ $items["lab-bulk-manage-exp/ajax"] = array(
+ "title" => "Ajax callbacks",
+ "page callback" => "lab_bulk_manage_exp_ajax",
+ "access arguments" => array(
+ "dwsim flowsheet bulk manage code"
+ ),
+ "type" => MENU_CALLBACK,
+ 'file' => 'bulk_approval.inc'
+ );
+ /* $items["dwsim_flowsheet/code_approval/dependency/ajax"] = array(
+ "title" => "Ajax callbacks",
+ "page callback" => "dwsim_flowsheet_dependency_approval_ajax",
+ "access arguments" => array("dwsim flowsheet bulk manage code"),
+ "type" => MENU_CALLBACK,
+ 'file' => 'dependency_approval.inc',
+ );*/
+ return $items;
+}
/**
* Implementation of hook_perm().
*/
function dwsim_flowsheet_permission()
- {
- return array(
- 'dwsim flowsheet create proposal' => array(
- 'title' => t('dwsim flowsheet create proposal'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet manage proposal' => array(
- 'title' => t('dwsim flowsheet manage proposal'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet edit proposal' => array(
- 'title' => t('dwsim flowsheet edit proposal'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet approve proposal' => array(
- 'title' => t('dwsim flowsheet approve proposal'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet propose solution' => array(
- 'title' => t('dwsim flowsheet propose solution'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet approve code' => array(
- 'title' => t('dwsim flowsheet approve code'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet bulk manage code' => array(
- 'title' => t('dwsim flowsheet bulk manage code'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet bulk delete code' => array(
- 'title' => t('dwsim flowsheet bulk delete code'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet upload code' => array(
- 'title' => t('dwsim flowsheet upload code'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet download code' => array(
- 'title' => t('dwsim flowsheet download code'),
- 'restrict access' => TRUE
- ),
- 'administer dwsim flowsheet' => array(
- 'title' => t('administer dwsim flowsheet'),
- 'restrict access' => TRUE
- ),
- 'dwsim flowsheet generate lab' => array(
- 'title' => t('dwsim flowsheet generate lab'),
- 'restrict access' => TRUE
- )
- );
- // return array('dwsim flowsheet create proposal', 'dwsim flowsheet manage proposal', 'dwsim flowsheet edit proposal', 'dwsim flowsheet approve proposal', 'dwsim flowsheet propose solution', 'dwsim flowsheet approve code', 'dwsim flowsheet bulk manage code', 'dwsim flowsheet bulk delete code', 'dwsim flowsheet upload code', 'dwsim flowsheet download code', 'administer dwsim flowsheet', 'dwsim flowsheet generate lab');
- }
+{
+ return array(
+ 'dwsim flowsheet create proposal' => array(
+ 'title' => t('dwsim flowsheet create proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet manage proposal' => array(
+ 'title' => t('dwsim flowsheet manage proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet edit proposal' => array(
+ 'title' => t('dwsim flowsheet edit proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet approve proposal' => array(
+ 'title' => t('dwsim flowsheet approve proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet propose solution' => array(
+ 'title' => t('dwsim flowsheet propose solution'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet approve code' => array(
+ 'title' => t('dwsim flowsheet approve code'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet bulk manage code' => array(
+ 'title' => t('dwsim flowsheet bulk manage code'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet bulk delete code' => array(
+ 'title' => t('dwsim flowsheet bulk delete code'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet upload code' => array(
+ 'title' => t('dwsim flowsheet upload code'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet download code' => array(
+ 'title' => t('dwsim flowsheet download code'),
+ 'restrict access' => TRUE
+ ),
+ 'administer dwsim flowsheet' => array(
+ 'title' => t('administer dwsim flowsheet'),
+ 'restrict access' => TRUE
+ ),
+ 'dwsim flowsheet generate lab' => array(
+ 'title' => t('dwsim flowsheet generate lab'),
+ 'restrict access' => TRUE
+ )
+ );
+ // return array('dwsim flowsheet create proposal', 'dwsim flowsheet manage proposal', 'dwsim flowsheet edit proposal', 'dwsim flowsheet approve proposal', 'dwsim flowsheet propose solution', 'dwsim flowsheet approve code', 'dwsim flowsheet bulk manage code', 'dwsim flowsheet bulk delete code', 'dwsim flowsheet upload code', 'dwsim flowsheet download code', 'administer dwsim flowsheet', 'dwsim flowsheet generate lab');
+}
/* AJAX CALLS */
function dwsim_flowsheet_ajax()
- {
- $query_type = arg(2);
- if ($query_type == 'chapter_title')
- {
- $chapter_number = arg(3);
- $preference_id = arg(4);
- //$chapter_q = db_query("SELECT * FROM {dwsim_flowsheet_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
- $query = db_select('dwsim_flowsheet_chapter');
- $query->fields('dwsim_flowsheet_chapter');
- $query->condition('number', $chapter_number);
- $query->condition('preference_id', $preference_id);
- $query->range(0, 1);
- $chapter_q = $query->execute();
- if ($chapter_data = $chapter_q->fetchObject())
- {
- echo $chapter_data->name;
- return;
- }
- }
- else if ($query_type == 'example_exists')
- {
- $chapter_number = arg(3);
- $preference_id = arg(4);
- $example_number = arg(5);
- $chapter_id = 0;
- $query = db_select('dwsim_flowsheet_chapter');
- $query->fields('dwsim_flowsheet_chapter');
- $query->condition('number', $chapter_number);
- $query->condition('preference_id', $preference_id);
- $query->range(0, 1);
- $chapter_q = $query->execute();
- if (!$chapter_data = $chapter_q->fetchObject())
- {
- echo '';
- return;
- }
- else
- {
- $chapter_id = $chapter_data->id;
- }
- $query = db_select('dwsim_flowsheet_example');
- $query->fields('dwsim_flowsheet_example');
- $query->condition('chapter_id', $chapter_id);
- $query->condition('number', $example_number);
- $query->range(0, 1);
- $example_q = $query->execute();
- if ($example_data = $example_q->fetchObject())
- {
- if ($example_data->approval_status == 1)
- echo 'Warning! Solution already approved. You cannot upload the same solution again.';
- else
- echo 'Warning! Solution already uploaded. Delete the solution and reupload it.';
- return;
- }
- }
- echo '';
- }
+{
+ $query_type = arg(2);
+ if ($query_type == 'chapter_title')
+ {
+ $chapter_number = arg(3);
+ $preference_id = arg(4);
+ //$chapter_q = db_query("SELECT * FROM {dwsim_flowsheet_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
+ $query = db_select('dwsim_flowsheet_chapter');
+ $query->fields('dwsim_flowsheet_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if ($chapter_data = $chapter_q->fetchObject())
+ {
+ echo $chapter_data->name;
+ return;
+ } //$chapter_data = $chapter_q->fetchObject()
+ } //$query_type == 'chapter_title'
+ else if ($query_type == 'example_exists')
+ {
+ $chapter_number = arg(3);
+ $preference_id = arg(4);
+ $example_number = arg(5);
+ $chapter_id = 0;
+ $query = db_select('dwsim_flowsheet_chapter');
+ $query->fields('dwsim_flowsheet_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if (!$chapter_data = $chapter_q->fetchObject())
+ {
+ echo '';
+ return;
+ } //!$chapter_data = $chapter_q->fetchObject()
+ else
+ {
+ $chapter_id = $chapter_data->id;
+ }
+ $query = db_select('dwsim_flowsheet_example');
+ $query->fields('dwsim_flowsheet_example');
+ $query->condition('chapter_id', $chapter_id);
+ $query->condition('number', $example_number);
+ $query->range(0, 1);
+ $example_q = $query->execute();
+ if ($example_data = $example_q->fetchObject())
+ {
+ if ($example_data->approval_status == 1)
+ echo 'Warning! Solution already approved. You cannot upload the same solution again.';
+ else
+ echo 'Warning! Solution already uploaded. Delete the solution and reupload it.';
+ return;
+ } //$example_data = $example_q->fetchObject()
+ } //$query_type == 'example_exists'
+ echo '';
+}
/*************************** VALIDATION FUNCTIONS *****************************/
function dwsim_flowsheet_check_valid_filename($file_name)
- {
- if (!preg_match('/^[0-9a-zA-Z\.]+$/', $file_name))
- return FALSE;
- else if (substr_count($file_name, ".") > 1)
- return FALSE;
- else
- return TRUE;
- }
+{
+ if (!preg_match('/^[0-9a-zA-Z\.\_]+$/', $file_name))
+ return FALSE;
+ else if (substr_count($file_name, ".") > 1)
+ return FALSE;
+ else
+ return TRUE;
+}
function dwsim_flowsheet_check_name($name = '')
- {
- if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
- return FALSE;
- else
- return TRUE;
- }
+{
+ if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
+ return FALSE;
+ else
+ return TRUE;
+}
function dwsim_flowsheet_check_code_number($number = '')
- {
- if (!preg_match('/^[0-9]+$/', $number))
- return FALSE;
- else
- return TRUE;
- }
+{
+ if (!preg_match('/^[0-9]+$/', $number))
+ return FALSE;
+ else
+ return TRUE;
+}
function dwsim_flowsheet_path()
- {
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/dwsim_flowsheet_uploads/';
- }
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/dwsim_flowsheet_uploads/';
+}
/************************* USER VERIFICATION FUNCTIONS ************************/
function dwsim_flowsheet_get_proposal()
- {
- global $user;
- //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1");
- $query = db_select('dwsim_flowsheet_proposal');
- $query->fields('dwsim_flowsheet_proposal');
- $query->condition('solution_provider_uid', $user->uid);
- $query->condition('solution_status', 2);
- $query->orderBy('id', 'DESC');
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
- {
- drupal_set_message("You do not have any approved Lab migraion solution proposal. Please check the " . l('available', 'dwsim-flowsheet/open-proposal') . " dwsim flowsheet proposal.", 'error');
- drupal_goto('');
- }
- switch ($proposal_data->approval_status)
- {
- case 0:
- drupal_set_message(t('Proposal is awaiting approval.'), 'status');
- return FALSE;
- case 1:
- return $proposal_data;
- case 2:
- drupal_set_message(t('Proposal has been dis-approved.'), 'error');
- return FALSE;
- case 3:
- drupal_set_message(t('Proposal has been marked as completed.'), 'status');
- return FALSE;
- default:
- drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
- return FALSE;
- }
- return FALSE;
- }
-/***************************** GENERAL FUNCTIONS ******************************/
-function dwsim_flowsheet_get_category_name($category_id)
- {
- $category_data = '';
- switch ($category_id)
- {
- case 0:
- $category_data = 'Not Selected';
- break;
- case 1:
- $category_data = 'Fluid Mechanics';
- break;
- case 2:
- $category_data = 'Control Theory & Control Systems';
- break;
- case 3:
- $category_data = 'Chemical Engineering';
- break;
- case 4:
- $category_data = 'Thermodynamics';
- break;
- case 5:
- $category_data = 'Mechanical Engineering';
- break;
- case 6:
- $category_data = 'Signal Processing';
- break;
- case 7:
- $category_data = 'Digital Communications';
- break;
- case 8:
- $category_data = 'Electrical Technology';
- break;
- case 9:
- $category_data = 'Mathematics & Pure Science';
- break;
- case 10:
- $category_data = 'Analog Electronics';
- break;
- case 11:
- $category_data = 'Digital Electronics';
- break;
- case 12:
- $category_data = 'Computer Programming';
- break;
- case 13:
- $category_data = 'Others';
- break;
- default:
- $category_data = 'Unknown';
- break;
- }
- return $category_data;
- }
-/*function dwsim_flowsheet_init() {
-
-drupal_add_js(drupal_get_path('module', 'dwsim_flowsheet') . '/js/dwsim_flowsheet_ajax.js', array ('scope' => 'footer'));
-}*/
+{
+ global $user;
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1");
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message("You do not have any approved DWSIM Flowsheet proposal. Please check the ", 'error');
+ drupal_goto('');
+ } //!$proposal_data
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ drupal_set_message(t('Proposal is awaiting approval.'), 'status');
+ return FALSE;
+ case 1:
+ return $proposal_data;
+ case 2:
+ drupal_set_message(t('Proposal has been dis-approved.'), 'error');
+ return FALSE;
+ case 3:
+ drupal_set_message(t('Proposal has been marked as completed.'), 'status');
+ return FALSE;
+ default:
+ drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
+ return FALSE;
+ } //$proposal_data->approval_status
+ return FALSE;
+}
/*************************************************************************/
/***** Function To convert only first charater of string in uppercase ****/
/*************************************************************************/
function dwsim_flowsheet_ucname($string)
- {
- $string = ucwords(strtolower($string));
- foreach (array(
- '-',
- '\''
- ) as $delimiter)
- {
- if (strpos($string, $delimiter) !== false)
- {
- $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
- }
- }
- return $string;
- }
-
- function _df_list_of_dwsim_compound()
{
-
- $dwsim_compound = array();
- $query = db_select('dwsim_flowsheet_compounds_from_dwsim');
- $query->fields('dwsim_flowsheet_compounds_from_dwsim');
- $query->orderBy('id', 'DESC');
- $dwsim_compound_list = $query->execute();
- while ($dwsim_compound_list_data = $dwsim_compound_list->fetchObject())
- {
- $dwsim_compound[$dwsim_compound_list_data->compound] = $dwsim_compound_list_data->compound;
- }
- return $dwsim_compound;
-}
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ } //strpos($string, $delimiter) !== false
+ } //array( '-', '\'' ) as $delimiter
+ return $string;
+}
+function _df_sentence_case($string)
+{
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ } //strpos($string, $delimiter) !== false
+ } //array( '-', '\'' ) as $delimiter
+ return $string;
+}
+function _df_list_of_dwsim_compound()
+{
+ $dwsim_compound = array();
+ $query = db_select('dwsim_flowsheet_compounds_from_dwsim');
+ $query->fields('dwsim_flowsheet_compounds_from_dwsim');
+ $query->orderBy('compound', 'ASC');
+ $dwsim_compound_list = $query->execute();
+ while ($dwsim_compound_list_data = $dwsim_compound_list->fetchObject())
+ {
+ $dwsim_compound[$dwsim_compound_list_data->compound] = $dwsim_compound_list_data->compound;
+ } //$dwsim_compound_list_data = $dwsim_compound_list->fetchObject()
+ return $dwsim_compound;
+}
+function _df_list_of_unit_operations()
+{
+ $dwsim_unit_operations = array();
+ $query = db_select('dwsim_flowsheet_unit_operations');
+ $query->fields('dwsim_flowsheet_unit_operations');
+ $query->orderBy('id', 'ASC');
+ $dwsim_unit_operations_list = $query->execute();
+ while ($dwsim_unit_operations_list_data = $dwsim_unit_operations_list->fetchObject())
+ {
+ $dwsim_unit_operations[$dwsim_unit_operations_list_data->unit_operations] = $dwsim_unit_operations_list_data->unit_operations;
+ } //$dwsim_unit_operations_list_data = $dwsim_unit_operations_list->fetchObject()
+ return $dwsim_unit_operations;
+}
+function _df_list_of_thermodynamic_packages()
+{
+ $dwsim_thermodynamic_packages = array();
+ $query = db_select('dwsim_flowsheet_thermodynamic_packages');
+ $query->fields('dwsim_flowsheet_thermodynamic_packages');
+ $query->orderBy('id', 'ASC');
+ $dwsim_thermodynamic_packages_list = $query->execute();
+ while ($dwsim_thermodynamic_packages_list_data = $dwsim_thermodynamic_packages_list->fetchObject())
+ {
+ $dwsim_thermodynamic_packages[$dwsim_thermodynamic_packages_list_data->thermodynamic_packages] = $dwsim_thermodynamic_packages_list_data->thermodynamic_packages;
+ } //$dwsim_thermodynamic_packages_list_data = $dwsim_thermodynamic_packages_list->fetchObject()
+ return $dwsim_thermodynamic_packages;
+}
+function _df_list_of_logical_block()
+{
+ $dwsim_logical_block = array();
+ $query = db_select('dwsim_flowsheet_logical_block');
+ $query->fields('dwsim_flowsheet_logical_block');
+ $query->orderBy('id', 'ASC');
+ $dwsim_logical_block_list = $query->execute();
+ while ($dwsim_logical_block_list_data = $dwsim_logical_block_list->fetchObject())
+ {
+ $dwsim_logical_block[$dwsim_logical_block_list_data->logical_block] = $dwsim_logical_block_list_data->logical_block;
+ } //$dwsim_logical_block_list_data = $dwsim_logical_block_list->fetchObject()
+ return $dwsim_logical_block;
+}
+function _df_list_of_states()
+{
+ $states = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_states_of_india');
+ $query->fields('list_states_of_india');
+ //$query->orderBy('', '');
+ $states_list = $query->execute();
+ while ($states_list_data = $states_list->fetchObject())
+ {
+ $states[$states_list_data->state] = $states_list_data->state;
+ } //$states_list_data = $states_list->fetchObject()
+ return $states;
+}
+function _df_list_of_cities()
+{
+ $city = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_cities_of_india');
+ $query->fields('list_cities_of_india');
+ $query->orderBy('city', 'ASC');
+ $city_list = $query->execute();
+ while ($city_list_data = $city_list->fetchObject())
+ {
+ $city[$city_list_data->city] = $city_list_data->city;
+ } //$city_list_data = $city_list->fetchObject()
+ return $city;
+}
+function _df_list_of_departments()
+{
+ $department = array();
+ $query = db_select('list_of_departments');
+ $query->fields('list_of_departments');
+ $query->orderBy('id', 'DESC');
+ $department_list = $query->execute();
+ while ($department_list_data = $department_list->fetchObject())
+ {
+ $department[$department_list_data->department] = $department_list_data->department;
+ } //$department_list_data = $department_list->fetchObject()
+ return $department;
+}
+function _df_list_of_software_version()
+{
+ $software_version = array();
+ $query = db_select('dwsim_software_version');
+ $query->fields('dwsim_software_version');
+ $query->orderBy('dwsim_version', 'ASC');
+ $software_version_list = $query->execute();
+ while ($software_version_list_data = $software_version_list->fetchObject())
+ {
+ $software_version[$software_version_list_data->dwsim_version] = $software_version_list_data->dwsim_version;
+ } //$software_version_list_data = $software_version_list->fetchObject()
+ return $software_version;
+}
+function _df_dir_name($project)
+{
+ $project_title = ucname($project);
+ $proposar_name = ucname($student_name);
+ $university_name = ucname($university);
+ $dir_name = $project_title;
+ $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name));
+ return $directory_name;
+}
+function dwsim_flowsheet_document_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/dwsim_flowsheet_uploads/';
+}
diff --git a/email.inc b/email.inc
index a090b59..cc9d1cf 100755
--- a/email.inc
+++ b/email.inc
@@ -9,183 +9,19 @@ function dwsim_flowsheet_mail($key, &$message, $params)
//$language = user_preferred_language($user);
switch ($key)
{
- case 'solution_proposal_approved':
- /* initializing data */
- //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_approved']['proposal_id']);
- $query = db_select('dwsim_flowsheet_proposal');
- $query->fields('dwsim_flowsheet_proposal');
- $query->condition('id', $params['solution_proposal_approved']['proposal_id']);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if ($proposal_data->solution_display == 1)
- {
- $solution_display = 'Yes';
- }
- else
- {
- $solution_display = 'No';
- }
- // $experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_approved']['proposal_id'], 1);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $params['solution_proposal_approved']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
- ';
- while ($experiment_data = $experiment_q->fetchObject())
- {
- $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
- $experiment_list .= ' ';
- $experiment_list .= '</p>';
- }
- $user_data = user_load($params['solution_proposal_approved']['user_id']);
- $message['headers'] = $params['solution_proposal_approved']['headers'];
- $message['subject'] = t('[!site_name] DWSIM flowsheet Solution Proposal Approval', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 0 => t('
-Dear !user_name,
-
-Your following DWSIM flowsheet solution proposal has been approved:
-
-Full Name : ' . $proposal_data->solution_provider_name_title . ' ' . $proposal_data->solution_provider_name . '
-Email : ' . $user_data->mail . '
-Contact No. : ' . $proposal_data->solution_provider_contact_ph . '
-Department/Branch : ' . $proposal_data->solution_provider_department . '
-University/Institute : ' . $proposal_data->solution_provider_university . '
-City : ' . $proposal_data->solution_provider_city . '
-State : ' . $proposal_data->solution_provider_state . '
-
-List of experiments : ' . $experiment_list . '
-
-Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/dwsim-flowsheet/dwsim-flowsheet-guidelines
-
-Best Wishes,
-
-!site_name Team,
-FOSSEE,IIT Bombay', array(
- '!site_name' => variable_get('site_name', ''),
- '!user_name' => $user_data->name
- ), array(
- 'language' => $language->language
- ))
- );
- break;
- case 'solution_proposal_disapproved':
- $user_data = user_load($params['solution_proposal_disapproved']['user_id']);
- $proposal_id = $params['solution_proposal_disapproved']['proposal_id'];
- $query = db_select('dwsim_flowsheet_proposal');
- $query->fields('dwsim_flowsheet_proposal');
- $query->condition('id', $proposal_id);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
-
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $proposal_id);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
- ';
- while ($experiment_data = $experiment_q->fetchObject())
- {
- $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
- $experiment_list .= ' ';
- $experiment_list .= '</p>';
- }
- $message['headers'] = $params['solution_proposal_disapproved']['headers'];
- $message['subject'] = t('[!site_name] DWSIM flowsheet Solution Disapproval', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 'body' => t('
-Dear !user_name,
-
-We regret to inform you that your DWSIM flowsheet solution proposal has been disapproved.
-
-Title of Lab :' . $proposal_data->lab_title . '
-
-List of experiments : ' . $experiment_list . '
-
-Reason: ' . $params['solution_proposal_disapproved']['message'] . '
-
-You are welcome to submit a new proposal.
-
-Best Wishes,
-
-!site_name Team,
-FOSSEE,IIT Bombay', array(
- '!site_name' => variable_get('site_name', ''),
- '!user_name' => $user_data->name
- ), array(
- 'language' => $language->language
- ))
- );
- break;
- case 'proposal_received':
+
+ case 'dwsim_flowsheet_proposal_received':
/* initializing data */
// $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
// $proposal_data = $proposal_q->fetchObject();
$query = db_select('dwsim_flowsheet_proposal');
$query->fields('dwsim_flowsheet_proposal');
- $query->condition('id', $params['proposal_received']['proposal_id']);
+ $query->condition('id', $params['dwsim_flowsheet_proposal_received']['proposal_id']);
$query->range(0, 1);
$proposal_data = $query->execute()->fetchObject();
- /* $samplecodefilename = "";
- if (strlen($proposal_data->samplefilepath) >= 5)
- {
- $samplecodefilename = substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
- }
- else
- {
- $samplecodefilename = "Not provided";
- }*/
- if ($proposal_data->solution_display == 1)
- {
- $solution_display = 'Yes';
- }
- else
- {
- $solution_display = 'No';
- }
- if ($proposal_data->solution_provider_uid == 0)
- {
- $solution_provider_user = 'Open';
- }
- else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
- {
- $solution_provider_user = 'Proposer';
- }
- else
- {
- $solution_provider_user = 'Unknown';
- }
- // $experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number",
- // $params['proposal_received']['proposal_id'], 1);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $params['proposal_received']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
- ';
- while ($experiment_data = $experiment_q->fetchObject())
- {
- $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
- $experiment_list .= ' ';
- $experiment_list .= '</p>';
- }
$user_data = user_load($params['proposal_received']['user_id']);
$message['headers'] = $params['proposal_received']['headers'];
- $message['subject'] = t('[!site_name] Your DWSIM flowsheet proposal has been received', array(
+ $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Chemical Process Flowsheeting Project proposal has been received', array(
'!site_name' => variable_get('site_name', '')
), array(
'language' => $language->language
@@ -194,7 +30,7 @@ FOSSEE,IIT Bombay', array(
'body' => t('
Dear !user_name,
-We have received your DWSIM flowsheet proposal with the following details:
+We have received your DWSIM Chemical Process Flowsheeting Project with the following details:
Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
Email : ' . $user_data->mail . '
@@ -205,10 +41,6 @@ City : ' . $proposal_data->city . '
State : ' . $proposal_data->state . '
-Solution Provided By : ' . $solution_provider_user . '
-
-List of experiments : ' . $experiment_list . '
-
Your proposal is under review. You will soon receive an email when same has been approved/disapproved.
Best Wishes,
@@ -222,13 +54,13 @@ FOSSEE,IIT Bombay', array(
))
);
break;
- case 'proposal_disapproved':
+ case 'dwsim_flowsheet_proposal_disapproved':
/* initializing data */
// $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']);
//$proposal_data = $proposal_q->fetchObject();
$query = db_select('dwsim_flowsheet_proposal');
$query->fields('dwsim_flowsheet_proposal');
- $query->condition('id', $params['proposal_disapproved']['proposal_id']);
+ $query->condition('id', $params['dwsim_flowsheet_proposal_disapproved']['proposal_id']);
$query->range(0, 1);
$proposal_data = $query->execute()->fetchObject();
$samplecodefilename = "";
@@ -240,42 +72,9 @@ FOSSEE,IIT Bombay', array(
{
$samplecodefilename = "Not provided";
}
- if ($proposal_data->solution_display == 1)
- {
- $solution_display = 'Yes';
- }
- else
- {
- $solution_display = 'No';
- }
- if ($proposal_data->solution_provider_uid == 0)
- {
- $solution_provider_user = 'Open';
- }
- else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
- {
- $solution_provider_user = 'Proposer';
- }
- else
- {
- $solution_provider_user = 'Unknown';
- }
- // $experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_disapproved']['proposal_id'], 1);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $params['proposal_disapproved']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
- ';
- while ($experiment_data = $experiment_q->fetchObject())
- {
- $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
- $experiment_list .= ' ';
- $experiment_list .= '</p>';
- }
- $user_data = user_load($params['proposal_disapproved']['user_id']);
- $message['headers'] = $params['proposal_disapproved']['headers'];
+
+ $user_data = user_load($params['dwsim_flowsheet_proposal_disapproved']['user_id']);
+ $message['headers'] = $params['dwsim_flowsheet_proposal_disapproved']['headers'];
$message['subject'] = t('[!site_name] Your DWSIM flowsheet proposal has been disapproved', array(
'!site_name' => variable_get('site_name', '')
), array(
@@ -285,7 +84,7 @@ FOSSEE,IIT Bombay', array(
'body' => t('
Dear !user_name,
-We regret to inform you that all the Experiments of your Lab with following details have been dis-approved.
+We regret to inform you that DWSIM Flowsheeing Project proposal details have been dis-approved.
Reason for disapproval: ' . $proposal_data->message . '
@@ -315,7 +114,7 @@ FOSSEE,IIT Bombay', array(
))
);
break;
- case 'proposal_approved':
+ case 'dwsim_flowsheet_proposal_approved':
/* initializing data */
// $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']);
$query = db_select('dwsim_flowsheet_proposal');
@@ -324,52 +123,11 @@ FOSSEE,IIT Bombay', array(
$query->range(0, 1);
$proposal_q = $query->execute();
$proposal_data = $proposal_q->fetchObject();
- /* $samplecodefilename = "";
- if (strlen($proposal_data->samplefilepath) >= 5)
- {
- $samplecodefilename = substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
- }
- else
- {
- $samplecodefilename = "Not provided";
- }*/
- if ($proposal_data->solution_display == 1)
- {
- $solution_display = 'Yes';
- }
- else
- {
- $solution_display = 'No';
- }
- if ($proposal_data->solution_provider_uid == 0)
- {
- $solution_provider_user = 'Open';
- }
- else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
- {
- $solution_provider_user = 'Proposer';
- }
- else
- {
- $solution_provider_user = 'Unknown';
- }
- //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_approved']['proposal_id'], 1);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $params['proposal_approved']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
- ';
- while ($experiment_data = $experiment_q->fetchObject())
- {
- $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
- $experiment_list .= ' ';
- $experiment_list .= '</p>';
- }
+
+
$user_data = user_load($params['proposal_approved']['user_id']);
$message['headers'] = $params['proposal_approved']['headers'];
- $message['subject'] = t('[!site_name] Your DWSIM flowsheet proposal has been approved', array(
+ $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM flowsheet proposal has been approved', array(
'!site_name' => variable_get('site_name', '')
), array(
'language' => $language->language
@@ -378,21 +136,19 @@ FOSSEE,IIT Bombay', array(
0 => t('
Dear !user_name,
-Congratulations! Your DWSIM flowsheet proposal with the below details has been approved:
+Congratulations! Your DWSIM Flowsheet proposal with the below details has been approved:
-Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->student_name . '
Email : ' . $user_data->mail . '
-Contact No. : ' . $proposal_data->contact_ph . '
-Department/Branch : ' . $proposal_data->department . '
+Month and year of award of degree : ' . $proposal_data->month_year_of_degree . '
University/Institute : ' . $proposal_data->university . '
+Project guide name : ' . $proposal_data->project_guide_name . '
+Project guide email : ' . $proposal_data->project_guide_email_id . '
City : ' . $proposal_data->city . '
State : ' . $proposal_data->state . '
+Country : ' . $proposal_data->country . '
-Solution Provided By : ' . $solution_provider_user . '
-
-List of experiments : ' . $experiment_list . '
-
Please ensure that ALL the guidelines for coding are strictly followed:
http://dwsim.fossee.in/dwsim-flowsheet-project/dwsim-flowsheet-guidelines
@@ -407,53 +163,14 @@ FOSSEE,IIT Bombay', array(
))
);
break;
- case 'proposal_completed':
+ case 'dwsim_flowsheet_proposal_completed':
/* initializing data */
- //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['proposal_completed']['proposal_id']);
$query = db_select('dwsim_flowsheet_proposal');
$query->fields('dwsim_flowsheet_proposal');
$query->condition('id', $params['proposal_completed']['proposal_id']);
$query->range(0, 1);
$proposal_q = $query->execute();
$proposal_data = $proposal_q->fetchObject();
- if ($proposal_data->solution_display == 1)
- {
- $solution_display = 'Yes';
- }
- else
- {
- $solution_display = 'No';
- }
- if ($proposal_data->solution_provider_uid == 0)
- {
- $solution_provider_user = 'Open';
- }
- else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
- {
- $solution_provider_user = 'Proposer';
- }
- else
- {
- $user_data = user_load($proposal_data->solution_provider_uid);
- if (!$user_data)
- {
- $solution_provider_user = 'Unknown';
- }
- }
- //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_completed']['proposal_id'], 1);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $params['proposal_completed']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
- ';
- while ($experiment_data = $experiment_q->fetchObject())
- {
- $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
- $experiment_list .= ' ';
- $experiment_list .= '</p>';
- }
$user_data = user_load($params['proposal_completed']['user_id']);
$message['headers'] = $params['proposal_completed']['headers'];
$message['subject'] = t('[!site_name] Congratulations for completion of the DWSIM flowsheet', array(
@@ -486,75 +203,7 @@ http://dwsim.fossee.in/dwsim-flowsheet/dwsim-flowsheet-run/' . $proposal_data->i
Now you should be able to propose a new DWSIM flowsheet.
-Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/dwsim-flowsheet-project/dwsim-flowsheet-guidelines
-
-Best Wishes,
-
-!site_name Team,
-FOSSEE,IIT Bombay', array(
- '!site_name' => variable_get('site_name', ''),
- '!user_name' => $user_data->name
- ), array(
- 'language' => $language->language
- ))
- );
- break;
- case 'solution_proposal_received':
- /* initializing data */
- //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_received']['proposal_id']);
- $query = db_select('dwsim_flowsheet_proposal');
- $query->fields('dwsim_flowsheet_proposal');
- $query->condition('id', $params['solution_proposal_received']['proposal_id']);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if ($proposal_data->solution_display == 1)
- {
- $solution_display = 'Yes';
- }
- else
- {
- $solution_display = 'No';
- }
- //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_received']['proposal_id'], 1);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $params['solution_proposal_received']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
- ';
- while ($experiment_data = $experiment_q->fetchObject())
- {
- $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
- $experiment_list .= ' ';
- $experiment_list .= '</p>';
- }
- $user_data = user_load($params['solution_proposal_received']['user_id']);
- $message['headers'] = $params['solution_proposal_received']['headers'];
- $message['subject'] = t('[!site_name] Your DWSIM flowsheet solution proposal has been received', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 'body' => t('
-Dear !user_name,
-
-We have received your proposal for providing solution for DWSIM flowsheet with the following details:
-
-List of experiments : ' . $experiment_list . '
-
-Full Name : ' . $proposal_data->solution_provider_name_title . ' ' . $proposal_data->solution_provider_name . '
-Email : ' . $user->mail . '
-Contact No. : ' . $proposal_data->solution_provider_contact_ph . '
-Department/Branch : ' . $proposal_data->department . '
-University/Institute : ' . $proposal_data->solution_provider_university . '
-
-
-Your proposal is under review. You will soon receive an email when the same has been approved / disapproved.
-
-Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/dwsim-flowsheet-project/dwsim-flowsheet-guidelines
+Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/flowsheeting-project/coding-guidelines-flowsheeting
Best Wishes,
diff --git a/full_download.inc b/full_download.inc
new file mode 100755
index 0000000..a8e7173
--- /dev/null
+++ b/full_download.inc
@@ -0,0 +1,241 @@
+<?php
+// $Id$
+function lab_migration_download_full_experiment()
+ {
+ $experiment_id = arg(3);
+ $root_path = lab_migration_path();
+ $APPROVE_PATH = 'APPROVED/';
+ $PENDING_PATH = 'PENDING/';
+ /* get solution data */
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $experiment_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_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);
+ /* approved solutions */
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_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 * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
+ /*$query = db_select('lab_migration_solution_files');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_files_q = $query->execute();*/
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
+ //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
+ }
+ /* dependency files */
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ // $dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
+ }
+ /* unapproved solutions */
+ // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_id);
+ $query->condition('approval_status', 0);
+ $solution_q = $query->execute();
+ while ($solution_row = $solution_q->fetchObject())
+ {
+ $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
+ //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
+ /*$query = db_select('lab_migration_solution_files');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_files_q = $query->execute();*/
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
+
+ //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_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, $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
+ }
+ /* dependency files */
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ // $dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_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, $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
+ }
+ $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));
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this experiment to download", 'error');
+ drupal_goto('lab-migration/code-approval/bulk');
+ }
+ }
+function lab_migration_download_full_lab()
+ {
+ $lab_id = arg(3);
+ var_dump($lab_id);
+ //die;
+ $root_path = lab_migration_path();
+ $APPROVE_PATH = 'APPROVED/';
+ $PENDING_PATH = 'PENDING/';
+ /* get solution data */
+ //$lab_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $lab_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_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);
+ /* approved solutions */
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $lab_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $lab_id);
+ $experiment_q = $query->execute();
+ while ($experiment_row = $experiment_q->fetchObject())
+ {
+ $EXP_PATH = 'EXP' . $experiment_row->number . '/';
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_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 * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
+ /*$query = db_select('lab_migration_solution_files');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_files_q = $query->execute();*/
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
+ //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
+ }
+ /* dependency files */
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ //$dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
+ }
+ /* unapproved solutions */
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_row->id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_row->id);
+ $query->condition('approval_status', 0);
+ $solution_q = $query->execute();
+ while ($solution_row = $solution_q->fetchObject())
+ {
+ $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
+ //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
+ /* $query = db_select('lab_migration_solution_files');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_files_q = $query->execute();*/
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
+
+ //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_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, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
+ }
+ /* dependency files */
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ //$dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_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, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
+ }
+ }
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ /* download zip file */
+ ob_clean();
+ //flush();
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . $lab_data->lab_title . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this lab to download", 'error');
+ drupal_goto('lab-migration/code-approval/bulk');
+ }
+ }
diff --git a/manage_proposal.inc b/manage_proposal.inc
new file mode 100644
index 0000000..af36cf3
--- /dev/null
+++ b/manage_proposal.inc
@@ -0,0 +1,1245 @@
+<?php
+// $Id$
+function dwsim_flowsheet_proposal_pending()
+{
+ /* get pending proposals to be approved */
+ $pending_rows = array();
+ //$pending_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE approval_status = 0 ORDER BY id DESC");
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('approval_status', 0);
+ $query->orderBy('id', 'DESC');
+ $pending_q = $query->execute();
+ while ($pending_data = $pending_q->fetchObject())
+ {
+ $pending_rows[$pending_data->id] = array(
+ date('d-m-Y', $pending_data->creation_date),
+ l($pending_data->name_title . ' ' . $pending_data->student_name, 'user/' . $pending_data->uid),
+ $pending_data->project_title,
+ l('Approve', 'flowsheeting-project/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'flowsheeting-project/manage-proposal/edit/' . $pending_data->id)
+ );
+ } //$pending_data = $pending_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$pending_rows)
+ {
+ drupal_set_message(t('There are no pending proposals.'), 'status');
+ return '';
+ } //!$pending_rows
+ $pending_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the Flowsheet Project',
+ 'Action'
+ );
+ //$output = theme_table($pending_header, $pending_rows);
+ $output = theme('table', array(
+ 'header' => $pending_header,
+ 'rows' => $pending_rows
+ ));
+ return $output;
+}
+function dwsim_flowsheet_proposal_pending_solution()
+{
+ /* get pending proposals to be approved */
+ $pending_rows = array();
+ //$pending_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE approval_status = 1 ORDER BY id DESC");
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('approval_status', 1);
+ $query->orderBy('id', 'DESC');
+ $pending_q = $query->execute();
+ while ($pending_data = $pending_q->fetchObject())
+ {
+ $pending_rows[$pending_data->id] = array(
+ date('d-m-Y', $pending_data->creation_date),
+ date('d-m-Y', $pending_data->approval_date),
+ l($pending_data->name, 'user/' . $pending_data->uid),
+ $pending_data->project_title,
+ $pending_data->department,
+ l('Status', 'flowsheeting-project/manage-proposal/status/' . $pending_data->id)
+ );
+ } //$pending_data = $pending_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$pending_rows)
+ {
+ drupal_set_message(t('There are no proposals pending for solutions.'), 'status');
+ return '';
+ } //!$pending_rows
+ $pending_header = array(
+ 'Date of Submission',
+ 'Date of Approval',
+ 'Student name',
+ 'Title of the Flowsheet Project',
+ 'Department',
+ 'Action'
+ );
+ $output = theme('table', array(
+ 'header' => $pending_header,
+ 'rows' => $pending_rows
+ ));
+ return $output;
+}
+function dwsim_flowsheet_proposal_all()
+{
+ /* get pending proposals to be approved */
+ $proposal_rows = array();
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} ORDER BY id DESC");
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->orderBy('id', 'DESC');
+ $proposal_q = $query->execute();
+ while ($proposal_data = $proposal_q->fetchObject())
+ {
+ $approval_status = '';
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ $approval_status = 'Pending';
+ break;
+ case 1:
+ $approval_status = 'Approved';
+ break;
+ case 2:
+ $approval_status = 'Dis-approved';
+ break;
+ case 3:
+ $approval_status = 'Solved';
+ break;
+ default:
+ $approval_status = 'Unknown';
+ break;
+ } //$proposal_data->approval_status
+ $proposal_rows[] = array(
+ date('d-m-Y', $proposal_data->creation_date),
+ l($proposal_data->student_name, 'user/' . $proposal_data->uid),
+ $proposal_data->project_title,
+ $approval_status,
+ l('Status', 'flowsheeting-project/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'flowsheeting-project/manage-proposal/edit/' . $proposal_data->id)
+ );
+ } //$proposal_data = $proposal_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$proposal_rows)
+ {
+ drupal_set_message(t('There are no proposals.'), 'status');
+ return '';
+ } //!$proposal_rows
+ $proposal_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the Lab',
+ 'Status',
+ 'Action'
+ );
+ $output = theme('table', array(
+ 'header' => $proposal_header,
+ 'rows' => $proposal_rows
+ ));
+ return $output;
+}
+/******************************************************************************/
+/************************** PROPOSAL APPROVAL FORM ****************************/
+/******************************************************************************/
+function dwsim_flowsheet_proposal_approval_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ $form['student_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->student_name, 'user/' . $proposal_data->uid),
+ '#title' => t('Student name')
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#disabled' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute')
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country')
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State')
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City')
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code')
+ );
+ $form['version'] = array(
+ '#type' => 'item',
+ '#title' => t('DWSIM version'),
+ '#markup' => $proposal_data->version
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide'),
+ '#markup' => $proposal_data->project_guide_name
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide email'),
+ '#markup' => $proposal_data->project_guide_email_id
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Flowsheet Project')
+ );
+ $form['process_development_compound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#markup' => $proposal_data->process_development_compound_name
+ );
+ $form['dwsim_database_compound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
+ '#markup' => $proposal_data->dwsim_database_compound_name
+ );
+ if ($proposal_data->user_defined_compounds_used_in_process != "" || $proposal_data->user_defined_compounds_used_in_process != NULL)
+ {
+ $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('List of user defined compounds used in process flowsheet'),
+ '#markup' => $proposal_data->user_defined_compounds_used_in_process
+ );
+ } //$proposal_data->user_defined_compounds_used_in_process != "" || $proposal_data->user_defined_compounds_used_in_process != NULL
+ else
+ {
+ $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('List of user defined compounds used in process flowsheet'),
+ '#markup' => "Not entered"
+ );
+ }
+ if ($proposal_data->user_defined_compound_filepath != "")
+ {
+ $form['user_defined_compound_filepath'] = array(
+ '#type' => 'item',
+ '#title' => t('Uploaded the user defined compound '),
+ '#markup' => l('Download user defined compound list', 'flowsheeting-project/download/user-defined-compound-file/' . $proposal_id) . "<br><br>"
+ );
+ } //$proposal_data->user_defined_compound_filepath != ""
+ else
+ {
+ $form['user_defined_compound_filepath'] = array(
+ '#type' => 'item',
+ '#title' => t('Uploaded the user defined compound '),
+ '#markup' => "Not uploaded<br><br>"
+ );
+ }
+ $form['approval'] = array(
+ '#type' => 'radios',
+ '#title' => t('DWSIM flowsheeting proposal'),
+ '#options' => array(
+ '1' => 'Approve',
+ '2' => 'Disapprove'
+ ),
+ '#required' => TRUE
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reason for disapproval'),
+ '#attributes' => array(
+ 'placeholder' => t('Enter reason for disapproval in minimum 30 characters '),
+ 'cols' => 50,
+ 'rows' => 4
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="approval"]' => array(
+ 'value' => '2'
+ )
+ )
+ )
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal')
+ );
+ return $form;
+}
+function dwsim_flowsheet_proposal_approval_form_validate($form, &$form_state)
+{
+ if ($form_state['values']['approval'] == 2)
+ {
+ if ($form_state['values']['message'] == '')
+ {
+ form_set_error('message', t('Reason for disapproval could not be empty'));
+ } //$form_state['values']['message'] == ''
+ } //$form_state['values']['approval'] == 2
+}
+function dwsim_flowsheet_proposal_approval_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ // $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ if ($form_state['values']['approval'] == 1)
+ {
+ $query = "UPDATE {dwsim_flowsheet_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 1 WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":proposal_id" => $proposal_id
+ );
+ db_query($query, $args);
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $params['dwsim_flowsheet_proposal_approved']['proposal_id'] = $proposal_id;
+ $params['dwsim_flowsheet_proposal_approved']['user_id'] = $proposal_data->uid;
+ $params['dwsim_flowsheet_proposal_approved']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('dwsim_flowsheet', 'dwsim_flowsheet_proposal_approved', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('DWSIM flowsheeting proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 1
+ else if ($form_state['values']['approval'] == 2)
+ {
+ $query = "UPDATE {dwsim_flowsheet_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, message = :message WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":message" => $form_state['values']['message'],
+ ":proposal_id" => $proposal_id
+ );
+ $result = db_query($query, $args);
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $params['dwsim_flowsheetproposal_disapproved']['proposal_id'] = $proposal_id;
+ $params['dwsim_flowsheetproposal_disapproved']['user_id'] = $proposal_data->uid;
+ $params['dwsim_flowsheetproposal_disapproved']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('dwsim_flowsheet', 'dwsim_flowsheet_proposal_disapproved', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('DWSIM flowsheeting proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 2
+}
+/******************************************************************************/
+/*************************** PROPOSAL STATUS FORM *****************************/
+/******************************************************************************/
+function dwsim_flowsheet_proposal_status_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ $form['student_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->student_name, 'user/' . $proposal_data->uid),
+ '#title' => t('Student name')
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#disabled' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute')
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country')
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State')
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City')
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code')
+ );
+ $form['version'] = array(
+ '#type' => 'item',
+ '#title' => t('DWSIM version'),
+ '#markup' => $proposal_data->version
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide'),
+ '#markup' => $proposal_data->project_guide_name
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide email'),
+ '#markup' => $proposal_data->project_guide_email_id
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Flowsheet Project')
+ );
+ $form['process_development_compound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#markup' => $proposal_data->process_development_compound_name
+ );
+ $form['dwsim_database_compound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
+ '#markup' => $proposal_data->dwsim_database_compound_name
+ );
+ if ($proposal_data->user_defined_compounds_used_in_process != "" || $proposal_data->user_defined_compounds_used_in_process != NULL)
+ {
+ $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('List of user defined compounds used in process flowsheet'),
+ '#markup' => $proposal_data->user_defined_compounds_used_in_process
+ );
+ } //$proposal_data->user_defined_compounds_used_in_process != "" || $proposal_data->user_defined_compounds_used_in_process != NULL
+ else
+ {
+ $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('List of user defined compounds used in process flowsheet'),
+ '#markup' => "Not entered"
+ );
+ }
+ if ($proposal_data->user_defined_compound_filepath != "")
+ {
+ $form['user_defined_compound_filepath'] = array(
+ '#type' => 'item',
+ '#title' => t('Uploaded the user defined compound '),
+ '#markup' => l('Download user defined compound list', 'flowsheeting-project/download/user-defined-compound-file/' . $proposal_id) . "<br><br>"
+ );
+ } //$proposal_data->user_defined_compound_filepath != ""
+ else
+ {
+ $form['user_defined_compound_filepath'] = array(
+ '#type' => 'item',
+ '#title' => t('Uploaded the user defined compound '),
+ '#markup' => "Not uploaded<br><br>"
+ );
+ }
+ $proposal_status = '';
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ $proposal_status = t('Pending');
+ break;
+ case 1:
+ $proposal_status = t('Approved');
+ break;
+ case 2:
+ $proposal_status = t('Dis-approved');
+ break;
+ case 3:
+ $proposal_status = t('Completed');
+ break;
+ default:
+ $proposal_status = t('Unkown');
+ break;
+ } //$proposal_data->approval_status
+ $form['proposal_status'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_status,
+ '#title' => t('Proposal Status')
+ );
+ if ($proposal_data->approval_status == 0)
+ {
+ $form['approve'] = array(
+ '#type' => 'item',
+ '#markup' => l('Click here', 'flowsheeting-project/manage-proposal/approve/' . $proposal_id),
+ '#title' => t('Approve')
+ );
+ } //$proposal_data->approval_status == 0
+ if ($proposal_data->approval_status == 1)
+ {
+ $form['completed'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Completed'),
+ '#description' => t('Check if user has provided all experiment solutions.')
+ );
+ } //$proposal_data->approval_status == 1
+ if ($proposal_data->approval_status == 2)
+ {
+ $form['message'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->message,
+ '#title' => t('Reason for disapproval')
+ );
+ } //$proposal_data->approval_status == 2
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal/all')
+ );
+ return $form;
+}
+function dwsim_flowsheet_proposal_status_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ /* set the book status to completed */
+ if ($form_state['values']['completed'] == 1)
+ {
+ $up_query = "UPDATE dwsim_flowsheet_proposal SET approval_status = :approval_status , expected_completion_date = :expected_completion_date WHERE id = :proposal_id";
+ $args = array(
+ ":approval_status" => '3',
+ ":proposal_id" => $proposal_id,
+ ":expected_completion_date" => time()
+ );
+ $result = db_query($up_query, $args);
+ CreateReadmeFileLabMigration($proposal_id);
+ if (!$result)
+ {
+ drupal_set_message('Error in update status', 'error');
+ return;
+ } //!$result
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $params['proposal_completed']['proposal_id'] = $proposal_id;
+ $params['proposal_completed']['user_id'] = $proposal_data->uid;
+ $params['proposal_completed']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('dwsim_flowsheet', 'proposal_completed', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ /*$email_to = $user->mail . ', ' . variable_get('dwsim_flowsheet_emails', '');;
+ if (!drupal_mail('dwsim_flowsheet', 'proposal_completed', $email_to , language_default(), $params, variable_get('dwsim_flowsheet_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');*/
+ drupal_set_message('Congratulations! DWSIM flowsheeting proposal has been marked as completed. User has been notified of the completion.', 'status');
+ } //$form_state['values']['completed'] == 1
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+}
+/******************************************************************************/
+/**************************** PROPOSAL EDIT FORM ******************************/
+/******************************************************************************/
+function dwsim_flowsheet_proposal_edit_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ $user_data = user_load($proposal_data->uid);
+ $form['name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof',
+ 'Mr' => 'Mr',
+ 'Mrs' => 'Mrs',
+ 'Ms' => 'Ms'
+ ),
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->name_title
+ );
+ $form['student_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Proposer'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->student_name
+ );
+ $form['student_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Email'),
+ '#markup' => $user_data->mail
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#required' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->university
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#default_value' => $proposal_data->country,
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#default_value' => $proposal_data->country,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#default_value' => $proposal_data->state,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#default_value' => $proposal_data->state,
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#default_value' => $proposal_data->pincode,
+ '#attributes' => array(
+ 'placeholder' => 'Insert pincode of your city/ village....'
+ )
+ );
+ $form['project_title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of the Flowsheet Project'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->project_title
+ );
+ $form['delete_proposal'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Delete Proposal')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal')
+ );
+ return $form;
+}
+function dwsim_flowsheet_proposal_edit_form_validate($form, &$form_state)
+{
+ $proposal_id = (int) arg(3);
+ /* check before delete proposal */
+ if ($form_state['values']['delete_proposal'] == 1)
+ {
+ //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $proposal_id);
+ $experiment_q = $query->execute();
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d", $experiment_data->id);
+ $query = db_select('dwsim_flowsheet_solution');
+ $query->fields('dwsim_flowsheet_solution');
+ $query->condition('experiment_id', $experiment_data->id);
+ $solution_q = $query->execute();
+ if ($solution_q->fetchObject())
+ {
+ form_set_error('', t('Cannot delete proposal since there are solutions already uploaded. Use the "Bulk Manage" interface to delete this proposal'));
+ } //$solution_q->fetchObject()
+ } //$experiment_data = $experiment_q->fetchObject()
+ } //$form_state['values']['delete_proposal'] == 1
+ return;
+}
+function dwsim_flowsheet_proposal_edit_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ // $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ /* delete proposal */
+ if ($form_state['values']['delete_proposal'] == 1)
+ {
+ //db_query("DELETE FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_delete('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $num_deleted = $query->execute();
+ //db_query("DELETE FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $proposal_id);
+ $query = db_delete('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $proposal_id);
+ $num_deleted = $query->execute();
+ drupal_set_message(t('Proposal Delete'), 'status');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ } //$form_state['values']['delete_proposal'] == 1
+ if ($form_state['values']['open_solution'] == 1)
+ {
+ // $query = "UPDATE {dwsim_flowsheet_proposal} SET solution_provider_uid = :solution_provider_uid, solution_status = :solution_status, solution_provider_name_title = '', solution_provider_name = '', solution_provider_contact_ph = '', solution_provider_department = '', solution_provider_university = '' WHERE id = :proposal_id";
+ // $args= array(
+ // ":solution_provider_uid" => 0,
+ // ":solution_status" => 0,
+ // ":proposal_id" => $proposal_id,
+ // );
+ // $result = db_query($query, $args);
+ $result = db_update('dwsim_flowsheet_proposal')->fields(array(
+ 'solution_provider_uid' => 0,
+ 'solution_status' => 0,
+ 'solution_provider_name_title' => '',
+ 'solution_provider_name' => '',
+ 'solution_provider_contact_ph' => '',
+ 'solution_provider_department' => '',
+ 'solution_provider_university' => ''
+ ))->condition('id', $proposal_id)->execute();
+ if (!$result)
+ {
+ drupal_set_message(t('Solution already open for everyone.'), 'error');
+ return;
+ } //!$result
+ } //$form_state['values']['open_solution'] == 1
+ $solution_display = 0;
+ if ($form_state['values']['solution_display'] == 1)
+ {
+ $solution_display = 1;
+ } //$form_state['values']['solution_display'] == 1
+ else
+ {
+ $solution_display = 0;
+ }
+ /* update proposal */
+ $v = $form_state['values'];
+ //$query = "UPDATE {dwsim_flowsheet_proposal} SET name_title = :name_title, name = :name, contact_ph = :contact_ph, department = :department, university = :unversity, project_title = :project_title, solution_display = :solution_display WHERE id = :id";
+ // $args= array(
+ // ":name_title" => $v['name_title'],
+ // ":name" => $v['student_name'],
+ // "contact_ph" => $v['contact_ph'],
+ // ":department" => $v['department'],
+ // ":university" => $v['university'],
+ // ":project_title" => $v['project_title'],
+ // ":solution_display" => $solution_display,
+ // ":id" => $proposal_id,
+ // );
+ $project_title = $v['project_title'];
+ $proposar_name = $v['name_title'] . ' ' . $v['student_name'];
+ $university = $v['university'];
+ $directory_names = _df_dir_name($project_title, $proposar_name, $university);
+ if (LM_RenameDir($proposal_id, $directory_names))
+ {
+ $directory_name = $directory_names;
+ } //LM_RenameDir($proposal_id, $directory_names)
+ else
+ {
+ return;
+ }
+ $query = db_update('dwsim_flowsheet_proposal')->fields(array(
+ 'name_title' => $v['name_title'],
+ 'student_name' => $v['student_name'],
+ 'department' => $v['department'],
+ 'university' => $v['university'],
+ 'city' => $v['city'],
+ 'pincode' => $v['pincode'],
+ 'state' => $v['all_state'],
+ 'project_title' => $v['project_title'],
+ 'solution_display' => $solution_display,
+ 'directory_name' => $directory_name
+ ))->condition('id', $proposal_id);
+ $result1 = $query->execute();
+ //$result=db_query($query, $args);
+ /* updating existing experiments */
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $proposal_id);
+ $query->orderBy('id', 'ASC');
+ $experiment_q = $query->execute();
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
+ $experiment_data = $experiment_q->fetchObject();
+ if ($experiment_data)
+ {
+ $experiment_field_name = 'lab_experiment_update' . $experiment_data->id;
+ $experiment_description = 'lab_experiment_description_update' . $experiment_data->id;
+ if (strlen(trim($form_state['values'][$experiment_field_name])) >= 1)
+ {
+ $query = "UPDATE {dwsim_flowsheet_experiment} SET title = :title, description= :description WHERE id = :id";
+ $args = array(
+ ":title" => trim($form_state['values'][$experiment_field_name]),
+ ":description" => trim($form_state['values'][$experiment_description]),
+ ":id" => $experiment_data->id
+ );
+ $result2 = db_query($query, $args);
+ if (!$result2)
+ {
+ drupal_set_message(t('Could not update Title of the Experiment : ') . trim($form_state['values'][$experiment_field_name]), 'error');
+ } //!$result2
+ } //strlen(trim($form_state['values'][$experiment_field_name])) >= 1
+ else
+ {
+ $query = "DELETE FROM {dwsim_flowsheet_experiment} WHERE id = :id LIMIT 1";
+ $args = array(
+ ":id" => $experiment_data->id
+ );
+ $result3 = db_query($query, $args);
+ }
+ } //$experiment_data
+ } //$counter = 1; $counter <= 15; $counter++
+ /* foreach ($form_state['values']['lab_experiment']['update'] as $update_id => $update_value) {
+ if (strlen(trim($update_value)) >= 1) {
+ $description= $form_state['values']['lab_experiment_description']['update'];
+ $query = "UPDATE {dwsim_flowsheet_experiment} SET title = :title and description=:description WHERE id = :id";
+ $args = array(
+ ":title"=> trim($update_value),
+ ":description"=>trim($description),
+ ":id"=> $update_id,
+ );
+ $result2 = db_query($query, $args);
+ if (!$result2)
+ {
+ drupal_set_message(t('Could not update Title of the Experiment : ') . trim($update_value), 'error');
+ }
+ } else {
+ $query = "DELETE FROM {dwsim_flowsheet_experiment} WHERE id = :id LIMIT 1";
+ $args = array(
+ ":id" => $update_id
+ );
+ $result3 = db_query($query, $args);
+ }
+ }*/
+ /* inserting new experiments */
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $proposal_id);
+ $query->orderBy('number', 'DESC');
+ $query->range(0, 1);
+ $number_q = $query->execute();
+ if ($number_data = $number_q->fetchObject())
+ {
+ $number = (int) $number_data->number;
+ $number++;
+ } //$number_data = $number_q->fetchObject()
+ else
+ {
+ $number = 1;
+ }
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
+ $lab_experiment_insert = 'lab_experiment_insert' . $counter;
+ //var_dump($form_state['values'][$lab_experiment_insert]);die;
+ $lab_experiment_description_insert = 'lab_experiment_description_insert' . $counter;
+ if (!empty($form_state['values'][$lab_experiment_insert]))
+ {
+ //var_dump($form_state['values'][$lab_experiment_insert]);die;
+ $query = "INSERT INTO {dwsim_flowsheet_experiment} (proposal_id, number, title, description) VALUES (:proposal_id, :number, :title, :description)";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":number" => $number,
+ ":title" => trim($form_state['values'][$lab_experiment_insert]),
+ ":description" => trim($form_state['values'][$lab_experiment_description_insert])
+ );
+ $result4 = db_query($query, $args);
+ if (!$result4)
+ {
+ drupal_set_message(t('Could not insert Title of the Experiment : ') . trim($form_state['values'][$lab_experiment_insert]), 'error');
+ } //!$result4
+ else
+ {
+ $number++;
+ }
+ } //!empty($form_state['values'][$lab_experiment_insert])
+ } //$counter = 1; $counter <= 15; $counter++
+ /* $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $proposal_id);
+ $query->orderBy('number', 'DESC');
+ $query->range(0, 1);
+ $number_q = $query->execute();
+ if ($number_data = $number_q->fetchObject()) {
+ $number = (int)$number_data->number;
+ $number++;
+ } else {
+ $number = 1;
+ }
+ $insertvalue = array($insert_id => $insert_value);
+ $lab_experimentinsert = $form_state['values']['lab_experiment']['insert'];
+ $lab_exp_descriptioninsert=$form_state['values']['lab_experiment_description']['insert'];
+ if (is_array($lab_experimentinsert) || is_object($lab_experimentinsert))
+ {
+ foreach ($lab_experimentinsert as $insertvalue) {
+ //foreach ($form_state['values']['lab_experiment']['insert'] as $insert_id => $insert_value) {
+ if (strlen(trim($insert_value)) >= 1) {
+ $query = "INSERT INTO {dwsim_flowsheet_experiment} (proposal_id, number, title, description) VALUES :proposal_id, :number, :title, :description";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":number" => $number,
+ ":title" => trim($insert_value),
+ ":description"=>""
+ );
+ $result4 = db_query($query, $args);
+ if (!$result4)
+ {
+ drupal_set_message(t('Could not insert Title of the Experiment : ') . trim($insert_value), 'error');
+ } else {
+ $number++;
+ }
+ }
+ }
+ }*/
+ drupal_set_message(t('Proposal Updated'), 'status');
+}
+function CreateReadmeFileDWSIMFlowsheetingProject($proposal_id)
+{
+ $result = db_query("
+ SELECT * from dwsim_flowsheet_proposal WHERE id = :proposal_id", array(
+ ":proposal_id" => $proposal_id
+ ));
+ $proposal_data = $result->fetchObject();
+ $root_path = dwsim_flowsheet_path();
+ $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!");
+ $txt = "";
+ $txt .= "About the lab";
+ $txt .= "\n" . "\n";
+ $txt .= "Title Of The Flowsheet Project: " . $proposal_data->project_title . "\n";
+ $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->student_name . "\n";
+ $txt .= "University: " . $proposal_data->university . "\n";
+ $txt .= "\n" . "\n";
+ $txt .= "DWSIM Flowsheet Project By FOSSEE, IIT Bombay" . "\n";
+ fwrite($readme_file, $txt);
+ fclose($readme_file);
+ return $txt;
+}
+function DF_RenameDir($proposal_id, $dir_name)
+{
+ $proposal_id = $proposal_id;
+ $dir_name = $dir_name;
+ $query = db_query("SELECT directory_name,id FROM dwsim_flowsheet_proposal WHERE id = :proposal_id", array(
+ ':proposal_id' => $proposal_id
+ ));
+ $result = $query->fetchObject();
+ if ($result != NULL)
+ {
+ $files = scandir(dwsim_flowsheet_path());
+ $files_id_dir = dwsim_flowsheet_path() . $result->id;
+ //var_dump($files);die;
+ $file_dir = dwsim_flowsheet_path() . $result->directory_name;
+ if (is_dir($file_dir))
+ {
+ $new_directory_name = rename(dwsim_flowsheet_path() . $result->directory_name, dwsim_flowsheet_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($file_dir)
+ else if (is_dir($files_id_dir))
+ {
+ $new_directory_name = rename(dwsim_flowsheet_path() . $result->id, dwsim_flowsheet_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($files_id_dir)
+ else
+ {
+ drupal_set_message('Directory not available for rename.');
+ return;
+ }
+ } //$result != NULL
+ else
+ {
+ drupal_set_message('Project names directory not present in databse');
+ return;
+ }
+ //var_dump($files);die;
+ /* if ($files != NULL)
+ {
+ $new_directory_name = rename(dwsim_flowsheet_path() . $result->directory_name, dwsim_flowsheet_path() . $dir_name) or drupal_set_message("Unable to rename folder");
+ }
+ else
+ {
+ $new_directory_name = 'Can not rename the directory. Directory not present';
+ }*/
+ return;
+}
diff --git a/proposal.inc b/proposal.inc
index c6f4991..4d94e8b 100755
--- a/proposal.inc
+++ b/proposal.inc
@@ -21,264 +21,262 @@ dwsim_flowsheet_solution : approval_status
2 - Disapproved (delete it)
*/
function dwsim_flowsheet_proposal_form($form, &$form_state)
- {
- global $user;
- /************************ start approve book details ************************/
- if ($user->uid == 0) {
- $msg = drupal_set_message(t('It is mandatory to ' . l('login', 'user') . ' on this website to access the lab proposal form. If you are new user please create a new account first.'), 'error');
- //drupal_goto('dwsim-flowsheet-project');
- drupal_goto('user');
- return $msg;
- }
- $query = db_select('dwsim_flowsheet_proposal');
- $query->fields('dwsim_flowsheet_proposal');
- $query->condition('uid', $user->uid);
- $query->orderBy('id', 'DESC');
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if ($proposal_data)
- {
- if ($proposal_data->approval_status == 0 || $proposal_data->approval_status == 1)
- {
- drupal_set_message(t('We have already received your proposal.'), 'status');
- drupal_goto('');
- return;
- }
- }
- $form['#attributes'] = array(
- 'enctype' => "multipart/form-data"
- );
- $form['name_title'] = array(
- '#type' => 'select',
- '#title' => t('Title'),
- '#options' => array(
- 'Dr' => 'Dr',
- 'Prof' => 'Prof',
- 'Mr' => 'Mr',
- 'Mrs' => 'Mrs',
- 'Ms' => 'Ms'
- ),
- '#required' => TRUE
- );
- $form['student_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of the student'),
- '#size' => 250,
- '#attributes' => array(
- 'placeholder' => t('Enter your full name')
- ),
- '#maxlength' => 250,
- '#required' => TRUE
- );
- $form['month_year_of_degree'] = array(
- '#type' => 'date_popup',
- '#title' => t('Month and year of award of degree'),
- '#date_label_position' => '',
- '#description' => '',
- '#default_value' => '',
- '#date_format' => 'M-Y',
- '#date_increment' => 0,
- '#date_year_range' => '1960:+0',
- '#datepicker_options' => array(
- 'maxDate' => 0
- ),
- );
- $form['student_email_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Email'),
- '#size' => 30,
- '#value' => $user->mail,
- '#disabled' => TRUE
- );
- $form['project_guide_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Project guide'),
- '#size' => 250,
- '#attributes' => array(
- 'placeholder' => t('Enter full name of project guide')
- ),
- '#maxlength' => 250,
- '#required' => TRUE
- );
- $form['project_guide_email_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Project guide email'),
- '#size' => 30,
- );
- $form['university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/ Institute'),
- '#size' => 80,
- '#maxlength' => 200,
- '#required' => TRUE,
- '#attributes' => array(
- 'placeholder' => 'Insert full name of your institute/ university.... '
- )
- );
- $form['country'] = array(
- '#type' => 'select',
- '#title' => t('Country'),
- '#options' => array(
- 'India' => 'India',
- 'Others' => 'Others'
- ),
- '#required' => TRUE,
- '#tree' => TRUE,
- '#validated' => TRUE
- );
- $form['other_country'] = array(
- '#type' => 'textfield',
- '#title' => t('Other than India'),
- '#size' => 100,
- '#attributes' => array(
- 'placeholder' => t('Enter your country name')
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'Others'
- )
- )
- )
- );
- $form['other_state'] = array(
- '#type' => 'textfield',
- '#title' => t('State other than India'),
- '#size' => 100,
- '#attributes' => array(
- 'placeholder' => t('Enter your state/region name')
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'Others'
- )
- )
- )
- );
- $form['other_city'] = array(
- '#type' => 'textfield',
- '#title' => t('City other than India'),
- '#size' => 100,
- '#attributes' => array(
- 'placeholder' => t('Enter your city name')
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'Others'
- )
- )
- )
- );
- $form['all_state'] = array(
- '#type' => 'select',
- '#title' => t('State'),
- '#options' => _df_list_of_states(),
- '#validated' => TRUE,
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'India'
- )
- )
- )
- );
- $form['city'] = array(
- '#type' => 'select',
- '#title' => t('City'),
- '#options' => _df_list_of_cities(),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'India'
- )
- )
- )
- );
- $form['pincode'] = array(
- '#type' => 'textfield',
- '#title' => t('Pincode'),
- '#size' => 30,
- '#maxlength' => 6,
- '#required' => False,
- '#attributes' => array(
- 'placeholder' => 'Enter pincode....'
- )
- );
- /***************************************************************************/
- $form['hr'] = array(
- '#type' => 'item',
- '#markup' => '<hr>'
- );
-
- $form['project_title'] = array(
- '#type' => 'textarea',
- '#title' => t('Project Title'),
- '#size' => 250,
- '#description' => t('Maximum character limit is 250'),
- '#required' => TRUE
- );
- $form['version'] = array(
- '#type' => 'hidden',
-
- '#value' => 'Not available',
-
- );
- $form['version'] = array(
- '#type' => 'select',
- '#title' => t('Version'),
- '#options' => _df_list_of_software_version(),
- '#required' => TRUE
- );
- $form['older'] = array(
- '#type' => 'textfield',
- '#title' => t('Other Version'),
- '#size' => 30,
- '#maxlength' => 50,
- //'#required' => TRUE,
- '#description' => t('Specify the Older version used'),
- '#states' => array(
- 'visible' => array(
- ':input[name="version"]' => array(
- 'value' => 'olderversion'
- )
- )
- )
- );
- $form['compound_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of compound for which process development is carried out'),
- '#size' => 50,
- '#description' => t('Maximum character limit is 50'),
- '#required' => TRUE
- );
- $form['compound_name'] = array(
- '#type' => 'select',
- '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
- '#multiple' => TRUE,
- '#options' => _df_list_of_dwsim_compound(),
- '#required' => TRUE
- );
- $form['ucompound'] = array(
+{
+ global $user;
+ /************************ start approve book details ************************/
+ if ($user->uid == 0)
+ {
+ $msg = drupal_set_message(t('It is mandatory to ' . l('login', 'user') . ' on this website to access the lab proposal form. If you are new user please create a new account first.'), 'error');
+ //drupal_goto('dwsim-flowsheet-project');
+ drupal_goto('user');
+ return $msg;
+ } //$user->uid == 0
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if ($proposal_data)
+ {
+ if ($proposal_data->approval_status == 0 || $proposal_data->approval_status == 1)
+ {
+ drupal_set_message(t('We have already received your proposal.'), 'status');
+ drupal_goto('');
+ return;
+ } //$proposal_data->approval_status == 0 || $proposal_data->approval_status == 1
+ } //$proposal_data
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ $form['name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof',
+ 'Mr' => 'Mr',
+ 'Mrs' => 'Mrs',
+ 'Ms' => 'Ms'
+ ),
+ '#required' => TRUE
+ );
+ $form['student_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the student'),
+ '#size' => 250,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your full name.....')
+ ),
+ '#maxlength' => 250,
+ '#required' => TRUE
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => '',
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#required' => TRUE
+ );
+ $form['student_email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email'),
+ '#size' => 30,
+ '#value' => $user->mail,
+ '#disabled' => TRUE
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project guide'),
+ '#size' => 250,
+ '#attributes' => array(
+ 'placeholder' => t('Enter full name of project guide')
+ ),
+ '#maxlength' => 250
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project guide email'),
+ '#size' => 30
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/ Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => 'Insert full name of your institute/ university.... '
+ )
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#required' => False,
+ '#attributes' => array(
+ 'placeholder' => 'Enter pincode....'
+ )
+ );
+ /***************************************************************************/
+ $form['hr'] = array(
+ '#type' => 'item',
+ '#markup' => '<hr>'
+ );
+ $form['project_title'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Project Title'),
+ '#size' => 250,
+ '#description' => t('Maximum character limit is 250'),
+ '#required' => TRUE
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#options' => _df_list_of_software_version(),
+ '#required' => TRUE
+ );
+ $form['older'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other Version'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ //'#required' => TRUE,
+ '#description' => t('Specify the Older version used as format "DWSIM v2.0"'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="version"]' => array(
+ 'value' => 'Old version'
+ )
+ )
+ )
+ );
+ $form['process_development_compound_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#size' => 50,
+ '#description' => t('Mention the compound name with CAS No as shown below:
+Ex: Ethanol (64-17-5)'),
+ '#required' => TRUE
+ );
+ $form['dwsim_database_compound_name'] = array(
+ '#type' => 'select',
+ '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
+ '#multiple' => TRUE,
+ '#description' => t('List the compound name from DWSIM database as shown below:
+Ex: Ethylene (74-85-1)[You can select multiple options by holding ctrl + left key of mouse]'),
+ '#options' => _df_list_of_dwsim_compound(),
+ '#required' => TRUE
+ );
+ $form['ucompound'] = array(
'#type' => 'checkbox',
'#title' => t('Upload user defind compound'),
- '#options' => array("1" => "Upload user defind compound"),
+ '#options' => array(
+ "1" => "Upload user defind compound"
+ )
);
- $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
- '#type' => 'textarea',
- '#title' => t('List of user defined compounds used in process flowsheet'),
- '#states' => array(
+ $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
+ '#type' => 'textarea',
+ '#title' => t('List of user defined compounds used in process flowsheet'),
+ '#states' => array(
'visible' => array(
':input[name="ucompound"]' => array(
'checked' => True
)
)
)
- );
-
- $form['upload_u_compound'] = array(
+ );
+ $form['upload_u_compound'] = array(
'#type' => 'fieldset',
'#title' => t('Upload user defind compound'),
'#collapsible' => FALSE,
@@ -293,8 +291,7 @@ function dwsim_flowsheet_proposal_form($form, &$form_state)
);
$form['upload_u_compound']['upload_user_compound'] = array(
'#type' => 'file',
- '#title' => t('Upload user defind compound'),
- '#size' => 48,
+ '#title' => t('Upload user defined compound'),
'#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('dwsim_flowsheet_user_defind_compound_source_extensions', '') . '</span>',
'#states' => array(
'visible' => array(
@@ -304,216 +301,283 @@ function dwsim_flowsheet_proposal_form($form, &$form_state)
)
)
);
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- return $form;
- }
+ $form['termconditions'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Terms And Conditions'),
+ '#options' => array(
+ 'status' => t('<a href="/term-and-conditions" target="_blank">I agree to the Terms and Conditions</a>')
+ ),
+ '#required' => TRUE
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+}
function dwsim_flowsheet_proposal_form_validate($form, &$form_state)
- {
- if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['contact_ph']))
- {
- form_set_error('contact_ph', t('Invalid contact phone number'));
- }
- if ($form_state['values']['country'] == 'Others')
- {
- if ($form_state['values']['other_country'] == '')
- {
- form_set_error('other_country', t('Enter country name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- else
- {
- $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- if ($form_state['values']['other_state'] == '')
- {
- form_set_error('other_state', t('Enter state name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- else
- {
- $form_state['values']['all_state'] = $form_state['values']['other_state'];
- }
- if ($form_state['values']['other_city'] == '')
- {
- form_set_error('other_city', t('Enter city name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- else
- {
- $form_state['values']['city'] = $form_state['values']['other_city'];
- }
- }
- else
- {
- if ($form_state['values']['country'] == '')
- {
- form_set_error('country', t('Select country name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- if ($form_state['values']['all_state'] == '')
- {
- form_set_error('all_state', t('Select state name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- if ($form_state['values']['city'] == '')
- {
- form_set_error('city', t('Select city name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- }
- if ($form_state['values']['version'] == 'olderversion')
- {
- if ($form_state['values']['older'] == '')
- {
- form_set_error('older', t('Please provide valid version'));
- }
- }
- return;
- }
+{
+ if ($form_state['values']['term_condition'] == '1')
+ {
+ form_set_error('other_state', t('Enter state name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['term_condition'] == '1'
+ if ($form_state['values']['country'] == 'Others')
+ {
+ if ($form_state['values']['other_country'] == '')
+ {
+ form_set_error('other_country', t('Enter country name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_country'] == ''
+ else
+ {
+ $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ if ($form_state['values']['other_state'] == '')
+ {
+ form_set_error('other_state', t('Enter state name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_state'] == ''
+ else
+ {
+ $form_state['values']['all_state'] = $form_state['values']['other_state'];
+ }
+ if ($form_state['values']['other_city'] == '')
+ {
+ form_set_error('other_city', t('Enter city name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_city'] == ''
+ else
+ {
+ $form_state['values']['city'] = $form_state['values']['other_city'];
+ }
+ } //$form_state['values']['country'] == 'Others'
+ else
+ {
+ if ($form_state['values']['country'] == '')
+ {
+ form_set_error('country', t('Select country name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['country'] == ''
+ if ($form_state['values']['all_state'] == '')
+ {
+ form_set_error('all_state', t('Select state name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['all_state'] == ''
+ if ($form_state['values']['city'] == '')
+ {
+ form_set_error('city', t('Select city name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['city'] == ''
+ }
+ if ($form_state['values']['version'] == 'Old version')
+ {
+ if ($form_state['values']['older'] == '')
+ {
+ form_set_error('older', t('Please provide valid version'));
+ } //$form_state['values']['older'] == ''
+ } //$form_state['values']['version'] == 'Old version'
+ if ($form_state['values']['dwsim_database_compound_name'])
+ {
+ $dwsim_database_compound_name = implode(", ", $_POST['dwsim_database_compound_name']);
+ $form_state['values']['dwsim_database_compound_name'] = $dwsim_database_compound_name;
+ } //$form_state['values']['dwsim_database_compound_name']
+ if (isset($_FILES['files']))
+ {
+ /* check if atleast one source or result file is uploaded */
+ if (!($_FILES['files']['name']['upload_user_compound']))
+ form_set_error('upload_user_compound', t('Please upload sample code main or source file.'));
+ /* check for valid filename extensions */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ if (strstr($file_form_name, 'user_compound'))
+ $file_type = 'S';
+ else
+ $file_type = 'U';
+ $allowed_extensions_str = '';
+ switch ($file_type)
+ {
+ case 'S':
+ $allowed_extensions_str = variable_get('dwsim_flowsheet_user_defind_compound_source_extensions', '');
+ break;
+ } //$file_type
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($fnames);
+ if (!in_array($temp_extension, $allowed_extensions))
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
+ if ($_FILES['files']['size'][$file_form_name] <= 0)
+ form_set_error($file_form_name, t('File size cannot be zero.'));
+ /* check if valid file name */
+ if (!textbook_companion_check_valid_filename($_FILES['files']['name'][$file_form_name]))
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ } //isset($_FILES['files'])
+ return;
+}
function dwsim_flowsheet_proposal_form_submit($form, &$form_state)
- {
- global $user;
- if (!$user->uid)
- {
- drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- return;
- }
-
- if ($form_state['values']['version'] == 'olderversion')
- {
- $form_state['values']['version'] = $form_state['values']['older'];
- }
- /* inserting the user proposal */
- $v = $form_state["values"];
- $lab_title = $v['lab_title'];
- $proposar_name = $v['name_title']. ' ' . $v['name'];
- $university = $v['university'];
- $directory_name = _df_dir_name($lab_title, $proposar_name, $university);
- $result = "INSERT INTO {dwsim_flowsheet_proposal}
- (uid, approver_uid, name_title, name, contact_ph, department, university, city, pincode, state, country, version, lab_title, approval_status, solution_status, solution_provider_uid, solution_display, creation_date, approval_date, solution_date, solution_provider_name_title, solution_provider_name, solution_provider_contact_ph, solution_provider_department, solution_provider_university, directory_name) VALUES
- (:uid, :approver_uid, :name_title, :name, :contact_ph, :department, :university, :city, :pincode, :state, :country,
- :version, :lab_title, :approval_status, :solution_status, :solution_provider_uid, :solution_display, :creation_date,
- :approval_date, :solution_date, :solution_provider_name_title, :solution_provider_name,
- :solution_provider_contact_ph, :solution_provider_department, :solution_provider_university, :directory_name)";
- $args = array(
- ":uid" => $user->uid,
- ":approver_uid" => 0,
- ":name_title" => $v['name_title'],
- ":name" => $v['name'],
- ":contact_ph" => $v['contact_ph'],
- ":department" => $v['department'],
- ":university" => $v['university'],
- ":city" => $v['city'],
- ":pincode" => $v['pincode'],
- ":state" => $v['all_state'],
- ":country" => $v['country'],
- ":version" => $form_state['values']['version'],
- ":lab_title" => $v['lab_title'],
- ":approval_status" => 0,
- ":solution_status" => $solution_status,
- ":solution_provider_uid" => $solution_provider_uid,
- ":solution_display" => $solution_display,
- ":creation_date" => time(),
- ":approval_date" => 0,
- ":solution_date" => 0,
- ":solution_provider_name_title" => $solution_provider_name_title,
- ":solution_provider_name" => $solution_provider_name,
- ":solution_provider_contact_ph" => $solution_provider_contact_ph,
- ":solution_provider_department" => $solution_provider_department,
- ":solution_provider_university" => $solution_provider_university,
- ":directory_name" => $directory_name
- );
- $proposal_id = db_query($result, $args, array(
- 'return' => Database::RETURN_INSERT_ID
- ));
- if (!$proposal_id)
- {
- drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
- return;
- }
-
- /* sending email */
- $email_to = $user->mail;
- $from = variable_get('dwsim_flowsheet_from_email', '');
- $bcc = variable_get('dwsim_flowsheet_emails', '');
- $cc = variable_get('dwsim_flowsheet_cc_emails', '');
- $param['proposal_received']['proposal_id'] = $proposal_id;
- $param['proposal_received']['user_id'] = $user->uid;
- $param['proposal_received']['headers'] = array(
- 'From' => $from,
- 'MIME-Version' => '1.0',
- 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
- 'Content-Transfer-Encoding' => '8Bit',
- 'X-Mailer' => 'Drupal',
- 'Cc' => $cc,
- 'Bcc' => $bcc
- );
- if (!drupal_mail('dwsim_flowsheet', 'proposal_received', $email_to, user_preferred_language($user), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- drupal_set_message(t('We have received you Lab migration proposal. We will get back to you soon.'), 'status');
- drupal_goto('');
- }
-function _df_list_of_states()
- {
- $states = array(0 => '-Select-');
- $query = db_select('list_states_of_india');
- $query->fields('list_states_of_india');
- //$query->orderBy('', '');
- $states_list = $query->execute();
- while ($states_list_data = $states_list->fetchObject())
- {
- $states[$states_list_data->state] = $states_list_data->state;
- }
- return $states;
- }
-function _df_list_of_cities()
- {
- $city = array(0 => '-Select-');
- $query = db_select('list_cities_of_india');
- $query->fields('list_cities_of_india');
- $query->orderBy('city', 'ASC');
- $city_list = $query->execute();
- while ($city_list_data = $city_list->fetchObject())
- {
- $city[$city_list_data->city] = $city_list_data->city;
- }
- return $city;
- }
-function _df_list_of_departments()
- {
- $department = array();
- $query = db_select('list_of_departments');
- $query->fields('list_of_departments');
- $query->orderBy('id', 'DESC');
- $department_list = $query->execute();
- while ($department_list_data = $department_list->fetchObject())
- {
- $department[$department_list_data->department] = $department_list_data->department;
- }
- return $department;
- }
-function _df_list_of_software_version()
- {
- $software_version = array();
- $query = db_select('dwsim_software_version');
- $query->fields('dwsim_software_version');
- $query->orderBy('id', 'DESC');
- $software_version_list = $query->execute();
- while ($software_version_list_data = $software_version_list->fetchObject())
- {
- $software_version[$software_version_list_data->dwsim_version] = $software_version_list_data->dwsim_version;
- }
- return $software_version;
- }
-function _df_dir_name($lab, $name, $university)
- {
- $lab_title = ucname($lab);
- $proposar_name = ucname($lab);
- $university_name = ucname($university);
- $dir_name = $lab_title . " " . "by". " " . $proposar_name . ' ' . $university_name;
- $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name));
- return $directory_name;
- }
+{
+ global $user;
+ if (!$user->uid)
+ {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ return;
+ } //!$user->uid
+ if ($form_state['values']['version'] == 'Old version')
+ {
+ $form_state['values']['version'] = $form_state['values']['older'];
+ } //$form_state['values']['version'] == 'Old version'
+ /* inserting the user proposal */
+ $v = $form_state["values"];
+ $project_title = $v['project_title'];
+ $proposar_name = $v['name_title'] . ' ' . $v['student_name'];
+ $university = $v['university'];
+ $month_year_of_degree = $v['month_year_of_degree'];
+ $directory_name = _df_dir_name($project_title);
+ $result = "INSERT INTO {dwsim_flowsheet_proposal}
+ (
+ uid,
+ approver_uid,
+ name_title,
+ student_name,
+ month_year_of_degree,
+ university,
+ city,
+ pincode,
+ state,
+ country,
+ version,
+ project_guide_name,
+ project_guide_email_id,
+ project_title,
+ process_development_compound_name,
+ dwsim_database_compound_name,
+ user_defined_compounds_used_in_process,
+ approval_status,
+ dissapproval_reason,
+ creation_date,
+ approval_date,
+ directory_name,
+ user_defined_compound_filepath
+ ) VALUES
+ (
+ :uid,
+ :approver_uid,
+ :name_title,
+ :student_name,
+ :month_year_of_degree,
+ :university,
+ :city,
+ :pincode,
+ :state,
+ :country,
+ :version,
+ :project_guide_name,
+ :project_guide_email_id,
+ :project_title,
+ :process_development_compound_name,
+ :dwsim_database_compound_name,
+ :user_defined_compounds_used_in_process,
+ :approval_status,
+ :dissapproval_reason,
+ :creation_date,
+ :approval_date,
+ :directory_name,
+ :user_defined_compound_filepath
+ )";
+ $args = array(
+ ":uid" => $user->uid,
+ ":approver_uid" => 0,
+ ":name_title" => $v['name_title'],
+ ":student_name" => _df_sentence_case($v['student_name']),
+ ":month_year_of_degree" => $month_year_of_degree,
+ ":university" => _df_sentence_case($v['university']),
+ ":city" => $v['city'],
+ ":pincode" => $v['pincode'],
+ ":state" => $v['all_state'],
+ ":country" => $v['country'],
+ ":version" => $v['version'],
+ ":project_guide_name" => _df_sentence_case($v['project_guide_name']),
+ ":project_guide_email_id" => $v['project_guide_email_id'],
+ ":project_title" => _df_dir_name($v['project_title']),
+ ":process_development_compound_name" => _df_sentence_case($v['process_development_compound_name']),
+ ":dwsim_database_compound_name" => $v['dwsim_database_compound_name'],
+ ":user_defined_compounds_used_in_process" => _df_sentence_case($v['user_defined_compounds_used_in_process_flowsheetcompound_name']),
+ ":approval_status" => 0,
+ ":dissapproval_reason" => "NULL",
+ ":creation_date" => time(),
+ ":approval_date" => 0,
+ ":directory_name" => $directory_name,
+ ":user_defined_compound_filepath" => "NULL"
+ );
+ //var_dump($args);die;
+ $proposal_id = db_query($result, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ $root_path = dwsim_flowsheet_document_path();
+ $dest_path1 = $directory_name . '/';
+ $dest_path = $dest_path1 . 'user_defined_compound/';
+ $db_path = 'user_defined_compound/';
+ if (!is_dir($root_path . $dest_path1))
+ mkdir($root_path . $dest_path1);
+ if (!is_dir($root_path . $dest_path))
+ mkdir($root_path . $dest_path);
+ /* uploading files */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ $file_type = 'S';
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ // drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name'][$file_form_name])), 'error');
+ unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ /* uploading file */
+ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ $query = "UPDATE {dwsim_flowsheet_proposal} SET user_defined_compound_filepath = :user_defined_compound_filepath WHERE id = :id";
+ $args = array(
+ ":user_defined_compound_filepath" => $dest_path . $_FILES['files']['name'][$file_form_name],
+ ":id" => $proposal_id
+ );
+ $updateresult = db_query($query, $args);
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ else
+ {
+ drupal_set_message('Error uploading file : ' . $db_path . '/' . $file_name, 'error');
+ }
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ if (!$proposal_id)
+ {
+ drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
+ return;
+ } //!$proposal_id
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $params['dwsim_flowsheet_proposal_received']['proposal_id'] = $proposal_id;
+ $params['dwsim_flowsheet_proposal_received']['user_id'] = $user->uid;
+ $params['dwsim_flowsheet_proposal_received']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('dwsim_flowsheet', 'dwsim_flowsheet_proposal_received', $email_to, user_preferred_language($user), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message(t('We have received you DWSIM Chemical Process Flowsheeting proposal. We will get back to you soon.'), 'status');
+ drupal_goto('');
+}
diff --git a/settings.inc b/settings.inc
index 1d96460..c7dff42 100755
--- a/settings.inc
+++ b/settings.inc
@@ -1,98 +1,98 @@
<?php
// $Id$
function dwsim_flowsheet_settings_form($form, $form_state)
- {
- $form['emails'] = array(
- '#type' => 'textfield',
- '#title' => t('(Bcc) Notification emails'),
- '#description' => t('Specify emails id for Bcc option of mail system with comma separated'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_emails', '')
- );
- $form['cc_emails'] = array(
- '#type' => 'textfield',
- '#title' => t('(Cc) Notification emails'),
- '#description' => t('Specify emails id for Cc option of mail system with comma separated'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_cc_emails', '')
- );
- $form['from_email'] = array(
- '#type' => 'textfield',
- '#title' => t('Outgoing from email address'),
- '#description' => t('Email address to be display in the from field of all outgoing messages'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_from_email', '')
- );
- $form['extensions']['user_defind_compound_source'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed source file extensions for user defind compound'),
- '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_user_defind_compound_source_extensions', '')
- );
- $form['extensions']['dependency'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed dependency file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of dependency file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_dependency_extensions', '')
- );
- $form['extensions']['result'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed result file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of result file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_result_extensions', '')
- );
- $form['extensions']['xcos'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed xcos file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of xcos file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_xcos_extensions', '')
- );
- $form['extensions']['pdf'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed pdf file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('dwsim_flowsheet_pdf_extensions', '')
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- return $form;
- }
+{
+ $form['emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('(Bcc) Notification emails'),
+ '#description' => t('Specify emails id for Bcc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_emails', '')
+ );
+ $form['cc_emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('(Cc) Notification emails'),
+ '#description' => t('Specify emails id for Cc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_cc_emails', '')
+ );
+ $form['from_email'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Outgoing from email address'),
+ '#description' => t('Email address to be display in the from field of all outgoing messages'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_from_email', '')
+ );
+ $form['extensions']['user_defind_compound_source'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed source file extensions for user defind compound'),
+ '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_user_defind_compound_source_extensions', '')
+ );
+ $form['extensions']['dependency'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed dependency file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of dependency file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_dependency_extensions', '')
+ );
+ $form['extensions']['result'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed result file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of result file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_result_extensions', '')
+ );
+ $form['extensions']['abstract_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed abstract file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_abstract_upload_extensions', '')
+ );
+ $form['extensions']['flowsheet_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed DWSIM flowsheet for the developed process'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('dwsim_flowsheet_flowsheet_developed_process_source_extensions', '')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+}
function dwsim_flowsheet_settings_form_validate($form, &$form_state)
- {
- return;
- }
+{
+ return;
+}
function dwsim_flowsheet_settings_form_submit($form, &$form_state)
- {
- variable_set('dwsim_flowsheet_emails', $form_state['values']['emails']);
- variable_set('dwsim_flowsheet_cc_emails', $form_state['values']['cc_emails']);
- variable_set('dwsim_flowsheet_from_email', $form_state['values']['from_email']);
- variable_set('dwsim_flowsheet_user_defind_compound_source_extensions', $form_state['values']['user_defind_compound_source']);
- variable_set('dwsim_flowsheet_dependency_extensions', $form_state['values']['dependency']);
- variable_set('dwsim_flowsheet_result_extensions', $form_state['values']['result']);
- variable_set('dwsim_flowsheet_xcos_extensions', $form_state['values']['xcos']);
- variable_set('dwsim_flowsheet_pdf_extensions', $form_state['values']['pdf']);
- drupal_set_message(t('Settings updated'), 'status');
- }
+{
+ variable_set('dwsim_flowsheet_emails', $form_state['values']['emails']);
+ variable_set('dwsim_flowsheet_cc_emails', $form_state['values']['cc_emails']);
+ variable_set('dwsim_flowsheet_from_email', $form_state['values']['from_email']);
+ variable_set('dwsim_flowsheet_user_defind_compound_source_extensions', $form_state['values']['user_defind_compound_source']);
+ variable_set('dwsim_flowsheet_dependency_extensions', $form_state['values']['dependency']);
+ variable_set('dwsim_flowsheet_result_extensions', $form_state['values']['result']);
+ variable_set('dwsim_flowsheet_abstract_upload_extensions', $form_state['values']['abstract_upload']);
+ variable_set('dwsim_flowsheet_flowsheet_developed_process_source_extensions', $form_state['values']['flowsheet_upload']);
+ drupal_set_message(t('Settings updated'), 'status');
+}
diff --git a/upload_code.inc b/upload_code.inc
new file mode 100755
index 0000000..2b53a89
--- /dev/null
+++ b/upload_code.inc
@@ -0,0 +1,317 @@
+<?php
+// $Id$
+function dwsim_flowsheet_abstract()
+{
+ global $user;
+ $proposal_data = dwsim_flowsheet_get_proposal();
+ if (!$proposal_data)
+ {
+ drupal_goto('');
+ return;
+ } //!$proposal_data
+ $return_html = '<strong>Title of the Flowsheet Project:</strong><br />' . $proposal_data->project_title . '<br /><br />';
+ $return_html .= '<strong>Proposer Name:</strong><br />' . $proposal_data->name_title . ' ' . $proposal_data->student_name . '<br /><br />';
+ $return_html .= l('Upload abstract', 'flowsheeting-project/abstract-code/upload') . '<br />';
+ /* get experiment list */
+ $experiment_rows = array();
+ //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number ASC", $proposal_data->id);
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $proposal_data->id);
+ $query->orderBy('number', 'ASC');
+ $experiment_q = $query->execute();
+ $experiment_header = array(
+ 'No. Uploaded File',
+ 'Type',
+ 'Status',
+ 'Actions'
+ );
+ // $return_html .= theme_table($experiment_header, $experiment_rows);
+ $return_html .= theme('table', array(
+ 'header' => $experiment_header,
+ 'rows' => $experiment_rows
+ ));
+ return $return_html;
+}
+function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
+{
+ global $user;
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ /* get current proposal */
+ //$proposal_id = (int) arg(3);
+ $uid = $user->uid;
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('uid', $uid);
+ $query->condition('approval_status', '1');
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/abstract-code');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/abstract-code');
+ return;
+ }
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Flowsheet Project')
+ );
+ $form['version'] = array(
+ '#type' => 'item',
+ '#title' => t('DWSIM version'),
+ '#markup' => $proposal_data->version
+ );
+ $form['unit_operations_used_in_dwsim'] = array(
+ '#type' => 'select',
+ '#title' => t('Unit Operations used in DWSIM'),
+ '#options' => _df_list_of_unit_operations(),
+ '#required' => TRUE,
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ $form['thermodynamic_packages_used'] = array(
+ '#type' => 'select',
+ '#title' => t('Thermodynamic Packages Used'),
+ '#options' => _df_list_of_thermodynamic_packages(),
+ '#required' => TRUE,
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ $form['logical_blocks_used'] = array(
+ '#type' => 'select',
+ '#title' => t('Logical Blocks used (If any)'),
+ '#options' => _df_list_of_logical_block(),
+ '#required' => TRUE,
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ $form['process_development_compound_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#size' => 50,
+ '#description' => t('Mention the compound name with CAS No as shown below:
+Ex: Ethanol (64-17-5)')
+ );
+ $form['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'] = array(
+ '#type' => 'select',
+ '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
+ '#options' => _df_list_of_dwsim_compound(),
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
+ '#type' => 'textarea',
+ '#title' => t('List of user defined compounds used in process flowsheet'),
+ '#required' => FALSE,
+ '#description' => 'List all user defined compounds with CAS No. as in format - Ex: Ethylene (74-85-1)'
+ );
+ $form['upload_an_abstract'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload an abstract (brief outline) of the project.'),
+ '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('dwsim_flowsheet_abstract_upload_extensions', '') . '</span>'
+ );
+ $form['upload_flowsheet_developed_process'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload the DWSIM flowsheet for the developed process.'),
+ '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('dwsim_flowsheet_flowsheet_developed_process_source_extensions', '') . '</span>'
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal')
+ );
+ return $form;
+}
+function dwsim_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
+{
+ if ($form_state['values']['unit_operations_used_in_dwsim'])
+ {
+ $unit_operations_used_in_dwsim = implode(", ", $_POST['unit_operations_used_in_dwsim']);
+ $form_state['values']['unit_operations_used_in_dwsim'] = $unit_operations_used_in_dwsim;
+ } //$form_state['values']['unit_operations_used_in_dwsim']
+ if ($form_state['values']['thermodynamic_packages_used'])
+ {
+ $thermodynamic_packages_used = implode(", ", $_POST['thermodynamic_packages_used']);
+ $form_state['values']['thermodynamic_packages_used'] = $thermodynamic_packages_used;
+ } //$form_state['values']['thermodynamic_packages_used']
+ if ($form_state['values']['logical_blocks_used'])
+ {
+ $logical_blocks_used = implode(", ", $_POST['logical_blocks_used']);
+ $form_state['values']['logical_blocks_used'] = $logical_blocks_used;
+ } //$form_state['values']['logical_blocks_used']
+ if ($form_state['values']['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'])
+ {
+ $list_of_compounds_from_dwsim_database_used_in_process_flowsheet = implode(", ", $_POST['list_of_compounds_from_dwsim_database_used_in_process_flowsheet']);
+ $form_state['values']['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'] = $list_of_compounds_from_dwsim_database_used_in_process_flowsheet;
+ } //$form_state['values']['list_of_compounds_from_dwsim_database_used_in_process_flowsheet']
+ if (isset($_FILES['files']))
+ {
+ /* check if file is uploaded */
+ if (!($_FILES['files']['name']['upload_flowsheet_developed_process']))
+ form_set_error('upload_flowsheet_developed_process', t('Please upload the file.'));
+ if (!($_FILES['files']['name']['upload_an_abstract']))
+ form_set_error('upload_an_abstract', t('Please upload the file.'));
+ /* check for valid filename extensions */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ if (strstr($file_form_name, 'upload_flowsheet_developed_process'))
+ $file_type = 'S';
+ else if (strstr($file_form_name, 'upload_an_abstract'))
+ $file_type = 'A';
+ else
+ $file_type = 'U';
+ $allowed_extensions_str = '';
+ switch ($file_type)
+ {
+ case 'S':
+ $allowed_extensions_str = variable_get('dwsim_flowsheet_flowsheet_developed_process_source_extensions', '');
+ break;
+ case 'A':
+ $allowed_extensions_str = variable_get('dwsim_flowsheet_abstract_upload_extensions', '');
+ break;
+ } //$file_type
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $tmp_ext = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($tmp_ext);
+ if (!in_array($temp_extension, $allowed_extensions))
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
+ if ($_FILES['files']['size'][$file_form_name] <= 0)
+ form_set_error($file_form_name, t('File size cannot be zero.'));
+ /* check if valid file name */
+ if (!dwsim_flowsheet_check_valid_filename($_FILES['files']['name'][$file_form_name]))
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ } //isset($_FILES['files'])
+ // drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
+ // drupal_static_reset('drupal_add_js') ;
+}
+function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
+{
+ global $user;
+ $v = $form_state['values'];
+ $root_path = dwsim_flowsheet_path();
+ $proposal_data = dwsim_flowsheet_get_proposal();
+ $proposal_id = $proposal_data->id;
+ if (!$proposal_data)
+ {
+ drupal_goto('');
+ return;
+ } //!$proposal_data
+ $proposal_id = $proposal_data->id;
+ $proposal_drectory = $proposal_data->directory_name;
+ /* create proposal folder if not present */
+ $dest_path = $proposal_drectory . '/';
+ if (!is_dir($root_path . $dest_path))
+ mkdir($root_path . $dest_path);
+ /* creating solution database entry */
+ $query = "INSERT INTO {dwsim_flowsheet_submitted_abstracts} (proposal_id, approver_uid, abstract_approval_status, unit_operations_used_in_dwsim, thermodynamic_packages_used, logical_blocks_used, process_development_compound_name, list_of_compounds_from_dwsim_database_used_in_process_flowsheet, user_defined_compounds_used_in_process_flowsheet, abstract_upload_date, abstract_approval_date) VALUES (:proposal_id, :approver_uid, :abstract_approval_status, :unit_operations_used_in_dwsim,
+ :thermodynamic_packages_used, :logical_blocks_used, :process_development_compound_name,
+ :list_of_compounds_from_dwsim_database_used_in_process_flowsheet,
+ :user_defined_compounds_used_in_process_flowsheet, :abstract_upload_date, :abstract_approval_date)";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":approver_uid" => 0,
+ ":abstract_approval_status" => 0,
+ ":unit_operations_used_in_dwsim" => $v['unit_operations_used_in_dwsim'],
+ ":thermodynamic_packages_used" => $v['thermodynamic_packages_used'],
+ ":logical_blocks_used" => $v['logical_blocks_used'],
+ ":process_development_compound_name" => $v['process_development_compound_name'],
+ ":list_of_compounds_from_dwsim_database_used_in_process_flowsheet" => $v['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'],
+ ":user_defined_compounds_used_in_process_flowsheet" => $v['user_defined_compounds_used_in_process_flowsheetcompound_name'],
+ ":abstract_upload_date" => time(),
+ ":abstract_approval_date" => 0
+ );
+ $submitted_abstract_id = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ /* uploading files */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ if (strstr($file_form_name, 'source'))
+ $file_type = 'S';
+ else if (strstr($file_form_name, 'result'))
+ $file_type = 'R';
+ else if (strstr($file_form_name, 'xcos'))
+ $file_type = 'X';
+ else
+ $file_type = 'U';
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ drupal_set_message(t("Error uploading file. File !filename already exists.", array(
+ '!filename' => $_FILES['files']['name'][$file_form_name]
+ )), 'error');
+ return;
+ } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ /* uploading file */
+ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ /* for uploaded files making an entry in the database */
+ $query = "INSERT INTO {dwsim_flowsheet_submitted_abstracts_file} (submitted_abstract_id, proposal_id,approvar_uid, filename, filepath, filemime, filesize, filetype, timestamp)
+ VALUES (:submitted_abstract_id, :proposal_id,:approvar_uid, :filename, :filepath, :filemime, :filesize, :filetype, :timestamp)";
+ $args = array(
+ ":submitted_abstract_id" => $submitted_abstract_id,
+ ":proposal_id" => $proposal_id,
+ ":approvar_uid" => 0,
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $file_path . $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":filetype" => $file_type,
+ ":timestamp" => time()
+ );
+ db_query($query, $args);
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ else
+ {
+ drupal_set_message('Error uploading file : ' . $dest_path . $file_name, 'error');
+ }
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ drupal_set_message('Solution uploaded successfully.', 'status');
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $params['solution_uploaded']['solution_id'] = $solution_id;
+ $params['solution_uploaded']['user_id'] = $user->uid;
+ $params['solution_uploaded']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('dwsim_flowsheet', 'solution_uploaded', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_goto('flowsheeting-project/abstract-code');
+}
diff --git a/upload_code_delete.inc b/upload_code_delete.inc
new file mode 100755
index 0000000..0c63e5f
--- /dev/null
+++ b/upload_code_delete.inc
@@ -0,0 +1,95 @@
+<?php
+
+/******************************************************************************/
+/***************************** DELETE CODE ************************************/
+/******************************************************************************/
+
+function lab_migration_upload_code_delete()
+{
+ global $user;
+
+ $root_path = lab_migration_path();
+ $solution_id = (int)arg(3);
+
+ /* check solution */
+ // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $solution_id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('id', $solution_id);
+ $query->range(0, 1);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ if (!$solution_data)
+ {
+ drupal_set_message('Invalid solution.', 'error');
+ drupal_goto('lab-migration/code');
+ return;
+ }
+ if ($solution_data->approval_status != 0)
+ {
+ drupal_set_message('You cannnot delete a solution after it has been approved. Please contact site administrator if you want to delete this solution.', 'error');
+ drupal_goto('lab-migration/code');
+ return;
+ }
+
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d LIMIT 1", $solution_data->experiment_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $query->range(0, 1);
+ $experiment_q = $query->execute();
+
+ $experiment_data = $experiment_q->fetchObject();
+ if (!$experiment_data)
+ {
+ drupal_set_message('You do not have permission to delete this solution.', 'error');
+ drupal_goto('lab-migration/code');
+ return;
+ }
+
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d AND solution_provider_uid = %d LIMIT 1", $experiment_data->proposal_id, $user->uid);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $experiment_data->proposal_id);
+ $query->condition('solution_provider_uid', $user->uid);
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message('You do not have permission to delete this solution.', 'error');
+ drupal_goto('lab-migration/code');
+ return;
+ }
+
+ /* deleting solution files */
+ if (lab_migration_delete_solution($solution_data->id))
+ {
+ drupal_set_message('Solution deleted.', 'status');
+
+ /* sending email */
+ $email_to = $user->mail;
+
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc= variable_get('lab_migration_emails', '');
+ $cc=variable_get('lab_migration_cc_emails', '');
+
+ $param['solution_deleted_user']['lab_title'] = $proposal_data->lab_title;
+ $param['solution_deleted_user']['experiment_title'] = $experiment_data->title;
+ $param['solution_deleted_user']['solution_number'] = $solution_data->code_number;
+ $param['solution_deleted_user']['solution_caption'] = $solution_data->caption;
+ $param['solution_deleted_user']['user_id'] = $user->uid;
+ $param['solution_deleted_user']['headers']=array('From'=>$from,'MIME-Version'=> '1.0',
+ 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc);
+
+ if (!drupal_mail('lab_migration', 'solution_deleted_user', $email_to, language_default(), $param , $from , TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ } else {
+ drupal_set_message('Error deleting example.', 'status');
+ }
+
+ drupal_goto('lab-migration/code');
+ return;
+}