diff options
-rwxr-xr-x | download.inc | 570 | ||||
-rwxr-xr-x | dwsim_flowsheet.module | 157 | ||||
-rwxr-xr-x | email.inc | 684 | ||||
-rw-r--r-- | manage_proposal.inc | 360 | ||||
-rwxr-xr-x | proposal.inc | 171 |
5 files changed, 1021 insertions, 921 deletions
diff --git a/download.inc b/download.inc index c409063..d52982c 100755 --- a/download.inc +++ b/download.inc @@ -1,301 +1,305 @@ <?php // $Id$ - function dwsim_flowsheet_download_user_defined_compound() { $proposal_id = arg(3); - $root_path = dwsim_flowsheet_document_path(); - $query = db_select('dwsim_flowsheet_proposal'); + $root_path = dwsim_flowsheet_document_path(); + $query = db_select('dwsim_flowsheet_proposal'); $query->fields('dwsim_flowsheet_proposal'); $query->condition('id', $proposal_id); $query->range(0, 1); - $result = $query->execute(); + $result = $query->execute(); $dwsim_flowsheet_user_compund_data = $result->fetchObject(); - $samplecodename = substr($dwsim_flowsheet_user_compund_data->user_defined_compound_filepath, strrpos($dwsim_flowsheet_user_compund_data->user_defined_compound_filepath, '/') + 1); + $samplecodename = substr($dwsim_flowsheet_user_compund_data->user_defined_compound_filepath, strrpos($dwsim_flowsheet_user_compund_data->user_defined_compound_filepath, '/') + 1); header('Content-Type: txt/zip'); header('Content-disposition: attachment; filename="' . $samplecodename . '"'); - header('Content-Length: ' . filesize($root_path . $dwsim_flowsheet_user_compund_data->directory_name. '/'. $dwsim_flowsheet_user_compund_data->user_defined_compound_filepath)); + header('Content-Length: ' . filesize($root_path . $dwsim_flowsheet_user_compund_data->directory_name . '/' . $dwsim_flowsheet_user_compund_data->user_defined_compound_filepath)); ob_clean(); - readfile($root_path . $dwsim_flowsheet_user_compund_data->directory_name. '/'.$dwsim_flowsheet_user_compund_data->user_defined_compound_filepath); + readfile($root_path . $dwsim_flowsheet_user_compund_data->directory_name . '/' . $dwsim_flowsheet_user_compund_data->user_defined_compound_filepath); } - function dwsim_flowsheet_download_solution_file() - { - $solution_file_id = arg(3); - $root_path = dwsim_flowsheet_path(); - // $solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE id = %d LIMIT 1", $solution_file_id); - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id LIMIT 1", array(':solution_id' => $solution_file_id)); - /*$query = db_select('dwsim_flowsheet_solution_files'); - $query->fields('dwsim_flowsheet_solution_files'); - $query->condition('id', $solution_file_id); - $query->range(0, 1); - $solution_files_q = $query->execute();*/ - $solution_file_data = $solution_files_q->fetchObject(); - header('Content-Type: ' . $solution_file_data->filemime); - //header('Content-Type: application/octet-stram'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($solution_file_data->filename)) . '"'); - header('Content-Length: ' . filesize($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath)); - readfile($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath); - } +{ + $solution_file_id = arg(3); + $root_path = dwsim_flowsheet_path(); + // $solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE id = %d LIMIT 1", $solution_file_id); + $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id LIMIT 1", array( + ':solution_id' => $solution_file_id + )); + /*$query = db_select('dwsim_flowsheet_solution_files'); + $query->fields('dwsim_flowsheet_solution_files'); + $query->condition('id', $solution_file_id); + $query->range(0, 1); + $solution_files_q = $query->execute();*/ + $solution_file_data = $solution_files_q->fetchObject(); + header('Content-Type: ' . $solution_file_data->filemime); + //header('Content-Type: application/octet-stram'); + header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($solution_file_data->filename)) . '"'); + header('Content-Length: ' . filesize($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath)); + readfile($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath); +} function dwsim_flowsheet_download_dependency_file() - { - $dependency_file_id = arg(3); - $root_path = dwsim_flowsheet_path(); - //$dependency_file_q = db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $dependency_file_id); - $query = db_select('dwsim_flowsheet_dependency_files'); - $query->fields('dwsim_flowsheet_dependency_files'); - $query->condition('id', $dependency_file_id); - $query->range(0, 1); - $dependency_files_q = $query->execute(); - $dependency_file_data = $dependency_files_q->fetchObject(); - header('Content-Type: ' . $dependency_file_data->filemime); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($dependency_file_data->filename)) . '"'); - header('Content-Length: ' . filesize($root_path . $dependency_file_data->filepath)); - readfile($root_path . $dependency_file_data->filepath); - } +{ + $dependency_file_id = arg(3); + $root_path = dwsim_flowsheet_path(); + //$dependency_file_q = db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $dependency_file_id); + $query = db_select('dwsim_flowsheet_dependency_files'); + $query->fields('dwsim_flowsheet_dependency_files'); + $query->condition('id', $dependency_file_id); + $query->range(0, 1); + $dependency_files_q = $query->execute(); + $dependency_file_data = $dependency_files_q->fetchObject(); + header('Content-Type: ' . $dependency_file_data->filemime); + header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($dependency_file_data->filename)) . '"'); + header('Content-Length: ' . filesize($root_path . $dependency_file_data->filepath)); + readfile($root_path . $dependency_file_data->filepath); +} function dwsim_flowsheet_download_solution() - { - $solution_id = arg(3); - $root_path = dwsim_flowsheet_path(); - /* get solution data */ - //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE id = %d", $solution_id); - $query = db_select('dwsim_flowsheet_solution'); - $query->fields('dwsim_flowsheet_solution'); - $query->condition('id', $solution_id); - $solution_q = $query->execute(); - $solution_data = $solution_q->fetchObject(); - //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $solution_data->experiment_id); - $query = db_select('dwsim_flowsheet_experiment'); - $query->fields('dwsim_flowsheet_experiment'); - $query->condition('id', $solution_data->experiment_id); - $experiment_q = $query->execute(); - $experiment_data = $experiment_q->fetchObject(); - //$solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_id); - /*$query = db_select('dwsim_flowsheet_solution_files'); - $query->fields('dwsim_flowsheet_solution_files'); - $query->condition('solution_id', $solution_id); - $solution_files_q = $query->execute();*/ - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array(':solution_id' => $solution_id)); - //$solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_id); - $query = db_select('dwsim_flowsheet_solution_dependency'); - $query->fields('dwsim_flowsheet_solution_dependency'); - $query->condition('solution_id', $solution_id); - $solution_dependency_files_q = $query->execute(); - $CODE_PATH = 'CODE' . $solution_data->code_number . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive; - $zip->open($zip_filename, ZipArchive::CREATE); - while ($solution_files_row = $solution_files_q->fetchObject()) - { - $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); - } - /* dependency files */ - while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) - { - //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject(); - $query = db_select('dwsim_flowsheet_dependency_files'); - $query->fields('dwsim_flowsheet_dependency_files'); - $query->condition('id', $solution_dependency_files_row->dependency_id); - $query->range(0, 1); - $dependency_file_data = $query->execute()->fetchObject(); - if ($dependency_file_data) - $zip->addFile($root_path . $dependency_file_data->filepath, $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); - } - $zip_file_count = $zip->numFiles; - $zip->close(); - if ($zip_file_count > 0) - { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="CODE' . $solution_data->code_number . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } - else - { - drupal_set_message("There are no files in this solutions to download", 'error'); - drupal_goto('lab-migration/lab-migration-run'); - } - } +{ + $solution_id = arg(3); + $root_path = dwsim_flowsheet_path(); + /* get solution data */ + //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE id = %d", $solution_id); + $query = db_select('dwsim_flowsheet_solution'); + $query->fields('dwsim_flowsheet_solution'); + $query->condition('id', $solution_id); + $solution_q = $query->execute(); + $solution_data = $solution_q->fetchObject(); + //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $solution_data->experiment_id); + $query = db_select('dwsim_flowsheet_experiment'); + $query->fields('dwsim_flowsheet_experiment'); + $query->condition('id', $solution_data->experiment_id); + $experiment_q = $query->execute(); + $experiment_data = $experiment_q->fetchObject(); + //$solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_id); + /*$query = db_select('dwsim_flowsheet_solution_files'); + $query->fields('dwsim_flowsheet_solution_files'); + $query->condition('solution_id', $solution_id); + $solution_files_q = $query->execute();*/ + $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array( + ':solution_id' => $solution_id + )); + //$solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_id); + $query = db_select('dwsim_flowsheet_solution_dependency'); + $query->fields('dwsim_flowsheet_solution_dependency'); + $query->condition('solution_id', $solution_id); + $solution_dependency_files_q = $query->execute(); + $CODE_PATH = 'CODE' . $solution_data->code_number . '/'; + /* zip filename */ + $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; + /* creating zip archive on the server */ + $zip = new ZipArchive; + $zip->open($zip_filename, ZipArchive::CREATE); + while ($solution_files_row = $solution_files_q->fetchObject()) + { + $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); + } //$solution_files_row = $solution_files_q->fetchObject() + /* dependency files */ + while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) + { + //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject(); + $query = db_select('dwsim_flowsheet_dependency_files'); + $query->fields('dwsim_flowsheet_dependency_files'); + $query->condition('id', $solution_dependency_files_row->dependency_id); + $query->range(0, 1); + $dependency_file_data = $query->execute()->fetchObject(); + if ($dependency_file_data) + $zip->addFile($root_path . $dependency_file_data->filepath, $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); + } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject() + $zip_file_count = $zip->numFiles; + $zip->close(); + if ($zip_file_count > 0) + { + /* download zip file */ + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename="CODE' . $solution_data->code_number . '.zip"'); + header('Content-Length: ' . filesize($zip_filename)); + ob_clean(); + //flush(); + readfile($zip_filename); + unlink($zip_filename); + } //$zip_file_count > 0 + else + { + drupal_set_message("There are no files in this solutions to download", 'error'); + drupal_goto('lab-migration/lab-migration-run'); + } +} function dwsim_flowsheet_download_experiment() - { - $experiment_id = (int)arg(3); - - $root_path = dwsim_flowsheet_path(); - /* get solution data */ - //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $experiment_id); - $query = db_select('dwsim_flowsheet_experiment'); - $query->fields('dwsim_flowsheet_experiment'); - $query->condition('id', $experiment_id); - $experiment_q = $query->execute(); - $experiment_data = $experiment_q->fetchObject(); - $EXP_PATH = 'EXP' . $experiment_data->number . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive; - $zip->open($zip_filename, ZipArchive::CREATE); - //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id); - $query = db_select('dwsim_flowsheet_solution'); - $query->fields('dwsim_flowsheet_solution'); - $query->condition('experiment_id', $experiment_id); - $query->condition('approval_status', 1); - $solution_q = $query->execute(); - while ($solution_row = $solution_q->fetchObject()) - { - $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; - // $solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_row->id); - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.solution_id = :solution_id", array(':solution_id' => $solution_row->id)); - /* $query = db_select('dwsim_flowsheet_solution_files'); - $query->fields('dwsim_flowsheet_solution_files'); - $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute();*/ - // $solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_row->id); - while ($solution_files_row = $solution_files_q->fetchObject()) - { - $zip->addFile($root_path . $solution_files_row->directory_name .'/'. $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); - } - /* dependency files */ - $query = db_select('dwsim_flowsheet_solution_dependency'); - $query->fields('dwsim_flowsheet_solution_dependency'); - $query->condition('solution_id', $solution_row->id); - $solution_dependency_files_q = $query->execute(); - while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) - { - //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject(); - $query = db_select('dwsim_flowsheet_dependency_files'); - $query->fields('dwsim_flowsheet_dependency_files'); - $query->condition('id', $solution_dependency_files_row->dependency_id); - $query->range(0, 1); - $dependency_file_data = $query->execute()->fetchObject(); - if ($dependency_file_data) - $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); - } - } - $zip_file_count = $zip->numFiles; - $zip->close(); - if ($zip_file_count > 0) - { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } - else - { - drupal_set_message("There are no solutions in this experiment to download", 'error'); - drupal_goto('lab-migration/lab-migration-run'); - } - } +{ + $experiment_id = (int) arg(3); + $root_path = dwsim_flowsheet_path(); + /* get solution data */ + //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $experiment_id); + $query = db_select('dwsim_flowsheet_experiment'); + $query->fields('dwsim_flowsheet_experiment'); + $query->condition('id', $experiment_id); + $experiment_q = $query->execute(); + $experiment_data = $experiment_q->fetchObject(); + $EXP_PATH = 'EXP' . $experiment_data->number . '/'; + /* zip filename */ + $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; + /* creating zip archive on the server */ + $zip = new ZipArchive; + $zip->open($zip_filename, ZipArchive::CREATE); + //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id); + $query = db_select('dwsim_flowsheet_solution'); + $query->fields('dwsim_flowsheet_solution'); + $query->condition('experiment_id', $experiment_id); + $query->condition('approval_status', 1); + $solution_q = $query->execute(); + while ($solution_row = $solution_q->fetchObject()) + { + $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; + // $solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_row->id); + $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.solution_id = :solution_id", array( + ':solution_id' => $solution_row->id + )); + /* $query = db_select('dwsim_flowsheet_solution_files'); + $query->fields('dwsim_flowsheet_solution_files'); + $query->condition('solution_id', $solution_row->id); + $solution_files_q = $query->execute();*/ + // $solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_row->id); + while ($solution_files_row = $solution_files_q->fetchObject()) + { + $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); + } //$solution_files_row = $solution_files_q->fetchObject() + /* dependency files */ + $query = db_select('dwsim_flowsheet_solution_dependency'); + $query->fields('dwsim_flowsheet_solution_dependency'); + $query->condition('solution_id', $solution_row->id); + $solution_dependency_files_q = $query->execute(); + while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) + { + //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject(); + $query = db_select('dwsim_flowsheet_dependency_files'); + $query->fields('dwsim_flowsheet_dependency_files'); + $query->condition('id', $solution_dependency_files_row->dependency_id); + $query->range(0, 1); + $dependency_file_data = $query->execute()->fetchObject(); + if ($dependency_file_data) + $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); + } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject() + } //$solution_row = $solution_q->fetchObject() + $zip_file_count = $zip->numFiles; + $zip->close(); + if ($zip_file_count > 0) + { + /* download zip file */ + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"'); + header('Content-Length: ' . filesize($zip_filename)); + ob_clean(); + //flush(); + readfile($zip_filename); + unlink($zip_filename); + } //$zip_file_count > 0 + else + { + drupal_set_message("There are no solutions in this experiment to download", 'error'); + drupal_goto('lab-migration/lab-migration-run'); + } +} function dwsim_flowsheet_download_lab() - { - global $user; - $lab_id = arg(3); - $root_path = dwsim_flowsheet_path(); - /* get solution data */ - //$lab_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $lab_id); - $query = db_select('dwsim_flowsheet_proposal'); - $query->fields('dwsim_flowsheet_proposal'); - $query->condition('id', $lab_id); - $lab_q = $query->execute(); - $lab_data = $lab_q->fetchObject(); - $LAB_PATH = $lab_data->lab_title . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive(); - $zip->open($zip_filename, ZipArchive::CREATE); - //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $lab_id); - $query = db_select('dwsim_flowsheet_experiment'); - $query->fields('dwsim_flowsheet_experiment'); - $query->condition('proposal_id', $lab_id); - $experiment_q = $query->execute(); - while ($experiment_row = $experiment_q->fetchObject()) - { - $EXP_PATH = 'EXP' . $experiment_row->number . '/'; - //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id); - $query = db_select('dwsim_flowsheet_solution'); - $query->fields('dwsim_flowsheet_solution'); - $query->condition('experiment_id', $experiment_row->id); - $query->condition('approval_status', 1); - $solution_q = $query->execute(); - while ($solution_row = $solution_q->fetchObject()) - { - $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; - //$solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_row->id); - - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array(':solution_id' => $solution_row->id)); - /*$query = db_select('dwsim_flowsheet_solution_files'); - $query->fields('dwsim_flowsheet_solution_files'); - $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute();*/ - //$solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_row->id); - $query = db_select('dwsim_flowsheet_solution_dependency'); - $query->fields('dwsim_flowsheet_solution_dependency'); - $query->condition('solution_id', $solution_row->id); - $solution_dependency_files_q = $query->execute(); - while ($solution_files_row = $solution_files_q->fetchObject()) - { - $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); - //var_dump($zip->numFiles); - } - // die; - /* dependency files */ - while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) - { - //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject(); - $query = db_select('dwsim_flowsheet_dependency_files'); - $query->fields('dwsim_flowsheet_dependency_files'); - $query->condition('id', $solution_dependency_files_row->dependency_id); - $query->range(0, 1); - $dependency_file_data = $query->execute()->fetchObject(); - if ($dependency_file_data) - $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); - } - } - } - $zip_file_count = $zip->numFiles; - $zip->close(); - if ($zip_file_count > 0) - { - if ($user->uid) - { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } - else - { - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - header("Content-Transfer-Encoding: binary"); - header('Expires: 0'); - header('Pragma: no-cache'); - ob_end_flush(); - ob_clean(); - flush(); - readfile($zip_filename); - unlink($zip_filename); - } - } - else - { - drupal_set_message("There are no solutions in this Lab to download", 'error'); - drupal_goto('lab-migration/lab-migration-run'); - } - } +{ + global $user; + $lab_id = arg(3); + $root_path = dwsim_flowsheet_path(); + /* get solution data */ + //$lab_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $lab_id); + $query = db_select('dwsim_flowsheet_proposal'); + $query->fields('dwsim_flowsheet_proposal'); + $query->condition('id', $lab_id); + $lab_q = $query->execute(); + $lab_data = $lab_q->fetchObject(); + $LAB_PATH = $lab_data->lab_title . '/'; + /* zip filename */ + $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; + /* creating zip archive on the server */ + $zip = new ZipArchive(); + $zip->open($zip_filename, ZipArchive::CREATE); + //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $lab_id); + $query = db_select('dwsim_flowsheet_experiment'); + $query->fields('dwsim_flowsheet_experiment'); + $query->condition('proposal_id', $lab_id); + $experiment_q = $query->execute(); + while ($experiment_row = $experiment_q->fetchObject()) + { + $EXP_PATH = 'EXP' . $experiment_row->number . '/'; + //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id); + $query = db_select('dwsim_flowsheet_solution'); + $query->fields('dwsim_flowsheet_solution'); + $query->condition('experiment_id', $experiment_row->id); + $query->condition('approval_status', 1); + $solution_q = $query->execute(); + while ($solution_row = $solution_q->fetchObject()) + { + $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; + //$solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_row->id); + $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array( + ':solution_id' => $solution_row->id + )); + /*$query = db_select('dwsim_flowsheet_solution_files'); + $query->fields('dwsim_flowsheet_solution_files'); + $query->condition('solution_id', $solution_row->id); + $solution_files_q = $query->execute();*/ + //$solution_dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_dependency} WHERE solution_id = %d", $solution_row->id); + $query = db_select('dwsim_flowsheet_solution_dependency'); + $query->fields('dwsim_flowsheet_solution_dependency'); + $query->condition('solution_id', $solution_row->id); + $solution_dependency_files_q = $query->execute(); + while ($solution_files_row = $solution_files_q->fetchObject()) + { + $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); + //var_dump($zip->numFiles); + } //$solution_files_row = $solution_files_q->fetchObject() + // die; + /* dependency files */ + while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) + { + //$dependency_file_data = (db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject(); + $query = db_select('dwsim_flowsheet_dependency_files'); + $query->fields('dwsim_flowsheet_dependency_files'); + $query->condition('id', $solution_dependency_files_row->dependency_id); + $query->range(0, 1); + $dependency_file_data = $query->execute()->fetchObject(); + if ($dependency_file_data) + $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename))); + } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject() + } //$solution_row = $solution_q->fetchObject() + } //$experiment_row = $experiment_q->fetchObject() + $zip_file_count = $zip->numFiles; + $zip->close(); + if ($zip_file_count > 0) + { + if ($user->uid) + { + /* download zip file */ + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"'); + header('Content-Length: ' . filesize($zip_filename)); + ob_clean(); + //flush(); + readfile($zip_filename); + unlink($zip_filename); + } //$user->uid + else + { + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"'); + header('Content-Length: ' . filesize($zip_filename)); + header("Content-Transfer-Encoding: binary"); + header('Expires: 0'); + header('Pragma: no-cache'); + ob_end_flush(); + ob_clean(); + flush(); + readfile($zip_filename); + unlink($zip_filename); + } + } //$zip_file_count > 0 + else + { + drupal_set_message("There are no solutions in this Lab to download", 'error'); + drupal_goto('lab-migration/lab-migration-run'); + } +} diff --git a/dwsim_flowsheet.module b/dwsim_flowsheet.module index 9ebbcfe..b31bb76 100755 --- a/dwsim_flowsheet.module +++ b/dwsim_flowsheet.module @@ -234,8 +234,8 @@ function dwsim_flowsheet_menu() 'weight' => 1 ); $items['flowsheeting-project/abstract-code/upload'] = array( - 'title' => 'Code Submission', - 'description' => 'Code Submission', + 'title' => 'Abstract Submission', + 'description' => 'Abstract Submission', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'dwsim_flowsheet_upload_abstract_code_form' @@ -610,7 +610,7 @@ function dwsim_flowsheet_get_proposal() $proposal_data = $proposal_q->fetchObject(); if (!$proposal_data) { - drupal_set_message("You do not have any approved DWSIM Flowsheet proposal. Please check the ", 'error'); + drupal_set_message("You do not have any approved DWSIM Flowsheet proposal. Please propose the flowsheet proposal", 'error'); drupal_goto(''); } //!$proposal_data switch ($proposal_data->approval_status) @@ -747,6 +747,21 @@ function _df_list_of_cities() } //$city_list_data = $city_list->fetchObject() return $city; } +function _df_list_of_pincodes() +{ + $pincode = array( + 0 => '-Select-' + ); + $query = db_select('list_of_all_india_pincode'); + $query->fields('list_of_all_india_pincode'); + $query->orderBy('pincode', 'ASC'); + $pincode_list = $query->execute(); + while ($pincode_list_data = $pincode_list->fetchObject()) + { + $pincode[$pincode_list_data->pincode] = $pincode_list_data->pincode; + } //$pincode_list_data = $pincode_list->fetchObject() + return $pincode; +} function _df_list_of_departments() { $department = array(); @@ -773,12 +788,11 @@ function _df_list_of_software_version() } //$software_version_list_data = $software_version_list->fetchObject() return $software_version; } -function _df_dir_name($project) +function _df_dir_name($project, $proposar_name) { $project_title = ucname($project); - $proposar_name = ucname($student_name); - $university_name = ucname($university); - $dir_name = $project_title; + $proposar_name = ucname($proposar_name); + $dir_name = $project_title . ' By ' . $proposar_name; $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name)); return $directory_name; } @@ -786,3 +800,132 @@ function dwsim_flowsheet_document_path() { return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/dwsim_flowsheet_uploads/'; } +function DF_RenameDir($proposal_id, $dir_name) +{ + $proposal_id = $proposal_id; + $dir_name = $dir_name; + $query = db_query("SELECT directory_name,id FROM dwsim_flowsheet_proposal WHERE id = :proposal_id", array( + ':proposal_id' => $proposal_id + )); + $result = $query->fetchObject(); + if ($result != NULL) + { + $files = scandir(dwsim_flowsheet_path()); + $files_id_dir = dwsim_flowsheet_path() . $result->id; + //var_dump($files);die; + $file_dir = dwsim_flowsheet_path() . $result->directory_name; + if (is_dir($file_dir)) + { + $new_directory_name = rename(dwsim_flowsheet_path() . $result->directory_name, dwsim_flowsheet_path() . $dir_name); + return $new_directory_name; + } //is_dir($file_dir) + else if (is_dir($files_id_dir)) + { + $new_directory_name = rename(dwsim_flowsheet_path() . $result->id, dwsim_flowsheet_path() . $dir_name); + return $new_directory_name; + } //is_dir($files_id_dir) + else + { + drupal_set_message('Directory not available for rename.'); + return; + } + } //$result != NULL + else + { + drupal_set_message('Project directory name not present in databse'); + return; + } + //var_dump($files);die; + /* if ($files != NULL) + { + $new_directory_name = rename(dwsim_flowsheet_path() . $result->directory_name, dwsim_flowsheet_path() . $dir_name) or drupal_set_message("Unable to rename folder"); + } + else + { + $new_directory_name = 'Can not rename the directory. Directory not present'; + }*/ + return; +} +function CreateReadmeFileDWSIMFlowsheetingProject($proposal_id) +{ + $result = db_query(" + SELECT * from dwsim_flowsheet_proposal WHERE id = :proposal_id", array( + ":proposal_id" => $proposal_id + )); + $proposal_data = $result->fetchObject(); + $root_path = dwsim_flowsheet_path(); + $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!"); + $txt = ""; + $txt .= "About the lab"; + $txt .= "\n" . "\n"; + $txt .= "Title Of The Flowsheet Project: " . $proposal_data->project_title . "\n"; + $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->student_name . "\n"; + $txt .= "University: " . $proposal_data->university . "\n"; + $txt .= "\n" . "\n"; + $txt .= "DWSIM Flowsheet Project By FOSSEE, IIT Bombay" . "\n"; + fwrite($readme_file, $txt); + fclose($readme_file); + return $txt; +} +function rrmdir_project($prop_id) +{ + $proposal_id = $prop_id; + $result = db_query(" + SELECT * from dwsim_flowsheet_proposal WHERE id = :proposal_id", array( + ":proposal_id" => $proposal_id + )); + $proposal_data = $result->fetchObject(); + $root_path = dwsim_flowsheet_document_path(); + $dir = $root_path . $proposal_data->directory_name; + if ($proposal_data->id == $prop_id) + { + if (is_dir($dir)) + { + $objects = scandir($dir); + foreach ($objects as $object) + { + if ($object != "." && $object != "..") + { + if (filetype($dir . "/" . $object) == "dir") + { + rrmdir($dir . "/" . $object); + } //filetype($dir . "/" . $object) == "dir" + else + { + unlink($dir . "/" . $object); + } + } //$object != "." && $object != ".." + } //$objects as $object + reset($objects); + rmdir($dir); + $msg = drupal_set_message("Directory deleted successfully"); + return $msg; + } //is_dir($dir) + $msg = drupal_set_message("Directory not present"); + return $msg; + } //$proposal_data->id == $prop_id + else + { + $msg = drupal_set_message("Data not found"); + return $msg; + } +} +function rrmdir($dir) +{ + if (is_dir($dir)) + { + $objects = scandir($dir); + foreach ($objects as $object) + { + if ($object != "." && $object != "..") + { + if (filetype($dir . "/" . $object) == "dir") + rrmdir($dir . "/" . $object); + else + unlink($dir . "/" . $object); + } //$object != "." && $object != ".." + } //$objects as $object + reset($objects); + rmdir($dir); + } //is_dir($dir) +} @@ -3,42 +3,71 @@ * Implementation of hook_mail(). */ function dwsim_flowsheet_mail($key, &$message, $params) - { - global $user; - $language = $message['language']; - //$language = user_preferred_language($user); - switch ($key) - { - - case 'dwsim_flowsheet_proposal_received': - /* initializing data */ - // $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']); - // $proposal_data = $proposal_q->fetchObject(); - $query = db_select('dwsim_flowsheet_proposal'); - $query->fields('dwsim_flowsheet_proposal'); - $query->condition('id', $params['dwsim_flowsheet_proposal_received']['proposal_id']); - $query->range(0, 1); - $proposal_data = $query->execute()->fetchObject(); - $user_data = user_load($params['proposal_received']['user_id']); - $message['headers'] = $params['proposal_received']['headers']; - $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Chemical Process Flowsheeting Project proposal has been received', array( - '!site_name' => variable_get('site_name', '') - ), array( - 'language' => $language->language - )); - $message['body'] = array( - 'body' => t(' +{ + global $user; + $language = $message['language']; + //$language = user_preferred_language($user); + switch ($key) + { + case 'dwsim_flowsheet_proposal_received': + /* initializing data */ + $query = db_select('dwsim_flowsheet_proposal'); + $query->fields('dwsim_flowsheet_proposal'); + $query->condition('id', $params['dwsim_flowsheet_proposal_received']['proposal_id']); + $query->range(0, 1); + $proposal_data = $query->execute()->fetchObject(); + $user_data = user_load($params['dwsim_flowsheet_proposal_received']['user_id']); + if ($proposal_data->user_defined_compounds_used_in_process == NULL) + { + $user_defined_compounds_used_in_process = "Not Entered"; + } //$proposal_data->user_defined_compounds_used_in_process == NULL + else + { + $user_defined_compounds_used_in_process = $proposal_data->user_defined_compounds_used_in_process; + } + if ($proposal_data->user_defined_compound_filepath == "NULL") + { + $file_name = "File not uploaded"; + } //$proposal_data->user_defined_compound_filepath == NULL + else + { + $file_name = basename($proposal_data->user_defined_compound_filepath); + } + $message['headers'] = $params['dwsim_flowsheet_proposal_received']['headers']; + $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Flowsheeting Project 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 Chemical Process Flowsheeting Project with the following details: +We have received your DWSIM Flowsheeting Project proposal with the following details: -Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . ' +Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->student_name . ' Email : ' . $user_data->mail . ' -Contact No. : ' . $proposal_data->contact_ph . ' -Department/Branch : ' . $proposal_data->department . ' +Month and Year of Award of Degree : ' . $proposal_data->month_year_of_degree . ' University/Institute : ' . $proposal_data->university . ' City : ' . $proposal_data->city . ' State : ' . $proposal_data->state . ' +Country : ' . $proposal_data->country . ' + +Project Guide : ' . $proposal_data->project_guide_name . ' +Project Guide Email : ' . $proposal_data->project_guide_email_id . ' + +DWSIM Version : ' . $proposal_data->version . ' + +Project Title : ' . $proposal_data->project_title . ' + +Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . ' + +List of compounds from DWSIM Database used in process flowsheet : ' . $proposal_data->dwsim_database_compound_name . ' + +List of user defined compounds used in process flowsheet : ' . $user_defined_compounds_used_in_process . ' + +Uploaded user defined compound : ' . $file_name . ' + Your proposal is under review. You will soon receive an email when same has been approved/disapproved. @@ -47,198 +76,323 @@ 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 'dwsim_flowsheet_proposal_disapproved': - /* initializing data */ - // $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']); - //$proposal_data = $proposal_q->fetchObject(); - $query = db_select('dwsim_flowsheet_proposal'); - $query->fields('dwsim_flowsheet_proposal'); - $query->condition('id', $params['dwsim_flowsheet_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"; - } - - $user_data = user_load($params['dwsim_flowsheet_proposal_disapproved']['user_id']); - $message['headers'] = $params['dwsim_flowsheet_proposal_disapproved']['headers']; - $message['subject'] = t('[!site_name] Your DWSIM flowsheet proposal has been disapproved', array( - '!site_name' => variable_get('site_name', '') - ), array( - 'language' => $language->language - )); - $message['body'] = array( - 'body' => t(' + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'dwsim_flowsheet_proposal_disapproved': + /* initializing data */ + $query = db_select('dwsim_flowsheet_proposal'); + $query->fields('dwsim_flowsheet_proposal'); + $query->condition('id', $params['dwsim_flowsheet_proposal_disapproved']['proposal_id']); + $query->range(0, 1); + $proposal_data = $query->execute()->fetchObject(); + $user_data = user_load($params['dwsim_flowsheet_proposal_disapproved']['user_id']); + if ($proposal_data->user_defined_compounds_used_in_process == NULL) + { + $user_defined_compounds_used_in_process = "Not Entered"; + } //$proposal_data->user_defined_compounds_used_in_process == NULL + else + { + $user_defined_compounds_used_in_process = $proposal_data->user_defined_compounds_used_in_process; + } + if ($proposal_data->user_defined_compound_filepath == "NULL") + { + $file_name = "File not uploaded"; + } //$proposal_data->user_defined_compound_filepath == NULL + else + { + $file_name = basename($proposal_data->user_defined_compound_filepath); + } + $message['headers'] = $params['dwsim_flowsheet_proposal_disapproved']['headers']; + $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Flowsheeting Project 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 DWSIM Flowsheeing Project proposal details have been dis-approved. +Your DWSIM Flowsheeting Project proposal with the following details has been disapproved : + +Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->student_name . ' +Email : ' . $user_data->mail . ' +Month and Year of Award of Degree : ' . $proposal_data->month_year_of_degree . ' +University/Institute : ' . $proposal_data->university . ' +City : ' . $proposal_data->city . ' +State : ' . $proposal_data->state . ' +Country : ' . $proposal_data->country . ' + +Project Guide : ' . $proposal_data->project_guide_name . ' +Project Guide Email : ' . $proposal_data->project_guide_email_id . ' + +Project Title : ' . $proposal_data->project_title . ' + +Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . ' + +List of compounds from DWSIM Database used in process flowsheet : ' . $proposal_data->dwsim_database_compound_name . ' + +List of user defined compounds used in process flowsheet : ' . $user_defined_compounds_used_in_process . ' + +Uploaded user defined compound : ' . $file_name . ' + -Reason for disapproval: ' . $proposal_data->message . ' +Reason for dissapproval : ' . $proposal_data->dissapproval_reason . ' -Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . ' + +Your are eligible to propose a new flowsheeting 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 'dwsim_flowsheet_proposal_approved': + /* initializing data */ + $query = db_select('dwsim_flowsheet_proposal'); + $query->fields('dwsim_flowsheet_proposal'); + $query->condition('id', $params['dwsim_flowsheet_proposal_approved']['proposal_id']); + $query->range(0, 1); + $proposal_data = $query->execute()->fetchObject(); + $user_data = user_load($params['dwsim_flowsheet_proposal_approved']['user_id']); + if ($proposal_data->user_defined_compounds_used_in_process == NULL) + { + $user_defined_compounds_used_in_process = "Not Entered"; + } //$proposal_data->user_defined_compounds_used_in_process == NULL + else + { + $user_defined_compounds_used_in_process = $proposal_data->user_defined_compounds_used_in_process; + } + if ($proposal_data->user_defined_compound_filepath == "NULL") + { + $file_name = "File not uploaded"; + } //$proposal_data->user_defined_compound_filepath == NULL + else + { + $file_name = $params['dwsim_flowsheet_proposal_approved']['file_name']; + } + $message['headers'] = $params['dwsim_flowsheet_proposal_approved']['headers']; + $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Flowsheeting Project proposal has been approved', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' +Dear !user_name, + +Your DWSIM Flowsheeting Project proposal with the following details has been approved: + +Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->student_name . ' Email : ' . $user_data->mail . ' -Contact No. : ' . $proposal_data->contact_ph . ' -Department/Branch : ' . $proposal_data->department . ' +Month and Year of Award of Degree : ' . $proposal_data->month_year_of_degree . ' University/Institute : ' . $proposal_data->university . ' City : ' . $proposal_data->city . ' State : ' . $proposal_data->state . ' +Country : ' . $proposal_data->country . ' + +Project Guide : ' . $proposal_data->project_guide_name . ' +Project Guide Email : ' . $proposal_data->project_guide_email_id . ' -Solution Provided By : ' . $solution_provider_user . ' +Project Title : ' . $proposal_data->project_title . ' -List of experiments : ' . $experiment_list . ' +Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . ' -Uploaded Sample Code : ' . $samplecodefilename . ' +List of compounds from DWSIM Database used in process flowsheet : ' . $proposal_data->dwsim_database_compound_name . ' +List of user defined compounds used in process flowsheet : ' . $user_defined_compounds_used_in_process . ' + +Uploaded user defined compound : ' . $file_name . ' + + + +You can upload your abstract using abstract submission interface. 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 'dwsim_flowsheet_proposal_approved': - /* initializing data */ - // $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']); - $query = db_select('dwsim_flowsheet_proposal'); - $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(); - - - $user_data = user_load($params['proposal_approved']['user_id']); - $message['headers'] = $params['proposal_approved']['headers']; - $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM flowsheet proposal has been approved', array( - '!site_name' => variable_get('site_name', '') - ), array( - 'language' => $language->language - )); - $message['body'] = array( - 0 => t(' + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'dwsim_flowsheet_proposal_completed': + /* initializing data */ + $query = db_select('dwsim_flowsheet_proposal'); + $query->fields('dwsim_flowsheet_proposal'); + $query->condition('id', $params['dwsim_flowsheet_proposal_approved']['proposal_id']); + $query->range(0, 1); + $proposal_data = $query->execute()->fetchObject(); + $user_data = user_load($params['dwsim_flowsheet_proposal_approved']['user_id']); + if ($proposal_data->user_defined_compounds_used_in_process == NULL) + { + $user_defined_compounds_used_in_process = "Not Entered"; + } //$proposal_data->user_defined_compounds_used_in_process == NULL + else + { + $user_defined_compounds_used_in_process = $proposal_data->user_defined_compounds_used_in_process; + } + if ($proposal_data->user_defined_compound_filepath == "NULL") + { + $file_name = "File not uploaded"; + } //$proposal_data->user_defined_compound_filepath == NULL + else + { + $file_name = $params['dwsim_flowsheet_proposal_approved']['file_name']; + } + $message['headers'] = $params['dwsim_flowsheet_proposal_approved']['headers']; + $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Flowsheeting Project proposal has been completed', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, -Congratulations! Your DWSIM Flowsheet proposal with the below details has been approved: +You have completed your DWSIM Flowsheeting Project with the following details: Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->student_name . ' Email : ' . $user_data->mail . ' -Month and year of award of degree : ' . $proposal_data->month_year_of_degree . ' +Month and Year of Award of Degree : ' . $proposal_data->month_year_of_degree . ' University/Institute : ' . $proposal_data->university . ' -Project guide name : ' . $proposal_data->project_guide_name . ' -Project guide email : ' . $proposal_data->project_guide_email_id . ' City : ' . $proposal_data->city . ' State : ' . $proposal_data->state . ' Country : ' . $proposal_data->country . ' +Project Guide : ' . $proposal_data->project_guide_name . ' +Project Guide Email : ' . $proposal_data->project_guide_email_id . ' + +Project Title : ' . $proposal_data->project_title . ' + +Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . ' + +List of compounds from DWSIM Database used in process flowsheet : ' . $proposal_data->dwsim_database_compound_name . ' + +List of user defined compounds used in process flowsheet : ' . $user_defined_compounds_used_in_process . ' + +Uploaded user defined compound : ' . $file_name . ' -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 'dwsim_flowsheet_proposal_completed': - /* initializing data */ - $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(); - $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(' + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'dwsim_flowsheet_proposal_deleted': + /* initializing data */ + $query = db_select('dwsim_flowsheet_proposal'); + $query->fields('dwsim_flowsheet_proposal'); + $query->condition('id', $params['dwsim_flowsheet_proposal_deleted']['proposal_id']); + $query->range(0, 1); + $proposal_data = $query->execute()->fetchObject(); + $user_data = user_load($params['dwsim_flowsheet_proposal_deleted']['user_id']); + if ($proposal_data->user_defined_compounds_used_in_process == NULL) + { + $user_defined_compounds_used_in_process = "Not Entered"; + } //$proposal_data->user_defined_compounds_used_in_process == NULL + else + { + $user_defined_compounds_used_in_process = $proposal_data->user_defined_compounds_used_in_process; + } + if ($proposal_data->user_defined_compound_filepath == "NULL") + { + $file_name = "File not uploaded"; + } //$proposal_data->user_defined_compound_filepath == NULL + else + { + $file_name = $params['dwsim_flowsheet_proposal_approved']['file_name']; + } + $message['headers'] = $params['dwsim_flowsheet_proposal_deleted']['headers']; + $message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Flowsheeting Project proposal has been deleted', 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 : +Your DWSIM Flowsheeting Project proposal with the following details has been deleted : -Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->name . ' +Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->student_name . ' Email : ' . $user_data->mail . ' -Contact No. : ' . $proposal_data->contact_ph . ' -Department/Branch : ' . $proposal_data->department . ' +Month and Year of Award of Degree : ' . $proposal_data->month_year_of_degree . ' University/Institute : ' . $proposal_data->university . ' City : ' . $proposal_data->city . ' State : ' . $proposal_data->state . ' +Country : ' . $proposal_data->country . ' + +Project Guide : ' . $proposal_data->project_guide_name . ' +Project Guide Email : ' . $proposal_data->project_guide_email_id . ' +Project Title : ' . $proposal_data->project_title . ' -Solution Provided By : ' . $solution_provider_user . ' +Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . ' -List of experiments : ' . $experiment_list . ' +List of compounds from DWSIM Database used in process flowsheet : ' . $proposal_data->dwsim_database_compound_name . ' -Your Lab solution is now available at following link to download. +List of user defined compounds used in process flowsheet : ' . $user_defined_compounds_used_in_process . ' -http://dwsim.fossee.in/dwsim-flowsheet/dwsim-flowsheet-run/' . $proposal_data->id . ' +Uploaded user defined compound : ' . $file_name . ' -Now you should be able to propose a new DWSIM flowsheet. -Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/flowsheeting-project/coding-guidelines-flowsheeting +You can propose a new flowsheet project 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 '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(' + '!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: @@ -254,36 +408,36 @@ 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(' + '!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: @@ -299,23 +453,23 @@ 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(' + '!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: @@ -330,23 +484,23 @@ 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(' + '!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 : @@ -362,24 +516,24 @@ 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(' + '!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 : @@ -391,17 +545,17 @@ 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; - } - } + '!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; + } //$key +} diff --git a/manage_proposal.inc b/manage_proposal.inc index af36cf3..6a0faf9 100644 --- a/manage_proposal.inc +++ b/manage_proposal.inc @@ -103,16 +103,25 @@ function dwsim_flowsheet_proposal_all() $approval_status = 'Dis-approved'; break; case 3: - $approval_status = 'Solved'; + $approval_status = 'Completed'; break; default: $approval_status = 'Unknown'; break; } //$proposal_data->approval_status + if ($proposal_data->actual_completion_date == 0) + { + $actual_completion_date = "Not Completed"; + } //$proposal_data->actual_completion_date == 0 + else + { + $actual_completion_date = date('d-m-Y', $proposal_data->actual_completion_date); + } $proposal_rows[] = array( date('d-m-Y', $proposal_data->creation_date), l($proposal_data->student_name, 'user/' . $proposal_data->uid), $proposal_data->project_title, + $actual_completion_date, $approval_status, l('Status', 'flowsheeting-project/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'flowsheeting-project/manage-proposal/edit/' . $proposal_data->id) ); @@ -127,6 +136,7 @@ function dwsim_flowsheet_proposal_all() 'Date of Submission', 'Student Name', 'Title of the Lab', + 'Date of Completion', 'Status', 'Action' ); @@ -388,11 +398,11 @@ function dwsim_flowsheet_proposal_approval_form_submit($form, &$form_state) } //$form_state['values']['approval'] == 1 else if ($form_state['values']['approval'] == 2) { - $query = "UPDATE {dwsim_flowsheet_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, message = :message WHERE id = :proposal_id"; + $query = "UPDATE {dwsim_flowsheet_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, dissapproval_reason = :dissapproval_reason WHERE id = :proposal_id"; $args = array( ":uid" => $user->uid, ":date" => time(), - ":message" => $form_state['values']['message'], + ":dissapproval_reason" => $form_state['values']['message'], ":proposal_id" => $proposal_id ); $result = db_query($query, $args); @@ -402,9 +412,9 @@ function dwsim_flowsheet_proposal_approval_form_submit($form, &$form_state) $from = variable_get('dwsim_flowsheet_from_email', ''); $bcc = $user->mail . ', ' . variable_get('dwsim_flowsheet_emails', ''); $cc = variable_get('dwsim_flowsheet_cc_emails', ''); - $params['dwsim_flowsheetproposal_disapproved']['proposal_id'] = $proposal_id; - $params['dwsim_flowsheetproposal_disapproved']['user_id'] = $proposal_data->uid; - $params['dwsim_flowsheetproposal_disapproved']['headers'] = array( + $params['dwsim_flowsheet_proposal_disapproved']['proposal_id'] = $proposal_id; + $params['dwsim_flowsheet_proposal_disapproved']['user_id'] = $proposal_data->uid; + $params['dwsim_flowsheet_proposal_disapproved']['headers'] = array( 'From' => $from, 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', @@ -601,7 +611,7 @@ function dwsim_flowsheet_proposal_status_form($form, &$form_state) $form['completed'] = array( '#type' => 'checkbox', '#title' => t('Completed'), - '#description' => t('Check if user has provided all experiment solutions.') + '#description' => t('Check if user has provided all the required files and pdfs.') ); } //$proposal_data->approval_status == 1 if ($proposal_data->approval_status == 2) @@ -654,14 +664,14 @@ function dwsim_flowsheet_proposal_status_form_submit($form, &$form_state) /* set the book status to completed */ if ($form_state['values']['completed'] == 1) { - $up_query = "UPDATE dwsim_flowsheet_proposal SET approval_status = :approval_status , expected_completion_date = :expected_completion_date WHERE id = :proposal_id"; + $up_query = "UPDATE dwsim_flowsheet_proposal SET approval_status = :approval_status , actual_completion_date = :expected_completion_date WHERE id = :proposal_id"; $args = array( ":approval_status" => '3', ":proposal_id" => $proposal_id, ":expected_completion_date" => time() ); $result = db_query($up_query, $args); - CreateReadmeFileLabMigration($proposal_id); + CreateReadmeFileDWSIMFlowsheetingProject($proposal_id); if (!$result) { drupal_set_message('Error in update status', 'error'); @@ -873,10 +883,10 @@ function dwsim_flowsheet_proposal_edit_form($form, &$form_state) ) ); $form['project_title'] = array( - '#type' => 'textfield', + '#type' => 'textarea', '#title' => t('Title of the Flowsheet Project'), - '#size' => 30, - '#maxlength' => 50, + '#size' => 300, + '#maxlength' => 350, '#required' => TRUE, '#default_value' => $proposal_data->project_title ); @@ -952,69 +962,48 @@ function dwsim_flowsheet_proposal_edit_form_submit($form, &$form_state) /* delete proposal */ if ($form_state['values']['delete_proposal'] == 1) { + /* sending email */ + $email_to = $user->mail; + $from = variable_get('dwsim_flowsheet_from_email', ''); + $bcc = variable_get('dwsim_flowsheet_emails', ''); + $cc = variable_get('dwsim_flowsheet_cc_emails', ''); + $params['dwsim_flowsheet_proposal_deleted']['proposal_id'] = $proposal_id; + $params['dwsim_flowsheet_proposal_deleted']['user_id'] = $user->uid; + $params['dwsim_flowsheet_proposal_deleted']['file_name'] = $_FILES['files']['name'][$file_form_name]; + $params['dwsim_flowsheet_proposal_deleted']['headers'] = array( + 'From' => $from, + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer' => 'Drupal', + 'Cc' => $cc, + 'Bcc' => $bcc + ); + if (!drupal_mail('dwsim_flowsheet', 'dwsim_flowsheet_proposal_deleted', $email_to, user_preferred_language($user), $params, $from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + drupal_set_message(t('DWSIM Flowsheeting proposal has been deleted.'), 'status'); //db_query("DELETE FROM {dwsim_flowsheet_proposal} WHERE id = %d", $proposal_id); - $query = db_delete('dwsim_flowsheet_proposal'); - $query->condition('id', $proposal_id); - $num_deleted = $query->execute(); - //db_query("DELETE FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $proposal_id); - $query = db_delete('dwsim_flowsheet_experiment'); - $query->condition('proposal_id', $proposal_id); - $num_deleted = $query->execute(); - drupal_set_message(t('Proposal Delete'), 'status'); - drupal_goto('flowsheeting-project/manage-proposal'); - return; - } //$form_state['values']['delete_proposal'] == 1 - if ($form_state['values']['open_solution'] == 1) - { - // $query = "UPDATE {dwsim_flowsheet_proposal} SET solution_provider_uid = :solution_provider_uid, solution_status = :solution_status, solution_provider_name_title = '', solution_provider_name = '', solution_provider_contact_ph = '', solution_provider_department = '', solution_provider_university = '' WHERE id = :proposal_id"; - // $args= array( - // ":solution_provider_uid" => 0, - // ":solution_status" => 0, - // ":proposal_id" => $proposal_id, - // ); - // $result = db_query($query, $args); - $result = db_update('dwsim_flowsheet_proposal')->fields(array( - 'solution_provider_uid' => 0, - 'solution_status' => 0, - 'solution_provider_name_title' => '', - 'solution_provider_name' => '', - 'solution_provider_contact_ph' => '', - 'solution_provider_department' => '', - 'solution_provider_university' => '' - ))->condition('id', $proposal_id)->execute(); - if (!$result) + if (rrmdir_project($proposal_id) == TRUE) { - drupal_set_message(t('Solution already open for everyone.'), 'error'); + $query = db_delete('dwsim_flowsheet_proposal'); + $query->condition('id', $proposal_id); + $num_deleted = $query->execute(); + //db_query("DELETE FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $proposal_id); + $query = db_delete('dwsim_flowsheet_experiment'); + $query->condition('proposal_id', $proposal_id); + $num_deleted = $query->execute(); + drupal_set_message(t('Proposal Deleted'), 'status'); + drupal_goto('flowsheeting-project/manage-proposal'); return; - } //!$result - } //$form_state['values']['open_solution'] == 1 - $solution_display = 0; - if ($form_state['values']['solution_display'] == 1) - { - $solution_display = 1; - } //$form_state['values']['solution_display'] == 1 - else - { - $solution_display = 0; - } + } //rrmdir_project($proposal_id) == TRUE + } //$form_state['values']['delete_proposal'] == 1 /* update proposal */ $v = $form_state['values']; - //$query = "UPDATE {dwsim_flowsheet_proposal} SET name_title = :name_title, name = :name, contact_ph = :contact_ph, department = :department, university = :unversity, project_title = :project_title, solution_display = :solution_display WHERE id = :id"; - // $args= array( - // ":name_title" => $v['name_title'], - // ":name" => $v['student_name'], - // "contact_ph" => $v['contact_ph'], - // ":department" => $v['department'], - // ":university" => $v['university'], - // ":project_title" => $v['project_title'], - // ":solution_display" => $solution_display, - // ":id" => $proposal_id, - // ); $project_title = $v['project_title']; $proposar_name = $v['name_title'] . ' ' . $v['student_name']; $university = $v['university']; - $directory_names = _df_dir_name($project_title, $proposar_name, $university); - if (LM_RenameDir($proposal_id, $directory_names)) + $directory_names = _df_dir_name($project_title, $proposar_name); + if (DF_RenameDir($proposal_id, $directory_names)) { $directory_name = $directory_names; } //LM_RenameDir($proposal_id, $directory_names) @@ -1022,224 +1011,27 @@ function dwsim_flowsheet_proposal_edit_form_submit($form, &$form_state) { return; } - $query = db_update('dwsim_flowsheet_proposal')->fields(array( - 'name_title' => $v['name_title'], - 'student_name' => $v['student_name'], - 'department' => $v['department'], - 'university' => $v['university'], - 'city' => $v['city'], - 'pincode' => $v['pincode'], - 'state' => $v['all_state'], - 'project_title' => $v['project_title'], - 'solution_display' => $solution_display, - 'directory_name' => $directory_name - ))->condition('id', $proposal_id); - $result1 = $query->execute(); - //$result=db_query($query, $args); - /* updating existing experiments */ - $query = db_select('dwsim_flowsheet_experiment'); - $query->fields('dwsim_flowsheet_experiment'); - $query->condition('proposal_id', $proposal_id); - $query->orderBy('id', 'ASC'); - $experiment_q = $query->execute(); - for ($counter = 1; $counter <= 15; $counter++) - { - $experiment_data = $experiment_q->fetchObject(); - if ($experiment_data) - { - $experiment_field_name = 'lab_experiment_update' . $experiment_data->id; - $experiment_description = 'lab_experiment_description_update' . $experiment_data->id; - if (strlen(trim($form_state['values'][$experiment_field_name])) >= 1) - { - $query = "UPDATE {dwsim_flowsheet_experiment} SET title = :title, description= :description WHERE id = :id"; - $args = array( - ":title" => trim($form_state['values'][$experiment_field_name]), - ":description" => trim($form_state['values'][$experiment_description]), - ":id" => $experiment_data->id - ); - $result2 = db_query($query, $args); - if (!$result2) - { - drupal_set_message(t('Could not update Title of the Experiment : ') . trim($form_state['values'][$experiment_field_name]), 'error'); - } //!$result2 - } //strlen(trim($form_state['values'][$experiment_field_name])) >= 1 - else - { - $query = "DELETE FROM {dwsim_flowsheet_experiment} WHERE id = :id LIMIT 1"; - $args = array( - ":id" => $experiment_data->id - ); - $result3 = db_query($query, $args); - } - } //$experiment_data - } //$counter = 1; $counter <= 15; $counter++ - /* foreach ($form_state['values']['lab_experiment']['update'] as $update_id => $update_value) { - if (strlen(trim($update_value)) >= 1) { - $description= $form_state['values']['lab_experiment_description']['update']; - $query = "UPDATE {dwsim_flowsheet_experiment} SET title = :title and description=:description WHERE id = :id"; - $args = array( - ":title"=> trim($update_value), - ":description"=>trim($description), - ":id"=> $update_id, - ); - $result2 = db_query($query, $args); - if (!$result2) - { - drupal_set_message(t('Could not update Title of the Experiment : ') . trim($update_value), 'error'); - } - } else { - $query = "DELETE FROM {dwsim_flowsheet_experiment} WHERE id = :id LIMIT 1"; - $args = array( - ":id" => $update_id - ); - $result3 = db_query($query, $args); - } - }*/ - /* inserting new experiments */ - $query = db_select('dwsim_flowsheet_experiment'); - $query->fields('dwsim_flowsheet_experiment'); - $query->condition('proposal_id', $proposal_id); - $query->orderBy('number', 'DESC'); - $query->range(0, 1); - $number_q = $query->execute(); - if ($number_data = $number_q->fetchObject()) - { - $number = (int) $number_data->number; - $number++; - } //$number_data = $number_q->fetchObject() - else - { - $number = 1; - } - for ($counter = 1; $counter <= 15; $counter++) - { - $lab_experiment_insert = 'lab_experiment_insert' . $counter; - //var_dump($form_state['values'][$lab_experiment_insert]);die; - $lab_experiment_description_insert = 'lab_experiment_description_insert' . $counter; - if (!empty($form_state['values'][$lab_experiment_insert])) - { - //var_dump($form_state['values'][$lab_experiment_insert]);die; - $query = "INSERT INTO {dwsim_flowsheet_experiment} (proposal_id, number, title, description) VALUES (:proposal_id, :number, :title, :description)"; - $args = array( - ":proposal_id" => $proposal_id, - ":number" => $number, - ":title" => trim($form_state['values'][$lab_experiment_insert]), - ":description" => trim($form_state['values'][$lab_experiment_description_insert]) - ); - $result4 = db_query($query, $args); - if (!$result4) - { - drupal_set_message(t('Could not insert Title of the Experiment : ') . trim($form_state['values'][$lab_experiment_insert]), 'error'); - } //!$result4 - else - { - $number++; - } - } //!empty($form_state['values'][$lab_experiment_insert]) - } //$counter = 1; $counter <= 15; $counter++ - /* $query = db_select('dwsim_flowsheet_experiment'); - $query->fields('dwsim_flowsheet_experiment'); - $query->condition('proposal_id', $proposal_id); - $query->orderBy('number', 'DESC'); - $query->range(0, 1); - $number_q = $query->execute(); - if ($number_data = $number_q->fetchObject()) { - $number = (int)$number_data->number; - $number++; - } else { - $number = 1; - } - $insertvalue = array($insert_id => $insert_value); - $lab_experimentinsert = $form_state['values']['lab_experiment']['insert']; - $lab_exp_descriptioninsert=$form_state['values']['lab_experiment_description']['insert']; - if (is_array($lab_experimentinsert) || is_object($lab_experimentinsert)) - { - foreach ($lab_experimentinsert as $insertvalue) { - //foreach ($form_state['values']['lab_experiment']['insert'] as $insert_id => $insert_value) { - if (strlen(trim($insert_value)) >= 1) { - $query = "INSERT INTO {dwsim_flowsheet_experiment} (proposal_id, number, title, description) VALUES :proposal_id, :number, :title, :description"; + $query = "UPDATE dwsim_flowsheet_proposal SET + name_title=:name_title, + student_name=:student_name, + university=:university, + city=:city, + pincode=:pincode, + state=:state, + project_title=:project_title, + directory_name=:directory_name + WHERE id=:proposal_id"; $args = array( - ":proposal_id" => $proposal_id, - ":number" => $number, - ":title" => trim($insert_value), - ":description"=>"" + ':name_title' => $v['name_title'], + ':student_name' => $v['student_name'], + ':university' => $v['university'], + ':city' => $v['city'], + ':pincode' => $v['pincode'], + ':state' => $v['all_state'], + ':project_title' => $project_title, + ':directory_name' => $directory_name, + ':proposal_id' => $proposal_id ); - $result4 = db_query($query, $args); - if (!$result4) - { - drupal_set_message(t('Could not insert Title of the Experiment : ') . trim($insert_value), 'error'); - } else { - $number++; - } - } - } - }*/ + $result = db_query($query, $args); drupal_set_message(t('Proposal Updated'), 'status'); } -function CreateReadmeFileDWSIMFlowsheetingProject($proposal_id) -{ - $result = db_query(" - SELECT * from dwsim_flowsheet_proposal WHERE id = :proposal_id", array( - ":proposal_id" => $proposal_id - )); - $proposal_data = $result->fetchObject(); - $root_path = dwsim_flowsheet_path(); - $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!"); - $txt = ""; - $txt .= "About the lab"; - $txt .= "\n" . "\n"; - $txt .= "Title Of The Flowsheet Project: " . $proposal_data->project_title . "\n"; - $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->student_name . "\n"; - $txt .= "University: " . $proposal_data->university . "\n"; - $txt .= "\n" . "\n"; - $txt .= "DWSIM Flowsheet Project By FOSSEE, IIT Bombay" . "\n"; - fwrite($readme_file, $txt); - fclose($readme_file); - return $txt; -} -function DF_RenameDir($proposal_id, $dir_name) -{ - $proposal_id = $proposal_id; - $dir_name = $dir_name; - $query = db_query("SELECT directory_name,id FROM dwsim_flowsheet_proposal WHERE id = :proposal_id", array( - ':proposal_id' => $proposal_id - )); - $result = $query->fetchObject(); - if ($result != NULL) - { - $files = scandir(dwsim_flowsheet_path()); - $files_id_dir = dwsim_flowsheet_path() . $result->id; - //var_dump($files);die; - $file_dir = dwsim_flowsheet_path() . $result->directory_name; - if (is_dir($file_dir)) - { - $new_directory_name = rename(dwsim_flowsheet_path() . $result->directory_name, dwsim_flowsheet_path() . $dir_name); - return $new_directory_name; - } //is_dir($file_dir) - else if (is_dir($files_id_dir)) - { - $new_directory_name = rename(dwsim_flowsheet_path() . $result->id, dwsim_flowsheet_path() . $dir_name); - return $new_directory_name; - } //is_dir($files_id_dir) - else - { - drupal_set_message('Directory not available for rename.'); - return; - } - } //$result != NULL - else - { - drupal_set_message('Project names directory not present in databse'); - return; - } - //var_dump($files);die; - /* if ($files != NULL) - { - $new_directory_name = rename(dwsim_flowsheet_path() . $result->directory_name, dwsim_flowsheet_path() . $dir_name) or drupal_set_message("Unable to rename folder"); - } - else - { - $new_directory_name = 'Can not rename the directory. Directory not present'; - }*/ - return; -} diff --git a/proposal.inc b/proposal.inc index 4d94e8b..abc84f2 100755 --- a/proposal.inc +++ b/proposal.inc @@ -5,7 +5,7 @@ Approval Status : 0 - Pending 1 - Approved 2 - Dis-Approved -3 - Solved +3 - Completed Solution Status : 0 - Pending 1 - Approved @@ -206,7 +206,8 @@ function dwsim_flowsheet_proposal_form($form, &$form_state) '#required' => False, '#attributes' => array( 'placeholder' => 'Enter pincode....' - ) + ), + '#required' => TRUE ); /***************************************************************************/ $form['hr'] = array( @@ -260,10 +261,7 @@ Ex: Ethylene (74-85-1)[You can select multiple options by holding ctrl + left ke ); $form['ucompound'] = array( '#type' => 'checkbox', - '#title' => t('Upload user defind compound'), - '#options' => array( - "1" => "Upload user defind compound" - ) + '#title' => t('Upload user defind compound') ); $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array( '#type' => 'textarea', @@ -319,7 +317,7 @@ function dwsim_flowsheet_proposal_form_validate($form, &$form_state) { if ($form_state['values']['term_condition'] == '1') { - form_set_error('other_state', t('Enter state name')); + form_set_error('term_condition', t('Please check the terms and conditions')); // $form_state['values']['country'] = $form_state['values']['other_country']; } //$form_state['values']['term_condition'] == '1' if ($form_state['values']['country'] == 'Others') @@ -380,43 +378,46 @@ function dwsim_flowsheet_proposal_form_validate($form, &$form_state) if ($form_state['values']['dwsim_database_compound_name']) { $dwsim_database_compound_name = implode(", ", $_POST['dwsim_database_compound_name']); - $form_state['values']['dwsim_database_compound_name'] = $dwsim_database_compound_name; + $form_state['values']['dwsim_database_compound_name'] = trim($dwsim_database_compound_name); } //$form_state['values']['dwsim_database_compound_name'] - if (isset($_FILES['files'])) + if ($form_state['values']['ucompound'] == 1) { - /* check if atleast one source or result file is uploaded */ - if (!($_FILES['files']['name']['upload_user_compound'])) - form_set_error('upload_user_compound', t('Please upload sample code main or source file.')); - /* check for valid filename extensions */ - foreach ($_FILES['files']['name'] as $file_form_name => $file_name) + if (isset($_FILES['files'])) { - if ($file_name) + /* check if atleast one source or result file is uploaded */ + if (!($_FILES['files']['name']['upload_user_compound'])) + form_set_error('upload_user_compound', t('Please upload a file.')); + /* check for valid filename extensions */ + foreach ($_FILES['files']['name'] as $file_form_name => $file_name) { - /* checking file type */ - if (strstr($file_form_name, 'user_compound')) - $file_type = 'S'; - else - $file_type = 'U'; - $allowed_extensions_str = ''; - switch ($file_type) + if ($file_name) { - case 'S': - $allowed_extensions_str = variable_get('dwsim_flowsheet_user_defind_compound_source_extensions', ''); - break; - } //$file_type - $allowed_extensions = explode(',', $allowed_extensions_str); - $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name])); - $temp_extension = end($fnames); - if (!in_array($temp_extension, $allowed_extensions)) - form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.')); - if ($_FILES['files']['size'][$file_form_name] <= 0) - form_set_error($file_form_name, t('File size cannot be zero.')); - /* check if valid file name */ - if (!textbook_companion_check_valid_filename($_FILES['files']['name'][$file_form_name])) - form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.')); - } //$file_name - } //$_FILES['files']['name'] as $file_form_name => $file_name - } //isset($_FILES['files']) + /* checking file type */ + if (strstr($file_form_name, 'user_compound')) + $file_type = 'S'; + else + $file_type = 'U'; + $allowed_extensions_str = ''; + switch ($file_type) + { + case 'S': + $allowed_extensions_str = variable_get('dwsim_flowsheet_user_defind_compound_source_extensions', ''); + break; + } //$file_type + $allowed_extensions = explode(',', $allowed_extensions_str); + $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name])); + $temp_extension = end($fnames); + if (!in_array($temp_extension, $allowed_extensions)) + form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.')); + if ($_FILES['files']['size'][$file_form_name] <= 0) + form_set_error($file_form_name, t('File size cannot be zero.')); + /* check if valid file name */ + if (!textbook_companion_check_valid_filename($_FILES['files']['name'][$file_form_name])) + form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.')); + } //$file_name + } //$_FILES['files']['name'] as $file_form_name => $file_name + } //isset($_FILES['files']) + } //$form_state['values']['ucompound'] == 1 return; } function dwsim_flowsheet_proposal_form_submit($form, &$form_state) @@ -429,15 +430,15 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) } //!$user->uid if ($form_state['values']['version'] == 'Old version') { - $form_state['values']['version'] = $form_state['values']['older']; + $form_state['values']['version'] = trim($form_state['values']['older']); } //$form_state['values']['version'] == 'Old version' /* inserting the user proposal */ $v = $form_state["values"]; - $project_title = $v['project_title']; + $project_title = trim($v['project_title']); $proposar_name = $v['name_title'] . ' ' . $v['student_name']; $university = $v['university']; $month_year_of_degree = $v['month_year_of_degree']; - $directory_name = _df_dir_name($project_title); + $directory_name = _df_dir_name($project_title, $proposar_name); $result = "INSERT INTO {dwsim_flowsheet_proposal} ( uid, @@ -493,7 +494,7 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) ":uid" => $user->uid, ":approver_uid" => 0, ":name_title" => $v['name_title'], - ":student_name" => _df_sentence_case($v['student_name']), + ":student_name" => _df_sentence_case(trim($v['student_name'])), ":month_year_of_degree" => $month_year_of_degree, ":university" => _df_sentence_case($v['university']), ":city" => $v['city'], @@ -502,11 +503,11 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) ":country" => $v['country'], ":version" => $v['version'], ":project_guide_name" => _df_sentence_case($v['project_guide_name']), - ":project_guide_email_id" => $v['project_guide_email_id'], - ":project_title" => _df_dir_name($v['project_title']), + ":project_guide_email_id" => trim($v['project_guide_email_id']), + ":project_title" => _df_sentence_case($v['project_title']), ":process_development_compound_name" => _df_sentence_case($v['process_development_compound_name']), - ":dwsim_database_compound_name" => $v['dwsim_database_compound_name'], - ":user_defined_compounds_used_in_process" => _df_sentence_case($v['user_defined_compounds_used_in_process_flowsheetcompound_name']), + ":dwsim_database_compound_name" => trim($v['dwsim_database_compound_name']), + ":user_defined_compounds_used_in_process" => _df_sentence_case(trim($v['user_defined_compounds_used_in_process_flowsheetcompound_name'])), ":approval_status" => 0, ":dissapproval_reason" => "NULL", ":creation_date" => time(), @@ -518,43 +519,49 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) $proposal_id = db_query($result, $args, array( 'return' => Database::RETURN_INSERT_ID )); - $root_path = dwsim_flowsheet_document_path(); - $dest_path1 = $directory_name . '/'; - $dest_path = $dest_path1 . 'user_defined_compound/'; - $db_path = 'user_defined_compound/'; - if (!is_dir($root_path . $dest_path1)) - mkdir($root_path . $dest_path1); - if (!is_dir($root_path . $dest_path)) - mkdir($root_path . $dest_path); - /* uploading files */ - foreach ($_FILES['files']['name'] as $file_form_name => $file_name) + if ($form_state['values']['ucompound'] == 1) { - if ($file_name) + $root_path = dwsim_flowsheet_document_path(); + $dest_path1 = $directory_name . '/'; + $dest_path2 = 'user_defined_compound/'; + $dest_path = $dest_path1 . 'user_defined_compound/'; + $db_path = 'user_defined_compound/'; + if (!is_dir($root_path . $dest_path1)) + mkdir($root_path . $dest_path1); + if (!is_dir($root_path . $dest_path)) + mkdir($root_path . $dest_path); + /* uploading files */ + foreach ($_FILES['files']['name'] as $file_form_name => $file_name) { - /* checking file type */ - $file_type = 'S'; - if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) - { - // drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name'][$file_form_name])), 'error'); - unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]); - } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]) - /* uploading file */ - if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) - { - $query = "UPDATE {dwsim_flowsheet_proposal} SET user_defined_compound_filepath = :user_defined_compound_filepath WHERE id = :id"; - $args = array( - ":user_defined_compound_filepath" => $dest_path . $_FILES['files']['name'][$file_form_name], - ":id" => $proposal_id - ); - $updateresult = db_query($query, $args); - drupal_set_message($file_name . ' uploaded successfully.', 'status'); - } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]) - else + if ($file_name) { - drupal_set_message('Error uploading file : ' . $db_path . '/' . $file_name, 'error'); - } - } //$file_name - } //$_FILES['files']['name'] as $file_form_name => $file_name + /* checking file type */ + $file_type = 'S'; + if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) + { + // drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name'][$file_form_name])), 'error'); + unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]); + } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]) + /* uploading file */ + if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) + { + $query = "UPDATE {dwsim_flowsheet_proposal} SET user_defined_compound_filepath = :user_defined_compound_filepath WHERE id = :id"; + $args = array( + ":user_defined_compound_filepath" => $dest_path2 . $_FILES['files']['name'][$file_form_name], + ":id" => $proposal_id + ); + $updateresult = db_query($query, $args); + drupal_set_message($file_name . ' uploaded successfully.', 'status'); + } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]) + else + { + drupal_set_message('Error uploading file : ' . $db_path . '/' . $file_name, 'error'); + } + } //$file_name + } //$_FILES['files']['name'] as $file_form_name => $file_name + }else{ + $file_name = "Not Uploaded"; + } if (!$proposal_id) { drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error'); @@ -578,6 +585,6 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) ); if (!drupal_mail('dwsim_flowsheet', 'dwsim_flowsheet_proposal_received', $email_to, user_preferred_language($user), $params, $from, TRUE)) drupal_set_message('Error sending email message.', 'error'); - drupal_set_message(t('We have received you DWSIM Chemical Process Flowsheeting proposal. We will get back to you soon.'), 'status'); + drupal_set_message(t('We have received your DWSIM Flowsheeting proposal. We will get back to you soon.'), 'status'); drupal_goto(''); } |