From d182e0f590139cfa7b9160cbf8a1289f102bec73 Mon Sep 17 00:00:00 2001
From: prashantsinalkar
Date: Wed, 8 Feb 2017 13:12:09 +0530
Subject: added skeleton for module
---
dwsim_flowsheet.info | 7 +
dwsim_flowsheet.module | 776 +++++++++++++++++++++++++++++++++++++++++++++++++
email.inc | 758 +++++++++++++++++++++++++++++++++++++++++++++++
general_deletion.inc | 301 +++++++++++++++++++
proposal.inc | 519 +++++++++++++++++++++++++++++++++
settings.inc | 98 +++++++
6 files changed, 2459 insertions(+)
create mode 100755 dwsim_flowsheet.info
create mode 100755 dwsim_flowsheet.module
create mode 100755 email.inc
create mode 100755 general_deletion.inc
create mode 100755 proposal.inc
create mode 100755 settings.inc
diff --git a/dwsim_flowsheet.info b/dwsim_flowsheet.info
new file mode 100755
index 0000000..564e188
--- /dev/null
+++ b/dwsim_flowsheet.info
@@ -0,0 +1,7 @@
+name = "DWSIM Flowsheet"
+description = "DWSIM Project, FOSSEE, IIT Bombay"
+package = FOSSEE
+version = "7.x"
+core = "7.x"
+
+;scripts[] = js/jquery-1.4.1.min.js
diff --git a/dwsim_flowsheet.module b/dwsim_flowsheet.module
new file mode 100755
index 0000000..9e135ab
--- /dev/null
+++ b/dwsim_flowsheet.module
@@ -0,0 +1,776 @@
+ '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;
+ }
+/**
+ * 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');
+ }
+/* 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 '';
+ }
+/*************************** 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;
+ }
+function dwsim_flowsheet_check_name($name = '')
+ {
+ 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;
+ }
+function dwsim_flowsheet_path()
+ {
+ 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'));
+}*/
+/*************************************************************************/
+/***** 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;
+}
diff --git a/email.inc b/email.inc
new file mode 100755
index 0000000..a090b59
--- /dev/null
+++ b/email.inc
@@ -0,0 +1,758 @@
+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 .= '
' . $experiment_data->number . ') ' . $experiment_data->title . '
Description : ' . $experiment_data->description . '
';
+ $experiment_list .= ' ';
+ $experiment_list .= '
';
+ }
+ $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 .= '' . $experiment_data->number . ') ' . $experiment_data->title . '
Description : ' . $experiment_data->description . '
';
+ $experiment_list .= ' ';
+ $experiment_list .= '
';
+ }
+ $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':
+ /* 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->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 .= '' . $experiment_data->number . ') ' . $experiment_data->title . '
Description : ' . $experiment_data->description . '
';
+ $experiment_list .= ' ';
+ $experiment_list .= '
';
+ }
+ $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(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+We have received your DWSIM flowsheet proposal with the following details:
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
+Email : ' . $user_data->mail . '
+Contact No. : ' . $proposal_data->contact_ph . '
+Department/Branch : ' . $proposal_data->department . '
+University/Institute : ' . $proposal_data->university . '
+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,
+
+!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_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->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_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 .= '' . $experiment_data->number . ') ' . $experiment_data->title . '
Description : ' . $experiment_data->description . '
';
+ $experiment_list .= ' ';
+ $experiment_list .= '
';
+ }
+ $user_data = user_load($params['proposal_disapproved']['user_id']);
+ $message['headers'] = $params['proposal_disapproved']['headers'];
+ $message['subject'] = t('[!site_name] Your DWSIM flowsheet proposal has been disapproved', 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 all the Experiments of your Lab with following details have been dis-approved.
+
+Reason for disapproval: ' . $proposal_data->message . '
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
+Email : ' . $user_data->mail . '
+Contact No. : ' . $proposal_data->contact_ph . '
+Department/Branch : ' . $proposal_data->department . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
+
+Solution Provided By : ' . $solution_provider_user . '
+
+List of experiments : ' . $experiment_list . '
+
+Uploaded Sample Code : ' . $samplecodefilename . '
+
+
+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_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');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $params['proposal_approved']['proposal_id']);
+ $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 .= '' . $experiment_data->number . ') ' . $experiment_data->title . '
Description : ' . $experiment_data->description . '
';
+ $experiment_list .= ' ';
+ $experiment_list .= '
';
+ }
+ $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(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 0 => t('
+Dear !user_name,
+
+Congratulations! Your DWSIM flowsheet proposal with the below details has been approved:
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
+Email : ' . $user_data->mail . '
+Contact No. : ' . $proposal_data->contact_ph . '
+Department/Branch : ' . $proposal_data->department . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
+
+
+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
+
+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_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 .= '' . $experiment_data->number . ') ' . $experiment_data->title . '
Description : ' . $experiment_data->description . '
';
+ $experiment_list .= ' ';
+ $experiment_list .= '
';
+ }
+ $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(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Following DWSIM flowsheet has been completed sucessfully :
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
+Email : ' . $user_data->mail . '
+Contact No. : ' . $proposal_data->contact_ph . '
+Department/Branch : ' . $proposal_data->department . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
+
+
+Solution Provided By : ' . $solution_provider_user . '
+
+List of experiments : ' . $experiment_list . '
+
+Your Lab solution is now available at following link to download.
+
+http://dwsim.fossee.in/dwsim-flowsheet/dwsim-flowsheet-run/' . $proposal_data->id . '
+
+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 .= '' . $experiment_data->number . ') ' . $experiment_data->title . '
Description : ' . $experiment_data->description . '
';
+ $experiment_list .= ' ';
+ $experiment_list .= '
';
+ }
+ $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
+
+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_uploaded':
+ // $solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE id = %d LIMIT 1", $params['solution_uploaded']['solution_id']);
+ $query = db_select('dwsim_flowsheet_solution');
+ $query->fields('dwsim_flowsheet_solution');
+ $query->condition('id', $params['solution_uploaded']['solution_id']);
+ $query->range(0, 1);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $query->range(0, 1);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ $user_data = user_load($params['solution_uploaded']['user_id']);
+ $message['subject'] = t('[!site_name] You have uploaded DWSIM flowsheet solution', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['headers'] = $params['solution_uploaded']['headers'];
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+You have uploaded the following solution:
+
+Experiment Title : ' . $experiment_data->title . '
+
+Solution number : ' . $solution_data->code_number . '
+Caption : ' . $solution_data->caption . '
+
+The solution is under review. You will be notified when it has been approved.
+
+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_approved':
+ //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE id = %d LIMIT 1", $params['solution_approved']['solution_id']);
+ $query = db_select('dwsim_flowsheet_solution');
+ $query->fields('dwsim_flowsheet_solution');
+ $query->condition('id', $params['solution_approved']['solution_id']);
+ $query->range(0, 1);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $query->range(0, 1);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ $user_data = user_load($params['solution_approved']['user_id']);
+ $message['headers'] = $params['solution_approved']['headers'];
+ $message['subject'] = t('[!site_name] Your uploaded DWSIM flowsheet solution has been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your following solution has been approved:
+
+Experiment Title : ' . $experiment_data->title . '
+
+Solution number : ' . $solution_data->code_number . '
+Caption : ' . $solution_data->caption . '
+
+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_disapproved':
+ $user_data = user_load($params['solution_disapproved']['user_id']);
+ $message['headers'] = $params['solution_disapproved']['headers'];
+ $message['subject'] = t('[!site_name] Your uploaded DWSIM flowsheet solution has been disapproved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your following solution has been disapproved:
+
+Solution number : ' . $params['solution_disapproved']['solution_number'] . '
+Caption : ' . $params['solution_disapproved']['solution_caption'] . '
+
+Reason for dis-approval : ' . $params['solution_disapproved']['message'] . '
+
+
+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_deleted_user':
+ $user_data = user_load($params['solution_deleted_user']['user_id']);
+ $message['headers'] = $params['solution_deleted_user']['headers'];
+ $message['subject'] = t('[!site_name] User has deleted pending DWSIM flowsheet solution', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your following pending solution has been deleted :
+
+Title of the Lab : ' . $params['solution_deleted_user']['lab_title'] . '
+Title of the Experiment : ' . $params['solution_deleted_user']['experiment_title'] . '
+
+Solution number : ' . $params['solution_deleted_user']['solution_number'] . '
+Caption : ' . $params['solution_deleted_user']['solution_caption'] . '
+
+
+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 'dependency_uploaded':
+ $user_data = user_load($params['dependency_uploaded']['user_id']);
+ $dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']);
+ $message['headers'] = $params['dependency_uploaded']['headers'];
+ $message['subject'] = t('[!site_name] You have uploaded dependency file', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+You have uploaded following dependency files :
+ ' . $dependency_files . '
+
+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 'standard':
+ $message['subject'] = $params['standard']['subject'];
+ $message['body'] = $params['standard']['body'];
+ $message['headers'] = $params['standard']['headers'];
+ break;
+ }
+ }
diff --git a/general_deletion.inc b/general_deletion.inc
new file mode 100755
index 0000000..6999595
--- /dev/null
+++ b/general_deletion.inc
@@ -0,0 +1,301 @@
+fields('dwsim_flowsheet_solution');
+ $query->condition('id', $solution_id);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ if (!$solution_data)
+ {
+ drupal_set_message(t('Invalid solution.'), 'error');
+ return FALSE;
+ }
+ //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $solution_data->experiment_id);
+ $experiment_q = db_query("SELECT lme.*, lmp.id, lmp.directory_name FROM dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lmp.id = lme.proposal_id AND lme.id = :experiment_id",array(':experiment_id' => $solution_data->experiment_id));
+ $experiment_data = $experiment_q->fetchObject();
+ if (!$experiment_data)
+ {
+ drupal_set_message(t('Invalid experiment.'), 'error');
+ return FALSE;
+ }
+ /* deleting solution files */
+ //$solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_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_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();*/
+ while ($solution_files_data = $solution_files_q->fetchObject())
+ {
+ if (!file_exists($root_path .$solution_files_data->directory_name. '/'. $solution_files_data->filepath))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file. File does not exists.', array(
+ '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath
+ )), 'error');
+ continue;
+ }
+ /* removing solution file */
+ if (!unlink($root_path . $solution_files_data->directory_name. '/'. $solution_files_data->filepath))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file', array(
+ '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath
+ )), 'error');
+ /* sending email to admins */
+ $email_to = variable_get('dwsim_flowsheet_emails', '');
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = "";
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $param['standard']['subject'] = "[ERROR] Error deleting example file";
+ $param['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
+ solution id : " . $solution_id . "
+ file id : " . $solution_files_data->id . "
+ file path : " . $solution_files_data->directory_name. '/'. $solution_files_data->filepath . "
+ PDF path : " . $PdfStatus;
+ $param['standard']['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', 'standard', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ else
+ {
+ /* deleting example files database entries */
+ db_delete('dwsim_flowsheet_solution_files')->condition('id', $solution_files_data->id)->execute();
+ }
+ }
+ if (!$status)
+ return FALSE;
+ /* removing code folder */
+ $ex_path = $experiment_data->directory_name . '/EXP' . $experiment_data->number . '/CODE' . $solution_data->code_number;
+ $dir_path = $root_path . $ex_path;
+ if (is_dir($dir_path))
+ {
+ if (!rmdir($dir_path))
+ {
+ drupal_set_message(t('Error deleting folder !folder', array(
+ '!folder' => $dir_path
+ )), 'error');
+ /* sending email to admins */
+ $email_to = variable_get('dwsim_flowsheet_emails', '');
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = "";
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $param['standard']['subject'] = "[ERROR] Error deleting folder";
+ $param['standard']['body'] = "Error deleting folder " . $dir_path . " by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $param['standard']['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', 'standard', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ return FALSE;
+ }
+ }
+ else
+ {
+ drupal_set_message(t('Cannot delete solution folder. !folder does not exists.', array(
+ '!folder' => $dir_path
+ )), 'error');
+ return FALSE;
+ }
+ /* deleting solution dependency and solution database entries */
+ db_delete('dwsim_flowsheet_solution_dependency')->condition('solution_id', $solution_id)->execute();
+ db_delete('dwsim_flowsheet_solution')->condition('id', $solution_id)->execute();
+ return $status;
+ }
+function dwsim_flowsheet_delete_experiment($experiment_id)
+ {
+ $status = TRUE;
+ $root_path = dwsim_flowsheet_path();
+ //$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();
+ if (!$experiment_data)
+ {
+ drupal_set_message('Invalid experiment.', 'error');
+ return FALSE;
+ }
+ /* deleting solutions */
+ //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d", $experiment_id);
+ $query = db_select('dwsim_flowsheet_solution');
+ $query->fields('dwsim_flowsheet_solution');
+ $query->condition('experiment_id', $experiment_id);
+ $solution_q = $query->execute();
+ $delete_exp_folder = FALSE;
+ while ($solution_data = $solution_q->fetchObject())
+ {
+ $delete_exp_folder = TRUE;
+ if (!dwsim_flowsheet_delete_solution($solution_data->id))
+ $status = FALSE;
+ }
+ if (!$delete_exp_folder)
+ {
+ return TRUE;
+ }
+ if ($status)
+ {
+ $dir_path = $root_path . $experiment_data->directory_name . '/EXP' . $experiment_data->number;
+ if (is_dir($dir_path))
+ {
+ $res = rmdir($dir_path);
+ if (!$res)
+ {
+ drupal_set_message(t('Error deleting experiment folder !folder', array(
+ '!folder' => $dir_path
+ )), 'error');
+ /* sending email to admins */
+ $email_to = variable_get('dwsim_flowsheet_emails', '');
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = "";
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $param['standard']['subject'] = "[ERROR] Error deleting experiment folder";
+ $param['standard']['body'] = "Error deleting folder " . $dir_path;
+ $param['standard']['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', 'standard', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+ else
+ {
+ drupal_set_message(t('Cannot delete experiment folder. !folder does not exists.', array(
+ '!folder' => $dir_path
+ )), 'error');
+ return FALSE;
+ }
+ }
+ return FALSE;
+ }
+function dwsim_flowsheet_delete_lab($lab_id)
+ {
+ $status = TRUE;
+ $root_path = dwsim_flowsheet_path();
+ //$proposal_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);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message('Invalid Lab.', 'error');
+ return FALSE;
+ }
+ /* delete experiments */
+ //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $proposal_data->id);
+ $query = db_select('dwsim_flowsheet_experiment');
+ $query->fields('dwsim_flowsheet_experiment');
+ $query->condition('proposal_id', $proposal_data->id);
+ $experiment_q = $query->execute();
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ if (!dwsim_flowsheet_delete_experiment($experiment_data->id))
+ {
+ $status = FALSE;
+ }
+ }
+ return $status;
+ }
+function dwsim_flowsheet_del_lab_pdf($lab_id)
+ {
+ $root_path = dwsim_flowsheet_path();
+ $dir_path = $root_path . "latex/";
+ $pdf_filename = "lab_" . $lab_id . ".pdf";
+ if (file_exists($dir_path . $pdf_filename))
+ unlink($dir_path . $pdf_filename);
+ }
+function dwsim_flowsheet_delete_dependency($dependency_id)
+ {
+ global $user;
+ $root_path = dwsim_flowsheet_path();
+ $status = TRUE;
+ //$dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d", $dependency_id);
+ $query = db_select('dwsim_flowsheet_dependency_files');
+ $query->fields('dwsim_flowsheet_dependency_files');
+ $query->condition('id', $dependency_id);
+ $dependency_files_q = $query->execute();
+ $dependency_files_data = $dependency_files_q->fetchObject();
+ if (!$dependency_files_data)
+ {
+ drupal_set_message(t('Invalid dependency.'), 'error');
+ return FALSE;
+ }
+ if (!file_exists($root_path . $dependency_files_data->filepath))
+ {
+ drupal_set_message(t('Error deleting !file. File does not exists.', array(
+ '!file' => $dependency_files_data->filepath
+ )), 'error');
+ return FALSE;
+ }
+ /* removing dependency file */
+ if (!unlink($root_path . $dependency_files_data->filepath))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file', array(
+ '!file' => $dependency_files_data->filepath
+ )), 'error');
+ /* sending email to admins */
+ $email_to = variable_get('dwsim_flowsheet_emails', '');
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = "";
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $param['standard']['subject'] = "[ERROR] Error deleting dependency file";
+ $param['standard']['body'] = "Error deleting dependency files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
+ dependency id : " . $dependency_id . "
+ file id : " . $dependency_files_data->id . "
+ file path : " . $dependency_files_data->filepath;
+ $param['standard']['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', 'standard', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ else
+ {
+ /* deleting dependency files database entries */
+ db_delete('dwsim_flowsheet_dependency_files')->condition('id', $dependency_id)->execute();
+ }
+ return $status;
+ }
diff --git a/proposal.inc b/proposal.inc
new file mode 100755
index 0000000..c6f4991
--- /dev/null
+++ b/proposal.inc
@@ -0,0 +1,519 @@
+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' => '
'
+ );
+
+ $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(
+ '#type' => 'checkbox',
+ '#title' => t('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(
+ 'visible' => array(
+ ':input[name="ucompound"]' => array(
+ 'checked' => True
+ )
+ )
+ )
+ );
+
+ $form['upload_u_compound'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Upload user defind compound'),
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="ucompound"]' => array(
+ 'checked' => True
+ )
+ )
+ )
+ );
+ $form['upload_u_compound']['upload_user_compound'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload user defind compound'),
+ '#size' => 48,
+ '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '
' . t('Allowed file extensions : ') . variable_get('dwsim_flowsheet_user_defind_compound_source_extensions', '') . '',
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="ucompound"]' => array(
+ 'checked' => 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;
+ }
+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;
+ }
diff --git a/settings.inc b/settings.inc
new file mode 100755
index 0000000..1d96460
--- /dev/null
+++ b/settings.inc
@@ -0,0 +1,98 @@
+ '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;
+ }
+function dwsim_flowsheet_settings_form_validate($form, &$form_state)
+ {
+ 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');
+ }
--
cgit