summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSashi202019-05-06 15:54:06 +0530
committerSashi202019-05-06 15:54:06 +0530
commitd72c96889df292a9911876d68abe51a19df5a33b (patch)
tree5b4bc7f642e72758dd39f9a7535155e1093654d3
parentb34eaf592792891d893ac06803b93c0d42b667b5 (diff)
downloadom_flowsheet-d72c96889df292a9911876d68abe51a19df5a33b.tar.gz
om_flowsheet-d72c96889df292a9911876d68abe51a19df5a33b.tar.bz2
om_flowsheet-d72c96889df292a9911876d68abe51a19df5a33b.zip
Add a new field to upload simulator package
-rwxr-xr-xabstract_bulk_approval.inc23
-rwxr-xr-xgeneral_deletion.inc7
-rwxr-xr-xpdf/list_flowsheet_certificate.inc2
-rwxr-xr-xsettings.inc10
-rwxr-xr-xupload_code.inc118
5 files changed, 154 insertions, 6 deletions
diff --git a/abstract_bulk_approval.inc b/abstract_bulk_approval.inc
index 85b0722..1cdb66b 100755
--- a/abstract_bulk_approval.inc
+++ b/abstract_bulk_approval.inc
@@ -395,6 +395,26 @@ function _flowsheet_details($flowsheet_proposal_id)
{
$abstract_filename = "File not uploaded";
}
+ $query_sp = db_select('om_flowsheet_submitted_abstracts_file');
+ $query_sp->fields('om_flowsheet_submitted_abstracts_file');
+ $query_sp->condition('proposal_id', $flowsheet_proposal_id);
+ $query_sp->condition('filetype', 'P');
+ $abstracts_sp = $query_sp->execute()->fetchObject();
+ if ($abstracts_sp == TRUE)
+ {
+ if ($abstracts_sp->filename != "NULL" || $abstracts_sp->filename != "")
+ {
+ $sp_filename = $abstracts_sp->filename;
+ } //$abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != ""
+ else
+ {
+ $sp_filename = "File not uploaded";
+ }
+ } //$abstracts_pdf == TRUE
+ else
+ {
+ $sp_filename = "File not uploaded";
+ }
$query_process = db_select('om_flowsheet_submitted_abstracts_file');
$query_process->fields('om_flowsheet_submitted_abstracts_file');
$query_process->condition('proposal_id', $flowsheet_proposal_id);
@@ -446,7 +466,7 @@ function _flowsheet_details($flowsheet_proposal_id)
$url = l('Upload abstract', 'flowsheeting-project/abstract-code/upload');
$unit_operations_used_in_om = "Not entered";
$thermodynamic_packages_used = "Not entered";
-
+ //$sp_filename = "File not uploaded";
$abstracts_query_process_filename = "File not uploaded";
}
$headers = array(
@@ -472,6 +492,7 @@ function _flowsheet_details($flowsheet_proposal_id)
$return_html .= '<strong>Name of compound for which process development is carried out:</strong><br />' . $prodata;
$return_html .= '<strong>Uploaded an abstract (brief outline) of the project:</strong><br />' . $abstract_filename . '<br /><br />';
$return_html .= '<strong>Upload the OpenModelica flowsheet for the developed process:</strong><br />' . $abstracts_query_process_filename . '<br /><br />';
+ $return_html .= '<strong>Upload the OpenModelica flowsheet for the simulator package:</strong><br />' . $sp_filename . '<br /><br />';
$return_html .= $download_flowsheet;
return $return_html;
}
diff --git a/general_deletion.inc b/general_deletion.inc
index 5912345..5982156 100755
--- a/general_deletion.inc
+++ b/general_deletion.inc
@@ -26,8 +26,9 @@ WHERE dfsa.id = :abstract_id", array(
while ($abstract_f_data = $abstract_f_q->fetchObject())
{
unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath);
-
+ db_delete('om_flowsheet_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute();
}
+
return True;
}
@@ -64,8 +65,8 @@ function om_flowsheet_abstract_delete_project($proposal_id)
{
$res_main = rmdir($dir_main_path);
} //is_dir($dir_main_path)
- db_delete('om_flowsheet_proposal')->condition('id', $proposal_data->id)->execute();
+
db_delete('om_flowsheet_submitted_abstracts')->condition('proposal_id', $proposal_data->id)->execute();
- db_delete('om_flowsheet_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute();
+ db_delete('om_flowsheet_proposal')->condition('id', $proposal_data->id)->execute();
return $status;
} \ No newline at end of file
diff --git a/pdf/list_flowsheet_certificate.inc b/pdf/list_flowsheet_certificate.inc
index dba066f..571cf1f 100755
--- a/pdf/list_flowsheet_certificate.inc
+++ b/pdf/list_flowsheet_certificate.inc
@@ -9,7 +9,7 @@ function _list_flowsheet_certificates()
//var_dump($exist_id->id);die;
if ($exist_id){
if ($exist_id->id) {
- if ($exist_id->id < 2) {
+ if ($exist_id->id < 1) {
drupal_set_message('<strong>You need to propose a <a href="https://om.fossee.in/flowsheeting-project/proposal">OpenModelica Flowsheeting Proposal</a></strong> or if you have already proposed then your Flowsheet is under reviewing process', 'status');
return '';
} //$exist_id->id < 3
diff --git a/settings.inc b/settings.inc
index cda4bc2..5f310da 100755
--- a/settings.inc
+++ b/settings.inc
@@ -47,6 +47,15 @@ function om_flowsheet_settings_form($form, $form_state)
'#required' => TRUE,
'#default_value' => variable_get('om_flowsheet_flowsheet_developed_process_source_extensions', '')
);
+ $form['extensions']['simulator_package_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed om flowsheet for the simulator package'),
+ '#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('om_flowsheet_simulator_package_extensions', '')
+ );
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
@@ -64,5 +73,6 @@ function om_flowsheet_settings_form_submit($form, &$form_state)
variable_set('om_flowsheet_from_email', $form_state['values']['from_email']);
variable_set('om_flowsheet_abstract_upload_extensions', $form_state['values']['abstract_upload']);
variable_set('om_flowsheet_flowsheet_developed_process_source_extensions', $form_state['values']['flowsheet_upload']);
+ variable_set('om_flowsheet_simulator_package_extensions', $form_state['values']['simulator_package_upload']);
drupal_set_message(t('Settings updated'), 'status');
}
diff --git a/upload_code.inc b/upload_code.inc
index bc8f9e9..a58be67 100755
--- a/upload_code.inc
+++ b/upload_code.inc
@@ -49,6 +49,26 @@ function om_flowsheet_abstract()
{
$abstract_filename = "File not uploaded";
}
+ $query_sp = db_select('om_flowsheet_submitted_abstracts_file');
+ $query_sp->fields('om_flowsheet_submitted_abstracts_file');
+ $query_sp->condition('proposal_id', $proposal_data->id);
+ $query_sp->condition('filetype', 'P');
+ $abstracts_sp = $query_sp->execute()->fetchObject();
+ if ($abstracts_sp == TRUE)
+ {
+ if ($abstracts_sp->filename != "NULL" || $abstracts_sp->filename != "")
+ {
+ $sp_filename = $abstracts_sp->filename;
+ } //$abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != ""
+ else
+ {
+ $sp_filename = "File not uploaded";
+ }
+ } //$abstracts_pdf == TRUE
+ else
+ {
+ $sp_filename = "File not uploaded";
+ }
$query_process = db_select('om_flowsheet_submitted_abstracts_file');
$query_process->fields('om_flowsheet_submitted_abstracts_file');
$query_process->condition('proposal_id', $proposal_data->id);
@@ -100,6 +120,7 @@ function om_flowsheet_abstract()
$unit_operations_used_in_om = "Not entered";
$thermodynamic_packages_used = "Not entered";
$abstracts_query_process_filename = "File not uploaded";
+ $sp_filename = "File not uploaded";
}
$headers = array(
"Name of compound for which process development is carried out",
@@ -124,6 +145,7 @@ function om_flowsheet_abstract()
$return_html .= '<strong>Name of compound for which process development is carried out:</strong><br />' . $prodata . '<br />';
$return_html .= '<strong>Uploaded an abstract (brief outline) of the project:</strong><br />' . $abstract_filename . '<br /><br />';
$return_html .= '<strong>Upload the om flowsheet for the developed process:</strong><br />' . $abstracts_query_process_filename . '<br /><br />';
+ $return_html .= '<strong>Upload the om flowsheet for the Simulator package:</strong><br />' . $sp_filename . '<br /><br />';
$return_html .= $url . '<br />';
return $return_html;
}
@@ -285,6 +307,17 @@ function om_flowsheet_upload_abstract_code_form($form, &$form_state)
'#title' => t('Upload the OpenModelica flowsheet for the developed process.'),
'#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_S_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('om_flowsheet_flowsheet_developed_process_source_extensions', '') . '</span>'
);
+ $existing_uploaded_P_file = default_value_for_uploaded_files("P", $proposal_data->id);
+ if (!$existing_uploaded_P_file)
+ {
+ $existing_uploaded_P_file = new stdClass();
+ $existing_uploaded_P_file->filename = "No file uploaded";
+ } //!$existing_uploaded_S_file
+ $form['upload_simulator_package'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload the Simulator package used to simulate the flowsheet'),
+ '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_P_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('om_flowsheet_simulator_package_extensions', '') . '</span>'
+ );
$form['prop_id'] = array(
'#type' => 'hidden',
'#value' => $proposal_data->id
@@ -335,6 +368,7 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
/* check if file is uploaded */
$existing_uploaded_A_file = default_value_for_uploaded_files("A", $form_state['values']['prop_id']);
$existing_uploaded_S_file = default_value_for_uploaded_files("S", $form_state['values']['prop_id']);
+ $existing_uploaded_P_file = default_value_for_uploaded_files("P", $form_state['values']['prop_id']);
if (!$existing_uploaded_S_file)
{
if (!($_FILES['files']['name']['upload_flowsheet_developed_process']))
@@ -345,8 +379,13 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
if (!($_FILES['files']['name']['upload_an_abstract']))
form_set_error('upload_an_abstract', t('Please upload the file.'));
} //!$existing_uploaded_A_file
+ if (!$existing_uploaded_P_file)
+ {
+ if (!($_FILES['files']['name']['upload_simulator_package']))
+ form_set_error('upload_simulator_package', t('Please upload the file.'));
+ }
/* check for valid filename extensions */
- if ($_FILES['files']['name']['upload_an_abstract'] || $_FILES['files']['name']['upload_flowsheet_developed_process'])
+ if ($_FILES['files']['name']['upload_an_abstract'] || $_FILES['files']['name']['upload_flowsheet_developed_process'] || $_FILES['files']['name']['upload_simulator_package'])
{
foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
{
@@ -357,6 +396,8 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
$file_type = 'S';
else if (strstr($file_form_name, 'upload_an_abstract'))
$file_type = 'A';
+ else if (strstr($file_form_name, 'upload_simulator_package'))
+ $file_type = 'P';
else
$file_type = 'U';
$allowed_extensions_str = '';
@@ -368,6 +409,9 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
case 'A':
$allowed_extensions_str = variable_get('om_flowsheet_abstract_upload_extensions', '');
break;
+ case 'P':
+ $allowed_extensions_str = variable_get('om_flowsheet_simulator_package_extensions', '');
+ break;
} //$file_type
$allowed_extensions = explode(',', $allowed_extensions_str);
$tmp_ext = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
@@ -485,6 +529,10 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
{
$file_type = 'A';
} //strstr($file_form_name, 'upload_an_abstract')
+ else if (strstr($file_form_name, 'upload_simulator_package'))
+ {
+ $file_type = 'P';
+ }
else
{
$file_type = 'U';
@@ -614,6 +662,68 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
drupal_set_message('Error uploading file : ' . $dest_path . $file_name, 'error');
}
break;
+ case 'P':
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+
+ drupal_set_message(t("File !filename already exists hence overwirtten the exisitng file ", array(
+ '!filename' => $_FILES['files']['name'][$file_form_name]
+ )), 'error');
+ } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ /* uploading file */
+ else 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_ab_f = "SELECT * FROM om_flowsheet_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype =
+ :filetype";
+ $args_ab_f = array(
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type
+ );
+ $query_ab_f_result = db_query($query_ab_f, $args_ab_f)->fetchObject();
+ if (!$query_ab_f_result)
+ {
+ $query = "INSERT INTO {om_flowsheet_submitted_abstracts_file} (submitted_abstract_id, proposal_id, uid, approvar_uid, filename, filepath, filemime, filesize, filetype, timestamp)
+ VALUES (:submitted_abstract_id, :proposal_id, :uid, :approvar_uid, :filename, :filepath, :filemime, :filesize, :filetype, :timestamp)";
+ $args = array(
+ ":submitted_abstract_id" => $submitted_abstract_id,
+ ":proposal_id" => $proposal_id,
+ ":uid" => $user->uid,
+ ":approvar_uid" => 0,
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $_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');
+ } //!$query_ab_f_result
+ else
+ {
+ unlink($root_path . $dest_path . $query_ab_f_result->filename);
+ $query = "UPDATE {om_flowsheet_submitted_abstracts_file} SET filename = :filename, filepath=:filepath, filemime=:filemime, filesize=:filesize, timestamp=:timestamp WHERE proposal_id = :proposal_id AND filetype = :filetype";
+ $args = array(
+ ":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],
+ ":timestamp" => time(),
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type
+ );
+ db_query($query, $args);
+ drupal_set_message($file_name . ' file updated 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');
+ }
+ break;
} //$file_type
} //$file_name
} //$_FILES['files']['name'] as $file_form_name => $file_name
@@ -690,6 +800,12 @@ function default_value_for_uploaded_files($filetype, $proposal_id)
$query->condition('filetype', $filetype);
$filetype_q = $query->execute()->fetchObject();
return $filetype_q;
+ }
+ elseif ($filetype == "P")
+ {
+ $query->condition('filetype', $filetype);
+ $filetype_q = $query->execute()->fetchObject();
+ return $filetype_q;
} //$filetype == "S"
else
{