From cbab3b0fef4c6cd1e163ab24eba1c2c4c0f64e5d Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Fri, 22 Mar 2019 11:20:35 +0530 Subject: Modify the mandatory fields in proposal form --- proposal.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposal.inc b/proposal.inc index af5fcd0..69c779f 100755 --- a/proposal.inc +++ b/proposal.inc @@ -225,7 +225,7 @@ function lab_migration_proposal_form($form, &$form_state) $first_experiemnt = TRUE; for ($counter = 1; $counter <= 15; $counter++) { - if ($counter <= 5) + if ($counter <= 1) { $form['lab_experiment-' . $counter] = array( '#type' => 'textfield', -- cgit From 1144614e0162f2ff26c9127ff8b6d10132d77821 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Wed, 27 Mar 2019 11:22:00 +0530 Subject: Fix issue to upload and delete solution --- bulk_approval.inc | 13 +- general_deletion.inc | 499 +++++++++++++++++++++++-------------------------- upload_code.inc | 2 +- upload_code_delete.inc | 1 + 4 files changed, 248 insertions(+), 267 deletions(-) diff --git a/bulk_approval.inc b/bulk_approval.inc index 39ac9c2..8afa5bc 100755 --- a/bulk_approval.inc +++ b/bulk_approval.inc @@ -574,11 +574,14 @@ FOSSEE,IIT Bombay', array( if (lab_migration_delete_lab($form_state['values']['lab'])) { drupal_set_message(t('Dis-Approved and Deleted Entire Lab solutions.'), 'status'); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $form_state['values']['lab']); - $experiment_q = $query->execute()->fetchObject(); - $dir_path = $root_path . $experiment_q->directory_name; + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $form_state['values']['lab']); + $experiment_q = $query->execute(); + $experiment_data = $experiment_q->fetchObject(); + //var_dump($experiment_q);die; + $dir_path = $root_path . $experiment_data->directory_name; + //var_dump($experiment_data->directory_name);die; if (is_dir($dir_path)) { $res = rmdir($dir_path); diff --git a/general_deletion.inc b/general_deletion.inc index 2125732..33ac98a 100755 --- a/general_deletion.inc +++ b/general_deletion.inc @@ -1,13 +1,14 @@ fields('lab_migration_solution'); $query->condition('id', $solution_id); @@ -18,284 +19,260 @@ function lab_migration_delete_solution($solution_id) drupal_set_message(t('Invalid solution.'), 'error'); return FALSE; } - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $solution_data->experiment_id); - $experiment_q = db_query("SELECT lme.*, lmp.id, lmp.directory_name FROM lab_migration_experiment lme JOIN lab_migration_proposal lmp WHERE lmp.id = lme.proposal_id AND lme.id = :experiment_id",array(':experiment_id' => $solution_data->experiment_id)); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('id', $solution_data->experiment_id); + $experiment_q = $query->execute(); $experiment_data = $experiment_q->fetchObject(); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $experiment_data->proposal_id); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); if (!$experiment_data) - { + { drupal_set_message(t('Invalid experiment.'), 'error'); return FALSE; - } - /* deleting solution files */ - //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_id); - $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array(':solution_id' => $solution_id)); - /*$query = db_select('lab_migration_solution_files'); - $query->fields('lab_migration_solution_files'); - $query->condition('solution_id', $solution_id); - $solution_files_q = $query->execute();*/ - while ($solution_files_data = $solution_files_q->fetchObject()) - { - if (!file_exists($root_path .$solution_files_data->directory_name. '/'. $solution_files_data->filepath)) - { - $status = FALSE; - drupal_set_message(t('Error deleting !file. File does not exists.', array( - '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath - )), 'error'); - continue; - } - /* removing solution file */ - if (!unlink($root_path . $solution_files_data->directory_name. '/'. $solution_files_data->filepath)) - { - $status = FALSE; - drupal_set_message(t('Error deleting !file', array( - '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath - )), 'error'); - /* sending email to admins */ - $email_to = variable_get('lab_migration_emails', ''); - $from = variable_get('lab_migration_from_email', ''); - $bcc = ""; - $cc = variable_get('lab_migration_cc_emails', ''); - $param['standard']['subject'] = "[ERROR] Error deleting example file"; - $param['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " : + } + + /* deleting solution files */ + //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_id); + $query = db_select('lab_migration_solution_files'); + $query->fields('lab_migration_solution_files'); + $query->condition('solution_id', $solution_id); + $solution_files_q = $query->execute(); + while ($solution_files_data = $solution_files_q->fetchObject()) + { + //var_dump($root_path . $solution_files_data->filepath);die; + $ex_path = $proposal_data->directory_name . '/' . $solution_files_data->filepath; + $dir_path = $root_path . $ex_path; + //var_dump($dir_path);die; + if (!file_exists($dir_path)) + { + $status = FALSE; + drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $dir_path)), 'error'); + continue; + } + /*if (!file_exists($root_path . $solution_files_data->pdfpath)) + { + $status = FALSE; + drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $solution_files_data->pdfpath)), 'error'); + continue; + }*/ + + /* Removing PDF File*/ + $PdfStatus=""; + if(strlen($solution_files_data->pdfpath)>=4){ + if (!unlink($root_path . $solution_files_data->pdfpath)){ + drupal_set_message(t('Error deleting !file', array('!file' => $solution_files_data->pdfpath)), 'error'); + } + $PdfStatus=$solution_files_data->pdfpath; + }else{ + $PdfStatus="PDF not uploaded"; + } + + /* removing solution file */ + if (!unlink($dir_path)) + { + + $status = FALSE; + drupal_set_message(t('Error deleting !file', array('!file' => $dir_path)), 'error'); + + /* sending email to admins */ + $email_to = variable_get('lab_migration_emails', ''); + + $from = variable_get('lab_migration_from_email', ''); + $bcc=""; + $cc=variable_get('lab_migration_cc_emails', ''); + + $param['standard']['subject'] = "[ERROR] Error deleting example file"; + $param['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " : solution id : " . $solution_id . " - file id : " . $solution_files_data->id . " - file path : " . $solution_files_data->directory_name. '/'. $solution_files_data->filepath . " - PDF path : " . $PdfStatus; - $param['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + file id : " . $solution_files_data->id . " + file path : " . $solution_files_data->filepath." + PDF path : " . $PdfStatus; + $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', + 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - } - else - { - /* deleting example files database entries */ - db_delete('lab_migration_solution_files')->condition('id', $solution_files_data->id)->execute(); - } - } - if (!$status) - return FALSE; - /* removing code folder */ - $ex_path = $experiment_data->directory_name . '/EXP' . $experiment_data->number . '/CODE' . $solution_data->code_number; - $dir_path = $root_path . $ex_path; - if (is_dir($dir_path)) - { - if (!rmdir($dir_path)) - { - drupal_set_message(t('Error deleting folder !folder', array( - '!folder' => $dir_path - )), 'error'); - /* sending email to admins */ - $email_to = variable_get('lab_migration_emails', ''); - $from = variable_get('lab_migration_from_email', ''); - $bcc = ""; - $cc = variable_get('lab_migration_cc_emails', ''); - $param['standard']['subject'] = "[ERROR] Error deleting folder"; - $param['standard']['body'] = "Error deleting folder " . $dir_path . " by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - $param['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); + + if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + } else { + /* deleting example files database entries */ + + db_delete('lab_migration_solution_files') + ->condition('id', $solution_files_data->id) + ->execute(); + } + } + + if (!$status) + return FALSE; + + /* removing code folder */ + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $experiment_data->proposal_id); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + $ex_path = $proposal_data->directory_name . '/' . $solution_files_data->filepath; + $dir_path = $root_path . $ex_path; + if (is_dir($dir_path)) + { + if (!rmdir($dir_path)) + { + drupal_set_message(t('Error deleting folder !folder', array('!folder' => $dir_path)), 'error'); + + /* sending email to admins */ + $email_to = variable_get('lab_migration_emails', ''); + $from = variable_get('lab_migration_from_email', ''); + $bcc=""; + $cc=variable_get('lab_migration_cc_emails', ''); + + + $param['standard']['subject'] = "[ERROR] Error deleting folder"; + $param['standard']['body'] = "Error deleting folder " . $dir_path . " by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', + 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - return FALSE; - } - } - else - { - drupal_set_message(t('Cannot delete solution folder. !folder does not exists.', array( - '!folder' => $dir_path - )), 'error'); - return FALSE; - } - /* deleting solution dependency and solution database entries */ - db_delete('lab_migration_solution_dependency')->condition('solution_id', $solution_id)->execute(); - db_delete('lab_migration_solution')->condition('id', $solution_id)->execute(); - return $status; + 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); + + + if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + return FALSE; + } + } else { + drupal_set_message(t('Cannot delete solution folder. !folder does not exists.', array('!folder' => $dir_path)), 'error'); + return FALSE; } + + /* deleting solution dependency and solution database entries */ + db_delete('lab_migration_solution_dependency')->condition('solution_id', $solution_id)->execute(); + + db_delete('lab_migration_solution')->condition('id', $solution_id)->execute(); + + return $status; +} + function lab_migration_delete_experiment($experiment_id) +{ + $status = TRUE; + $root_path = lab_migration_path(); + + //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $experiment_id); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('id', $experiment_id); + $experiment_q = $query->execute(); + $experiment_data = $experiment_q->fetchObject(); + if (!$experiment_data) { - $status = TRUE; - $root_path = lab_migration_path(); - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $experiment_id); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('id', $experiment_id); - $experiment_q = $query->execute(); - $experiment_data = $experiment_q->fetchObject(); - if (!$experiment_data) - { - drupal_set_message('Invalid experiment.', 'error'); - return FALSE; - } - /* deleting solutions */ - //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d", $experiment_id); - $query = db_select('lab_migration_solution'); - $query->fields('lab_migration_solution'); - $query->condition('experiment_id', $experiment_id); - $solution_q = $query->execute(); - $delete_exp_folder = FALSE; - while ($solution_data = $solution_q->fetchObject()) - { - $delete_exp_folder = TRUE; - if (!lab_migration_delete_solution($solution_data->id)) - $status = FALSE; - } - if (!$delete_exp_folder) - { - return TRUE; - } - if ($status) - { - $dir_path = $root_path . $experiment_data->directory_name . '/EXP' . $experiment_data->number; - if (is_dir($dir_path)) - { - $res = rmdir($dir_path); - if (!$res) - { - drupal_set_message(t('Error deleting experiment folder !folder', array( - '!folder' => $dir_path - )), 'error'); - /* sending email to admins */ - $email_to = variable_get('lab_migration_emails', ''); - $from = variable_get('lab_migration_from_email', ''); - $bcc = ""; - $cc = variable_get('lab_migration_cc_emails', ''); - $param['standard']['subject'] = "[ERROR] Error deleting experiment folder"; - $param['standard']['body'] = "Error deleting folder " . $dir_path; - $param['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - return FALSE; - } - else - { - return TRUE; - } - } - else - { - drupal_set_message(t('Cannot delete experiment folder. !folder does not exists.', array( - '!folder' => $dir_path - )), 'error'); - return FALSE; - } - } + drupal_set_message('Invalid experiment.', 'error'); return FALSE; } -function lab_migration_delete_lab($lab_id) + + /* deleting solutions */ + //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d", $experiment_id); + $query = db_select('lab_migration_solution'); + $query->fields('lab_migration_solution'); + $query->condition('experiment_id', $experiment_id); + $solution_q = $query->execute(); + + $delete_exp_folder = FALSE; + while ($solution_data = $solution_q->fetchObject()) { - $status = TRUE; - $root_path = lab_migration_path(); - //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $lab_id); - $query = db_select('lab_migration_proposal'); - $query->fields('lab_migration_proposal'); - $query->condition('id', $lab_id); - $proposal_q = $query->execute(); - $proposal_data = $proposal_q->fetchObject(); - if (!$proposal_data) - { - drupal_set_message('Invalid Lab.', 'error'); - return FALSE; - } - /* delete experiments */ - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $proposal_data->id); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $proposal_data->id); - $experiment_q = $query->execute(); - while ($experiment_data = $experiment_q->fetchObject()) - { - if (!lab_migration_delete_experiment($experiment_data->id)) - { - $status = FALSE; - } - } - return $status; + $delete_exp_folder = TRUE; + if (!lab_migration_delete_solution($solution_data->id)) + $status = FALSE; } -function lab_migration_del_lab_pdf($lab_id) + + if (!$delete_exp_folder) { - $root_path = lab_migration_path(); - $dir_path = $root_path . "latex/"; - $pdf_filename = "lab_" . $lab_id . ".pdf"; - if (file_exists($dir_path . $pdf_filename)) - unlink($dir_path . $pdf_filename); + return TRUE; } -function lab_migration_delete_dependency($dependency_id) + + if ($status) { - global $user; - $root_path = lab_migration_path(); - $status = TRUE; - //$dependency_files_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d", $dependency_id); - $query = db_select('lab_migration_dependency_files'); - $query->fields('lab_migration_dependency_files'); - $query->condition('id', $dependency_id); - $dependency_files_q = $query->execute(); - $dependency_files_data = $dependency_files_q->fetchObject(); - if (!$dependency_files_data) - { - drupal_set_message(t('Invalid dependency.'), 'error'); - return FALSE; - } - if (!file_exists($root_path . $dependency_files_data->filepath)) - { - drupal_set_message(t('Error deleting !file. File does not exists.', array( - '!file' => $dependency_files_data->filepath - )), 'error'); - return FALSE; - } - /* removing dependency file */ - if (!unlink($root_path . $dependency_files_data->filepath)) + $dir_path = $root_path . $experiment_data->proposal_id . '/EXP' . $experiment_data->number; + + if (is_dir($dir_path)) + { + $res = rmdir($dir_path); + if (!$res) { - $status = FALSE; - drupal_set_message(t('Error deleting !file', array( - '!file' => $dependency_files_data->filepath - )), 'error'); + drupal_set_message(t('Error deleting experiment folder !folder', array('!folder' => $dir_path)), 'error'); + /* sending email to admins */ $email_to = variable_get('lab_migration_emails', ''); - $from = variable_get('lab_migration_from_email', ''); - $bcc = ""; - $cc = variable_get('lab_migration_cc_emails', ''); - $param['standard']['subject'] = "[ERROR] Error deleting dependency file"; - $param['standard']['body'] = "Error deleting dependency files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " : - dependency id : " . $dependency_id . " - file id : " . $dependency_files_data->id . " - file path : " . $dependency_files_data->filepath; - $param['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - } - else - { - /* deleting dependency files database entries */ - db_delete('lab_migration_dependency_files')->condition('id', $dependency_id)->execute(); + + $from = variable_get('lab_migration_from_email', ''); + $bcc=""; + $cc=variable_get('lab_migration_cc_emails', ''); + + + $param['standard']['subject'] = "[ERROR] Error deleting experiment folder"; + $param['standard']['body'] = "Error deleting folder " . $dir_path; + $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', + 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); + if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param,$from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + return FALSE; + } else { + return TRUE; } - return $status; + } else { + drupal_set_message(t('Cannot delete experiment folder. !folder does not exists.', array('!folder' => $dir_path)), 'error'); + return FALSE; + } + } + return FALSE; +} + +function lab_migration_delete_lab($lab_id) +{ + $status = TRUE; + $root_path = lab_migration_path(); + + //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $lab_id); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $lab_id); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + if (!$proposal_data) + { + drupal_set_message('Invalid Lab.', 'error'); + return FALSE; } + + /* delete experiments */ + //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $proposal_data->id); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $proposal_data->id); + $experiment_q = $query->execute(); + + + while ($experiment_data = $experiment_q->fetchObject()) + { + if (!lab_migration_delete_experiment($experiment_data->id)) + { + $status = FALSE; + } + } + return $status; +} + +function lab_migration_del_lab_pdf($lab_id) +{ + $root_path = lab_migration_path(); + $dir_path = $root_path . "latex/"; + $pdf_filename = "lab_" . $lab_id . ".pdf"; + if (file_exists($dir_path . $pdf_filename)) + unlink($dir_path . $pdf_filename); +} + diff --git a/upload_code.inc b/upload_code.inc index bced2f5..be5bb59 100755 --- a/upload_code.inc +++ b/upload_code.inc @@ -503,7 +503,7 @@ function lab_migration_upload_code_form_submit($form, &$form_state) { /* creating file path */ $file_path = 'EXP' . $experiment_data->number . '/' . 'CODE' . $experiment_data->number . '.' . $form_state['values']['code_number'] . '/'; /* creating solution database entry */ - $query = "INSERT INTO {lab_migration_solution} (experiment_id, approver_uid, code_number, caption, approval_date, approval_status, timestamp, os_used, dwsim_version, toolbox_used) VALUES (:experiment_id, :approver_uid, :code_number, :caption, :approval_date, :approval_status, :timestamp, :os_used, :dwsim_version, :toolbox_used)"; + $query = "INSERT INTO {lab_migration_solution} (experiment_id, approver_uid, code_number, caption, approval_date, approval_status, timestamp, os_used, version, toolbox_used) VALUES (:experiment_id, :approver_uid, :code_number, :caption, :approval_date, :approval_status, :timestamp, :os_used, :dwsim_version, :toolbox_used)"; $args = array( ":experiment_id" => $experiment_id, ":approver_uid" => 0, diff --git a/upload_code_delete.inc b/upload_code_delete.inc index 0c63e5f..25ac329 100755 --- a/upload_code_delete.inc +++ b/upload_code_delete.inc @@ -9,6 +9,7 @@ function lab_migration_upload_code_delete() global $user; $root_path = lab_migration_path(); + //var_dump($root_path);die; $solution_id = (int)arg(3); /* check solution */ -- cgit From b32025aca1b725d36cce18a66f28409c8924f0cb Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Wed, 27 Mar 2019 11:51:31 +0530 Subject: Update column name in db query --- upload_code.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload_code.inc b/upload_code.inc index be5bb59..bced2f5 100755 --- a/upload_code.inc +++ b/upload_code.inc @@ -503,7 +503,7 @@ function lab_migration_upload_code_form_submit($form, &$form_state) { /* creating file path */ $file_path = 'EXP' . $experiment_data->number . '/' . 'CODE' . $experiment_data->number . '.' . $form_state['values']['code_number'] . '/'; /* creating solution database entry */ - $query = "INSERT INTO {lab_migration_solution} (experiment_id, approver_uid, code_number, caption, approval_date, approval_status, timestamp, os_used, version, toolbox_used) VALUES (:experiment_id, :approver_uid, :code_number, :caption, :approval_date, :approval_status, :timestamp, :os_used, :dwsim_version, :toolbox_used)"; + $query = "INSERT INTO {lab_migration_solution} (experiment_id, approver_uid, code_number, caption, approval_date, approval_status, timestamp, os_used, dwsim_version, toolbox_used) VALUES (:experiment_id, :approver_uid, :code_number, :caption, :approval_date, :approval_status, :timestamp, :os_used, :dwsim_version, :toolbox_used)"; $args = array( ":experiment_id" => $experiment_id, ":approver_uid" => 0, -- cgit From 9afb9aed90606594d73cc9958b886f3a7abb07b7 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Wed, 27 Mar 2019 15:37:57 +0530 Subject: Fix issue to disapprove the entire lab --- bulk_approval.inc | 31 ++++++++++++++++++++++++++++--- general_deletion.inc | 14 +++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/bulk_approval.inc b/bulk_approval.inc index 8afa5bc..0ec220a 100755 --- a/bulk_approval.inc +++ b/bulk_approval.inc @@ -489,6 +489,27 @@ FOSSEE,IIT Bombay', array( } elseif (($form_state['values']['lab_actions'] == 3) && ($form_state['values']['lab_experiment_actions'] == 0) && ($form_state['values']['lab_experiment_solution_actions'] == 0)) { + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $form_state['values']['lab']); + $proposal_q = $query->execute()->fetchObject(); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $form_state['values']['lab']); + $experiment_q = $query->execute(); + $experiment_data = $experiment_q->fetchObject(); + $exp_path = $root_path . $proposal_q->directory_name . '/EXP' . $experiment_data->number; + //$dir_path = $root_path . $proposal_q->directory_name; + if (is_dir($dir_path)) + { + //rmdir($exp_path); + $res = rmdir($exp_path); + if (!$res) + { + drupal_set_message(t("Cannot delete Lab directory : " . $dir_path . ". Please contact administrator."), 'error'); + return; + } + } if (strlen(trim($form_state['values']['message'])) <= 30) { form_set_error('message', t('')); @@ -577,13 +598,17 @@ FOSSEE,IIT Bombay', array( $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); $query->condition('id', $form_state['values']['lab']); + $proposal_q = $query->execute()->fetchObject(); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $form_state['values']['lab']); $experiment_q = $query->execute(); $experiment_data = $experiment_q->fetchObject(); - //var_dump($experiment_q);die; - $dir_path = $root_path . $experiment_data->directory_name; - //var_dump($experiment_data->directory_name);die; + $exp_path = $root_path . $proposal_q->directory_name . '/EXP' . $experiment_data->number; + $dir_path = $root_path . $proposal_q->directory_name; if (is_dir($dir_path)) { + rmdir($exp_path); $res = rmdir($dir_path); if (!$res) { diff --git a/general_deletion.inc b/general_deletion.inc index 33ac98a..1121ef5 100755 --- a/general_deletion.inc +++ b/general_deletion.inc @@ -116,8 +116,10 @@ function lab_migration_delete_solution($solution_id) $query->condition('id', $experiment_data->proposal_id); $proposal_q = $query->execute(); $proposal_data = $proposal_q->fetchObject(); - $ex_path = $proposal_data->directory_name . '/' . $solution_files_data->filepath; - $dir_path = $root_path . $ex_path; + //$ex_path = $proposal_data->directory_name . '/' . $solution_files_data->filepath; + //$dir_path = $root_path . $ex_path; + $dir_path = $root_path . $proposal_data->directory_name . '/EXP' . $experiment_data->number . '/CODE' . $solution_data->code_number; + //var_dump($dir_path);die; if (is_dir($dir_path)) { if (!rmdir($dir_path)) @@ -167,6 +169,12 @@ function lab_migration_delete_experiment($experiment_id) $query->condition('id', $experiment_id); $experiment_q = $query->execute(); $experiment_data = $experiment_q->fetchObject(); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $form_state['values']['lab']); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + if (!$experiment_data) { drupal_set_message('Invalid experiment.', 'error'); @@ -195,7 +203,7 @@ function lab_migration_delete_experiment($experiment_id) if ($status) { - $dir_path = $root_path . $experiment_data->proposal_id . '/EXP' . $experiment_data->number; + $dir_path = $root_path . $proposal_data->directory_name . '/EXP' . $experiment_data->number; if (is_dir($dir_path)) { -- cgit From 1d738976fe5129c3b597a546c17818a4fc585a06 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Wed, 27 Mar 2019 16:12:57 +0530 Subject: Modify path to the lab directory to disapprove and delete the solution files --- bulk_approval.inc | 22 +------------------- general_deletion.inc | 59 +++++++++++++++++++--------------------------------- 2 files changed, 22 insertions(+), 59 deletions(-) diff --git a/bulk_approval.inc b/bulk_approval.inc index 0ec220a..3cf7239 100755 --- a/bulk_approval.inc +++ b/bulk_approval.inc @@ -489,27 +489,7 @@ FOSSEE,IIT Bombay', array( } elseif (($form_state['values']['lab_actions'] == 3) && ($form_state['values']['lab_experiment_actions'] == 0) && ($form_state['values']['lab_experiment_solution_actions'] == 0)) { - $query = db_select('lab_migration_proposal'); - $query->fields('lab_migration_proposal'); - $query->condition('id', $form_state['values']['lab']); - $proposal_q = $query->execute()->fetchObject(); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $form_state['values']['lab']); - $experiment_q = $query->execute(); - $experiment_data = $experiment_q->fetchObject(); - $exp_path = $root_path . $proposal_q->directory_name . '/EXP' . $experiment_data->number; - //$dir_path = $root_path . $proposal_q->directory_name; - if (is_dir($dir_path)) - { - //rmdir($exp_path); - $res = rmdir($exp_path); - if (!$res) - { - drupal_set_message(t("Cannot delete Lab directory : " . $dir_path . ". Please contact administrator."), 'error'); - return; - } - } + if (strlen(trim($form_state['values']['message'])) <= 30) { form_set_error('message', t('')); diff --git a/general_deletion.inc b/general_deletion.inc index 1121ef5..d33a2e1 100755 --- a/general_deletion.inc +++ b/general_deletion.inc @@ -53,24 +53,6 @@ function lab_migration_delete_solution($solution_id) drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $dir_path)), 'error'); continue; } - /*if (!file_exists($root_path . $solution_files_data->pdfpath)) - { - $status = FALSE; - drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $solution_files_data->pdfpath)), 'error'); - continue; - }*/ - - /* Removing PDF File*/ - $PdfStatus=""; - if(strlen($solution_files_data->pdfpath)>=4){ - if (!unlink($root_path . $solution_files_data->pdfpath)){ - drupal_set_message(t('Error deleting !file', array('!file' => $solution_files_data->pdfpath)), 'error'); - } - $PdfStatus=$solution_files_data->pdfpath; - }else{ - $PdfStatus="PDF not uploaded"; - } - /* removing solution file */ if (!unlink($dir_path)) { @@ -109,15 +91,26 @@ function lab_migration_delete_solution($solution_id) if (!$status) return FALSE; - - /* removing code folder */ - $query = db_select('lab_migration_proposal'); - $query->fields('lab_migration_proposal'); - $query->condition('id', $experiment_data->proposal_id); - $proposal_q = $query->execute(); - $proposal_data = $proposal_q->fetchObject(); - //$ex_path = $proposal_data->directory_name . '/' . $solution_files_data->filepath; - //$dir_path = $root_path . $ex_path; +$query = db_select('lab_migration_solution'); + $query->fields('lab_migration_solution'); + $query->condition('id', $solution_id); + $solution_q = $query->execute(); + $solution_data = $solution_q->fetchObject(); + if (!$solution_data) + { + drupal_set_message(t('Invalid solution.'), 'error'); + return FALSE; + } + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('id', $solution_data->experiment_id); + $experiment_q = $query->execute(); + $experiment_data = $experiment_q->fetchObject(); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $experiment_data->proposal_id); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); $dir_path = $root_path . $proposal_data->directory_name . '/EXP' . $experiment_data->number . '/CODE' . $solution_data->code_number; //var_dump($dir_path);die; if (is_dir($dir_path)) @@ -162,8 +155,6 @@ function lab_migration_delete_experiment($experiment_id) { $status = TRUE; $root_path = lab_migration_path(); - - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $experiment_id); $query = db_select('lab_migration_experiment'); $query->fields('lab_migration_experiment'); $query->condition('id', $experiment_id); @@ -174,7 +165,6 @@ function lab_migration_delete_experiment($experiment_id) $query->condition('id', $form_state['values']['lab']); $proposal_q = $query->execute(); $proposal_data = $proposal_q->fetchObject(); - if (!$experiment_data) { drupal_set_message('Invalid experiment.', 'error'); @@ -182,8 +172,7 @@ function lab_migration_delete_experiment($experiment_id) } /* deleting solutions */ - //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d", $experiment_id); - $query = db_select('lab_migration_solution'); + $query = db_select('lab_migration_solution'); $query->fields('lab_migration_solution'); $query->condition('experiment_id', $experiment_id); $solution_q = $query->execute(); @@ -244,8 +233,6 @@ function lab_migration_delete_lab($lab_id) { $status = TRUE; $root_path = lab_migration_path(); - - //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $lab_id); $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); $query->condition('id', $lab_id); @@ -256,15 +243,11 @@ function lab_migration_delete_lab($lab_id) drupal_set_message('Invalid Lab.', 'error'); return FALSE; } - /* delete experiments */ - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $proposal_data->id); $query = db_select('lab_migration_experiment'); $query->fields('lab_migration_experiment'); $query->condition('proposal_id', $proposal_data->id); $experiment_q = $query->execute(); - - while ($experiment_data = $experiment_q->fetchObject()) { if (!lab_migration_delete_experiment($experiment_data->id)) -- cgit From 184ce3aeac1583a2126b883f670d91f26e98a001 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Thu, 28 Mar 2019 11:28:51 +0530 Subject: Clean code to delete the lab experiment --- general_deletion.inc | 295 +++++++++++++++++++++++---------------------------- 1 file changed, 134 insertions(+), 161 deletions(-) diff --git a/general_deletion.inc b/general_deletion.inc index d33a2e1..baaec21 100755 --- a/general_deletion.inc +++ b/general_deletion.inc @@ -3,7 +3,6 @@ /******************************************************************************/ /****************************** DELETION FUNCTIONS ****************************/ /******************************************************************************/ - function lab_migration_delete_solution($solution_id) { global $user; @@ -34,64 +33,55 @@ function lab_migration_delete_solution($solution_id) drupal_set_message(t('Invalid experiment.'), 'error'); return FALSE; } - /* deleting solution files */ - //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_id); - $query = db_select('lab_migration_solution_files'); - $query->fields('lab_migration_solution_files'); - $query->condition('solution_id', $solution_id); - $solution_files_q = $query->execute(); - while ($solution_files_data = $solution_files_q->fetchObject()) - { - //var_dump($root_path . $solution_files_data->filepath);die; - $ex_path = $proposal_data->directory_name . '/' . $solution_files_data->filepath; - $dir_path = $root_path . $ex_path; - //var_dump($dir_path);die; - if (!file_exists($dir_path)) + $query = db_select('lab_migration_solution_files'); + $query->fields('lab_migration_solution_files'); + $query->condition('solution_id', $solution_id); + $solution_files_q = $query->execute(); + while ($solution_files_data = $solution_files_q->fetchObject()) { - $status = FALSE; - drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $dir_path)), 'error'); - continue; - } + $ex_path = $proposal_data->directory_name . '/' . $solution_files_data->filepath; + $dir_path = $root_path . $ex_path; + if (!file_exists($dir_path)) + { + $status = FALSE; + drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $dir_path)), 'error'); + continue; + } /* removing solution file */ - if (!unlink($dir_path)) - { - - $status = FALSE; - drupal_set_message(t('Error deleting !file', array('!file' => $dir_path)), 'error'); - - /* sending email to admins */ - $email_to = variable_get('lab_migration_emails', ''); - - $from = variable_get('lab_migration_from_email', ''); - $bcc=""; - $cc=variable_get('lab_migration_cc_emails', ''); - - $param['standard']['subject'] = "[ERROR] Error deleting example file"; - $param['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " : - solution id : " . $solution_id . " - file id : " . $solution_files_data->id . " - file path : " . $solution_files_data->filepath." - PDF path : " . $PdfStatus; - $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', - 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); + if (!unlink($dir_path)) + { + $status = FALSE; + drupal_set_message(t('Error deleting !file', array('!file' => $dir_path)), 'error'); + + /* sending email to admins */ + $email_to = variable_get('lab_migration_emails', ''); + $from = variable_get('lab_migration_from_email', ''); + $bcc=""; + $cc=variable_get('lab_migration_cc_emails', ''); + $param['standard']['subject'] = "[ERROR] Error deleting example file"; + $param['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " : + solution id : " . $solution_id . " + file id : " . $solution_files_data->id . " + file path : " . $solution_files_data->filepath." + PDF path : " . $PdfStatus; + $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', + 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); - if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - } else { - /* deleting example files database entries */ - - db_delete('lab_migration_solution_files') - ->condition('id', $solution_files_data->id) - ->execute(); + if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + } + else { + /* deleting example files database entries */ + db_delete('lab_migration_solution_files')->condition('id', $solution_files_data->id)->execute(); + } } - } - if (!$status) + if (!$status) return FALSE; -$query = db_select('lab_migration_solution'); + $query = db_select('lab_migration_solution'); $query->fields('lab_migration_solution'); $query->condition('id', $solution_id); $solution_q = $query->execute(); @@ -111,121 +101,113 @@ $query = db_select('lab_migration_solution'); $query->condition('id', $experiment_data->proposal_id); $proposal_q = $query->execute(); $proposal_data = $proposal_q->fetchObject(); - $dir_path = $root_path . $proposal_data->directory_name . '/EXP' . $experiment_data->number . '/CODE' . $solution_data->code_number; - //var_dump($dir_path);die; - if (is_dir($dir_path)) - { - if (!rmdir($dir_path)) + $dir_path = $root_path . $proposal_data->directory_name . '/EXP' . $experiment_data->number . '/CODE' . $solution_data->code_number; + if (is_dir($dir_path)) { - drupal_set_message(t('Error deleting folder !folder', array('!folder' => $dir_path)), 'error'); - - /* sending email to admins */ - $email_to = variable_get('lab_migration_emails', ''); - $from = variable_get('lab_migration_from_email', ''); - $bcc=""; - $cc=variable_get('lab_migration_cc_emails', ''); - - - $param['standard']['subject'] = "[ERROR] Error deleting folder"; - $param['standard']['body'] = "Error deleting folder " . $dir_path . " by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', - 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); - - - if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - return FALSE; + if (!rmdir($dir_path)) + { + drupal_set_message(t('Error deleting folder !folder', array('!folder' => $dir_path)), 'error'); + + /* sending email to admins */ + $email_to = variable_get('lab_migration_emails', ''); + $from = variable_get('lab_migration_from_email', ''); + $bcc=""; + $cc=variable_get('lab_migration_cc_emails', ''); + + + $param['standard']['subject'] = "[ERROR] Error deleting folder"; + $param['standard']['body'] = "Error deleting folder " . $dir_path . " by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', + 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); + + if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, $from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + return FALSE; + } + } + else + { + drupal_set_message(t('Cannot delete solution folder. !folder does not exists.', array('!folder' => $dir_path)), 'error'); + return FALSE; } - } else { - drupal_set_message(t('Cannot delete solution folder. !folder does not exists.', array('!folder' => $dir_path)), 'error'); - return FALSE; - } - /* deleting solution dependency and solution database entries */ - db_delete('lab_migration_solution_dependency')->condition('solution_id', $solution_id)->execute(); - - db_delete('lab_migration_solution')->condition('id', $solution_id)->execute(); - - return $status; + /* deleting solution dependency and solution database entries */ + db_delete('lab_migration_solution_dependency')->condition('solution_id', $solution_id)->execute(); + db_delete('lab_migration_solution')->condition('id', $solution_id)->execute(); + return $status; } function lab_migration_delete_experiment($experiment_id) { - $status = TRUE; - $root_path = lab_migration_path(); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('id', $experiment_id); - $experiment_q = $query->execute(); - $experiment_data = $experiment_q->fetchObject(); - $query = db_select('lab_migration_proposal'); + $status = TRUE; + $root_path = lab_migration_path(); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('id', $experiment_id); + $experiment_q = $query->execute(); + $experiment_data = $experiment_q->fetchObject(); + $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); $query->condition('id', $form_state['values']['lab']); $proposal_q = $query->execute(); $proposal_data = $proposal_q->fetchObject(); - if (!$experiment_data) - { - drupal_set_message('Invalid experiment.', 'error'); - return FALSE; - } - - /* deleting solutions */ - $query = db_select('lab_migration_solution'); - $query->fields('lab_migration_solution'); - $query->condition('experiment_id', $experiment_id); - $solution_q = $query->execute(); - - $delete_exp_folder = FALSE; - while ($solution_data = $solution_q->fetchObject()) - { - $delete_exp_folder = TRUE; - if (!lab_migration_delete_solution($solution_data->id)) - $status = FALSE; - } - - if (!$delete_exp_folder) - { - return TRUE; - } - - if ($status) - { - $dir_path = $root_path . $proposal_data->directory_name . '/EXP' . $experiment_data->number; - - if (is_dir($dir_path)) + if (!$experiment_data) { - $res = rmdir($dir_path); - if (!$res) - { - drupal_set_message(t('Error deleting experiment folder !folder', array('!folder' => $dir_path)), 'error'); - - /* sending email to admins */ - $email_to = variable_get('lab_migration_emails', ''); - - $from = variable_get('lab_migration_from_email', ''); - $bcc=""; - $cc=variable_get('lab_migration_cc_emails', ''); - - - $param['standard']['subject'] = "[ERROR] Error deleting experiment folder"; - $param['standard']['body'] = "Error deleting folder " . $dir_path; - $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', - 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); - if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param,$from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); + drupal_set_message('Invalid experiment.', 'error'); return FALSE; - } else { + } + /* deleting solutions */ + $query = db_select('lab_migration_solution'); + $query->fields('lab_migration_solution'); + $query->condition('experiment_id', $experiment_id); + $solution_q = $query->execute(); + $delete_exp_folder = FALSE; + while ($solution_data = $solution_q->fetchObject()) + { + $delete_exp_folder = TRUE; + if (!lab_migration_delete_solution($solution_data->id)) + $status = FALSE; + } + if (!$delete_exp_folder) + { return TRUE; - } - } else { - drupal_set_message(t('Cannot delete experiment folder. !folder does not exists.', array('!folder' => $dir_path)), 'error'); - return FALSE; } - } + if ($status) + { + $dir_path = $root_path . $proposal_data->directory_name . '/EXP' . $experiment_data->number; + if (is_dir($dir_path)) + { + $res = rmdir($dir_path); + if (!$res) + { + drupal_set_message(t('Error deleting experiment folder !folder', array('!folder' => $dir_path)), 'error'); + /* sending email to admins */ + $email_to = variable_get('lab_migration_emails', ''); + $from = variable_get('lab_migration_from_email', ''); + $bcc=""; + $cc=variable_get('lab_migration_cc_emails', ''); + $param['standard']['subject'] = "[ERROR] Error deleting experiment folder"; + $param['standard']['body'] = "Error deleting folder " . $dir_path; + $param['standard']['headers']=array('From'=>$from,'MIME-Version'=> '1.0', + 'Content-Type'=> 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer'=> 'Drupal','Cc' => $cc, 'Bcc' => $bcc); + if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param,$from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + return FALSE; + } + else + { + return TRUE; + } + } + else { + drupal_set_message(t('Cannot delete experiment folder. !folder does not exists.', array('!folder' => $dir_path)), 'error'); + return FALSE; + } + } return FALSE; } @@ -258,12 +240,3 @@ function lab_migration_delete_lab($lab_id) return $status; } -function lab_migration_del_lab_pdf($lab_id) -{ - $root_path = lab_migration_path(); - $dir_path = $root_path . "latex/"; - $pdf_filename = "lab_" . $lab_id . ".pdf"; - if (file_exists($dir_path . $pdf_filename)) - unlink($dir_path . $pdf_filename); -} - -- cgit From aaf08681bec4ee689d402700bc9e0e0f9aff7d1d Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Thu, 28 Mar 2019 11:32:19 +0530 Subject: Remove code to delete pdf file in the lab experiment --- bulk_approval.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bulk_approval.inc b/bulk_approval.inc index 3cf7239..ca3b9ab 100755 --- a/bulk_approval.inc +++ b/bulk_approval.inc @@ -392,7 +392,7 @@ function lab_migration_bulk_approval_form_submit($form, &$form_state) if ($form_state['clicked_button']['#value'] == 'Submit') { if ($form_state['values']['lab']) - lab_migration_del_lab_pdf($form_state['values']['lab']); + //lab_migration_del_lab_pdf($form_state['values']['lab']); if (user_access('lab migration bulk manage code')) { $query = db_select('lab_migration_proposal'); -- cgit From 0b0bf588eab1157edae2e3a19758e3ca59308ec7 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Thu, 28 Mar 2019 11:35:54 +0530 Subject: Modify code to check proposal id to delete experiment --- general_deletion.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/general_deletion.inc b/general_deletion.inc index baaec21..e6a9e04 100755 --- a/general_deletion.inc +++ b/general_deletion.inc @@ -150,7 +150,7 @@ function lab_migration_delete_experiment($experiment_id) $experiment_data = $experiment_q->fetchObject(); $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); - $query->condition('id', $form_state['values']['lab']); + $query->condition('id', $experiment_data->proposal_id); $proposal_q = $query->execute(); $proposal_data = $proposal_q->fetchObject(); if (!$experiment_data) -- cgit From f7e323084ad4bd9a86b4e825b4767bdbe56cc561 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Thu, 28 Mar 2019 16:30:32 +0530 Subject: Modify directory naming convention when proposal is submitted --- proposal.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposal.inc b/proposal.inc index 69c779f..d7b6fde 100755 --- a/proposal.inc +++ b/proposal.inc @@ -576,7 +576,7 @@ function _lm_list_of_software_version() function _lm_dir_name($lab, $name, $university) { $lab_title = ucname($lab); - $proposar_name = ucname($lab); + $proposar_name = ucname($name); $university_name = ucname($university); $dir_name = $lab_title . " " . "by". " " . $proposar_name . ' ' . $university_name; $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name)); -- cgit From 08f13958d245fe0d628ebd05618fcc4462c09b75 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Thu, 28 Mar 2019 16:31:02 +0530 Subject: Modify labs in progess from list to table view --- lab_details.inc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lab_details.inc b/lab_details.inc index 0c9d07f..e091852 100755 --- a/lab_details.inc +++ b/lab_details.inc @@ -18,7 +18,7 @@ function lab_migration_completed_labs_all() $i = 1; while ($row = $result->fetchObject()) { - $approval_date = date("Y", $row->approval_date); + $approval_date = date("Y", $row->expected_completion_date); $preference_rows[] = array( $i, $row->university, @@ -55,15 +55,29 @@ function lab_migration_labs_progress_all() } else { - //$result = db_query($query); - $page_content .= "
    "; + $preference_rows = array(); + $i = 1; while ($row = $result->fetchObject()) { - $page_content .= "
  1. "; - $page_content .= $row->university . " ({$row->lab_title})"; - $page_content .= "
  2. "; + $approval_date = date("Y", $row->approval_date); + $preference_rows[] = array( + $i, + $row->university, + $row->lab_title, + $approval_date + ); + $i++; } - $page_content .= "
"; + $preference_header = array( + 'No', + 'Institute', + 'Lab', + 'Year' + ); + $page_content .= theme('table', array( + 'header' => $preference_header, + 'rows' => $preference_rows + )); } return $page_content; - } + } \ No newline at end of file -- cgit From d0536f2f87005f0b2f646921541f32ec7fed1ebd Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Fri, 29 Mar 2019 10:40:07 +0530 Subject: Remove duplicate link to download the codes --- run.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.inc b/run.inc index 4ad250b..2ba4a44 100755 --- a/run.inc +++ b/run.inc @@ -120,13 +120,13 @@ function lab_migration_run_form($form, &$form_state) '#markup' => '
'. l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1') .'
', );*/ - if ($lab_default_value == '2') + /*if ($lab_default_value == '2') { $form['selected_lab_dwsim'] = array( '#type' => 'item', '#markup' => '
' . l('Download Lab Solutions (dwsim Version)', 'lab-migration-uploads/dwsim_Version.zip') . '
' ); - } + }*/ $form['lab_details'] = array( '#type' => 'item', '#markup' => '
' . _lab_details($lab_default_value) . '
' @@ -223,7 +223,7 @@ function ajax_experiment_list_callback($form, $form_state) if ($lab_details->solution_provider_uid > 0) { $commands[] = ajax_command_html('#ajax_selected_lab', l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value)); - if ($lab_default_value == '2') + /*if ($lab_default_value == '2') { $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', l('Download Lab Solutions (dwsim Version)', 'lab-migration_uploads/dwsim_Version.zip')); } -- cgit From 9f21cf74562ec66b0b5699014fc720ac518e34b6 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Thu, 4 Apr 2019 11:52:26 +0530 Subject: Add help text for field in upload code form --- lab_details.inc | 6 +++--- upload_code.inc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lab_details.inc b/lab_details.inc index e091852..b04986e 100755 --- a/lab_details.inc +++ b/lab_details.inc @@ -18,12 +18,12 @@ function lab_migration_completed_labs_all() $i = 1; while ($row = $result->fetchObject()) { - $approval_date = date("Y", $row->expected_completion_date); + $completion_date = date("Y", $row->expected_completion_date); $preference_rows[] = array( $i, $row->university, - l($row->lab_title, "lab-migration/lab-migration-run/" . $row->id), - $approval_date + $row->lab_title, + $completion_date ); $i++; } diff --git a/upload_code.inc b/upload_code.inc index bced2f5..4dafe6c 100755 --- a/upload_code.inc +++ b/upload_code.inc @@ -186,9 +186,9 @@ function lab_migration_upload_code_form($form,$form_state) $form['code_caption'] = array( '#type' => 'textfield', '#title' => t('Caption'), + '#description' => t('For eg: Shell & Tube Heat Exchanger Simulation'), '#size' => 40, '#maxlength' => 255, - '#description' => t(''), '#required' => TRUE, ); $form['os_used'] = array( @@ -214,7 +214,7 @@ function lab_migration_upload_code_form($form,$form_state) ); $form['code_warning'] = array( '#type' => 'item', - '#title' => t('Upload all the dwsim project files in .zip format'), + '#title' => t('Upload all the dwsim project files in .dwxml/dwxmz format'), '#prefix' => '
', '#suffix' => '
', ); -- cgit