From 2d0c4265e1a061522d0e4f4d1b5b772c92f3803a Mon Sep 17 00:00:00 2001 From: prashant Date: Thu, 5 Nov 2015 10:54:12 +0530 Subject: added rename directory function in lab proposal edit --- bulk_approval.inc | 2 +- download.inc | 48 +++++++++++++++++++++++++++--------------------- full_download.inc | 34 ++++++++++++++++++++-------------- general_deletion.inc | 20 +++++++++----------- lab_details.inc | 2 +- lab_migration.install | 2 +- manage_proposal.inc | 36 +++++++++++++++++++++++++++++++++--- proposal.inc | 26 ++++++++++++++++++-------- run.inc | 19 ++++++++++++++++--- upload_code.inc | 35 ++++++++++++++++++----------------- 10 files changed, 144 insertions(+), 80 deletions(-) diff --git a/bulk_approval.inc b/bulk_approval.inc index 212963a..39ac9c2 100755 --- a/bulk_approval.inc +++ b/bulk_approval.inc @@ -259,7 +259,7 @@ function ajax_bulk_solution_list_callback($form, $form_state) { $form['lab_experiment_actions']['#options'] = _bulk_list_experiment_actions(); $form['lab_solution_list']['#options'] = _ajax_bulk_get_solution_list($experiment_list_default_value); - $commands[] = ajax_command_html('#ajax_download_experiment', l('Download Experiment', 'lab-migration/download/experiment/' . $experiment_list_default_value)); + $commands[] = ajax_command_html('#ajax_download_experiment', l('Download Experiment', 'lab-migration/full-download/experiment/' . $experiment_list_default_value)); $commands[] = ajax_command_data('#ajax_selected_experiment', 'form_state_value_select', $form_state['values']['lab_experiment_list']); $commands[] = ajax_command_html('#ajax_selected_experiment', drupal_render($form['lab_experiment_list'])); $commands[] = ajax_command_html('#ajax_selected_lab_experiment_action', drupal_render($form['lab_experiment_actions'])); diff --git a/download.inc b/download.inc index a829f54..dcd5608 100755 --- a/download.inc +++ b/download.inc @@ -5,16 +5,17 @@ function lab_migration_download_solution_file() $solution_file_id = arg(3); $root_path = lab_migration_path(); // $solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE id = %d LIMIT 1", $solution_file_id); - $query = db_select('lab_migration_solution_files'); + $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 LIMIT 1", array(':solution_id' => $solution_file_id)); + /*$query = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('id', $solution_file_id); $query->range(0, 1); - $solution_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ $solution_file_data = $solution_files_q->fetchObject(); header('Content-Type: ' . $solution_file_data->filemime); header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($solution_file_data->filename)) . '"'); - header('Content-Length: ' . filesize($root_path . $solution_file_data->filepath)); - readfile($root_path . $solution_file_data->filepath); + 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 lab_migration_download_dependency_file() { @@ -50,10 +51,11 @@ function lab_migration_download_solution() $experiment_q = $query->execute(); $experiment_data = $experiment_q->fetchObject(); //$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 = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('solution_id', $solution_id); - $solution_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ + $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)); //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_id); $query = db_select('lab_migration_solution_dependency'); $query->fields('lab_migration_solution_dependency'); @@ -67,7 +69,7 @@ function lab_migration_download_solution() $zip->open($zip_filename, ZipArchive::CREATE); while ($solution_files_row = $solution_files_q->fetchObject()) { - $zip->addFile($root_path . $solution_files_row->filepath, $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); + $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()) @@ -97,12 +99,13 @@ function lab_migration_download_solution() else { drupal_set_message("There are no files in this solutions to download", 'error'); - drupal_goto('lab_migration_run'); + drupal_goto('lab-migration/lab-migration-run'); } } function lab_migration_download_experiment() { - $experiment_id = arg(3); + $experiment_id = (int)arg(3); + $root_path = lab_migration_path(); /* get solution data */ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $experiment_id); @@ -127,20 +130,21 @@ function lab_migration_download_experiment() { $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; // $solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id); - $query = db_select('lab_migration_solution_files'); + $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.solution_id = :solution_id", array(':solution_id' => $solution_row->id)); + /* $query = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute(); - // $solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id); - $query = db_select('lab_migration_solution_dependency'); - $query->fields('lab_migration_solution_dependency'); - $query->condition('solution_id', $solution_row->id); - $solution_dependency_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ + // $solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id); while ($solution_files_row = $solution_files_q->fetchObject()) { - $zip->addFile($root_path . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); + $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('lab_migration_solution_dependency'); + $query->fields('lab_migration_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 {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject(); @@ -169,7 +173,7 @@ function lab_migration_download_experiment() else { drupal_set_message("There are no solutions in this experiment to download", 'error'); - drupal_goto('lab_migration_run'); + drupal_goto('lab-migration/lab-migration-run'); } } function lab_migration_download_lab() @@ -208,10 +212,12 @@ function lab_migration_download_lab() { $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id); - $query = db_select('lab_migration_solution_files'); + + $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_row->id)); + /*$query = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id); $query = db_select('lab_migration_solution_dependency'); $query->fields('lab_migration_solution_dependency'); @@ -219,7 +225,7 @@ function lab_migration_download_lab() $solution_dependency_files_q = $query->execute(); while ($solution_files_row = $solution_files_q->fetchObject()) { - $zip->addFile($root_path . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename))); + $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; diff --git a/full_download.inc b/full_download.inc index 0546be2..a8e7173 100755 --- a/full_download.inc +++ b/full_download.inc @@ -25,15 +25,16 @@ function lab_migration_download_full_experiment() $query->fields('lab_migration_solution'); $query->condition('experiment_id', $experiment_id); $query->condition('approval_status', 1); - $result = $query->execute(); + $solution_q = $query->execute(); while ($solution_row = $solution_q->fetchObject()) { $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id); - $query = db_select('lab_migration_solution_files'); + /*$query = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ + $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_row->id)); //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id); $query = db_select('lab_migration_solution_dependency'); $query->fields('lab_migration_solution_dependency'); @@ -41,7 +42,7 @@ function lab_migration_download_full_experiment() $solution_dependency_files_q = $query->execute(); while ($solution_files_row = $solution_files_q->fetchObject()) { - $zip->addFile($root_path . $solution_files_row->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); + $zip->addFile($root_path . $solution_files_row->directory_name. '/' . $solution_files_row->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); } /* dependency files */ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) @@ -67,10 +68,12 @@ function lab_migration_download_full_experiment() { $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id); - $query = db_select('lab_migration_solution_files'); + /*$query = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ + $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_row->id)); + //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id); $query = db_select('lab_migration_solution_dependency'); $query->fields('lab_migration_solution_dependency'); @@ -78,7 +81,7 @@ function lab_migration_download_full_experiment() $solution_dependency_files_q = $query->execute(); while ($solution_files_row = $solution_files_q->fetchObject()) { - $zip->addFile($root_path . $solution_files_row->filepath, $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); + $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); } /* dependency files */ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) @@ -107,7 +110,7 @@ function lab_migration_download_full_experiment() else { drupal_set_message("There are no solutions in this experiment to download", 'error'); - drupal_goto('lab_migration/code_approval/bulk'); + drupal_goto('lab-migration/code-approval/bulk'); } } function lab_migration_download_full_lab() @@ -150,10 +153,11 @@ function lab_migration_download_full_lab() { $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id); - $query = db_select('lab_migration_solution_files'); + /*$query = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ + $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_row->id)); //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id); $query = db_select('lab_migration_solution_dependency'); $query->fields('lab_migration_solution_dependency'); @@ -161,7 +165,7 @@ function lab_migration_download_full_lab() $solution_dependency_files_q = $query->execute(); while ($solution_files_row = $solution_files_q->fetchObject()) { - $zip->addFile($root_path . $solution_files_row->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); + $zip->addFile($root_path . $solution_files_row->directory_name. '/' . $solution_files_row->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); } /* dependency files */ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) @@ -187,10 +191,12 @@ function lab_migration_download_full_lab() { $CODE_PATH = 'CODE' . $solution_row->code_number . '/'; //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id); - $query = db_select('lab_migration_solution_files'); + /* $query = db_select('lab_migration_solution_files'); $query->fields('lab_migration_solution_files'); $query->condition('solution_id', $solution_row->id); - $solution_files_q = $query->execute(); + $solution_files_q = $query->execute();*/ + $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_row->id)); + //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id); $query = db_select('lab_migration_solution_dependency'); $query->fields('lab_migration_solution_dependency'); @@ -198,7 +204,7 @@ function lab_migration_download_full_lab() $solution_dependency_files_q = $query->execute(); while ($solution_files_row = $solution_files_q->fetchObject()) { - $zip->addFile($root_path . $solution_files_row->filepath, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); + $zip->addFile($root_path .$solution_files_row->directory_name . '/' . $solution_files_row->filepath, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename); } /* dependency files */ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject()) diff --git a/general_deletion.inc b/general_deletion.inc index aa81cee..2125732 100755 --- a/general_deletion.inc +++ b/general_deletion.inc @@ -19,10 +19,7 @@ function lab_migration_delete_solution($solution_id) return FALSE; } //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $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_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)); $experiment_data = $experiment_q->fetchObject(); if (!$experiment_data) { @@ -31,26 +28,27 @@ function lab_migration_delete_solution($solution_id) } /* 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'); + $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(); + $solution_files_q = $query->execute();*/ while ($solution_files_data = $solution_files_q->fetchObject()) { - if (!file_exists($root_path . $solution_files_data->filepath)) + 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->filepath + '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath )), 'error'); continue; } /* removing solution file */ - if (!unlink($root_path . $solution_files_data->filepath)) + 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->filepath + '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath )), 'error'); /* sending email to admins */ $email_to = variable_get('lab_migration_emails', ''); @@ -61,7 +59,7 @@ function lab_migration_delete_solution($solution_id) $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 . " + file path : " . $solution_files_data->directory_name. '/'. $solution_files_data->filepath . " PDF path : " . $PdfStatus; $param['standard']['headers'] = array( 'From' => $from, diff --git a/lab_details.inc b/lab_details.inc index 66e35dd..6f3b4e0 100755 --- a/lab_details.inc +++ b/lab_details.inc @@ -22,7 +22,7 @@ function lab_migration_completed_labs_all() $preference_rows[] = array( $i, $row->university, - l($row->lab_title, "lab-migration-run/" . $row->id), + l($row->lab_title, "lab-migration/lab-migration-run/" . $row->id), $approval_date ); $i++; diff --git a/lab_migration.install b/lab_migration.install index cec3600..b1edc81 100755 --- a/lab_migration.install +++ b/lab_migration.install @@ -14,7 +14,7 @@ function lab_migration_install() variable_set('lab_migration_result_extensions', ''); variable_set('lab_migration_xcos_extensions', ''); // create uploads folder - $upload_path = $_SERVER['DOCUMENT_ROOT'] . base_path() . 'lab_migration_uploads'; + $upload_path = $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/lab_migration_uploads'; if (!is_dir($upload_path)) mkdir($upload_path); if (!is_dir($upload_path . '/latex')) diff --git a/manage_proposal.inc b/manage_proposal.inc index fe013cc..8f89158 100755 --- a/manage_proposal.inc +++ b/manage_proposal.inc @@ -1108,6 +1108,18 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state) // ":solution_display" => $solution_display, // ":id" => $proposal_id, // ); + + $lab_title = $v['lab_title']; + $proposar_name = $v['name_title']. ' ' . $v['name']; + $university = $v['university']; + $directory_names = _lm_dir_name($lab_title, $proposar_name, $university); + if (LM_RenameDir($proposal_id, $directory_names)) + { + $directory_name = $directory_names; + }else{ + return; + } + $query = db_update('lab_migration_proposal')->fields(array( 'name_title' => $v['name_title'], 'name' => $v['name'], @@ -1118,9 +1130,10 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state) 'pincode' => $v['pincode'], 'state' => $v['all_state'], 'lab_title' => $v['lab_title'], - 'solution_display' => $solution_display - ))->condition('id', $proposal_id); - $result1 = $query->execute(); + '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('lab_migration_experiment'); @@ -1446,3 +1459,20 @@ function CreateReadmeFileLabMigration($proposal_id) fclose($readme_file); return $txt; } + function LM_RenameDir($proposal_id,$dir_name){ + $query = db_query("SELECT directory_name FROM lab_migration_proposal WHERE id = :proposal_id", array(':proposal_id' => $proposal_id)); + $result = $query->fetchObject(); + $new_directory_name = rename(lab_migration_path().$result->directory_name, lab_migration_path().$dir_name) or drupal_set_message("Unable to rename folder"); + + return $new_directory_name; + +} +function _lm_dir_name($lab, $name, $university) + { + $lab_title = 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)); + return $directory_name; + } diff --git a/proposal.inc b/proposal.inc index 66900a8..5f097c1 100755 --- a/proposal.inc +++ b/proposal.inc @@ -419,10 +419,10 @@ function lab_migration_proposal_form_submit($form, &$form_state) } /* inserting the user proposal */ $v = $form_state["values"]; - $lab_title = ucname($v['lab_title']); - $university = ucname($v['university']); - $dir_name = $lab_title . " " . $university; - $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name)); + $lab_title = $v['lab_title']; + $proposar_name = $v['name_title']. ' ' . $v['name']; + $university = $v['university']; + $directory_name = _lm_dir_name($lab_title, $proposar_name, $university); $result = "INSERT INTO {lab_migration_proposal} (uid, approver_uid, name_title, name, contact_ph, department, university, city, pincode, state, country, version, lab_title, approval_status, solution_status, solution_provider_uid, solution_display, creation_date, approval_date, solution_date, solution_provider_name_title, solution_provider_name, solution_provider_contact_ph, solution_provider_department, solution_provider_university, directory_name) VALUES (:uid, :approver_uid, :name_title, :name, :contact_ph, :department, :university, :city, :pincode, :state, :country, @@ -475,10 +475,11 @@ function lab_migration_proposal_form_submit($form, &$form_state) $experiment_description = 'lab_experiment_description-' . $counter; if (strlen(trim($form_state['values'][$experiment_field_name])) >= 1) { - $query = "INSERT INTO {lab_migration_experiment} (proposal_id, directory_name, number, title,description) VALUES (:proposal_id, :directory_name, :number, :experiment_field_name,:description)"; + //$query = "INSERT INTO {lab_migration_experiment} (proposal_id, directory_name, number, title,description) VALUES (:proposal_id, :directory_name, :number, :experiment_field_name,:description)"; + $query = "INSERT INTO {lab_migration_experiment} (proposal_id, number, title,description) VALUES (:proposal_id, :number, :experiment_field_name,:description)"; $args = array( ":proposal_id" => $proposal_id, - ":directory_name" => $directory_name, + // ":directory_name" => $directory_name, ":number" => $number, ":experiment_field_name" => trim($form_state['values'][$experiment_field_name]), ":description" => trim($form_state['values'][$experiment_description]) @@ -517,7 +518,7 @@ function lab_migration_proposal_form_submit($form, &$form_state) } function _lm_list_of_states() { - $states = array(); + $states = array(0 => '-Select-'); $query = db_select('list_states_of_india'); $query->fields('list_states_of_india'); //$query->orderBy('', ''); @@ -530,7 +531,7 @@ function _lm_list_of_states() } function _lm_list_of_cities() { - $city = array(); + $city = array(0 => '-Select-'); $query = db_select('list_cities_of_india'); $query->fields('list_cities_of_india'); $query->orderBy('city', 'ASC'); @@ -567,3 +568,12 @@ function _lm_list_of_software_version() } return $software_version; } +function _lm_dir_name($lab, $name, $university) + { + $lab_title = ucname($lab); + $proposar_name = ucname($lab); + $university_name = ucname($university); + $dir_name = $lab_title . " " . "by". " " . $proposar_name . ' ' . $university_name; + $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name)); + return $directory_name; + } diff --git a/run.inc b/run.inc index f6791a1..4ad250b 100755 --- a/run.inc +++ b/run.inc @@ -425,7 +425,7 @@ function _list_of_labs() $lab_titles_q = $query->execute(); while ($lab_titles_data = $lab_titles_q->fetchObject()) { - $lab_titles[$lab_titles_data->id] = $lab_titles_data->lab_title . ' (Proposed by ' . $lab_titles_data->name . ')'; + $lab_titles[$lab_titles_data->id] = $lab_titles_data->lab_title . ' (Proposed by ' . $lab_titles_data->name_title .' '.$lab_titles_data->name . ')'; } return $lab_titles; } @@ -474,9 +474,17 @@ function _lab_information($proposal_id) $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); $query->condition('id', $proposal_id); + $query->condition('approval_status', 3); $lab_q = $query->execute(); $lab_data = $lab_q->fetchObject(); - return $lab_data; + if($lab_data){ + return $lab_data; + } + else + { + return ; + } + } function _lab_details($lab_default_value) { @@ -484,6 +492,7 @@ function _lab_details($lab_default_value) $lab_details = _lab_information($lab_default_value); if ($lab_default_value != 0) { + if ($lab_details){ if ($lab_details->solution_provider_uid > 0) { $user_solution_provider = user_load($lab_details->solution_provider_uid); @@ -499,9 +508,13 @@ function _lab_details($lab_default_value) else { $solution_provider = 'Solution Provider