summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrashant P. Shah2011-07-15 18:16:17 +0530
committerPrashant P. Shah2011-07-15 18:16:17 +0530
commit6c51a358b8659f167d2e2efb6705d0f75dc7dedd (patch)
tree6fb2fa31ecc4e70e4b68ece7807786477c6f33f6
parent9d23b552b50a6f14ab29765220d5508e503f4431 (diff)
downloadscilab_lab_migration-6c51a358b8659f167d2e2efb6705d0f75dc7dedd.tar.gz
scilab_lab_migration-6c51a358b8659f167d2e2efb6705d0f75dc7dedd.tar.bz2
scilab_lab_migration-6c51a358b8659f167d2e2efb6705d0f75dc7dedd.zip
Reupload solution
Signed-off-by: Prashant P. Shah <pshah.mumbai@gmail.com>
-rw-r--r--lab_migration.module2
-rw-r--r--manage_proposal.inc35
-rw-r--r--solution.inc41
3 files changed, 66 insertions, 12 deletions
diff --git a/lab_migration.module b/lab_migration.module
index 37262c5..4941d5a 100644
--- a/lab_migration.module
+++ b/lab_migration.module
@@ -29,7 +29,7 @@ function lab_migration_menu()
/* for reviewers */
$items['lab_migration/manage_proposal'] = array(
- 'title' => 'Manage Lab Migration Proposals',
+ 'title' => 'Manage Lab Migration',
'description' => 'Manage Lab Migration Proposals',
'page callback' => '_proposal_pending',
'access callback' => 'user_access',
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 4c4cb4d..de325e5 100644
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -36,7 +36,7 @@ function _proposal_all()
}
if ($proposal_data->solution_status == 1) {
$proposal_status = 'Migrated';
- $proposal_rows[] = array(date('d-m-Y', $proposal_data->creation_date), l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid), $proposal_data->department, $proposal_data->university, $proposal_data->lab_title, $proposal_status, l('Edit', 'lab_migration/manage_proposal/edit/' . $proposal_data->id));
+ $proposal_rows[] = array(date('d-m-Y', $proposal_data->creation_date), l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid), $proposal_data->department, $proposal_data->university, $proposal_data->lab_title, $proposal_status, l('Reupload Solution', 'lab_migration/manage_proposal/solution/' . $proposal_data->id) . ' | ' . l('Edit', 'lab_migration/manage_proposal/edit/' . $proposal_data->id));
} else {
$proposal_rows[] = array(date('d-m-Y', $proposal_data->creation_date), l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid), $proposal_data->department, $proposal_data->university, $proposal_data->lab_title, $proposal_status, l('Approve', 'lab_migration/manage_proposal/approve/' . $proposal_data->id) . ' | ' . l('Edit', 'lab_migration/manage_proposal/edit/' . $proposal_data->id));
}
@@ -352,6 +352,11 @@ function proposal_edit_form($form_state)
}
}
+ $form['delete_proposal'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Delete Proposal')
+ );
+
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
@@ -373,6 +378,8 @@ function proposal_edit_form_validate($form, &$form_state)
function proposal_edit_form_submit($form, &$form_state)
{
+ $root_path = lab_migration_path();
+
/* get current proposal */
$proposal_id = arg(3);
$result = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
@@ -382,6 +389,32 @@ function proposal_edit_form_submit($form, &$form_state)
return;
}
+ if ($form_state['values']['delete_proposal'] == 1) {
+ $files_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d", $proposal_id);
+ while ($file_data = db_fetch_object($files_q)) {
+ if (!file_exists($root_path . $file_data->filepath)) {
+ drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $file_data->filepath)), 'error');
+ return;
+ }
+ /* removing file */
+ if (!unlink($root_path . $file_data->filepath)) {
+ drupal_set_message(t('Error deleting !file', array('!file' => $file_data->filepath)), 'error');
+ return;
+ } else {
+ /* deleting example files database entries */
+ db_query("DELETE FROM {lab_migration_files} WHERE id = %d", $file_data->id);
+ }
+ }
+ if (!rmdir($root_path . $proposal_id . '/')) {
+ drupal_set_message(t('Error deleting !folder', array('!folder' => $root_path . $proposal_id . '/')), 'error');
+ return;
+ }
+ db_query("DELETE FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
+ drupal_set_message(t('Proposal Delete'), 'status');
+ drupal_goto('lab_migration/manage_proposal');
+ return;
+ }
+
db_query("UPDATE {lab_migration_proposal} SET name_title = '%s', name = '%s', contact_ph = '%s', department = '%s', university = '%s', lab_title = '%s', problem_topic = '%s' WHERE id = %d",
$form_state['values']['name_title'],
$form_state['values']['name'],
diff --git a/solution.inc b/solution.inc
index 61c4b45..7db37ac 100644
--- a/solution.inc
+++ b/solution.inc
@@ -43,11 +43,9 @@ function proposal_solution_form($form_state)
drupal_goto('lab_migration/manage_proposal/pending_proposal');
return;
}
- if ($row->solution_status != 0) {
- drupal_set_message(t('Selected Proposal has already been solved.'), 'error');
- drupal_goto('lab_migration/manage_proposal/pending_proposal');
- return;
- }
+ if ($row->solution_status != 0) {
+ drupal_set_message(t('Selected Proposal has already been solved. You can reupload a new solution.'), 'status');
+ }
$form['#attributes'] = array('enctype' => "multipart/form-data");
@@ -119,6 +117,16 @@ function proposal_solution_form($form_state)
. 'On : ' . date('d-m-Y', $row->approval_date),
);
+ $sol_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A'", $row->id);
+ $sol_file_data = db_fetch_object($sol_file_q);
+ if ($sol_file_data) {
+ $form['sol_file'] = array(
+ '#type' => 'item',
+ '#value' => l($sol_file_data->filename, $dl_root_path . $sol_file_data->filepath),
+ '#title' => t('Solution file'),
+ );
+ }
+
$form['solution_file'] = array(
'#type' => 'file',
'#title' => t('Upload solution statement'),
@@ -184,11 +192,24 @@ function proposal_solution_form_submit($form, &$form_state)
drupal_goto('lab_migration/manage_proposal/pending_solution');
return;
}
- if ($row->solution_status != 0) {
- drupal_set_message(t('Selected Proposal has already been solved.'), 'error');
- drupal_goto('lab_migration/manage_proposal/pending_solution');
- return;
- }
+
+ if ($row->solution_status == 1) {
+ $files_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A'", $proposal_id);
+ while ($file_data = db_fetch_object($files_q)) {
+ if (!file_exists($root_path . $file_data->filepath)) {
+ drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $file_data->filepath)), 'error');
+ return;
+ }
+ /* removing file */
+ if (!unlink($root_path . $file_data->filepath)) {
+ drupal_set_message(t('Error deleting !file', array('!file' => $file_data->filepath)), 'error');
+ return;
+ } else {
+ /* deleting example files database entries */
+ db_query("DELETE FROM {lab_migration_files} WHERE id = %d", $file_data->id);
+ }
+ }
+ }
/************** uploading file *******************/
/* creating directories */