summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSashi202019-03-27 16:12:57 +0530
committerSashi202019-03-27 16:12:57 +0530
commit1d738976fe5129c3b597a546c17818a4fc585a06 (patch)
tree368b762dcbaeca1ffa9a64acbfb5c6fa5b58731d
parent9afb9aed90606594d73cc9958b886f3a7abb07b7 (diff)
downloadDWSIM_lab_migration-1d738976fe5129c3b597a546c17818a4fc585a06.tar.gz
DWSIM_lab_migration-1d738976fe5129c3b597a546c17818a4fc585a06.tar.bz2
DWSIM_lab_migration-1d738976fe5129c3b597a546c17818a4fc585a06.zip
Modify path to the lab directory to disapprove and delete the solution files
-rwxr-xr-xbulk_approval.inc22
-rwxr-xr-xgeneral_deletion.inc59
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))