summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashant2015-11-04 19:06:22 +0530
committerprashant2015-11-04 19:06:22 +0530
commit1ba859d4f6b4fc64ac51eadc6bc1a5fa40869590 (patch)
tree1b4947d59b876ad80c053b0432250720b8e4207f
parentdee787c3aa6237b6bf732cdcd205265d10f26b97 (diff)
downloadDWSIM_lab_migration_module-1ba859d4f6b4fc64ac51eadc6bc1a5fa40869590.tar.gz
DWSIM_lab_migration_module-1ba859d4f6b4fc64ac51eadc6bc1a5fa40869590.tar.bz2
DWSIM_lab_migration_module-1ba859d4f6b4fc64ac51eadc6bc1a5fa40869590.zip
changed mail functions and formated the code
-rwxr-xr-xbulk_approval.inc8
-rwxr-xr-xdependency.inc377
-rwxr-xr-xdependency_approval.inc254
-rwxr-xr-xdownload.inc523
-rwxr-xr-xemail.inc916
-rwxr-xr-xfull_download.inc452
-rwxr-xr-xgeneral_deletion.inc560
-rwxr-xr-xlab_details.inc46
-rwxr-xr-xlab_migration.install844
-rwxr-xr-xlab_migration.module1209
-rwxr-xr-xlatex.inc501
-rwxr-xr-xmanage_proposal.inc597
-rwxr-xr-xmanage_solution_proposal.inc547
-rwxr-xr-xnotes.inc203
-rwxr-xr-xproposal.inc1029
-rwxr-xr-xrun.inc910
-rwxr-xr-xsettings.inc196
-rwxr-xr-xsolution_proposal.inc427
-rwxr-xr-xupload_code_delete.inc3
19 files changed, 4999 insertions, 4603 deletions
diff --git a/bulk_approval.inc b/bulk_approval.inc
index f5a1ff0..212963a 100755
--- a/bulk_approval.inc
+++ b/bulk_approval.inc
@@ -519,7 +519,7 @@ Dear !user_name,
Your all the uploaded solutions for the whole Lab with Title : ' . $user_info->lab_title . ' have been marked as dis-approved.
-Reason for dis-approval:' . $form_state['values']['message'] . '
+Reason for dis-approval: ' . $form_state['values']['message'] . '
Best Wishes,
@@ -621,7 +621,7 @@ Title of Lab :' . $user_info->lab_title . '
List of experiments : ' . $experiment_list . '
-Reason for dis-approval:' . $form_state['values']['message'] . '
+Reason for dis-approval: ' . $form_state['values']['message'] . '
Best Wishes,
@@ -776,7 +776,7 @@ We regret to inform you that your experiment with the following details under DW
Experiment name : ' . $experiment_value->title . '
Caption : ' . $solution_value->caption . '
-Reason for dis-approval:' . $form_state['values']['message'] . '
+Reason for dis-approval: ' . $form_state['values']['message'] . '
Please resubmit the modified solution.
@@ -927,7 +927,7 @@ We regret to inform you that your experiment with the following details under DW
Experiment name : ' . $experiment_value->title . '
Caption : ' . $solution_value->caption . '
-Reason for dis-approval:' . $form_state['values']['message'] . '
+Reason for dis-approval: ' . $form_state['values']['message'] . '
Please resubmit the modified solution.
diff --git a/dependency.inc b/dependency.inc
index 0137ca4..a507218 100755
--- a/dependency.inc
+++ b/dependency.inc
@@ -1,214 +1,195 @@
<?php
// $Id$
-
-function lab_migration_upload_dependency_form($form_state)
-{
- global $user;
-
- $proposal_data = lab_migration_get_proposal();
- if (!$proposal_data) {
- drupal_goto('');
- return;
- }
-
- $form['#attributes'] = array('enctype' => "multipart/form-data");
-
- $form['lab_title'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->lab_title,
- '#title' => t('Title of the Lab'),
- );
- $form['name'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->name_title . ' ' . $proposal_data->name,
- '#title' => t('Proposer Name'),
- );
-
- $form['existing_depfile'] = array(
- '#type' => 'item',
- '#value' => _list_existing_dependency($proposal_data->id),
- '#title' => t('List of existing dependency files for this book'),
- );
-
- $form['depfile'] = array(
- '#type' => 'fieldset',
- '#title' => t('Upload Dependency Files'),
- '#collapsible' => FALSE,
- '#collapsed' => FALSE,
- );
- $form['depfile']['depfile1'] = array(
- '#type' => 'file',
- '#title' => t('Upload dependency file'),
- '#description' => t("Allowed file extensions : ") . variable_get('lab_migration_dependency_extensions', ''),
- );
- $form['depfile']['depfile1_caption'] = array(
- '#type' => 'textfield',
- '#title' => t('Caption for dependency file'),
- '#size' => 15,
- '#maxlength' => 100,
- '#required' => TRUE,
- );
- $form['depfile']['depfile1_description'] = array(
- '#type' => 'textarea',
- '#title' => t('Brief Description of the dependency file'),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Back'), 'lab_migration/code'),
- );
- return $form;
-}
-
-function lab_migration_upload_dependency_form_validate($form, &$form_state)
-{
- global $user;
-
- /* get approved proposal details */
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE uid = %d OR solution_provider_uid = %d ORDER BY id DESC LIMIT 1", $user->uid, $user->uid);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
-
- $or = db_or();
- $or->condition('uid', $user->uid);
- $or->condition('solution_provider_uid', $user->uid);
- $query->condition($or);
- $query->orderBy('id', 'DESC');
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
+function lab_migration_upload_dependency_form($form, $form_state)
{
- form_set_error('', t('Invalid1'));
+ global $user;
+ $proposal_data = lab_migration_get_proposal();
+ if (!$proposal_data)
+ {
+ drupal_goto('');
+ return;
+ }
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ $form['lab_title'] = array(
+ '#type' => 'item',
+ '#value' => $proposal_data->lab_title,
+ '#title' => t('Title of the Lab')
+ );
+ $form['name'] = array(
+ '#type' => 'item',
+ '#value' => $proposal_data->name_title . ' ' . $proposal_data->name,
+ '#title' => t('Proposer Name')
+ );
+ $form['existing_depfile'] = array(
+ '#type' => 'item',
+ '#value' => _list_existing_dependency($proposal_data->id),
+ '#title' => t('List of existing dependency files for this book')
+ );
+ $form['depfile'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Upload Dependency Files'),
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE
+ );
+ $form['depfile']['depfile1'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload dependency file'),
+ '#description' => t("Allowed file extensions : ") . variable_get('lab_migration_dependency_extensions', '')
+ );
+ $form['depfile']['depfile1_caption'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Caption for dependency file'),
+ '#size' => 15,
+ '#maxlength' => 100,
+ '#required' => TRUE
+ );
+ $form['depfile']['depfile1_description'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Brief Description of the dependency file')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#value' => l(t('Back'), 'lab_migration/code')
+ );
+ return $form;
}
-
- if (!lab_migration_check_name($form_state['values']['depfile1_caption']))
- form_set_error('code_caption', t('Caption can contain only alphabets, numbers and spaces.'));
-
- if (isset($_FILES['files']))
+function lab_migration_upload_dependency_form_validate($form, &$form_state)
{
- /* check for valid filename extensions */
- $allowed_extensions = explode(',' , variable_get('lab_migration_dependency_extensions', ''));
- foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
- {
- if ($file_name)
+ global $user;
+ /* get approved proposal details */
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE uid = %d OR solution_provider_uid = %d ORDER BY id DESC LIMIT 1", $user->uid, $user->uid);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $or = db_or();
+ $or->condition('uid', $user->uid);
+ $or->condition('solution_provider_uid', $user->uid);
+ $query->condition($or);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
{
- $temp_extension = end(explode('.', strtolower($_FILES['files']['name'][$file_form_name])));
- if (!in_array($temp_extension, $allowed_extensions))
- form_set_error($file_form_name, t('Only ' . variable_get('lab_migration_dependency_extensions', '') . ' extensions can be uploaded.'));
- if ($_FILES['files']['size'][$file_form_name] <= 0)
- form_set_error($file_form_name, t('File size cannot be zero.'));
-
- /* check if file already exists */
- //$dep_exists_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE filename = '%s'", $_FILES['files']['name'][$file_form_name]))->fetchObject();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('filename', $_FILES['files']['name'][$file_form_name]);
- $dep_exists_data = $query->execute();
- if ($dep_exists_data)
- form_set_error($file_form_name, t('Dependency file with the same name has already been uploaded in this or some other lab solution. Please rename the file and try again.'));
-
- /* check if valid file name */
- if (!lab_migration_check_valid_filename($_FILES['files']['name'][$file_form_name]))
- form_set_error($file_form_name, t('Invalid file name specified. Only alphabets, numbers and underscore is allowed as a valid filename.'));
+ form_set_error('', t('Invalid1'));
+ }
+ if (!lab_migration_check_name($form_state['values']['depfile1_caption']))
+ form_set_error('code_caption', t('Caption can contain only alphabets, numbers and spaces.'));
+ if (isset($_FILES['files']))
+ {
+ /* check for valid filename extensions */
+ $allowed_extensions = explode(',', variable_get('lab_migration_dependency_extensions', ''));
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ $temp_extension = end(explode('.', strtolower($_FILES['files']['name'][$file_form_name])));
+ if (!in_array($temp_extension, $allowed_extensions))
+ form_set_error($file_form_name, t('Only ' . variable_get('lab_migration_dependency_extensions', '') . ' extensions can be uploaded.'));
+ if ($_FILES['files']['size'][$file_form_name] <= 0)
+ form_set_error($file_form_name, t('File size cannot be zero.'));
+ /* check if file already exists */
+ //$dep_exists_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE filename = '%s'", $_FILES['files']['name'][$file_form_name]))->fetchObject();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('filename', $_FILES['files']['name'][$file_form_name]);
+ $dep_exists_data = $query->execute();
+ if ($dep_exists_data)
+ form_set_error($file_form_name, t('Dependency file with the same name has already been uploaded in this or some other lab solution. Please rename the file and try again.'));
+ /* check if valid file name */
+ if (!lab_migration_check_valid_filename($_FILES['files']['name'][$file_form_name]))
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets, numbers and underscore is allowed as a valid filename.'));
+ }
+ }
}
- }
- }
-}
-
-function lab_migration_upload_dependency_form_submit($form, &$form_state) {
- global $user;
-
- $root_path = lab_migration_path();
-
- $proposal_data = lab_migration_get_proposal();
- if (!$proposal_data) {
- drupal_goto('');
- return;
}
-
- $dest_path .= 'DEPENDENCIES' . '/';
- if (!is_dir($root_path . $dest_path))
- mkdir($root_path . $dest_path);
-
- /* uploading dependencies */
- $file_upload_counter = 0;
- $dependency_ids = array();
- $dependency_names = array();
-
- foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+function lab_migration_upload_dependency_form_submit($form, &$form_state)
{
- if ($file_name)
- {
- /* uploading file */
- if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ global $user;
+ $root_path = lab_migration_path();
+ $proposal_data = lab_migration_get_proposal();
+ if (!$proposal_data)
{
- /* for uploaded files making an entry in the database */
- $query = "INSERT INTO {lab_migration_dependency_files} (proposal_id, filename, filepath, filemime, filesize, caption, description, timestamp)
+ drupal_goto('');
+ return;
+ }
+ $dest_path .= 'DEPENDENCIES' . '/';
+ if (!is_dir($root_path . $dest_path))
+ mkdir($root_path . $dest_path);
+ /* uploading dependencies */
+ $file_upload_counter = 0;
+ $dependency_ids = array();
+ $dependency_names = array();
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* uploading file */
+ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ /* for uploaded files making an entry in the database */
+ $query = "INSERT INTO {lab_migration_dependency_files} (proposal_id, filename, filepath, filemime, filesize, caption, description, timestamp)
VALUES (:proposal_id, :filename, :filepath, :filemime, :filesize, :caption, :description, :timestamp)";
- $args = array(
- ":proposal_id" => $proposal_data->id,
- ":filename" => $_FILES['files']['name'][$file_form_name],
- ":filepath" => $dest_path . $_FILES['files']['name'][$file_form_name],
- ":filemime" => $_FILES['files']['type'][$file_form_name],
- ":filesize" => $_FILES['files']['size'][$file_form_name],
- ":caption" => check_plain($form_state['values'][$file_form_name . '_caption']),
- ":description" => check_plain($form_state['values'][$file_form_name . '_description']),
- ":timestamp" => time()
- );
- $dependency_ids[] = db_query($query, $args, array('return' => Database::RETURN_INSERT_ID));
- drupal_set_message($file_name . ' uploaded successfully.', 'status');
- $dependency_names[] = $_FILES['files']['name'][$file_form_name];
- $file_upload_counter++;
- } else {
- drupal_set_message('Error uploading dependency : ' . $dest_path . $_FILES['files']['name'][$file_form_name], 'error');
+ $args = array(
+ ":proposal_id" => $proposal_data->id,
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $dest_path . $_FILES['files']['name'][$file_form_name],
+ ":filemime" => $_FILES['files']['type'][$file_form_name],
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":caption" => check_plain($form_state['values'][$file_form_name . '_caption']),
+ ":description" => check_plain($form_state['values'][$file_form_name . '_description']),
+ ":timestamp" => time()
+ );
+ $dependency_ids[] = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ $dependency_names[] = $_FILES['files']['name'][$file_form_name];
+ $file_upload_counter++;
+ }
+ else
+ {
+ drupal_set_message('Error uploading dependency : ' . $dest_path . $_FILES['files']['name'][$file_form_name], 'error');
+ }
+ }
}
- }
- }
-
- if ($file_upload_counter > 0)
- {
- drupal_set_message('Dependencies uploaded successfully.', 'status');
-
- /* sending email */
- $param['dependency_uploaded']['user_id'] = $user->uid;
- $param['dependency_uploaded']['dependency_names'] = $dependency_names;
-
- $email_to = $user->mail . ', ' . variable_get('lab_migration_emails', '');
- if (!drupal_mail('lab_migration', 'dependency_uploaded', $email_to, language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
+ if ($file_upload_counter > 0)
+ {
+ drupal_set_message('Dependencies uploaded successfully.', 'status');
+ /* sending email */
+ $param['dependency_uploaded']['user_id'] = $user->uid;
+ $param['dependency_uploaded']['dependency_names'] = $dependency_names;
+ $email_to = $user->mail . ', ' . variable_get('lab_migration_emails', '');
+ if (!drupal_mail('lab_migration', 'dependency_uploaded', $email_to, language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ drupal_goto('lab-migration/code/upload-dep');
}
-
- drupal_goto('lab_migration/code/upload_dep');
-}
-
function _list_existing_dependency($proposal_id)
-{
- $return_html = '<ul>';
- // $proposal_dependency_files_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE proposal_id = %d ORDER BY filename ASC", $proposal_id);
- $query = db_select('lab_migration_dependency_files');
-$query->fields('lab_migration_dependency_files');
-$query->condition('proposal_id', $proposal_id);
-$query->orderBy('filename', 'ASC');
-$proposal_dependency_files_q = $query->execute();
-
- $counter = 0;
- while ($proposal_dependency_files_data = $proposal_dependency_files_q->fetchObject())
{
- $temp_caption = '';
- if ($proposal_dependency_files_data->caption)
- $temp_caption = ' (' . $proposal_dependency_files_data->caption . ')';
- $return_html .= '<li>' . l($proposal_dependency_files_data->filename . $temp_caption, 'lab_migration/download/dependency/' . $proposal_dependency_files_data->id) . '</li>';
- $counter++;
+ $return_html = '<ul>';
+ // $proposal_dependency_files_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE proposal_id = %d ORDER BY filename ASC", $proposal_id);
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('proposal_id', $proposal_id);
+ $query->orderBy('filename', 'ASC');
+ $proposal_dependency_files_q = $query->execute();
+ $counter = 0;
+ while ($proposal_dependency_files_data = $proposal_dependency_files_q->fetchObject())
+ {
+ $temp_caption = '';
+ if ($proposal_dependency_files_data->caption)
+ $temp_caption = ' (' . $proposal_dependency_files_data->caption . ')';
+ $return_html .= '<li>' . l($proposal_dependency_files_data->filename . $temp_caption, 'lab-migration/download/dependency/' . $proposal_dependency_files_data->id) . '</li>';
+ $counter++;
+ }
+ if ($counter == 0)
+ $return_html .= '<li>(None)</li>';
+ $return_html .= '</ul>';
+ return $return_html;
}
- if ($counter == 0)
- $return_html .= '<li>(None)</li>';
- $return_html .= '</ul>';
- return $return_html;
-}
-
diff --git a/dependency_approval.inc b/dependency_approval.inc
index e8f5819..625761c 100755
--- a/dependency_approval.inc
+++ b/dependency_approval.inc
@@ -1,150 +1,156 @@
<?php
-
/******************************************************************************/
/********************************* BULK APPROVAL ******************************/
/******************************************************************************/
-
function lab_migration_dependency_approval_form($form, $form_state)
-{
-
- /* default value for ahah fields */
- if (!isset($form_state['values']['dependency']))
{
- $dependency_default_value = 0;
- } else {
- $dependency_default_value = $form_state['values']['dependency'];
- }
-
- $form['wrapper'] = array(
- '#type' => 'fieldset',
- '#title' => t('Bulk Manage Code'),
- '#collapsible' => FALSE,
- '#collapsed' => FALSE,
- '#prefix' => '<div id="run-wrapper">',
- '#suffix' => '</div>',
- '#tree' => TRUE,
- );
-
- $form['wrapper']['dependency'] = array(
- '#type' => 'select',
- '#title' => t('Dependency'),
- '#options' => _list_of_dependencies(),
- '#default_value' => $dependency_default_value,
- '#tree' => TRUE,
- '#attributes' => array('id' => 'dependancy'),
- );
-
- $form["wrapper"]['dependencyfiles'] = array(
- '#markup' =>'<div id = "dependency-files"></div>',
- );
-
- $form['wrapper']['delete_dependency'] = array(
- '#type' => 'checkbox',
- "#description" => 'Please unlink the dependency from the above solutions before deleting it',
- '#title' => t('Delete Dependency'),
- '#prefix' => '<div id="delete-dependency-file">',
- '#attributes' => array('id' => 'delete-dependancy'),
+ /* default value for ahah fields */
+ if (!isset($form_state['values']['dependency']))
+ {
+ $dependency_default_value = 0;
+ }
+ else
+ {
+ $dependency_default_value = $form_state['values']['dependency'];
+ }
+ $form['wrapper'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Bulk Manage Code'),
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE,
+ '#prefix' => '<div id="run-wrapper">',
+ '#suffix' => '</div>',
+ '#tree' => TRUE
+ );
+ $form['wrapper']['dependency'] = array(
+ '#type' => 'select',
+ '#title' => t('Dependency'),
+ '#options' => _list_of_dependencies(),
+ '#default_value' => $dependency_default_value,
+ '#tree' => TRUE,
+ '#attributes' => array(
+ 'id' => 'dependancy'
+ )
+ );
+ $form["wrapper"]['dependencyfiles'] = array(
+ '#markup' => '<div id = "dependency-files"></div>'
+ );
+ $form['wrapper']['delete_dependency'] = array(
+ '#type' => 'checkbox',
+ "#description" => 'Please unlink the dependency from the above solutions before deleting it',
+ '#title' => t('Delete Dependency'),
+ '#prefix' => '<div id="delete-dependency-file">',
+ '#attributes' => array(
+ 'id' => 'delete-dependancy'
+ )
);
$form['wrapper']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit'),
- '#suffix' => '</div>',
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ '#suffix' => '</div>'
);
-
-
- return $form;
-}
-
-function lab_migration_dependency_approval_ajax($item="",$key=""){
- $data = "";
- $dependency_default_value = $key;
- $solution_list = array();
- //$solution_id_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE dependency_id = %d", $dependency_default_value);
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_solution_dependency');
- $query->condition('dependency_id', $dependency_default_value);
- $solution_id_q = $query->execute();
-
- while ($solution_id_data = $solution_id_q->fetchObject()) {
+ return $form;
+ }
+function lab_migration_dependency_approval_ajax($item = "", $key = "")
+ {
+ $data = "";
+ $dependency_default_value = $key;
+ $solution_list = array();
+ //$solution_id_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE dependency_id = %d", $dependency_default_value);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_solution_dependency');
+ $query->condition('dependency_id', $dependency_default_value);
+ $solution_id_q = $query->execute();
+ while ($solution_id_data = $solution_id_q->fetchObject())
+ {
//$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d", $solution_id_data->solution_id);
$query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('id', $solution_id_data->solution_id);
- $solution_q = $query->execute();
+ $query->fields('lab_migration_solution');
+ $query->condition('id', $solution_id_data->solution_id);
+ $solution_q = $query->execute();
$solution_data = $solution_q->fetchObject();
//$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();
-
+ $query->fields('lab_migration_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $experiment_q = $query->execute();
$experiment_data = $experiment_q->fetchObject();
//$lab_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $experiment_data->proposal_id);
$query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $experiment_data->proposal_id );
- $lab_q = $query->execute();
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $experiment_data->proposal_id);
+ $lab_q = $query->execute();
$lab_data = $lab_q->fetchObject();
- $solution_list[] = array($solution_data->code_number, $experiment_data->number . ' . ' . $experiment_data->title, $lab_data->lab_title);
+ $solution_list[] = array(
+ $solution_data->code_number,
+ $experiment_data->number . ' . ' . $experiment_data->title,
+ $lab_data->lab_title
+ );
}
- $solution_list_header = array('Code', 'Experiment', 'Lab');
- //$solution = theme_table($solution_list_header, $solution_list);
- $solution = theme('table', array('header' => $solution_list_header, 'rows' => $solution_list));
- $data .= $solution;
- echo $data;
-}
-
-
+ $solution_list_header = array(
+ 'Code',
+ 'Experiment',
+ 'Lab'
+ );
+ //$solution = theme_table($solution_list_header, $solution_list);
+ $solution = theme('table', array(
+ 'header' => $solution_list_header,
+ 'rows' => $solution_list
+ ));
+ $data .= $solution;
+ echo $data;
+ }
function lab_migration_dependency_approval_form_submit($form, &$form_state)
-{
- global $user;
- $root_path = lab_migration_path();
-
- if ($form_state['clicked_button']['#value'] == 'Submit')
- {
- if (user_access('bulk manage code'))
- {
- if ($form_state['values']['delete_dependency'] == "1")
+ {
+ global $user;
+ $root_path = lab_migration_path();
+ if ($form_state['clicked_button']['#value'] == 'Submit')
{
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE dependency_id = %d", $form_state['values']['wrapper']['dependency']);
-
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_solution_dependency');
- $query->condition('dependency_id', $form_state['values']['dependency']);
- $solution_q = $query->execute();
- if ($solution_data = $solution_q->fetchObject()) {
- drupal_set_message('Cannot delete dependency since it is linked with some solutions' , 'error');
- } else {
- if (lab_migration_delete_dependency($form_state['values']['dependency']))
- {
- drupal_set_message('Dependency deleted' , 'status');
-
- /* email */
- $email_subject = t('Dependency deleted');
- $email_body = t('Dependency deleted : .') . $form_state['values']['dependency'];
- $email_to = variable_get('lab_migration_emails', '') . ', ' . $user->mail;
- $param['standard']['subject'] = $email_subject;
- $param['standard']['body'] = $email_body;
- if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
- }
- }
+ if (user_access('bulk manage code'))
+ {
+ if ($form_state['values']['delete_dependency'] == "1")
+ {
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE dependency_id = %d", $form_state['values']['wrapper']['dependency']);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_solution_dependency');
+ $query->condition('dependency_id', $form_state['values']['dependency']);
+ $solution_q = $query->execute();
+ if ($solution_data = $solution_q->fetchObject())
+ {
+ drupal_set_message('Cannot delete dependency since it is linked with some solutions', 'error');
+ }
+ else
+ {
+ if (lab_migration_delete_dependency($form_state['values']['dependency']))
+ {
+ drupal_set_message('Dependency deleted', 'status');
+ /* email */
+ $email_subject = t('Dependency deleted');
+ $email_body = t('Dependency deleted : .') . $form_state['values']['dependency'];
+ $email_to = variable_get('lab_migration_emails', '') . ', ' . $user->mail;
+ $param['standard']['subject'] = $email_subject;
+ $param['standard']['body'] = $email_body;
+ if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ }
+ }
+ }
}
- }
}
-}
-
function _list_of_dependencies()
-{
- $dependencies = array('0' => 'Please select...');
- //$dependency_q = db_query("SELECT * FROM {lab_migration_dependency_files} ORDER BY filename ASC");
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->orderBy('filename', 'ASC');
- $dependency_q = $query->execute();
- while ($dependency_data = $dependency_q->fetchObject())
{
- $dependencies[$dependency_data->id] = $dependency_data->filename . ' (' . $dependency_data->filepath . ')';
+ $dependencies = array(
+ '0' => 'Please select...'
+ );
+ //$dependency_q = db_query("SELECT * FROM {lab_migration_dependency_files} ORDER BY filename ASC");
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->orderBy('filename', 'ASC');
+ $dependency_q = $query->execute();
+ while ($dependency_data = $dependency_q->fetchObject())
+ {
+ $dependencies[$dependency_data->id] = $dependency_data->filename . ' (' . $dependency_data->filepath . ')';
+ }
+ return $dependencies;
}
- return $dependencies;
-}
diff --git a/download.inc b/download.inc
index d22a702..a829f54 100755
--- a/download.inc
+++ b/download.inc
@@ -1,298 +1,275 @@
<?php
// $Id$
-
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');
- $query->fields('lab_migration_solution_files');
- $query->condition('id', $solution_file_id);
- $query->range(0, 1);
- $solution_files_q = $query->execute();
- $solution_file_data = $solution_files_q->fetchObject();
- header('Content-Type: ' . $solution_file_data->filemime);
- header('Content-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);
-}
-
-function lab_migration_download_dependency_file()
-{
- $dependency_file_id = arg(3);
- $root_path = lab_migration_path();
-
- //$dependency_file_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $dependency_file_id);
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $dependency_file_id);
- $query->range(0, 1);
- $dependency_files_q = $query->execute();
- $dependency_file_data = $dependency_files_q->fetchObject();
- header('Content-Type: ' . $dependency_file_data->filemime);
- header('Content-disposition: attachment; filename="' . str_replace(' ','_',($dependency_file_data->filename)) . '"');
- header('Content-Length: ' . filesize($root_path . $dependency_file_data->filepath));
- readfile($root_path . $dependency_file_data->filepath);
-}
-
-function lab_migration_download_solution()
-{
- $solution_id = arg(3);
- $root_path = lab_migration_path();
-
- /* get solution data */
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d", $solution_id);
- $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();
- //$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_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->fields('lab_migration_solution_files');
- $query->condition('solution_id', $solution_id );
- $solution_files_q = $query->execute();
- //$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');
- $query->condition('solution_id', $solution_id);
- $solution_dependency_files_q = $query->execute();
-
- $CODE_PATH = 'CODE' . $solution_data->code_number . '/';
-
- /* zip filename */
- $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
-
- /* creating zip archive on the server */
- $zip = new ZipArchive;
- $zip->open($zip_filename, ZipArchive::CREATE);
-
- while ($solution_files_row = $solution_files_q->fetchObject())
{
- $zip->addFile($root_path . $solution_files_row->filepath, $CODE_PATH . str_replace(' ','_',($solution_files_row->filename)));
+ $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');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('id', $solution_file_id);
+ $query->range(0, 1);
+ $solution_files_q = $query->execute();
+ $solution_file_data = $solution_files_q->fetchObject();
+ header('Content-Type: ' . $solution_file_data->filemime);
+ header('Content-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);
}
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+function lab_migration_download_dependency_file()
{
- //$dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
+ $dependency_file_id = arg(3);
+ $root_path = lab_migration_path();
+ //$dependency_file_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $dependency_file_id);
$query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $solution_dependency_files_row->dependency_id);
- $query->range(0, 1);
- $dependency_file_data = $query->execute()->fetchObject();
-
- if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ','_',($dependency_file_data->filename)));
- }
- $zip_file_count = $zip->numFiles;
- $zip->close();
-
- if ($zip_file_count > 0)
- {
- /* download zip file */
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="CODE' . $solution_data->code_number . '.zip"');
- header('Content-Length: ' . filesize($zip_filename));
- ob_clean();
- //flush();
- readfile($zip_filename);
- unlink($zip_filename);
- } else {
- drupal_set_message("There are no files in this solutions to download", 'error');
- drupal_goto('lab_migration_run');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $dependency_file_id);
+ $query->range(0, 1);
+ $dependency_files_q = $query->execute();
+ $dependency_file_data = $dependency_files_q->fetchObject();
+ header('Content-Type: ' . $dependency_file_data->filemime);
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($dependency_file_data->filename)) . '"');
+ header('Content-Length: ' . filesize($root_path . $dependency_file_data->filepath));
+ readfile($root_path . $dependency_file_data->filepath);
}
-}
-
-function lab_migration_download_experiment()
-{
- $experiment_id = arg(3);
- $root_path = lab_migration_path();
-
- /* get solution data */
- //$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();
- $EXP_PATH = 'EXP' . $experiment_data->number . '/';
-
- /* zip filename */
- $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
-
- /* creating zip archive on the server */
- $zip = new ZipArchive;
- $zip->open($zip_filename, ZipArchive::CREATE);
-
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_id);
- $query->condition('approval_status', 1);
- $solution_q = $query->execute();
- while ($solution_row = $solution_q->fetchObject())
+function lab_migration_download_solution()
{
- $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);
+ $solution_id = arg(3);
+ $root_path = lab_migration_path();
+ /* get solution data */
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d", $solution_id);
+ $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();
+ //$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_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->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->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_id);
+ $solution_files_q = $query->execute();
+ //$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');
- $query->condition('solution_id', $solution_row->id);
- $solution_dependency_files_q = $query->execute();
+ $query->fields('lab_migration_solution_dependency');
+ $query->condition('solution_id', $solution_id);
+ $solution_dependency_files_q = $query->execute();
+ $CODE_PATH = 'CODE' . $solution_data->code_number . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive;
+ $zip->open($zip_filename, ZipArchive::CREATE);
while ($solution_files_row = $solution_files_q->fetchObject())
- {
- $zip->addFile($root_path . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ','_',($solution_files_row->filename)));
- }
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
- {
- //$dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $solution_dependency_files_row->dependency_id);
- $query->range(0, 1);
- $dependency_file_data = $query->execute()->fetchObject();
- if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ','_',($dependency_file_data->filename)));
- }
- }
- $zip_file_count = $zip->numFiles;
- $zip->close();
-
- if ($zip_file_count > 0)
- {
- /* download zip file */
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"');
- header('Content-Length: ' . filesize($zip_filename));
- ob_clean();
- //flush();
- readfile($zip_filename);
- unlink($zip_filename);
- } else {
- drupal_set_message("There are no solutions in this experiment to download", 'error');
- drupal_goto('lab_migration_run');
- }
-}
-
-function lab_migration_download_lab()
-{
- global $user;
- $lab_id = arg(3);
-
- $root_path = lab_migration_path();
-
- /* get solution data */
- //$lab_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);
- $lab_q = $query->execute();
- $lab_data = $lab_q->fetchObject();
- $LAB_PATH = $lab_data->lab_title . '/';
-
-
-
- /* zip filename */
- $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
-
- /* creating zip archive on the server */
- $zip = new ZipArchive();
- $zip->open($zip_filename, ZipArchive::CREATE);
-
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $lab_id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $lab_id);
- $experiment_q = $query->execute();
- while ($experiment_row = $experiment_q->fetchObject())
- {
- $EXP_PATH = 'EXP' . $experiment_row->number . '/';
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_row->id);
- $query->condition('approval_status', 1);
- $solution_q = $query->execute();
- while ($solution_row = $solution_q->fetchObject())
- {
- $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
- //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $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();
- 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)));
- //var_dump($zip->numFiles);
+ $zip->addFile($root_path . $solution_files_row->filepath, $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename)));
}
-
- // die;
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ /* dependency files */
+ 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();
$query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $solution_dependency_files_row->dependency_id);
- $query->range(0, 1);
- $dependency_file_data = $query->execute()->fetchObject();
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ','_',($dependency_file_data->filename)));
+ $zip->addFile($root_path . $dependency_file_data->filepath, $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename)));
+ }
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="CODE' . $solution_data->code_number . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_clean();
+ //flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ else
+ {
+ drupal_set_message("There are no files in this solutions to download", 'error');
+ drupal_goto('lab_migration_run');
}
- }
}
- $zip_file_count = $zip->numFiles;
- $zip->close();
-
- if ($zip_file_count > 0)
+function lab_migration_download_experiment()
{
- if($user->uid) {
- /* download zip file */
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="' .str_replace(' ', '_', $lab_data->lab_title) . '.zip"');
- header('Content-Length: ' . filesize($zip_filename));
- ob_clean();
- //flush();
- readfile($zip_filename);
- unlink($zip_filename);
- } else {
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="' .str_replace(' ', '_', $lab_data->lab_title) . '.zip"');
+ $experiment_id = arg(3);
+ $root_path = lab_migration_path();
+ /* get solution data */
+ //$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();
+ $EXP_PATH = 'EXP' . $experiment_data->number . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive;
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_id);
+ $query->condition('approval_status', 1);
+ $solution_q = $query->execute();
+ while ($solution_row = $solution_q->fetchObject())
+ {
+ $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
+ // $solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $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();
+ 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)));
+ }
+ /* dependency files */
+ 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();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename)));
+ }
+ }
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"');
header('Content-Length: ' . filesize($zip_filename));
- header("Content-Transfer-Encoding: binary");
- header('Expires: 0');
- header('Pragma: no-cache');
- ob_end_flush();
- ob_clean();
- flush();
+ ob_clean();
+ //flush();
readfile($zip_filename);
unlink($zip_filename);
- }
- } else {
- drupal_set_message("There are no solutions in this Lab to download", 'error');
- drupal_goto('lab-migration/lab-migration-run');
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this experiment to download", 'error');
+ drupal_goto('lab_migration_run');
+ }
+ }
+function lab_migration_download_lab()
+ {
+ global $user;
+ $lab_id = arg(3);
+ $root_path = lab_migration_path();
+ /* get solution data */
+ //$lab_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);
+ $lab_q = $query->execute();
+ $lab_data = $lab_q->fetchObject();
+ $LAB_PATH = $lab_data->lab_title . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive();
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $lab_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $lab_id);
+ $experiment_q = $query->execute();
+ while ($experiment_row = $experiment_q->fetchObject())
+ {
+ $EXP_PATH = 'EXP' . $experiment_row->number . '/';
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_row->id);
+ $query->condition('approval_status', 1);
+ $solution_q = $query->execute();
+ while ($solution_row = $solution_q->fetchObject())
+ {
+ $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
+ //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $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();
+ 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)));
+ //var_dump($zip->numFiles);
+ }
+ // die;
+ /* dependency files */
+ 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();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename)));
+ }
+ }
+ }
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ if ($user->uid)
+ {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_clean();
+ //flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ else
+ {
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this Lab to download", 'error');
+ drupal_goto('lab-migration/lab-migration-run');
+ }
}
-}
-
diff --git a/email.inc b/email.inc
index 0f7f650..6900d0b 100755
--- a/email.inc
+++ b/email.inc
@@ -1,52 +1,54 @@
<?php
-
/**
* Implementation of hook_mail().
*/
function lab_migration_mail($key, &$message, $params)
-{
-
- global $user;
- $language = $message['language'];
- //$language = user_preferred_language($user);
- switch ($key)
{
- case 'solution_proposal_approved':
-
- /* initializing data */
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_approved']['proposal_id']);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $params['solution_proposal_approved']['proposal_id']);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
-
- if ($proposal_data->solution_display == 1) {
- $solution_display = 'Yes';
- } else {
- $solution_display = 'No';
- }
-
- // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_approved']['proposal_id'], 1);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $params['solution_proposal_approved']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
+ global $user;
+ $language = $message['language'];
+ //$language = user_preferred_language($user);
+ switch ($key)
+ {
+ case 'solution_proposal_approved':
+ /* initializing data */
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_approved']['proposal_id']);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $params['solution_proposal_approved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if ($proposal_data->solution_display == 1)
+ {
+ $solution_display = 'Yes';
+ }
+ else
+ {
+ $solution_display = 'No';
+ }
+ // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_approved']['proposal_id'], 1);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $params['solution_proposal_approved']['proposal_id']);
+ $query->orderBy('number', 'ASC');
+ $experiment_q = $query->execute();
+ $experiment_list = '
';
- while ($experiment_data = $experiment_q->fetchObject()) {
- $experiment_list .='<p>'. $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : '.$experiment_data->description.'<br>';
- $experiment_list .=' ';
- $experiment_list .='</p>';
- }
-
- $user_data = user_load($params['solution_proposal_approved']['user_id']);
-
- $message['headers'] = $params['solution_proposal_approved']['headers'];
- $message['subject'] = t('[!site_name] Lab Migration Solution Proposal Approval', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array(0 => t('
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
+ $experiment_list .= ' ';
+ $experiment_list .= '</p>';
+ }
+ $user_data = user_load($params['solution_proposal_approved']['user_id']);
+ $message['headers'] = $params['solution_proposal_approved']['headers'];
+ $message['subject'] = t('[!site_name] Lab Migration Solution Proposal Approval', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 0 => t('
Dear !user_name,
Your following Lab migration solution proposal has been approved:
@@ -56,8 +58,8 @@ Email : ' . $user_data->mail . '
Contact No. : ' . $proposal_data->solution_provider_contact_ph . '
Department/Branch : ' . $proposal_data->solution_provider_department . '
University/Institute : ' . $proposal_data->solution_provider_university . '
-City : '.$proposal_data->city.'
-State : '.$proposal_data->state.'
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
List of experiments : ' . $experiment_list . '
@@ -66,16 +68,24 @@ Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/lab
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'solution_proposal_disapproved':
- $user_data = user_load($params['solution_proposal_disapproved']['user_id']);
-
- $message['headers'] = $params['solution_proposal_disapproved']['headers'];
- $message['subject'] = t('[!site_name] Lab Migration Solution Disapproval', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_proposal_disapproved':
+ $user_data = user_load($params['solution_proposal_disapproved']['user_id']);
+ $message['headers'] = $params['solution_proposal_disapproved']['headers'];
+ $message['subject'] = t('[!site_name] Lab Migration Solution Disapproval', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your Lab migration solution proposal has been disapproved.
@@ -85,65 +95,76 @@ Reason: ' . $params['solution_proposal_disapproved']['message'] . '
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'proposal_received':
-
- /* initializing data */
- // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
- // $proposal_data = $proposal_q->fetchObject();
-
- $query = db_select('lab_migration_proposal');
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'proposal_received':
+ /* initializing data */
+ // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
+ // $proposal_data = $proposal_q->fetchObject();
+ $query = db_select('lab_migration_proposal');
$query->fields('lab_migration_proposal');
$query->condition('id', $params['proposal_received']['proposal_id']);
$query->range(0, 1);
$proposal_data = $query->execute()->fetchObject();
-
- $samplecodefilename="";
- if(strlen($proposal_data->samplefilepath)>=5){
- $samplecodefilename=substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
- }else{
- $samplecodefilename="Not provided";
- }
-
- if ($proposal_data->solution_display == 1) {
- $solution_display = 'Yes';
- } else {
- $solution_display = 'No';
- }
-
- if ($proposal_data->solution_provider_uid == 0) {
- $solution_provider_user = 'Open';
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
- $solution_provider_user = 'Proposer';
- } else {
- $solution_provider_user = 'Unknown';
- }
-
- // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number",
- // $params['proposal_received']['proposal_id'], 1);
-
- $query = db_select('lab_migration_experiment');
+ /* $samplecodefilename = "";
+ if (strlen($proposal_data->samplefilepath) >= 5)
+ {
+ $samplecodefilename = substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
+ }
+ else
+ {
+ $samplecodefilename = "Not provided";
+ }*/
+ if ($proposal_data->solution_display == 1)
+ {
+ $solution_display = 'Yes';
+ }
+ else
+ {
+ $solution_display = 'No';
+ }
+ if ($proposal_data->solution_provider_uid == 0)
+ {
+ $solution_provider_user = 'Open';
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
+ $solution_provider_user = 'Proposer';
+ }
+ else
+ {
+ $solution_provider_user = 'Unknown';
+ }
+ // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number",
+ // $params['proposal_received']['proposal_id'], 1);
+ $query = db_select('lab_migration_experiment');
$query->fields('lab_migration_experiment');
$query->condition('proposal_id', $params['proposal_received']['proposal_id']);
$query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
-
- $experiment_list = '
+ $experiment_q = $query->execute();
+ $experiment_list = '
';
- while ($experiment_data = $experiment_q->fetchObject()) {
- $experiment_list .='<p>'. $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : '.$experiment_data->description.'<br>';
- $experiment_list .=' ';
- $experiment_list .='</p>';
- }
-
- $user_data = user_load($params['proposal_received']['user_id']);
- $message['headers'] = $params['proposal_received']['headers'];
- $message['subject'] = t('[!site_name] Your Lab migration proposal has been received', array('!site_name' => variable_get('site_name', '')),array('language' => $language->language));
-
- $message['body'] = array('body' => t('
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
+ $experiment_list .= ' ';
+ $experiment_list .= '</p>';
+ }
+ $user_data = user_load($params['proposal_received']['user_id']);
+ $message['headers'] = $params['proposal_received']['headers'];
+ $message['subject'] = t('[!site_name] Your Lab migration proposal has been received', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We have received your Lab migration proposal with the following details:
@@ -153,77 +174,88 @@ Email : ' . $user_data->mail . '
Contact No. : ' . $proposal_data->contact_ph . '
Department/Branch : ' . $proposal_data->department . '
University/Institute : ' . $proposal_data->university . '
-City : '.$proposal_data->city.'
-State : '.$proposal_data->state.'
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
Solution Provided By : ' . $solution_provider_user . '
List of experiments : ' . $experiment_list . '
-Uploaded Sample Code : '.$samplecodefilename.'
-
Your proposal is under review. You will soon receive an email when same has been approved/disapproved.
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
-
-
- break;
-
- case 'proposal_disapproved':
-
- /* initializing data */
- // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']);
- //$proposal_data = $proposal_q->fetchObject();
- $query = db_select('lab_migration_proposal');
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'proposal_disapproved':
+ /* initializing data */
+ // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']);
+ //$proposal_data = $proposal_q->fetchObject();
+ $query = db_select('lab_migration_proposal');
$query->fields('lab_migration_proposal');
$query->condition('id', $params['proposal_disapproved']['proposal_id']);
$query->range(0, 1);
$proposal_data = $query->execute()->fetchObject();
-
- $samplecodefilename="";
- if(strlen($proposal_data->samplefilepath)>=5){
- $samplecodefilename=substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
- }else{
- $samplecodefilename="Not provided";
- }
-
- if ($proposal_data->solution_display == 1) {
- $solution_display = 'Yes';
- } else {
- $solution_display = 'No';
- }
-
- if ($proposal_data->solution_provider_uid == 0) {
- $solution_provider_user = 'Open';
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
- $solution_provider_user = 'Proposer';
- } else {
- $solution_provider_user = 'Unknown';
- }
-
- // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_disapproved']['proposal_id'], 1);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $params['proposal_disapproved']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
+ $samplecodefilename = "";
+ if (strlen($proposal_data->samplefilepath) >= 5)
+ {
+ $samplecodefilename = substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
+ }
+ else
+ {
+ $samplecodefilename = "Not provided";
+ }
+ if ($proposal_data->solution_display == 1)
+ {
+ $solution_display = 'Yes';
+ }
+ else
+ {
+ $solution_display = 'No';
+ }
+ if ($proposal_data->solution_provider_uid == 0)
+ {
+ $solution_provider_user = 'Open';
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
+ $solution_provider_user = 'Proposer';
+ }
+ else
+ {
+ $solution_provider_user = 'Unknown';
+ }
+ // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_disapproved']['proposal_id'], 1);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $params['proposal_disapproved']['proposal_id']);
+ $query->orderBy('number', 'ASC');
+ $experiment_q = $query->execute();
+ $experiment_list = '
';
- while ($experiment_data = $experiment_q->fetchObject()) {
- $experiment_list .='<p>'. $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : '.$experiment_data->description.'<br>';
- $experiment_list .=' ';
- $experiment_list .='</p>';
- }
-
- $user_data = user_load($params['proposal_disapproved']['user_id']);
- $message['headers'] = $params['proposal_disapproved']['headers'];
- $message['subject'] = t('[!site_name] Your Lab migration proposal has been disapproved', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
+ $experiment_list .= ' ';
+ $experiment_list .= '</p>';
+ }
+ $user_data = user_load($params['proposal_disapproved']['user_id']);
+ $message['headers'] = $params['proposal_disapproved']['headers'];
+ $message['subject'] = t('[!site_name] Your Lab migration proposal has been disapproved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We regret to inform you that all the Experiments of your Lab with following details have been dis-approved.
@@ -235,74 +267,88 @@ Email : ' . $user_data->mail . '
Contact No. : ' . $proposal_data->contact_ph . '
Department/Branch : ' . $proposal_data->department . '
University/Institute : ' . $proposal_data->university . '
-City : '.$proposal_data->city.'
-State : '.$proposal_data->state.'
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
Solution Provided By : ' . $solution_provider_user . '
List of experiments : ' . $experiment_list . '
-Uploaded Sample Code : '.$samplecodefilename.'
+Uploaded Sample Code : ' . $samplecodefilename . '
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'proposal_approved':
-
- /* initializing data */
- // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']);
-
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $params['proposal_approved']['proposal_id']);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- $samplecodefilename="";
- if(strlen($proposal_data->samplefilepath)>=5){
- $samplecodefilename=substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
- }else{
- $samplecodefilename="Not provided";
- }
- if ($proposal_data->solution_display == 1) {
- $solution_display = 'Yes';
- } else {
- $solution_display = 'No';
- }
-
- if ($proposal_data->solution_provider_uid == 0) {
- $solution_provider_user = 'Open';
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
- $solution_provider_user = 'Proposer';
- } else {
- $solution_provider_user = 'Unknown';
- }
-
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_approved']['proposal_id'], 1);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $params['proposal_approved']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
-
- $experiment_list = '
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'proposal_approved':
+ /* initializing data */
+ // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $params['proposal_approved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ /* $samplecodefilename = "";
+ if (strlen($proposal_data->samplefilepath) >= 5)
+ {
+ $samplecodefilename = substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
+ }
+ else
+ {
+ $samplecodefilename = "Not provided";
+ }*/
+ if ($proposal_data->solution_display == 1)
+ {
+ $solution_display = 'Yes';
+ }
+ else
+ {
+ $solution_display = 'No';
+ }
+ if ($proposal_data->solution_provider_uid == 0)
+ {
+ $solution_provider_user = 'Open';
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
+ $solution_provider_user = 'Proposer';
+ }
+ else
+ {
+ $solution_provider_user = 'Unknown';
+ }
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_approved']['proposal_id'], 1);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $params['proposal_approved']['proposal_id']);
+ $query->orderBy('number', 'ASC');
+ $experiment_q = $query->execute();
+ $experiment_list = '
';
- while ($experiment_data = $experiment_q->fetchObject()) {
- $experiment_list .='<p>'. $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : '.$experiment_data->description.'<br>';
- $experiment_list .=' ';
- $experiment_list .='</p>';
- }
-
- $user_data = user_load($params['proposal_approved']['user_id']);
- $message['headers'] = $params['proposal_approved']['headers'];
- $message['subject'] = t('[!site_name] Your Lab migration proposal has been approved',
- array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array(0 => t('
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
+ $experiment_list .= ' ';
+ $experiment_list .= '</p>';
+ }
+ $user_data = user_load($params['proposal_approved']['user_id']);
+ $message['headers'] = $params['proposal_approved']['headers'];
+ $message['subject'] = t('[!site_name] Your Lab migration proposal has been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 0 => t('
Dear !user_name,
Congratulations! Your Lab migration proposal with the below details has been approved:
@@ -312,72 +358,84 @@ Email : ' . $user_data->mail . '
Contact No. : ' . $proposal_data->contact_ph . '
Department/Branch : ' . $proposal_data->department . '
University/Institute : ' . $proposal_data->university . '
-City : '.$proposal_data->city.'
-State : '.$proposal_data->state.'
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
Solution Provided By : ' . $solution_provider_user . '
List of experiments : ' . $experiment_list . '
-Uploaded Sample Code : '.$samplecodefilename.'
-
Please ensure that ALL the guidelines for coding are strictly followed:
http://dwsim.fossee.in/lab-migration-project/lab-migration-guidelines
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'proposal_completed':
-
- /* initializing data */
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_completed']['proposal_id']);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $params['proposal_completed']['proposal_id']);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
-
- if ($proposal_data->solution_display == 1) {
- $solution_display = 'Yes';
- } else {
- $solution_display = 'No';
- }
-
- if ($proposal_data->solution_provider_uid == 0) {
- $solution_provider_user = 'Open';
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
- $solution_provider_user = 'Proposer';
- } else {
- $user_data = user_load($proposal_data->solution_provider_uid);
- if (!$user_data) {
- $solution_provider_user = 'Unknown';
- }
- }
-
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_completed']['proposal_id'], 1);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $params['proposal_completed']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'proposal_completed':
+ /* initializing data */
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_completed']['proposal_id']);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $params['proposal_completed']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if ($proposal_data->solution_display == 1)
+ {
+ $solution_display = 'Yes';
+ }
+ else
+ {
+ $solution_display = 'No';
+ }
+ if ($proposal_data->solution_provider_uid == 0)
+ {
+ $solution_provider_user = 'Open';
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
+ $solution_provider_user = 'Proposer';
+ }
+ else
+ {
+ $user_data = user_load($proposal_data->solution_provider_uid);
+ if (!$user_data)
+ {
+ $solution_provider_user = 'Unknown';
+ }
+ }
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_completed']['proposal_id'], 1);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $params['proposal_completed']['proposal_id']);
+ $query->orderBy('number', 'ASC');
+ $experiment_q = $query->execute();
+ $experiment_list = '
';
- while ($experiment_data = $experiment_q->fetchObject()) {
- $experiment_list .='<p>'. $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : '.$experiment_data->description.'<br>';
- $experiment_list .=' ';
- $experiment_list .='</p>';
- }
-
- $user_data = user_load($params['proposal_completed']['user_id']);
- $message['headers'] = $params['proposal_completed']['headers'];
- $message['subject'] = t('[!site_name] Congratulations for completion of the Lab migration', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
+ $experiment_list .= ' ';
+ $experiment_list .= '</p>';
+ }
+ $user_data = user_load($params['proposal_completed']['user_id']);
+ $message['headers'] = $params['proposal_completed']['headers'];
+ $message['subject'] = t('[!site_name] Congratulations for completion of the Lab migration', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Following Lab migration has been completed sucessfully :
@@ -387,8 +445,8 @@ Email : ' . $user_data->mail . '
Contact No. : ' . $proposal_data->contact_ph . '
Department/Branch : ' . $proposal_data->department . '
University/Institute : ' . $proposal_data->university . '
-City : '.$proposal_data->city.'
-State : '.$proposal_data->state.'
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
Solution Provided By : ' . $solution_provider_user . '
@@ -406,45 +464,54 @@ Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/lab
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'solution_proposal_received':
-
- /* initializing data */
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_received']['proposal_id']);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $params['solution_proposal_received']['proposal_id']);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
-
- if ($proposal_data->solution_display == 1) {
- $solution_display = 'Yes';
- } else {
- $solution_display = 'No';
- }
-
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_received']['proposal_id'], 1);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $params['solution_proposal_received']['proposal_id']);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_list = '
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_proposal_received':
+ /* initializing data */
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_received']['proposal_id']);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $params['solution_proposal_received']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if ($proposal_data->solution_display == 1)
+ {
+ $solution_display = 'Yes';
+ }
+ else
+ {
+ $solution_display = 'No';
+ }
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_received']['proposal_id'], 1);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $params['solution_proposal_received']['proposal_id']);
+ $query->orderBy('number', 'ASC');
+ $experiment_q = $query->execute();
+ $experiment_list = '
';
- while ($experiment_data = $experiment_q->fetchObject()) {
- $experiment_list .='<p>'. $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : '.$experiment_data->description.'<br>';
- $experiment_list .=' ';
- $experiment_list .='</p>';
- }
-
- $user_data = user_load($params['solution_proposal_received']['user_id']);
- $message['headers'] = $params['solution_proposal_received']['headers'];
- $message['subject'] = t('[!site_name] Your Lab migration solution proposal has been received', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
+ $experiment_list .= ' ';
+ $experiment_list .= '</p>';
+ }
+ $user_data = user_load($params['solution_proposal_received']['user_id']);
+ $message['headers'] = $params['solution_proposal_received']['headers'];
+ $message['subject'] = t('[!site_name] Your Lab migration solution proposal has been received', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We have received your proposal for solution for following Lab migration :
@@ -454,11 +521,11 @@ Email : ' . $user_data->mail . '
Contact No. : ' . $proposal_data->contact_ph . '
Department/Branch : ' . $proposal_data->department . '
University/Institute : ' . $proposal_data->university . '
-City : '.$proposal_data->city.'
-State : '.$proposal_data->state.'
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
-Solution Provided By : ' . $proposal_data->name_title .'
+Solution Provided By : ' . $proposal_data->name_title . '
List of experiments : ' . $experiment_list . '
@@ -469,31 +536,37 @@ Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/lab
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'solution_uploaded':
- // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_uploaded']['solution_id']);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('id', $params['solution_uploaded']['solution_id']);
- $query->range(0, 1);
- $solution_q = $query->execute();
- $solution_data = $solution_q->fetchObject();
-
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('id', $solution_data->experiment_id);
- $query->range(0, 1);
- $experiment_q = $query->execute();
- $experiment_data = $experiment_q->fetchObject();
-
- $user_data = user_load($params['solution_uploaded']['user_id']);
-
- $message['subject'] = t('[!site_name] You have uploaded Lab migration solution', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['headers'] = $params['solution_uploaded']['headers'];
- $message['body'] = array('body' => t('
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_uploaded':
+ // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_uploaded']['solution_id']);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('id', $params['solution_uploaded']['solution_id']);
+ $query->range(0, 1);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $query->range(0, 1);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ $user_data = user_load($params['solution_uploaded']['user_id']);
+ $message['subject'] = t('[!site_name] You have uploaded Lab migration solution', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['headers'] = $params['solution_uploaded']['headers'];
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
You have uploaded the following solution:
@@ -501,37 +574,44 @@ You have uploaded the following solution:
Experiment Title : ' . $experiment_data->title . '
Solution number : ' . $solution_data->code_number . '
-Caption : ' . $solution_data->caption . '
+Caption : ' . $solution_data->caption . '
The solution is under review. You will be notified when it has been approved.
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'solution_approved':
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_approved']['solution_id']);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('id', $params['solution_approved']['solution_id']);
- $query->range(0, 1);
- $solution_q = $query->execute();
- $solution_data = $solution_q->fetchObject();
-
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('id', $solution_data->experiment_id);
- $query->range(0, 1);
- $experiment_q = $query->execute();
- $experiment_data = $experiment_q->fetchObject();
-
- $user_data = user_load($params['solution_approved']['user_id']);
- $message['headers'] = $params['solution_approved']['headers'];
- $message['subject'] = t('[!site_name] Your uploaded Lab migration solution has been approved', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_approved':
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_approved']['solution_id']);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('id', $params['solution_approved']['solution_id']);
+ $query->range(0, 1);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $query->range(0, 1);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ $user_data = user_load($params['solution_approved']['user_id']);
+ $message['headers'] = $params['solution_approved']['headers'];
+ $message['subject'] = t('[!site_name] Your uploaded Lab migration solution has been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your following solution has been approved:
@@ -539,22 +619,31 @@ Your following solution has been approved:
Experiment Title : ' . $experiment_data->title . '
Solution number : ' . $solution_data->code_number . '
-Caption : ' . $solution_data->caption . '
+Caption : ' . $solution_data->caption . '
Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/lab-migration-project/lab-migration-guidelines
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'solution_disapproved':
- $user_data = user_load($params['solution_disapproved']['user_id']);
- $message['headers'] = $params['solution_disapproved']['headers'];
- $message['subject'] = t('[!site_name] Your uploaded Lab migration solution has been disapproved', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_disapproved':
+ $user_data = user_load($params['solution_disapproved']['user_id']);
+ $message['headers'] = $params['solution_disapproved']['headers'];
+ $message['subject'] = t('[!site_name] Your uploaded Lab migration solution has been disapproved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your following solution has been disapproved:
@@ -568,15 +657,24 @@ Reason for dis-approval : ' . $params['solution_disapproved']['message'] . '
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'solution_deleted_user':
- $user_data = user_load($params['solution_deleted_user']['user_id']);
- $message['headers'] = $params['solution_deleted_user']['headers'];
- $message['subject'] = t('[!site_name] User has deleted pending Lab migration solution', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_deleted_user':
+ $user_data = user_load($params['solution_deleted_user']['user_id']);
+ $message['headers'] = $params['solution_deleted_user']['headers'];
+ $message['subject'] = t('[!site_name] User has deleted pending Lab migration solution', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your following pending solution has been deleted :
@@ -591,16 +689,25 @@ Caption : ' . $params['solution_deleted_user']['solution_caption'] . '
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'dependency_uploaded':
- $user_data = user_load($params['dependency_uploaded']['user_id']);
- $dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']);
- $message['headers'] = $params['dependency_uploaded']['headers'];
- $message['subject'] = t('[!site_name] You have uploaded dependency file', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language));
- $message['body'] = array('body' => t('
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'dependency_uploaded':
+ $user_data = user_load($params['dependency_uploaded']['user_id']);
+ $dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']);
+ $message['headers'] = $params['dependency_uploaded']['headers'];
+ $message['subject'] = t('[!site_name] You have uploaded dependency file', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
You have uploaded following dependency files :
@@ -611,15 +718,18 @@ Please ensure that ALL the codes follow guidelines at http://dwsim.fossee.in/lab
Best Wishes,
!site_name Team,
-FOSSEE,IIT Bombay', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language)));
-
- break;
-
- case 'standard':
- $message['subject'] = $params['standard']['subject'];
- $message['body'] = $params['standard']['body'];
- $message['headers'] = $params['standard']['headers'];
- break;
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'standard':
+ $message['subject'] = $params['standard']['subject'];
+ $message['body'] = $params['standard']['body'];
+ $message['headers'] = $params['standard']['headers'];
+ break;
+ }
}
-}
-
diff --git a/full_download.inc b/full_download.inc
index 9b8a617..0546be2 100755
--- a/full_download.inc
+++ b/full_download.inc
@@ -1,253 +1,235 @@
<?php
// $Id$
-
function lab_migration_download_full_experiment()
-{
- $experiment_id = arg(3);
- $root_path = lab_migration_path();
- $APPROVE_PATH = 'APPROVED/';
- $PENDING_PATH = 'PENDING/';
-
- /* get solution data */
- //$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();
- $EXP_PATH = 'EXP' . $experiment_data->number . '/';
-
- /* zip filename */
- $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
-
- /* creating zip archive on the server */
- $zip = new ZipArchive;
- $zip->open($zip_filename, ZipArchive::CREATE);
-
- /* approved solutions */
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_id);
- $query->condition('approval_status', 1);
- $result = $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->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();
-
- 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);
- }
- /* dependency files */
- 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();
-
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $solution_dependency_files_row->dependency_id);
- $query->range(0, 1);
- $dependency_file_data = $query->execute()->fetchObject();
- if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
- }
- }
-
- /* unapproved solutions */
- // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_id);
- $query->condition('approval_status', 0);
- $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->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();
- 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);
- }
- /* dependency files */
- 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();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $solution_dependency_files_row->dependency_id);
- $query->range(0, 1);
- $dependency_file_data = $query->execute()->fetchObject();
- if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
- }
- }
-
- $zip_file_count = $zip->numFiles;
- $zip->close();
-
- if ($zip_file_count > 0)
- {
- /* download zip file */
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"');
- header('Content-Length: ' . filesize($zip_filename));
- readfile($zip_filename);
- unlink($zip_filename);
- } else {
- drupal_set_message("There are no solutions in this experiment to download", 'error');
- drupal_goto('lab_migration/code_approval/bulk');
- }
-}
-
-function lab_migration_download_full_lab()
-{
- $lab_id = arg(3);
- var_dump($lab_id);
- //die;
- $root_path = lab_migration_path();
- $APPROVE_PATH = 'APPROVED/';
- $PENDING_PATH = 'PENDING/';
-
- /* get solution data */
- //$lab_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);
- $lab_q = $query->execute();
- $lab_data = $lab_q->fetchObject();
- $LAB_PATH = $lab_data->lab_title . '/';
-
- /* zip filename */
- $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
-
- /* creating zip archive on the server */
- $zip = new ZipArchive;
- $zip->open($zip_filename, ZipArchive::CREATE);
-
- /* approved solutions */
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $lab_id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $lab_id);
- $experiment_q = $query->execute();
- while ($experiment_row = $experiment_q->fetchObject())
- {
- $EXP_PATH = 'EXP' . $experiment_row->number . '/';
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id);
+ $experiment_id = arg(3);
+ $root_path = lab_migration_path();
+ $APPROVE_PATH = 'APPROVED/';
+ $PENDING_PATH = 'PENDING/';
+ /* get solution data */
+ //$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();
+ $EXP_PATH = 'EXP' . $experiment_data->number . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive;
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ /* approved solutions */
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id);
$query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_row->id);
- $query->condition('approval_status', 1);
- $solution_q = $query->execute();
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_id);
+ $query->condition('approval_status', 1);
+ $result = $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->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();
- 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);
- }
- /* dependency files */
- 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();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $solution_dependency_files_row->dependency_id);
- $query->range(0, 1);
- $dependency_file_data = $query->execute()->fetchObject();
- if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ $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->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();
+ 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);
+ }
+ /* dependency files */
+ 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();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
}
- }
-
/* unapproved solutions */
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_row->id);
+ // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_id);
$query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_row->id);
- $query->condition('approval_status', 0);
- $solution_q = $query->execute();
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_id);
+ $query->condition('approval_status', 0);
+ $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->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();
- 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);
+ $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->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();
+ 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);
+ }
+ /* dependency files */
+ 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();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
}
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
{
- //$dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $solution_dependency_files_row->dependency_id);
- $query->range(0, 1);
- $dependency_file_data = $query->execute()->fetchObject();
- if ($dependency_file_data)
- $zip->addFile($root_path . $dependency_file_data->filepath, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this experiment to download", 'error');
+ drupal_goto('lab_migration/code_approval/bulk');
}
- }
}
-
- $zip_file_count = $zip->numFiles;
- $zip->close();
-
- if ($zip_file_count > 0)
+function lab_migration_download_full_lab()
{
- /* download zip file */
- ob_clean();
- //flush();
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="' . $lab_data->lab_title . '.zip"');
- header('Content-Length: ' . filesize($zip_filename));
- readfile($zip_filename);
- unlink($zip_filename);
- } else {
- drupal_set_message("There are no solutions in this lab to download", 'error');
- drupal_goto('lab-migration/code-approval/bulk');
+ $lab_id = arg(3);
+ var_dump($lab_id);
+ //die;
+ $root_path = lab_migration_path();
+ $APPROVE_PATH = 'APPROVED/';
+ $PENDING_PATH = 'PENDING/';
+ /* get solution data */
+ //$lab_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);
+ $lab_q = $query->execute();
+ $lab_data = $lab_q->fetchObject();
+ $LAB_PATH = $lab_data->lab_title . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive;
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ /* approved solutions */
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $lab_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $lab_id);
+ $experiment_q = $query->execute();
+ while ($experiment_row = $experiment_q->fetchObject())
+ {
+ $EXP_PATH = 'EXP' . $experiment_row->number . '/';
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_row->id);
+ $query->condition('approval_status', 1);
+ $solution_q = $query->execute();
+ while ($solution_row = $solution_q->fetchObject())
+ {
+ $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
+ //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $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();
+ 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);
+ }
+ /* dependency files */
+ 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();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
+ }
+ /* unapproved solutions */
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_row->id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_row->id);
+ $query->condition('approval_status', 0);
+ $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->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();
+ 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);
+ }
+ /* dependency files */
+ 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();
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
+ }
+ }
+ }
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ /* download zip file */
+ ob_clean();
+ //flush();
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . $lab_data->lab_title . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ else
+ {
+ drupal_set_message("There are no solutions in this lab to download", 'error');
+ drupal_goto('lab-migration/code-approval/bulk');
+ }
}
-}
-
diff --git a/general_deletion.inc b/general_deletion.inc
index dbc9b8e..aa81cee 100755
--- a/general_deletion.inc
+++ b/general_deletion.inc
@@ -1,309 +1,303 @@
<?php
-
/******************************************************************************/
/****************************** DELETION FUNCTIONS ****************************/
/******************************************************************************/
-
function lab_migration_delete_solution($solution_id)
-{
- global $user;
- $root_path = lab_migration_path();
- $status = TRUE;
-
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d", $solution_id);
- $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;
- }
-
- //$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_data = $experiment_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);
- $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->filepath))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $solution_files_data->filepath)), 'error');
- continue;
- }
-
- /* removing solution file */
- if (!unlink($root_path . $solution_files_data->filepath))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file', array('!file' => $solution_files_data->filepath)), 'error');
-
+ global $user;
+ $root_path = lab_migration_path();
+ $status = TRUE;
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d", $solution_id);
+ $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;
+ }
+ //$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_data = $experiment_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);
+ $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->filepath))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file. File does not exists.', array(
+ '!file' => $solution_files_data->filepath
+ )), 'error');
+ continue;
+ }
+ /* removing solution file */
+ if (!unlink($root_path . $solution_files_data->filepath))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file', array(
+ '!file' => $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'] . " :
+ $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."
+ 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',
- '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;
+ $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',
+ '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;
}
-
- /* 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)
- {
- 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)
+ $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(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 */
+ //$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;
}
- } 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 . $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;
+ }
+ }
+ 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;
+ $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 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())
+function lab_migration_del_lab_pdf($lab_id)
{
- if (!lab_migration_delete_experiment($experiment_data->id))
- {
- $status = FALSE;
- }
+ $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 $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);
-}
-
-
function lab_migration_delete_dependency($dependency_id)
-{
- 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))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file', array('!file' => $dependency_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 dependency file";
- $param['standard']['body'] = "Error deleting dependency files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
+ 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))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file', array(
+ '!file' => $dependency_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 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 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();
- }
-
- return $status;
-}
-
+ $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();
+ }
+ return $status;
+ }
diff --git a/lab_details.inc b/lab_details.inc
index 9c4db1e..66e35dd 100755
--- a/lab_details.inc
+++ b/lab_details.inc
@@ -1,6 +1,6 @@
<?php
function lab_migration_completed_labs_all()
-{
+ {
$output = "";
//$query = "SELECT * FROM {lab_migration_proposal} WHERE approval_status = 3";
$query = db_select('lab_migration_proposal');
@@ -8,15 +8,16 @@ function lab_migration_completed_labs_all()
$query->condition('approval_status', 3);
$result = $query->execute();
//$result = db_query($query);
-
- if ($result->rowCount() == 0) {
-
+ if ($result->rowCount() == 0)
+ {
$output .= "We will in process to update lab migration data";
-
- } else {
+ }
+ else
+ {
$preference_rows = array();
$i = 1;
- while ($row = $result->fetchObject()) {
+ while ($row = $result->fetchObject())
+ {
$approval_date = date("Y", $row->approval_date);
$preference_rows[] = array(
$i,
@@ -25,7 +26,7 @@ function lab_migration_completed_labs_all()
$approval_date
);
$i++;
- }
+ }
$preference_header = array(
'No',
'Institute',
@@ -36,13 +37,11 @@ function lab_migration_completed_labs_all()
'header' => $preference_header,
'rows' => $preference_rows
));
- }
-
+ }
return $output;
-}
-
+ }
function lab_migration_labs_progress_all()
-{
+ {
$page_content = "";
//$query = "SELECT * FROM {lab_migration_proposal} WHERE approval_status = 1 and solution_status = 2";
$query = db_select('lab_migration_proposal');
@@ -50,23 +49,22 @@ function lab_migration_labs_progress_all()
$query->condition('approval_status', 1);
$query->condition('solution_status', 2);
$result = $query->execute();
-
- if ($result->rowCount() == 0) {
-
+ if ($result->rowCount() == 0)
+ {
$page_content .= "We will in process to update lab migration data";
-
- } else {
+ }
+ else
+ {
//$result = db_query($query);
$page_content .= "<ol>";
- while ($row = $result->fetchObject()) {
+ while ($row = $result->fetchObject())
+ {
$page_content .= "<li>";
$page_content .= $row->university . " ({$row->lab_title})";
$page_content .= "</li>";
- }
+ }
$page_content .= "</ol>";
- }
+ }
return $page_content;
-}
-
-
+ }
?>
diff --git a/lab_migration.install b/lab_migration.install
index 6589a42..cec3600 100755
--- a/lab_migration.install
+++ b/lab_migration.install
@@ -1,431 +1,435 @@
<?php
// $Id$
-
/**
* Implementation of hook_install().
*/
-function lab_migration_install() {
- // Create tables.
- drupal_install_schema('lab_migration');
- variable_set('lab_migration_emails', '');
- variable_set('lab_migration_from_email', '');
- variable_set('lab_migration_source_extensions', '');
- variable_set('lab_migration_dependency_extensions', '');
- 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';
- if (!is_dir($upload_path))
- mkdir($upload_path);
- if (!is_dir($upload_path . '/latex'))
- mkdir($upload_path . '/latex');
- if (!is_dir($upload_path . '/DEPENDENCIES'))
- mkdir($upload_path . '/DEPENDENCIES');
-}
-
+function lab_migration_install()
+ {
+ // Create tables.
+ drupal_install_schema('lab_migration');
+ variable_set('lab_migration_emails', '');
+ variable_set('lab_migration_from_email', '');
+ variable_set('lab_migration_source_extensions', '');
+ variable_set('lab_migration_dependency_extensions', '');
+ 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';
+ if (!is_dir($upload_path))
+ mkdir($upload_path);
+ if (!is_dir($upload_path . '/latex'))
+ mkdir($upload_path . '/latex');
+ if (!is_dir($upload_path . '/DEPENDENCIES'))
+ mkdir($upload_path . '/DEPENDENCIES');
+ }
/**
* Implementation of hook_uninstall().
*/
-function lab_migration_uninstall() {
- // Remove tables.
- drupal_uninstall_schema('lab_migration');
- // Remove variables
- variable_del('lab_migration_emails');
- variable_del('lab_migration_from_email');
- variable_del('lab_migration_source_extensions');
- variable_del('lab_migration_dependency_extensions');
- variable_del('lab_migration_result_extensions');
- variable_del('lab_migration_xcos_extensions');
-}
-
+function lab_migration_uninstall()
+ {
+ // Remove tables.
+ drupal_uninstall_schema('lab_migration');
+ // Remove variables
+ variable_del('lab_migration_emails');
+ variable_del('lab_migration_from_email');
+ variable_del('lab_migration_source_extensions');
+ variable_del('lab_migration_dependency_extensions');
+ variable_del('lab_migration_result_extensions');
+ variable_del('lab_migration_xcos_extensions');
+ }
/**
* Implementation of hook_schema().
*/
-function lab_migration_schema() {
-
- /* proposal */
- $schema['lab_migration_proposal'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'uid' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'approver_uid' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'solution_provider_uid' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'name_title' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '5',
- 'not null' => TRUE,
- ),
- 'name' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'contact_ph' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '15',
- 'not null' => TRUE,
- ),
- 'department' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'university' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'lab_title' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'category' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'approval_status' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'solution_status' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'solution_display' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'creation_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'approval_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'solution_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'expected_completion_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'message' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'text',
- 'size' => 'medium',
- 'not null' => TRUE,
- ),
- 'solution_provider_name_title' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '5',
- 'not null' => TRUE,
- ),
- 'solution_provider_name' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'solution_provider_contact_ph' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '15',
- 'not null' => TRUE,
- ),
- 'solution_provider_department' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'solution_provider_university' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- /* experiment */
- $schema['lab_migration_experiment'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'proposal_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'number' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'title' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '500',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- /* solution */
- $schema['lab_migration_solution'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'experiment_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'approver_uid' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'code_number' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '10',
- 'not null' => TRUE,
- ),
- 'caption' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'approval_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'approval_status' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'timestamp' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- /* solution files */
- $schema['lab_migration_solution_files'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'solution_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'filename' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'filepath' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '500',
- 'not null' => TRUE,
- ),
- 'filemime' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'filesize' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'filetype' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '1',
- 'not null' => TRUE,
- ),
- 'caption' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '100',
- 'not null' => TRUE,
- ),
- 'timestamp' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- /* depedency files */
- $schema['lab_migration_dependency_files'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'proposal_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'filename' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'filepath' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '500',
- 'not null' => TRUE,
- ),
- 'filemime' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'filesize' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'caption' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '100',
- 'not null' => TRUE,
- ),
- 'description' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'text',
- 'size' => 'medium',
- 'not null' => TRUE,
- ),
- 'timestamp' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- /* dependency files - links */
- $schema['lab_migration_solution_dependency'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'solution_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'dependency_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- /* notes */
- $schema['lab_migration_notes'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'proposal_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'notes' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'text',
- 'size' => 'medium',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- return $schema;
-}
-
+function lab_migration_schema()
+ {
+ /* proposal */
+ $schema['lab_migration_proposal'] = array(
+ 'description' => t('TODO: please describe this table!'),
+ 'fields' => array(
+ 'id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'serial',
+ 'not null' => TRUE
+ ),
+ 'uid' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'approver_uid' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'solution_provider_uid' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'name_title' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '5',
+ 'not null' => TRUE
+ ),
+ 'name' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'contact_ph' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '15',
+ 'not null' => TRUE
+ ),
+ 'department' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'university' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'lab_title' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'category' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'approval_status' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'solution_status' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'solution_display' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'creation_date' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'approval_date' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'solution_date' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'expected_completion_date' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'message' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'not null' => TRUE
+ ),
+ 'solution_provider_name_title' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '5',
+ 'not null' => TRUE
+ ),
+ 'solution_provider_name' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'solution_provider_contact_ph' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '15',
+ 'not null' => TRUE
+ ),
+ 'solution_provider_department' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'solution_provider_university' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ )
+ ),
+ 'primary key' => array(
+ 'id'
+ )
+ );
+ /* experiment */
+ $schema['lab_migration_experiment'] = array(
+ 'description' => t('TODO: please describe this table!'),
+ 'fields' => array(
+ 'id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'serial',
+ 'not null' => TRUE
+ ),
+ 'proposal_id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'number' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'title' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '500',
+ 'not null' => TRUE
+ )
+ ),
+ 'primary key' => array(
+ 'id'
+ )
+ );
+ /* solution */
+ $schema['lab_migration_solution'] = array(
+ 'description' => t('TODO: please describe this table!'),
+ 'fields' => array(
+ 'id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'serial',
+ 'not null' => TRUE
+ ),
+ 'experiment_id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'approver_uid' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'code_number' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '10',
+ 'not null' => TRUE
+ ),
+ 'caption' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'approval_date' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'approval_status' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'timestamp' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ )
+ ),
+ 'primary key' => array(
+ 'id'
+ )
+ );
+ /* solution files */
+ $schema['lab_migration_solution_files'] = array(
+ 'description' => t('TODO: please describe this table!'),
+ 'fields' => array(
+ 'id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'serial',
+ 'not null' => TRUE
+ ),
+ 'solution_id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'filename' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'filepath' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '500',
+ 'not null' => TRUE
+ ),
+ 'filemime' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'filesize' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'filetype' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '1',
+ 'not null' => TRUE
+ ),
+ 'caption' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '100',
+ 'not null' => TRUE
+ ),
+ 'timestamp' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ )
+ ),
+ 'primary key' => array(
+ 'id'
+ )
+ );
+ /* depedency files */
+ $schema['lab_migration_dependency_files'] = array(
+ 'description' => t('TODO: please describe this table!'),
+ 'fields' => array(
+ 'id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'serial',
+ 'not null' => TRUE
+ ),
+ 'proposal_id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'filename' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'filepath' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '500',
+ 'not null' => TRUE
+ ),
+ 'filemime' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE
+ ),
+ 'filesize' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'caption' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'varchar',
+ 'length' => '100',
+ 'not null' => TRUE
+ ),
+ 'description' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'not null' => TRUE
+ ),
+ 'timestamp' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ )
+ ),
+ 'primary key' => array(
+ 'id'
+ )
+ );
+ /* dependency files - links */
+ $schema['lab_migration_solution_dependency'] = array(
+ 'description' => t('TODO: please describe this table!'),
+ 'fields' => array(
+ 'id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'serial',
+ 'not null' => TRUE
+ ),
+ 'solution_id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'dependency_id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ )
+ ),
+ 'primary key' => array(
+ 'id'
+ )
+ );
+ /* notes */
+ $schema['lab_migration_notes'] = array(
+ 'description' => t('TODO: please describe this table!'),
+ 'fields' => array(
+ 'id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'serial',
+ 'not null' => TRUE
+ ),
+ 'proposal_id' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'int',
+ 'not null' => TRUE
+ ),
+ 'notes' => array(
+ 'description' => t('TODO: please describe this field!'),
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'not null' => TRUE
+ )
+ ),
+ 'primary key' => array(
+ 'id'
+ )
+ );
+ return $schema;
+ }
diff --git a/lab_migration.module b/lab_migration.module
index 7de16e2..4941426 100755
--- a/lab_migration.module
+++ b/lab_migration.module
@@ -1,190 +1,239 @@
<?php
// $Id$
-
require_once('general_deletion.inc');
require_once('email.inc');
-
/**
* Implementation of hook_menu().
*/
function lab_migration_menu()
-{
- $items = array();
-
- /* PROPOSAL */
- $items['lab-migration/proposal'] = array(
- 'title' => 'Lab Migration Proposal',
- 'description' => 'Lab Migration Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_proposal_form'),
- 'access arguments' => array('lab migration create proposal'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'proposal.inc',
- );
- $items['lab-migration/manage-proposal'] = array(
- 'title' => 'LM Manage Lab Proposals',
- 'description' => 'Manage Lab Migration Proposals',
- 'page callback' => 'lab_migration_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array('lab migration manage proposal'),
- 'file' => 'manage_proposal.inc',
- );
-
- $items['lab-migration/manage-proposal/pending'] = array(
- 'title' => 'Pending Proposals',
- 'description' => 'Pending Lab Migration Proposals Queue',
- 'page callback' => 'lab_migration_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab-migration/manage-proposal/pending-solution-proposal'] = array(
- 'title' => 'Pending Solution Proposals',
- 'description' => 'Pending Lab Migration Solution Proposals Queue',
- 'page callback' => 'lab_migration_solution_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'manage_solution_proposal.inc',
- );
- $items['lab-migration/manage-proposal/pending-solution'] = array(
- 'title' => 'Pending Solution',
- 'description' => 'Pending Lab Migration Solution',
- 'page callback' => 'lab_migration_proposal_pending_solution',
- 'access callback' => 'user_access',
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab-migration/manage-proposal/all'] = array(
- 'title' => 'All Proposals',
- 'description' => 'All Proposals',
- 'page callback' => 'lab_migration_proposal_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 4,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab-migration/manage-proposal/category'] = array(
- 'title' => 'Category',
- 'description' => 'Category',
- 'page callback' => 'lab_migration_category_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 5,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab-migration/manage-proposal/category/edit'] = array(
- 'title' => 'Edit Category',
- 'description' => 'Edit category',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_category_edit_form'),
- 'access arguments' => array('lab migration edit proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab-migration/manage-proposal/approve'] = array(
- 'title' => 'Approve Proposal',
- 'description' => 'Approve Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_proposal_approval_form'),
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab-migration/manage-proposal/solution-proposal-approve'] = array(
- 'title' => 'Approve Solution Proposal',
- 'description' => 'Approve Solution Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_solution_proposal_approval_form'),
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_solution_proposal.inc',
- );
- $items['lab-migration/manage-proposal/edit'] = array(
- 'title' => 'Edit Proposal',
- 'description' => 'Edit Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_proposal_edit_form'),
- 'access arguments' => array('lab migration manage proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab-migration/manage-proposal/status'] = array(
- 'title' => 'Proposal Status',
- 'description' => 'Proposal Status',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_proposal_status_form'),
- 'access arguments' => array('lab migration approve proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
-
- /* SOLUTION PROPOSAL */
- $items['lab-migration/open-proposal'] = array(
- 'title' => 'Lab Migration Solve',
- 'description' => 'Lab Migration Proposal Open For Solution',
- 'page callback' => 'lab_migration_proposal_open',
- 'access arguments' => array('lab migration propose solution'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'solution_proposal.inc',
- );
- $items['lab-migration/show-proposal'] = array(
- 'title' => 'Lab Migration Solution Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_solution_proposal_form'),
- 'access arguments' => array('lab migration propose solution'),
- 'type' => MENU_CALLBACK,
- 'file' => 'solution_proposal.inc',
- );
-
- /* CODE REVIEW */
- $items['lab-migration/code-approval'] = array(
- 'title' => 'LM Manage Code Approval',
- 'description' => 'Manage Code Approval',
- 'page callback' => 'lab_migration_code_approval',
- 'access arguments' => array('lab migration approve code'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'code_approval.inc',
- );
- $items['lab-migration/code-approval/approve'] = array(
- 'title' => 'Code Approval',
- 'description' => 'Code Approval',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_code_approval_form'),
- 'access arguments' => array('lab migration approve code'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'code_approval.inc',
- );
- $items['lab-migration/code-approval/bulk'] = array(
- 'title' => 'Bulk Manage',
- 'description' => 'Bulk Mangage',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_bulk_approval_form'),
- 'access arguments' => array('lab migration bulk manage code'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'bulk_approval.inc',
- );
- $items['lab-migration/code-approval/bulk'] = array(
- 'title' => 'Bulk Manage',
- 'description' => 'Bulk Mangage',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_bulk_approval_form'),
- 'access arguments' => array('lab migration bulk manage code'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'bulk_approval.inc',
- );
-
- /*$items['lab_migration/code_approval/dependency'] = array(
+ {
+ $items = array();
+ /* PROPOSAL */
+ $items['lab-migration/proposal'] = array(
+ 'title' => 'Lab Migration Proposal',
+ 'description' => 'Lab Migration Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_proposal_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration create proposal'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'proposal.inc'
+ );
+ $items['lab-migration/manage-proposal'] = array(
+ 'title' => 'LM Manage Lab Proposals',
+ 'description' => 'Manage Lab Migration Proposals',
+ 'page callback' => 'lab_migration_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/pending'] = array(
+ 'title' => 'Pending Proposals',
+ 'description' => 'Pending Lab Migration Proposals Queue',
+ 'page callback' => 'lab_migration_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/pending-solution-proposal'] = array(
+ 'title' => 'Pending Solution Proposals',
+ 'description' => 'Pending Lab Migration Solution Proposals Queue',
+ 'page callback' => 'lab_migration_solution_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'manage_solution_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/pending-solution'] = array(
+ 'title' => 'Pending Solution',
+ 'description' => 'Pending Lab Migration Solution',
+ 'page callback' => 'lab_migration_proposal_pending_solution',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 3,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/all'] = array(
+ 'title' => 'All Proposals',
+ 'description' => 'All Proposals',
+ 'page callback' => 'lab_migration_proposal_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/category'] = array(
+ 'title' => 'Category',
+ 'description' => 'Category',
+ 'page callback' => 'lab_migration_category_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 5,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/category/edit'] = array(
+ 'title' => 'Edit Category',
+ 'description' => 'Edit category',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_category_edit_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration edit proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/approve'] = array(
+ 'title' => 'Approve Proposal',
+ 'description' => 'Approve Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_proposal_approval_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/solution-proposal-approve'] = array(
+ 'title' => 'Approve Solution Proposal',
+ 'description' => 'Approve Solution Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_solution_proposal_approval_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_solution_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/edit'] = array(
+ 'title' => 'Edit Proposal',
+ 'description' => 'Edit Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_proposal_edit_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['lab-migration/manage-proposal/status'] = array(
+ 'title' => 'Proposal Status',
+ 'description' => 'Proposal Status',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_proposal_status_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration approve proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ /* SOLUTION PROPOSAL */
+ $items['lab-migration/open-proposal'] = array(
+ 'title' => 'Lab Migration Solve',
+ 'description' => 'Lab Migration Proposal Open For Solution',
+ 'page callback' => 'lab_migration_proposal_open',
+ 'access arguments' => array(
+ 'lab migration propose solution'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'solution_proposal.inc'
+ );
+ $items['lab-migration/show-proposal'] = array(
+ 'title' => 'Lab Migration Solution Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_solution_proposal_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration propose solution'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'solution_proposal.inc'
+ );
+ /* CODE REVIEW */
+ $items['lab-migration/code-approval'] = array(
+ 'title' => 'LM Manage Code Approval',
+ 'description' => 'Manage Code Approval',
+ 'page callback' => 'lab_migration_code_approval',
+ 'access arguments' => array(
+ 'lab migration approve code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'code_approval.inc'
+ );
+ $items['lab-migration/code-approval/approve'] = array(
+ 'title' => 'Code Approval',
+ 'description' => 'Code Approval',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_code_approval_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration approve code'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'code_approval.inc'
+ );
+ $items['lab-migration/code-approval/bulk'] = array(
+ 'title' => 'Bulk Manage',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_bulk_approval_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration bulk manage code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'bulk_approval.inc'
+ );
+ $items['lab-migration/code-approval/bulk'] = array(
+ 'title' => 'Bulk Manage',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_bulk_approval_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration bulk manage code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'bulk_approval.inc'
+ );
+ /*$items['lab_migration/code_approval/dependency'] = array(
'title' => 'Dependency',
'description' => 'Dependency Mangage',
'page callback' => 'drupal_get_form',
@@ -193,58 +242,72 @@ function lab_migration_menu()
'type' => MENU_LOCAL_TASK,
'weight' => 3,
'file' => 'dependency_approval.inc',
- );*/
- $items['lab-migration/code-approval/upload'] = array(
- 'title' => 'Upload Code',
- 'description' => 'Admin Upload',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_bulk_upload_code_form'),
- 'access arguments' => array('lab migration bulk manage code'),
- 'type' => MENU_CALLBACK,
- 'weight' => 4,
- 'file' => 'bulk_upload_code.inc',
- );
- $items['lab-migration/code-approval/notes'] = array(
- 'title' => 'Notes for Reviewers',
- 'description' => 'Notes for Reviewers',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_lab_notes_form'),
- 'access arguments' => array('lab migration bulk manage code'),
- 'type' => MENU_CALLBACK,
- 'weight' => 4,
- 'file' => 'notes.inc',
- );
-
-
- /* CODE UPLOAD */
- $items['lab-migration/code'] = array(
- 'title' => 'Code Submission',
- 'description' => 'Code Submission',
- 'page callback' => 'lab_migration_list_experiments',
- 'access callback' => 'user_access',
- 'access arguments' => array('lab migration upload code'),
- 'file' => 'upload_code.inc',
- );
- $items['lab-migration/code/list-experiments'] = array(
- 'title' => 'List Experiments',
- 'description' => 'List Experiments',
- 'page callback' => 'lab_migration_list_experiments',
- 'access arguments' => array('lab migration upload code'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'file' => 'upload_code.inc',
- 'weight' => 1,
- );
- $items['lab-migration/code/upload'] = array(
- 'title' => 'Code Submission',
- 'description' => 'Code Submission',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_upload_code_form'),
- 'access arguments' => array('lab migration upload code'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'upload_code.inc',
- 'weight' => 2,
- );
- /* $items['lab_migration/code/upload_dep'] = array(
+ );*/
+ $items['lab-migration/code-approval/upload'] = array(
+ 'title' => 'Upload Code',
+ 'description' => 'Admin Upload',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_bulk_upload_code_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration bulk manage code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'weight' => 4,
+ 'file' => 'bulk_upload_code.inc'
+ );
+ $items['lab-migration/code-approval/notes'] = array(
+ 'title' => 'Notes for Reviewers',
+ 'description' => 'Notes for Reviewers',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_lab_notes_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration bulk manage code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'weight' => 4,
+ 'file' => 'notes.inc'
+ );
+ /* CODE UPLOAD */
+ $items['lab-migration/code'] = array(
+ 'title' => 'Code Submission',
+ 'description' => 'Code Submission',
+ 'page callback' => 'lab_migration_list_experiments',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'lab migration upload code'
+ ),
+ 'file' => 'upload_code.inc'
+ );
+ $items['lab-migration/code/list-experiments'] = array(
+ 'title' => 'List Experiments',
+ 'description' => 'List Experiments',
+ 'page callback' => 'lab_migration_list_experiments',
+ 'access arguments' => array(
+ 'lab migration upload code'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 1
+ );
+ $items['lab-migration/code/upload'] = array(
+ 'title' => 'Code Submission',
+ 'description' => 'Code Submission',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_upload_code_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration upload code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 2
+ );
+ /* $items['lab_migration/code/upload_dep'] = array(
'title' => 'Upload Dependency',
'description' => 'Upload Dependency Files',
'page callback' => 'drupal_get_form',
@@ -253,100 +316,117 @@ function lab_migration_menu()
'type' => MENU_LOCAL_TASK,
'file' => 'dependency.inc',
'weight' => 3,
- );*/
-
- $items['lab-migration/code/delete'] = array(
- 'title' => 'Delete Solution',
- 'description' => 'Delete Solution',
- 'page callback' => 'lab_migration_upload_code_delete',
- 'access arguments' => array('lab migration upload code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'upload_code_delete.inc',
- );
-
- /* CODE DOWNLOADS */
- $items['lab-migration/download/file'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'lab_migration_download_solution_file',
- 'access arguments' => array('lab migration download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- /*$items['lab_migration/download/dependency'] = array(
+ );*/
+ $items['lab-migration/code/delete'] = array(
+ 'title' => 'Delete Solution',
+ 'description' => 'Delete Solution',
+ 'page callback' => 'lab_migration_upload_code_delete',
+ 'access arguments' => array(
+ 'lab migration upload code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'upload_code_delete.inc'
+ );
+ /* CODE DOWNLOADS */
+ $items['lab-migration/download/file'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'lab_migration_download_solution_file',
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ /*$items['lab_migration/download/dependency'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_dependency_file',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
- );*/
- $items['lab-migration/download/solution'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'lab_migration_download_solution',
- 'access arguments' => array('lab migration download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- $items['lab-migration/download/experiment'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'lab_migration_download_experiment',
- 'access arguments' => array('lab migration download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- $items['lab-migration/download/lab'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'lab_migration_download_lab',
- 'access arguments' => array('lab migration download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- $items['lab-migration/full-download/experiment'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'lab_migration_download_full_experiment',
- 'access arguments' => array('lab migration approve code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc',
- );
- $items['lab-migration/full-download/lab'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'lab_migration_download_full_lab',
- 'access arguments' => array('lab migration approve code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc',
- );
- /* COMPLETED LAB MIGRATIONS */
- $items['lab-migration/completed-labs'] = array(
- 'title' => 'Completed Labs',
- 'page callback' => 'lab_migration_completed_labs_all',
- 'access arguments' => array('lab migration download code'),
- 'file' => 'lab_details.inc',
- );
-
- /* LABS IN PROGRESS */
- $items['lab-migration/labs-progress'] = array(
- 'title' => 'Labs in Progress',
- 'page callback' => 'lab_migration_labs_progress_all',
- 'access arguments' => array('lab migration download code'),
- 'file' => 'lab_details.inc',
- );
-
- /* DOWNLOAD FOR EVERYONE */
- $items['lab-migration/lab-migration-run'] = array(
- 'title' => 'Download Codes',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_run_form'),
- 'access arguments' => array('lab migration download code'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'run.inc',
- );
-
+ );*/
+ $items['lab-migration/download/solution'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'lab_migration_download_solution',
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['lab-migration/download/experiment'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'lab_migration_download_experiment',
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['lab-migration/download/lab'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'lab_migration_download_lab',
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['lab-migration/full-download/experiment'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'lab_migration_download_full_experiment',
+ 'access arguments' => array(
+ 'lab migration approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ $items['lab-migration/full-download/lab'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'lab_migration_download_full_lab',
+ 'access arguments' => array(
+ 'lab migration approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ /* COMPLETED LAB MIGRATIONS */
+ $items['lab-migration/completed-labs'] = array(
+ 'title' => 'Completed Labs',
+ 'page callback' => 'lab_migration_completed_labs_all',
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'file' => 'lab_details.inc'
+ );
+ /* LABS IN PROGRESS */
+ $items['lab-migration/labs-progress'] = array(
+ 'title' => 'Labs in Progress',
+ 'page callback' => 'lab_migration_labs_progress_all',
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'file' => 'lab_details.inc'
+ );
+ /* DOWNLOAD FOR EVERYONE */
+ $items['lab-migration/lab-migration-run'] = array(
+ 'title' => 'Download Codes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_run_form'
+ ),
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'run.inc'
+ );
/*$items['lab_migration_run'] = array(
'title' => 'Download Codes',
'page callback' => 'drupal_get_form',
@@ -354,300 +434,331 @@ function lab_migration_menu()
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'file' => 'run.inc',
- );
- $items['lab_migration_run_ajax'] = array(
+ );
+ $items['lab_migration_run_ajax'] = array(
'page callback' => 'lab_migration_run_ajax',
'access callback' => TRUE,
'file' => 'run.inc',
- );
- $items['download_codes'] = array(
+ );
+ $items['download_codes'] = array(
'title' => 'Download Codes',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_run_form_ajax'),
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'file' => 'run.inc',
- );*/
-
- /* LATEX SCRIPT */
- $items['lab-migration/generate-lab'] = array(
- 'title' => 'Generate Lab',
- 'description' => 'Generate Lab From Latex Script',
- 'page callback' => 'lab_migration_download_lab_pdf',
- 'access arguments' => array('lab migration generate lab'),
- 'type' => MENU_CALLBACK,
- 'file' => 'latex.inc',
- );
- $items['lab-migration/delete-lab'] = array(
- 'title' => 'Delete Lab PDF',
- 'description' => 'Delete Lab PDF',
- 'page callback' => 'lab_migration_delete_lab_pdf',
- 'access arguments' => array('lab migration approve code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'latex.inc',
- );
-
- /* ADMIN SETTINGS */
- $items['admin/settings/lab-migration'] = array(
- 'title' => 'Lab Migration Settings',
- 'description' => 'Lab Migration Settings',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_settings_form'),
- 'access arguments' => array('administer lab migration'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'settings.inc',
- );
- /* AJAX REQUEST */
-$items["lab-bulk-manage-exp/ajax"] = array(
- "title" => "Ajax callbacks",
- "page callback" => "lab_bulk_manage_exp_ajax",
- "access arguments" => array("lab migration bulk manage code"),
- "type" => MENU_CALLBACK,
- 'file' => 'bulk_approval.inc',
- );
- /* $items["lab_migration/code_approval/dependency/ajax"] = array(
- "title" => "Ajax callbacks",
- "page callback" => "lab_migration_dependency_approval_ajax",
- "access arguments" => array("lab migration bulk manage code"),
- "type" => MENU_CALLBACK,
- 'file' => 'dependency_approval.inc',
- );*/
-
- return $items;
-}
-
+ );*/
+ /* LATEX SCRIPT */
+ $items['lab-migration/generate-lab'] = array(
+ 'title' => 'Generate Lab',
+ 'description' => 'Generate Lab From Latex Script',
+ 'page callback' => 'lab_migration_download_lab_pdf',
+ 'access arguments' => array(
+ 'lab migration generate lab'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'latex.inc'
+ );
+ $items['lab-migration/delete-lab'] = array(
+ 'title' => 'Delete Lab PDF',
+ 'description' => 'Delete Lab PDF',
+ 'page callback' => 'lab_migration_delete_lab_pdf',
+ 'access arguments' => array(
+ 'lab migration approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'latex.inc'
+ );
+ /* ADMIN SETTINGS */
+ $items['admin/settings/lab-migration'] = array(
+ 'title' => 'Lab Migration Settings',
+ 'description' => 'Lab Migration Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_settings_form'
+ ),
+ 'access arguments' => array(
+ 'administer lab migration'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'settings.inc'
+ );
+ /* AJAX REQUEST */
+ $items["lab-bulk-manage-exp/ajax"] = array(
+ "title" => "Ajax callbacks",
+ "page callback" => "lab_bulk_manage_exp_ajax",
+ "access arguments" => array(
+ "lab migration bulk manage code"
+ ),
+ "type" => MENU_CALLBACK,
+ 'file' => 'bulk_approval.inc'
+ );
+ /* $items["lab_migration/code_approval/dependency/ajax"] = array(
+ "title" => "Ajax callbacks",
+ "page callback" => "lab_migration_dependency_approval_ajax",
+ "access arguments" => array("lab migration bulk manage code"),
+ "type" => MENU_CALLBACK,
+ 'file' => 'dependency_approval.inc',
+ );*/
+ return $items;
+ }
/**
* Implementation of hook_perm().
*/
-function lab_migration_permission() {
+function lab_migration_permission()
+ {
return array(
'lab migration create proposal' => array(
'title' => t('lab migration create proposal'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration manage proposal' => array(
'title' => t('lab migration manage proposal'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration edit proposal' => array(
'title' => t('lab migration edit proposal'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration approve proposal' => array(
'title' => t('lab migration approve proposal'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration propose solution' => array(
'title' => t('lab migration propose solution'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration approve code' => array(
'title' => t('lab migration approve code'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration bulk manage code' => array(
'title' => t('lab migration bulk manage code'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration bulk delete code' => array(
'title' => t('lab migration bulk delete code'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration upload code' => array(
'title' => t('lab migration upload code'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration download code' => array(
'title' => t('lab migration download code'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'administer lab migration' => array(
'title' => t('administer lab migration'),
- 'restrict access' => TRUE,
+ 'restrict access' => TRUE
),
'lab migration generate lab' => array(
'title' => t('lab migration generate lab'),
- 'restrict access' => TRUE,
- ),
+ 'restrict access' => TRUE
+ )
);
- // return array('lab migration create proposal', 'lab migration manage proposal', 'lab migration edit proposal', 'lab migration approve proposal', 'lab migration propose solution', 'lab migration approve code', 'lab migration bulk manage code', 'lab migration bulk delete code', 'lab migration upload code', 'lab migration download code', 'administer lab migration', 'lab migration generate lab');
-}
-
+ // return array('lab migration create proposal', 'lab migration manage proposal', 'lab migration edit proposal', 'lab migration approve proposal', 'lab migration propose solution', 'lab migration approve code', 'lab migration bulk manage code', 'lab migration bulk delete code', 'lab migration upload code', 'lab migration download code', 'administer lab migration', 'lab migration generate lab');
+ }
/* AJAX CALLS */
function lab_migration_ajax()
-{
- $query_type = arg(2);
- if ($query_type == 'chapter_title')
{
- $chapter_number = arg(3);
- $preference_id = arg(4);
- //$chapter_q = db_query("SELECT * FROM {lab_migration_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
- $query = db_select('lab_migration_chapter');
- $query->fields('lab_migration_chapter');
- $query->condition('number', $chapter_number);
- $query->condition('preference_id', $preference_id);
- $query->range(0, 1);
- $chapter_q = $query->execute();
- if ($chapter_data = $chapter_q->fetchObject())
- {
- echo $chapter_data->name;
- return;
- }
- } else if ($query_type == 'example_exists') {
- $chapter_number = arg(3);
- $preference_id = arg(4);
- $example_number = arg(5);
-
- $chapter_id = 0;
- $query = db_select('lab_migration_chapter');
- $query->fields('lab_migration_chapter');
- $query->condition('number', $chapter_number);
- $query->condition('preference_id', $preference_id);
- $query->range(0, 1);
- $chapter_q = $query->execute();
- if (!$chapter_data = $chapter_q->fetchObject())
- {
- echo '';
- return;
- } else {
- $chapter_id = $chapter_data->id;
- }
-
-
- $query = db_select('lab_migration_example');
- $query->fields('lab_migration_example');
- $query->condition('chapter_id', $chapter_id);
- $query->condition('number', $example_number);
- $query->range(0, 1);
- $example_q = $query->execute();
-
- if ($example_data = $example_q->fetchObject())
- {
- if ($example_data->approval_status == 1)
- echo 'Warning! Solution already approved. You cannot upload the same solution again.';
- else
- echo 'Warning! Solution already uploaded. Delete the solution and reupload it.';
- return;
- }
+ $query_type = arg(2);
+ if ($query_type == 'chapter_title')
+ {
+ $chapter_number = arg(3);
+ $preference_id = arg(4);
+ //$chapter_q = db_query("SELECT * FROM {lab_migration_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
+ $query = db_select('lab_migration_chapter');
+ $query->fields('lab_migration_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if ($chapter_data = $chapter_q->fetchObject())
+ {
+ echo $chapter_data->name;
+ return;
+ }
+ }
+ else if ($query_type == 'example_exists')
+ {
+ $chapter_number = arg(3);
+ $preference_id = arg(4);
+ $example_number = arg(5);
+ $chapter_id = 0;
+ $query = db_select('lab_migration_chapter');
+ $query->fields('lab_migration_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if (!$chapter_data = $chapter_q->fetchObject())
+ {
+ echo '';
+ return;
+ }
+ else
+ {
+ $chapter_id = $chapter_data->id;
+ }
+ $query = db_select('lab_migration_example');
+ $query->fields('lab_migration_example');
+ $query->condition('chapter_id', $chapter_id);
+ $query->condition('number', $example_number);
+ $query->range(0, 1);
+ $example_q = $query->execute();
+ if ($example_data = $example_q->fetchObject())
+ {
+ if ($example_data->approval_status == 1)
+ echo 'Warning! Solution already approved. You cannot upload the same solution again.';
+ else
+ echo 'Warning! Solution already uploaded. Delete the solution and reupload it.';
+ return;
+ }
+ }
+ echo '';
}
- echo '';
-}
-
/*************************** VALIDATION FUNCTIONS *****************************/
-
-function lab_migration_check_valid_filename($file_name) {
- if (!preg_match('/^[0-9a-zA-Z\.]+$/', $file_name))
- return FALSE;
- else
- if (substr_count($file_name, ".") > 1)
- return FALSE;
+function lab_migration_check_valid_filename($file_name)
+ {
+ if (!preg_match('/^[0-9a-zA-Z\.]+$/', $file_name))
+ return FALSE;
+ else if (substr_count($file_name, ".") > 1)
+ return FALSE;
else
- return TRUE;
-}
-
-function lab_migration_check_name($name = '') {
- if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
- return FALSE;
- else
- return TRUE;
-}
-
-function lab_migration_check_code_number($number = '') {
- if (!preg_match('/^[0-9]+$/', $number))
- return FALSE;
- else
- return TRUE;
-}
-
-function lab_migration_path() {
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/lab_migration_uploads/';
-}
-
+ return TRUE;
+ }
+function lab_migration_check_name($name = '')
+ {
+ if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
+ return FALSE;
+ else
+ return TRUE;
+ }
+function lab_migration_check_code_number($number = '')
+ {
+ if (!preg_match('/^[0-9]+$/', $number))
+ return FALSE;
+ else
+ return TRUE;
+ }
+function lab_migration_path()
+ {
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/lab_migration_uploads/';
+ }
/************************* USER VERIFICATION FUNCTIONS ************************/
-
-function lab_migration_get_proposal() {
- global $user;
-
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1");
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('solution_provider_uid', $user->uid);
- $query->condition('solution_status', 2);
- $query->orderBy('id', 'DESC');
- $query->range(0, 1);
- $proposal_q= $query->execute();
-
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
+function lab_migration_get_proposal()
{
- drupal_set_message("You do not have any approved Lab migraion solution proposal. Please check the " . l('available', 'lab-migration/open-proposal') . " Lab migration proposal.", 'error');
- drupal_goto('');
+ global $user;
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1");
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('solution_provider_uid', $user->uid);
+ $query->condition('solution_status', 2);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message("You do not have any approved Lab migraion solution proposal. Please check the " . l('available', 'lab-migration/open-proposal') . " Lab migration proposal.", 'error');
+ drupal_goto('');
+ }
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ drupal_set_message(t('Proposal is awaiting approval.'), 'status');
+ return FALSE;
+ case 1:
+ return $proposal_data;
+ case 2:
+ drupal_set_message(t('Proposal has been dis-approved.'), 'error');
+ return FALSE;
+ case 3:
+ drupal_set_message(t('Proposal has been marked as completed.'), 'status');
+ return FALSE;
+ default:
+ drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
+ return FALSE;
+ }
+ return FALSE;
}
- switch ($proposal_data->approval_status)
- {
- case 0:
- drupal_set_message(t('Proposal is awaiting approval.'), 'status');
- return FALSE;
- case 1:
- return $proposal_data;
- case 2:
- drupal_set_message(t('Proposal has been dis-approved.'), 'error');
- return FALSE;
- case 3:
- drupal_set_message(t('Proposal has been marked as completed.'), 'status');
- return FALSE;
- default:
- drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
- return FALSE;
- }
- return FALSE;
-
-
-}
-
/***************************** GENERAL FUNCTIONS ******************************/
-
-function lab_migration_get_category_name($category_id) {
- $category_data = '';
- switch ($category_id)
+function lab_migration_get_category_name($category_id)
{
- case 0: $category_data = 'Not Selected'; break;
- case 1: $category_data = 'Fluid Mechanics'; break;
- case 2: $category_data = 'Control Theory & Control Systems'; break;
- case 3: $category_data = 'Chemical Engineering'; break;
- case 4: $category_data = 'Thermodynamics'; break;
- case 5: $category_data = 'Mechanical Engineering'; break;
- case 6: $category_data = 'Signal Processing'; break;
- case 7: $category_data = 'Digital Communications'; break;
- case 8: $category_data = 'Electrical Technology'; break;
- case 9: $category_data = 'Mathematics & Pure Science'; break;
- case 10: $category_data = 'Analog Electronics'; break;
- case 11: $category_data = 'Digital Electronics'; break;
- case 12: $category_data = 'Computer Programming'; break;
- case 13: $category_data = 'Others'; break;
- default: $category_data = 'Unknown'; break;
+ $category_data = '';
+ switch ($category_id)
+ {
+ case 0:
+ $category_data = 'Not Selected';
+ break;
+ case 1:
+ $category_data = 'Fluid Mechanics';
+ break;
+ case 2:
+ $category_data = 'Control Theory & Control Systems';
+ break;
+ case 3:
+ $category_data = 'Chemical Engineering';
+ break;
+ case 4:
+ $category_data = 'Thermodynamics';
+ break;
+ case 5:
+ $category_data = 'Mechanical Engineering';
+ break;
+ case 6:
+ $category_data = 'Signal Processing';
+ break;
+ case 7:
+ $category_data = 'Digital Communications';
+ break;
+ case 8:
+ $category_data = 'Electrical Technology';
+ break;
+ case 9:
+ $category_data = 'Mathematics & Pure Science';
+ break;
+ case 10:
+ $category_data = 'Analog Electronics';
+ break;
+ case 11:
+ $category_data = 'Digital Electronics';
+ break;
+ case 12:
+ $category_data = 'Computer Programming';
+ break;
+ case 13:
+ $category_data = 'Others';
+ break;
+ default:
+ $category_data = 'Unknown';
+ break;
+ }
+ return $category_data;
}
- return $category_data;
-}
-
- /*function lab_migration_init() {
-
- drupal_add_js(drupal_get_path('module', 'lab_migration') . '/js/lab_migration_ajax.js', array ('scope' => 'footer'));
- }*/
-
- /*************************************************************************/
- /***** Function To convert only first charater of string in uppercase ****/
- /*************************************************************************/
- function ucname($string) {
- $string =ucwords(strtolower($string));
+/*function lab_migration_init() {
- foreach (array('-', '\'') as $delimiter) {
- if (strpos($string, $delimiter)!==false) {
- $string =implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+drupal_add_js(drupal_get_path('module', 'lab_migration') . '/js/lab_migration_ajax.js', array ('scope' => 'footer'));
+}*/
+/*************************************************************************/
+/***** Function To convert only first charater of string in uppercase ****/
+/*************************************************************************/
+function ucname($string)
+ {
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ }
}
- }
return $string;
-}
+ }
diff --git a/latex.inc b/latex.inc
index c6778a6..f630f36 100755
--- a/latex.inc
+++ b/latex.inc
@@ -1,261 +1,274 @@
<?php
-
function lab_migration_download_lab_pdf()
-{
- $lab_id = arg(2);
- _latex_copy_script_file();
- $full_lab = arg(3);
- if ($full_lab == "1"){
- _latex_generate_files($lab_id, TRUE);
- }else{
- _latex_generate_files($lab_id, FALSE);
-}
-}
-
-
-/* full lab parameter is for gennerating the entire lab pdf including all unapproved solutions */
-function _latex_generate_files($lab_id, $full_lab = FALSE)
-{
-
- $root_path = lab_migration_path();
- $dir_path = $root_path . "latex/";
-
- $lab_filedata = "";
- $solution_provider_filedata = "";
- $latex_filedata = "";
- $latex_dep_filedata = "";
-
- $depedency_list = array();
-
- $eol = "\n";
- $sep = "#";
-
- //$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 specified.', 'error');
- drupal_goto('');
- }
- if ($proposal_data->approval_status == 0)
- {
- drupal_set_message('Lab proposal is still in pending review.', 'error');
- drupal_goto('');
- }
-
- $category_data = '';
- switch ($proposal_data->category)
- {
- case 0: $category_data = 'Not Selected'; break;
- case 1: $category_data = 'Fluid Mechanics'; break;
- case 2: $category_data = 'Control Theory & Control Systems'; break;
- case 3: $category_data = 'Chemical Engineering'; break;
- case 4: $category_data = 'Thermodynamics'; break;
- case 5: $category_data = 'Mechanical Engineering'; break;
- case 6: $category_data = 'Signal Processing'; break;
- case 7: $category_data = 'Digital Communications'; break;
- case 8: $category_data = 'Electrical Technology'; break;
- case 9: $category_data = 'Mathematics & Pure Science'; break;
- case 10: $category_data = 'Analog Electronics'; break;
- case 11: $category_data = 'Digital Electronics'; break;
- case 12: $category_data = 'Computer Programming'; break;
- case 13: $category_data = 'Others'; break;
- default: $category_data = 'Unknown'; break;
- }
-
- $lab_filedata = $proposal_data->lab_title . $sep . $proposal_data->name_title . $sep . $proposal_data->name . $sep . $proposal_data->department . $sep . $proposal_data->university . $sep . $category_data . $eol;
-
- /* regenerate lab if full lab selected */
- if ($full_lab){
- lab_migration_del_lab_pdf($proposal_data->id);
-}
- /* check if lab already generated */
- if (file_exists($dir_path . "lab_" . $proposal_data->id . ".pdf"))
{
- /* download zip file */
- header('Content-Type: application/pdf');
- header('Content-disposition: attachment; filename="' . $proposal_data->lab_title . '.pdf"');
- header('Content-Length: ' . filesize($dir_path . "lab_" . $proposal_data->id . ".pdf"));
- readfile($dir_path . "lab_" . $proposal_data->id . ".pdf");
- return;
- }
-
- $solution_provider_user = user_load($proposal_data->solution_provider_uid);
- if (!$solution_provider_user)
- {
- drupal_set_message('Could not fetch solution provider information for the lab specified.', 'error');
+ $lab_id = arg(2);
+ _latex_copy_script_file();
+ $full_lab = arg(3);
+ if ($full_lab == "1")
+ {
+ _latex_generate_files($lab_id, TRUE);
+ }
+ else
+ {
+ _latex_generate_files($lab_id, FALSE);
+ }
}
- $solution_provider_filedata .= $proposal_data->solution_provider_name_title . $sep . $proposal_data->solution_provider_name . $sep . $proposal_data->solution_provider_department . $sep . $proposal_data->solution_provider_university . $eol;
-
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number DESC", $proposal_data->id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $proposal_data->id);
- $query->orderBy('number', 'DESC');
- $experiment_q = $query->execute();
- while ($experiment_data = $experiment_q->fetchObject())
+/* full lab parameter is for gennerating the entire lab pdf including all unapproved solutions */
+function _latex_generate_files($lab_id, $full_lab = FALSE)
{
- if ($full_lab){
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d ORDER BY code_number DESC", $experiment_data->id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_data->id);
- $query->orderBy('code_number', 'DESC');
- $solution_q = $query->execute();
- }else{
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1 ORDER BY code_number DESC", $experiment_data->id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_data->id);
- $query->condition('approval_status', 1);
- $query->orderBy('code_number', 'DESC');
- $solution_q = $query->execute();
-}
- while ($solution_data = $solution_q->fetchObject())
- {
- //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_data->id);
- $query = db_select('lab_migration_solution_files');
- $query->fields('lab_migration_solution_files');
- $query->condition('solution_id', $solution_data->id);
- $solution_files_q = $query->execute();
- while ($solution_files_data = $solution_files_q->fetchObject())
+ $root_path = lab_migration_path();
+ $dir_path = $root_path . "latex/";
+ $lab_filedata = "";
+ $solution_provider_filedata = "";
+ $latex_filedata = "";
+ $latex_dep_filedata = "";
+ $depedency_list = array();
+ $eol = "\n";
+ $sep = "#";
+ //$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)
{
- $latex_filedata .= $experiment_data->number . $sep;
- $latex_filedata .= $experiment_data->title . $sep;
- $latex_filedata .= $solution_data->code_number . $sep;
- $latex_filedata .= $solution_data->caption . $sep;
- $latex_filedata .= $solution_files_data->filename . $sep;
- $latex_filedata .= $solution_files_data->filepath . $sep;
- $latex_filedata .= $solution_files_data->filetype . $sep;
- $latex_filedata .= $sep;
- $latex_filedata .= $solution_files_data->id;
- $latex_filedata .= $eol;
+ drupal_set_message('Invalid lab specified.', 'error');
+ drupal_goto('');
}
- //$dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_data->id);
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_solution_dependency');
- $query->condition('solution_id', $solution_data->id);
- $dependency_files_q = $query->execute();
- while ($dependency_files_data = $dependency_files_q->fetchObject())
+ if ($proposal_data->approval_status == 0)
{
- //$dependency_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $dependency_files_data->dependency_id);
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $dependency_files_data->dependency_id);
- $query->range(0, 1);
- $dependency_q = $query->execute();
- if ($dependency_data = $dependency_q->fetchObject())
- {
- if(substr($dependency_data->filename, -3) != "wav") {
- $latex_filedata .= $experiment_data->number . $sep;
- $latex_filedata .= $experiment_data->title . $sep;
- $latex_filedata .= $solution_data->code_number . $sep;
- $latex_filedata .= $solution_data->caption . $sep;
- $latex_filedata .= $dependency_data->filename . $sep;
- $latex_filedata .= $dependency_data->filepath . $sep;
- $latex_filedata .= 'D' . $sep;
- $latex_filedata .= $dependency_data->caption . $sep;
- $latex_filedata .= $dependency_data->id;
- $latex_filedata .= $eol;
-
- $depedency_list[$dependency_data->id] = "D";
- }
-
- }
+ drupal_set_message('Lab proposal is still in pending review.', 'error');
+ drupal_goto('');
}
+ $category_data = '';
+ switch ($proposal_data->category)
+ {
+ case 0:
+ $category_data = 'Not Selected';
+ break;
+ case 1:
+ $category_data = 'Fluid Mechanics';
+ break;
+ case 2:
+ $category_data = 'Control Theory & Control Systems';
+ break;
+ case 3:
+ $category_data = 'Chemical Engineering';
+ break;
+ case 4:
+ $category_data = 'Thermodynamics';
+ break;
+ case 5:
+ $category_data = 'Mechanical Engineering';
+ break;
+ case 6:
+ $category_data = 'Signal Processing';
+ break;
+ case 7:
+ $category_data = 'Digital Communications';
+ break;
+ case 8:
+ $category_data = 'Electrical Technology';
+ break;
+ case 9:
+ $category_data = 'Mathematics & Pure Science';
+ break;
+ case 10:
+ $category_data = 'Analog Electronics';
+ break;
+ case 11:
+ $category_data = 'Digital Electronics';
+ break;
+ case 12:
+ $category_data = 'Computer Programming';
+ break;
+ case 13:
+ $category_data = 'Others';
+ break;
+ default:
+ $category_data = 'Unknown';
+ break;
}
- }
-
- foreach ($depedency_list as $row => $data) {
- //$dependency_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $row);
- $query = db_select('lab_migration_dependency_files');
+ $lab_filedata = $proposal_data->lab_title . $sep . $proposal_data->name_title . $sep . $proposal_data->name . $sep . $proposal_data->department . $sep . $proposal_data->university . $sep . $category_data . $eol;
+ /* regenerate lab if full lab selected */
+ if ($full_lab)
+ {
+ lab_migration_del_lab_pdf($proposal_data->id);
+ }
+ /* check if lab already generated */
+ if (file_exists($dir_path . "lab_" . $proposal_data->id . ".pdf"))
+ {
+ /* download zip file */
+ header('Content-Type: application/pdf');
+ header('Content-disposition: attachment; filename="' . $proposal_data->lab_title . '.pdf"');
+ header('Content-Length: ' . filesize($dir_path . "lab_" . $proposal_data->id . ".pdf"));
+ readfile($dir_path . "lab_" . $proposal_data->id . ".pdf");
+ return;
+ }
+ $solution_provider_user = user_load($proposal_data->solution_provider_uid);
+ if (!$solution_provider_user)
+ {
+ drupal_set_message('Could not fetch solution provider information for the lab specified.', 'error');
+ }
+ $solution_provider_filedata .= $proposal_data->solution_provider_name_title . $sep . $proposal_data->solution_provider_name . $sep . $proposal_data->solution_provider_department . $sep . $proposal_data->solution_provider_university . $eol;
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number DESC", $proposal_data->id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $proposal_data->id);
+ $query->orderBy('number', 'DESC');
+ $experiment_q = $query->execute();
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ if ($full_lab)
+ {
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d ORDER BY code_number DESC", $experiment_data->id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_data->id);
+ $query->orderBy('code_number', 'DESC');
+ $solution_q = $query->execute();
+ }
+ else
+ {
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1 ORDER BY code_number DESC", $experiment_data->id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $experiment_data->id);
+ $query->condition('approval_status', 1);
+ $query->orderBy('code_number', 'DESC');
+ $solution_q = $query->execute();
+ }
+ while ($solution_data = $solution_q->fetchObject())
+ {
+ //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_data->id);
+ $query = db_select('lab_migration_solution_files');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_data->id);
+ $solution_files_q = $query->execute();
+ while ($solution_files_data = $solution_files_q->fetchObject())
+ {
+ $latex_filedata .= $experiment_data->number . $sep;
+ $latex_filedata .= $experiment_data->title . $sep;
+ $latex_filedata .= $solution_data->code_number . $sep;
+ $latex_filedata .= $solution_data->caption . $sep;
+ $latex_filedata .= $solution_files_data->filename . $sep;
+ $latex_filedata .= $solution_files_data->filepath . $sep;
+ $latex_filedata .= $solution_files_data->filetype . $sep;
+ $latex_filedata .= $sep;
+ $latex_filedata .= $solution_files_data->id;
+ $latex_filedata .= $eol;
+ }
+ //$dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_data->id);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_solution_dependency');
+ $query->condition('solution_id', $solution_data->id);
+ $dependency_files_q = $query->execute();
+ while ($dependency_files_data = $dependency_files_q->fetchObject())
+ {
+ //$dependency_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $dependency_files_data->dependency_id);
+ $query = db_select('lab_migration_dependency_files');
$query->fields('lab_migration_dependency_files');
- $query->condition('id', $row);
+ $query->condition('id', $dependency_files_data->dependency_id);
$query->range(0, 1);
$dependency_q = $query->execute();
- if ($dependency_data = $dependency_q->fetchObject())
- {
- $latex_dep_filedata .= $dependency_data->filename . $sep;
- $latex_dep_filedata .= $dependency_data->filepath . $sep;
- $latex_dep_filedata .= $dependency_data->caption . $sep;
- $latex_dep_filedata .= $dependency_data->id;
- $latex_dep_filedata .= $eol;
- }
+ if ($dependency_data = $dependency_q->fetchObject())
+ {
+ if (substr($dependency_data->filename, -3) != "wav")
+ {
+ $latex_filedata .= $experiment_data->number . $sep;
+ $latex_filedata .= $experiment_data->title . $sep;
+ $latex_filedata .= $solution_data->code_number . $sep;
+ $latex_filedata .= $solution_data->caption . $sep;
+ $latex_filedata .= $dependency_data->filename . $sep;
+ $latex_filedata .= $dependency_data->filepath . $sep;
+ $latex_filedata .= 'D' . $sep;
+ $latex_filedata .= $dependency_data->caption . $sep;
+ $latex_filedata .= $dependency_data->id;
+ $latex_filedata .= $eol;
+ $depedency_list[$dependency_data->id] = "D";
+ }
+ }
+ }
+ }
+ }
+ foreach ($depedency_list as $row => $data)
+ {
+ //$dependency_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $row);
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $row);
+ $query->range(0, 1);
+ $dependency_q = $query->execute();
+ if ($dependency_data = $dependency_q->fetchObject())
+ {
+ $latex_dep_filedata .= $dependency_data->filename . $sep;
+ $latex_dep_filedata .= $dependency_data->filepath . $sep;
+ $latex_dep_filedata .= $dependency_data->caption . $sep;
+ $latex_dep_filedata .= $dependency_data->id;
+ $latex_dep_filedata .= $eol;
+ }
+ }
+ /**************************** WRITE TO FILES ********************************/
+ $download_filename = $proposal_data->lab;
+ $lab_filename = "tmp_" . $proposal_data->id . "_lab.txt";
+ $solution_provider_filename = "tmp_" . $proposal_data->id . "_solution_provider.txt";
+ $latex_filename = "tmp_" . $proposal_data->id . "_data.txt";
+ $latex_dep_filename = "tmp_" . $proposal_data->id . "_dep_data.txt";
+ $pdf_filename = "lab_" . $proposal_data->id . ".pdf";
+ $fb = fopen($dir_path . $lab_filename, 'w');
+ fwrite($fb, $lab_filedata);
+ fclose($fb);
+ $fc = fopen($dir_path . $solution_provider_filename, 'w');
+ fwrite($fc, $solution_provider_filedata);
+ fclose($fc);
+ $fl = fopen($dir_path . $latex_filename, 'w');
+ fwrite($fl, $latex_filedata);
+ fclose($fl);
+ $fd = fopen($dir_path . $latex_dep_filename, 'w');
+ fwrite($fd, $latex_dep_filedata);
+ fclose($fd);
+ if (_latex_run_script($lab_filename, $solution_provider_filename, $latex_filename, $latex_dep_filename, $pdf_filename))
+ {
+ /* download zip file */
+ header('Content-Type: application/pdf');
+ header('Content-disposition: attachment; filename="' . $proposal_data->lab_title . '_' . $proposal_data->name_title . '_' . $proposal_data->name . '.pdf"');
+ header('Content-Length: ' . filesize($dir_path . $pdf_filename));
+ readfile($dir_path . $pdf_filename);
+ }
+ else
+ {
+ drupal_set_message("Error occurred when generating the PDF version of the Book.", 'error');
+ }
+ /*********************** DELETING TEMPORARY FILES ***************************/
+ /* regenerate lab if full lab selected */
+ if ($full_lab)
+ lab_migration_del_lab_pdf($proposal_data->id);
}
-
- /**************************** WRITE TO FILES ********************************/
- $download_filename = $proposal_data->lab;
- $lab_filename = "tmp_" . $proposal_data->id . "_lab.txt";
- $solution_provider_filename = "tmp_" . $proposal_data->id . "_solution_provider.txt";
- $latex_filename = "tmp_" . $proposal_data->id . "_data.txt";
- $latex_dep_filename = "tmp_" . $proposal_data->id . "_dep_data.txt";
- $pdf_filename = "lab_" . $proposal_data->id . ".pdf";
-
- $fb = fopen($dir_path . $lab_filename, 'w');
- fwrite($fb, $lab_filedata);
- fclose($fb);
-
- $fc = fopen($dir_path . $solution_provider_filename, 'w');
- fwrite($fc, $solution_provider_filedata);
- fclose($fc);
-
- $fl = fopen($dir_path . $latex_filename, 'w');
- fwrite($fl, $latex_filedata);
- fclose($fl);
-
- $fd = fopen($dir_path . $latex_dep_filename, 'w');
- fwrite($fd, $latex_dep_filedata);
- fclose($fd);
- if (_latex_run_script($lab_filename, $solution_provider_filename, $latex_filename, $latex_dep_filename, $pdf_filename))
- {
- /* download zip file */
- header('Content-Type: application/pdf');
- header('Content-disposition: attachment; filename="' . $proposal_data->lab_title . '_' . $proposal_data->name_title . '_' . $proposal_data->name . '.pdf"');
- header('Content-Length: ' . filesize($dir_path . $pdf_filename));
- readfile($dir_path . $pdf_filename);
- } else {
- drupal_set_message("Error occurred when generating the PDF version of the Book.", 'error');
- }
-
- /*********************** DELETING TEMPORARY FILES ***************************/
- /* regenerate lab if full lab selected */
- if ($full_lab)
- lab_migration_del_lab_pdf($proposal_data->id);
-}
-
function _latex_copy_script_file()
-{
- exec("cp ./" . drupal_get_path('module', 'lab_migration') . "/latex/* " . lab_migration_path() . "latex");
- exec("chmod u+x ./uploads/latex/*.sh");
-}
-
+ {
+ exec("cp ./" . drupal_get_path('module', 'lab_migration') . "/latex/* " . lab_migration_path() . "latex");
+ exec("chmod u+x ./uploads/latex/*.sh");
+ }
function _latex_run_script($lab_filename, $solution_provider_filename, $latex_filename, $latex_dep_filename, $pdf_filename)
-{
- $root_path = lab_migration_path();
- $ret = 0;
- chdir("lab_migration_uploads");
- chdir("latex");
-
- $sh_command = "./pdf_creator.sh " . $lab_filename . " " . $solution_provider_filename . " " . $latex_filename . " " . $latex_dep_filename;
- exec($sh_command);
- exec("mv TEX_final.pdf " . $pdf_filename);
-
- if ($ret == 0)
- return TRUE;
- else
- return FALSE;
-}
-
+ {
+ $root_path = lab_migration_path();
+ $ret = 0;
+ chdir("lab_migration_uploads");
+ chdir("latex");
+ $sh_command = "./pdf_creator.sh " . $lab_filename . " " . $solution_provider_filename . " " . $latex_filename . " " . $latex_dep_filename;
+ exec($sh_command);
+ exec("mv TEX_final.pdf " . $pdf_filename);
+ if ($ret == 0)
+ return TRUE;
+ else
+ return FALSE;
+ }
function lab_migration_delete_lab_pdf()
-{
- $lab_id = arg(3);
- lab_migration_del_lab_pdf($lab_id);
- drupal_set_message(t('Lab schedule for regeneration.'), 'status');
- drupal_goto('lab_migration/code_approval/bulk');
- return;
-}
-
+ {
+ $lab_id = arg(3);
+ lab_migration_del_lab_pdf($lab_id);
+ drupal_set_message(t('Lab schedule for regeneration.'), 'status');
+ drupal_goto('lab_migration/code_approval/bulk');
+ return;
+ }
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 90ab732..fe013cc 100755
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -1,7 +1,7 @@
<?php
// $Id$
function lab_migration_proposal_pending()
-{
+ {
/* get pending proposals to be approved */
$pending_rows = array();
//$pending_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 0 ORDER BY id DESC");
@@ -10,7 +10,8 @@ function lab_migration_proposal_pending()
$query->condition('approval_status', 0);
$query->orderBy('id', 'DESC');
$pending_q = $query->execute();
- while ($pending_data = $pending_q->fetchObject()) {
+ while ($pending_data = $pending_q->fetchObject())
+ {
$pending_rows[$pending_data->id] = array(
date('d-m-Y', $pending_data->creation_date),
l($pending_data->name, 'user/' . $pending_data->uid),
@@ -18,12 +19,13 @@ function lab_migration_proposal_pending()
$pending_data->department,
l('Approve', 'lab-migration/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'lab-migration/manage-proposal/edit/' . $pending_data->id)
);
- }
+ }
/* check if there are any pending proposals */
- if (!$pending_rows) {
+ if (!$pending_rows)
+ {
drupal_set_message(t('There are no pending proposals.'), 'status');
return '';
- }
+ }
$pending_header = array(
'Date of Submission',
'Name',
@@ -37,9 +39,9 @@ function lab_migration_proposal_pending()
'rows' => $pending_rows
));
return $output;
-}
+ }
function lab_migration_proposal_pending_solution()
-{
+ {
/* get pending proposals to be approved */
$pending_rows = array();
//$pending_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 1 ORDER BY id DESC");
@@ -48,7 +50,8 @@ function lab_migration_proposal_pending_solution()
$query->condition('approval_status', 1);
$query->orderBy('id', 'DESC');
$pending_q = $query->execute();
- while ($pending_data = $pending_q->fetchObject()) {
+ while ($pending_data = $pending_q->fetchObject())
+ {
$pending_rows[$pending_data->id] = array(
date('d-m-Y', $pending_data->creation_date),
date('d-m-Y', $pending_data->approval_date),
@@ -57,12 +60,13 @@ function lab_migration_proposal_pending_solution()
$pending_data->department,
l('Status', 'lab-migration/manage-proposal/status/' . $pending_data->id)
);
- }
+ }
/* check if there are any pending proposals */
- if (!$pending_rows) {
+ if (!$pending_rows)
+ {
drupal_set_message(t('There are no proposals pending for solutions.'), 'status');
return '';
- }
+ }
$pending_header = array(
'Date of Submission',
'Date of Approval',
@@ -76,9 +80,9 @@ function lab_migration_proposal_pending_solution()
'rows' => $pending_rows
));
return $output;
-}
+ }
function lab_migration_proposal_all()
-{
+ {
/* get pending proposals to be approved */
$proposal_rows = array();
//$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} ORDER BY id DESC");
@@ -86,9 +90,11 @@ function lab_migration_proposal_all()
$query->fields('lab_migration_proposal');
$query->orderBy('id', 'DESC');
$proposal_q = $query->execute();
- while ($proposal_data = $proposal_q->fetchObject()) {
+ while ($proposal_data = $proposal_q->fetchObject())
+ {
$approval_status = '';
- switch ($proposal_data->approval_status) {
+ switch ($proposal_data->approval_status)
+ {
case 0:
$approval_status = 'Pending';
break;
@@ -113,12 +119,13 @@ function lab_migration_proposal_all()
$approval_status,
l('Status', 'lab-migration/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'lab-migration/manage-proposal/edit/' . $proposal_data->id)
);
- }
+ }
/* check if there are any pending proposals */
- if (!$proposal_rows) {
+ if (!$proposal_rows)
+ {
drupal_set_message(t('There are no proposals.'), 'status');
return '';
- }
+ }
$proposal_header = array(
'Date of Submission',
'Name',
@@ -132,9 +139,9 @@ function lab_migration_proposal_all()
'rows' => $proposal_rows
));
return $output;
-}
+ }
function lab_migration_category_all()
-{
+ {
/* get pending proposals to be approved */
$proposal_rows = array();
// $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} ORDER BY id DESC");
@@ -142,7 +149,8 @@ function lab_migration_category_all()
$query->fields('lab_migration_proposal');
$query->orderBy('id', 'DESC');
$proposal_q = $query->execute();
- while ($proposal_data = $proposal_q->fetchObject()) {
+ while ($proposal_data = $proposal_q->fetchObject())
+ {
$proposal_rows[] = array(
date('d-m-Y', $proposal_data->creation_date),
l($proposal_data->name, 'user/' . $proposal_data->uid),
@@ -151,7 +159,7 @@ function lab_migration_category_all()
$proposal_data->category,
l('Edit Category', 'lab-migration/manage-proposal/category/edit/' . $proposal_data->id)
);
- }
+ }
$proposal_header = array(
'Date of Submission',
'Name',
@@ -165,12 +173,12 @@ function lab_migration_category_all()
'rows' => $proposal_rows
));
return $output;
-}
+ }
/******************************************************************************/
/************************** PROPOSAL APPROVAL FORM ****************************/
/******************************************************************************/
function lab_migration_proposal_approval_form($form, $form_state)
-{
+ {
global $user;
/* get current proposal */
$proposal_id = (int) arg(3);
@@ -179,19 +187,25 @@ function lab_migration_proposal_approval_form($form, $form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
+ }
// var_dump($proposal_data->name_title);
// die;
$form['name'] = array(
@@ -252,26 +266,32 @@ function lab_migration_proposal_approval_form($form, $form_state)
$query->condition('proposal_id', $proposal_id);
$query->orderBy('id', 'ASC');
$experiment_q = $query->execute();
- while ($experiment_data = $experiment_q->fetchObject()) {
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
$experiment_list .= '<li>' . $experiment_data->title . '</li>Description of Experiment : ' . $experiment_data->description . '<br>';
- }
+ }
$experiment_list .= '</ul>';
$form['experiment'] = array(
'#type' => 'item',
'#markup' => $experiment_list,
'#title' => t('Experiments')
);
- if ($proposal_data->solution_provider_uid == 0) {
+ if ($proposal_data->solution_provider_uid == 0)
+ {
$solution_provider = "User will not provide solution, we will have to provide solution";
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
$solution_provider = "Proposer will provide the solution of the lab";
- } else {
+ }
+ else
+ {
$solution_provider_user_data = user_load($proposal_data->solution_provider_uid);
if ($solution_provider_user_data)
$solution_provider = "Solution will be provided by user " . l($solution_provider_user_data->name, 'user/' . $proposal_data->solution_provider_uid);
else
$solution_provider = "User does not exists";
- }
+ }
$form['solution_provider_uid'] = array(
'#type' => 'item',
'#title' => t('Do you want to provide the solution'),
@@ -316,17 +336,19 @@ function lab_migration_proposal_approval_form($form, $form_state)
'#markup' => l(t('Cancel'), 'lab-migration/manage-proposal')
);
return $form;
-}
+ }
function lab_migration_proposal_approval_form_validate($form, &$form_state)
-{
- if ($form_state['values']['approval'] == 2) {
- if ($form_state['values']['message'] == '') {
+ {
+ if ($form_state['values']['approval'] == 2)
+ {
+ if ($form_state['values']['message'] == '')
+ {
form_set_error('message', t('Reason for disapproval could not be empty'));
- }
- }
-}
+ }
+ }
+ }
function lab_migration_proposal_approval_form_submit($form, &$form_state)
-{
+ {
global $user;
/* get current proposal */
$proposal_id = (int) arg(3);
@@ -335,20 +357,27 @@ function lab_migration_proposal_approval_form_submit($form, &$form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- if ($form_state['values']['approval'] == 1) {
+ }
+ if ($form_state['values']['approval'] == 1)
+ {
$query = "UPDATE {lab_migration_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 1, solution_status = 2 WHERE id = :proposal_id";
$args = array(
":uid" => $user->uid,
@@ -356,28 +385,31 @@ function lab_migration_proposal_approval_form_submit($form, &$form_state)
":proposal_id" => $proposal_id
);
db_query($query, $args);
- /* sending email */
- $user_data = user_load($proposal_data->uid);
- $email_to = $user_data->mail;
-
- $from = variable_get('lab_migration_from_email', '');
- $bcc= $user->mail . ', ' .variable_get('lab_migration_emails', '');
- $cc=variable_get('lab_migration_cc_emails', '');
-
- $param['proposal_approved']['proposal_id'] = $proposal_id;
- $param['proposal_approved']['user_id'] = $proposal_data->uid;
- $param['proposal_approved']['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', 'proposal_approved', $email_to, language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['proposal_approved']['proposal_id'] = $proposal_id;
+ $param['proposal_approved']['user_id'] = $proposal_data->uid;
+ $param['proposal_approved']['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', 'proposal_approved', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
drupal_set_message('Lab migration proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status');
drupal_goto('lab-migration/manage-proposal');
return;
- } else if ($form_state['values']['approval'] == 2) {
+ }
+ else if ($form_state['values']['approval'] == 2)
+ {
$query = "UPDATE {lab_migration_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, message = :message, solution_provider_uid = 0, solution_status = 0 WHERE id = :proposal_id";
$args = array(
":uid" => $user->uid,
@@ -386,34 +418,35 @@ function lab_migration_proposal_approval_form_submit($form, &$form_state)
":proposal_id" => $proposal_id
);
$result = db_query($query, $args);
- /* sending email */
- $user_data = user_load($proposal_data->uid);
- $email_to = $user_data->mail;
-
- $from=variable_get('lab_migration_from_email', '');
- $bcc=$user->mail . ', ' .variable_get('lab_migration_emails', '');
- $cc=variable_get('lab_migration_cc_emails', '');
-
- $param['proposal_disapproved']['proposal_id'] = $proposal_id;
- $param['proposal_disapproved']['user_id'] = $proposal_data->uid;
- $param['proposal_disapproved']['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', 'proposal_disapproved', $email_to , language_default(), $param,$from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['proposal_disapproved']['proposal_id'] = $proposal_id;
+ $param['proposal_disapproved']['user_id'] = $proposal_data->uid;
+ $param['proposal_disapproved']['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', 'proposal_disapproved', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
drupal_set_message('Lab migration proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
-}
+ }
+ }
/******************************************************************************/
/*************************** PROPOSAL STATUS FORM *****************************/
/******************************************************************************/
function lab_migration_proposal_status_form($form, $form_state)
-{
+ {
global $user;
/* get current proposal */
$proposal_id = (int) arg(3);
@@ -422,19 +455,25 @@ function lab_migration_proposal_status_form($form, $form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
+ }
$form['name'] = array(
'#type' => 'item',
'#markup' => l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid),
@@ -473,26 +512,32 @@ function lab_migration_proposal_status_form($form, $form_state)
$query->condition('proposal_id', $proposal_id);
$query->orderBy('id', 'ASC');
$experiment_q = $query->execute();
- while ($experiment_data = $experiment_q->fetchObject()) {
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
$experiment_list .= '<li>' . $experiment_data->title . '</li>Description of Experiment : ' . $experiment_data->description . '<br>';
- }
+ }
$experiment_list .= '</ul>';
$form['experiment'] = array(
'#type' => 'item',
'#markup' => $experiment_list,
'#title' => t('Experiments')
);
- if ($proposal_data->solution_provider_uid == 0) {
+ if ($proposal_data->solution_provider_uid == 0)
+ {
$solution_provider = "User will not provide solution, we will have to provide solution";
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
$solution_provider = "Proposer will provide the solution of the lab";
- } else {
+ }
+ else
+ {
$solution_provider_user_data = user_load($proposal_data->solution_provider_uid);
if ($solution_provider_user_data)
$solution_provider = "Solution will be provided by user " . l($solution_provider_user_data->name, 'user/' . $proposal_data->solution_provider_uid);
else
$solution_provider = "User does not exists";
- }
+ }
$form['solution_provider_uid'] = array(
'#type' => 'item',
'#title' => t('Who will provide the solution'),
@@ -504,7 +549,8 @@ function lab_migration_proposal_status_form($form, $form_state)
'#markup' => ($proposal_data->solution_display == 1) ? "Yes" : "No",
);*/
$proposal_status = '';
- switch ($proposal_data->approval_status) {
+ switch ($proposal_data->approval_status)
+ {
case 0:
$proposal_status = t('Pending');
break;
@@ -526,27 +572,30 @@ function lab_migration_proposal_status_form($form, $form_state)
'#markup' => $proposal_status,
'#title' => t('Proposal Status')
);
- if ($proposal_data->approval_status == 0) {
+ if ($proposal_data->approval_status == 0)
+ {
$form['approve'] = array(
'#type' => 'item',
'#markup' => l('Click here', 'lab-migration/manage-proposal/approve/' . $proposal_id),
'#title' => t('Approve')
);
- }
- if ($proposal_data->approval_status == 1) {
+ }
+ if ($proposal_data->approval_status == 1)
+ {
$form['completed'] = array(
'#type' => 'checkbox',
'#title' => t('Completed'),
'#description' => t('Check if user has provided all experiment solutions.')
);
- }
- if ($proposal_data->approval_status == 2) {
+ }
+ if ($proposal_data->approval_status == 2)
+ {
$form['message'] = array(
'#type' => 'item',
'#markup' => $proposal_data->message,
'#title' => t('Reason for disapproval')
);
- }
+ }
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
@@ -556,9 +605,9 @@ function lab_migration_proposal_status_form($form, $form_state)
'#markup' => l(t('Cancel'), 'lab-migration/manage-proposal/all')
);
return $form;
-}
+ }
function lab_migration_proposal_status_form_submit($form, &$form_state)
-{
+ {
global $user;
/* get current proposal */
$proposal_id = (int) arg(3);
@@ -567,21 +616,28 @@ function lab_migration_proposal_status_form_submit($form, &$form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
+ }
/* set the book status to completed */
- if ($form_state['values']['completed'] == 1) {
+ if ($form_state['values']['completed'] == 1)
+ {
$up_query = "UPDATE lab_migration_proposal SET approval_status = :approval_status , expected_completion_date = :expected_completion_date WHERE id = :proposal_id";
$args = array(
":approval_status" => '3',
@@ -590,42 +646,43 @@ function lab_migration_proposal_status_form_submit($form, &$form_state)
);
$result = db_query($up_query, $args);
CreateReadmeFileLabMigration($proposal_id);
- if (!$result) {
+ if (!$result)
+ {
drupal_set_message('Error in update status', 'error');
return;
- }
- /* sending email */
- $user_data = user_load($proposal_data->uid);
- $email_to = $user_data->mail;
-
- $from=variable_get('lab_migration_from_email', '');
- $bcc=$user->mail . ', ' .variable_get('lab_migration_emails', '');
- $cc=variable_get('lab_migration_cc_emails', '');
-
- $param['proposal_completed']['proposal_id'] = $proposal_id;
- $param['proposal_completed']['user_id'] = $proposal_data->uid;
- $param['proposal_completed']['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', 'proposal_completed', $email_to , language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- /*$email_to = $user->mail . ', ' . variable_get('lab_migration_emails', '');;
- if (!drupal_mail('lab_migration', 'proposal_completed', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');*/
-
- drupal_set_message('Congratulations! Lab Migration proposal has been marked as completed. User has been notified of the completion.', 'status');
+ }
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['proposal_completed']['proposal_id'] = $proposal_id;
+ $param['proposal_completed']['user_id'] = $proposal_data->uid;
+ $param['proposal_completed']['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', 'proposal_completed', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ /*$email_to = $user->mail . ', ' . variable_get('lab_migration_emails', '');;
+ if (!drupal_mail('lab_migration', 'proposal_completed', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');*/
+ drupal_set_message('Congratulations! Lab Migration proposal has been marked as completed. User has been notified of the completion.', 'status');
+ }
+ drupal_goto('lab-migration/manage-proposal');
+ return;
}
- drupal_goto('lab-migration/manage-proposal');
- return;
-}
/******************************************************************************/
/**************************** PROPOSAL EDIT FORM ******************************/
/******************************************************************************/
function lab_migration_proposal_edit_form($form, $form_state)
-{
+ {
global $user;
/* get current proposal */
$proposal_id = (int) arg(3);
@@ -634,19 +691,25 @@ function lab_migration_proposal_edit_form($form, $form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
+ }
$user_data = user_load($proposal_data->uid);
$form['name_title'] = array(
'#type' => 'select',
@@ -814,10 +877,12 @@ function lab_migration_proposal_edit_form($form, $form_state)
'#collapsible' => FALSE,
'#tree' => TRUE,
);*/
- for ($counter = 1; $counter <= 15; $counter++) {
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
$experiment_title = '';
$experiment_data = $experiment_q->fetchObject();
- if ($experiment_data) {
+ if ($experiment_data)
+ {
$experiment_title = $experiment_data->title;
$experiment_description = $experiment_data->description;
/*$form['lab_experiment_']['update'][$experiment_data->id] = array(
@@ -849,7 +914,9 @@ function lab_migration_proposal_edit_form($form, $form_state)
'#default_value' => $experiment_description,
'#title' => t('Description for Experiment ') . $counter
);
- } else {
+ }
+ else
+ {
$form['lab_experiment_insert' . $counter] = array(
'#type' => 'textfield',
'#title' => t('Title of the Experiment ') . $counter,
@@ -872,20 +939,26 @@ function lab_migration_proposal_edit_form($form, $form_state)
)
)
);
- }
- }
- if ($proposal_data->solution_provider_uid == 0) {
+ }
+ }
+ if ($proposal_data->solution_provider_uid == 0)
+ {
$solution_provider_user = 'Open';
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
$solution_provider_user = 'Proposer';
- } else {
+ }
+ else
+ {
$user_data = user_load($proposal_data->solution_provider_uid);
- if (!$user_data) {
+ if (!$user_data)
+ {
$solution_provider_user = 1;
drupal_set_message('Solution provider user name is invalid', 'error');
- }
+ }
$solution_provider_user = $user_data->name;
- }
+ }
$form['solution_provider_uid'] = array(
'#type' => 'item',
'#title' => t('Who will provide the solution'),
@@ -918,32 +991,35 @@ function lab_migration_proposal_edit_form($form, $form_state)
'#markup' => l(t('Cancel'), 'lab-migration/manage-proposal')
);
return $form;
-}
+ }
function lab_migration_proposal_edit_form_validate($form, &$form_state)
-{
+ {
$proposal_id = (int) arg(3);
/* check before delete proposal */
- if ($form_state['values']['delete_proposal'] == 1) {
+ if ($form_state['values']['delete_proposal'] == 1)
+ {
//$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $proposal_id);
$query = db_select('lab_migration_experiment');
$query->fields('lab_migration_experiment');
$query->condition('proposal_id', $proposal_id);
$experiment_q = $query->execute();
- while ($experiment_data = $experiment_q->fetchObject()) {
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
//$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d", $experiment_data->id);
$query = db_select('lab_migration_solution');
$query->fields('lab_migration_solution');
$query->condition('experiment_id', $experiment_data->id);
$solution_q = $query->execute();
- if ($solution_q->fetchObject()) {
+ if ($solution_q->fetchObject())
+ {
form_set_error('', t('Cannot delete proposal since there are solutions already uploaded. Use the "Bulk Manage" interface to delete this proposal'));
- }
- }
- }
+ }
+ }
+ }
return;
-}
+ }
function lab_migration_proposal_edit_form_submit($form, &$form_state)
-{
+ {
global $user;
/* get current proposal */
$proposal_id = (int) arg(3);
@@ -952,21 +1028,28 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
+ }
/* delete proposal */
- if ($form_state['values']['delete_proposal'] == 1) {
+ if ($form_state['values']['delete_proposal'] == 1)
+ {
//db_query("DELETE FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
$query = db_delete('lab_migration_proposal');
$query->condition('id', $proposal_id);
@@ -978,8 +1061,9 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
drupal_set_message(t('Proposal Delete'), 'status');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- if ($form_state['values']['open_solution'] == 1) {
+ }
+ if ($form_state['values']['open_solution'] == 1)
+ {
// $query = "UPDATE {lab_migration_proposal} SET solution_provider_uid = :solution_provider_uid, solution_status = :solution_status, solution_provider_name_title = '', solution_provider_name = '', solution_provider_contact_ph = '', solution_provider_department = '', solution_provider_university = '' WHERE id = :proposal_id";
// $args= array(
// ":solution_provider_uid" => 0,
@@ -996,17 +1080,21 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
'solution_provider_department' => '',
'solution_provider_university' => ''
))->condition('id', $proposal_id)->execute();
- if (!$result) {
+ if (!$result)
+ {
drupal_set_message(t('Solution already open for everyone.'), 'error');
return;
- }
- }
+ }
+ }
$solution_display = 0;
- if ($form_state['values']['solution_display'] == 1) {
+ if ($form_state['values']['solution_display'] == 1)
+ {
$solution_display = 1;
- } else {
+ }
+ else
+ {
$solution_display = 0;
- }
+ }
/* update proposal */
$v = $form_state['values'];
//$query = "UPDATE {lab_migration_proposal} SET name_title = :name_title, name = :name, contact_ph = :contact_ph, department = :department, university = :unversity, lab_title = :lab_title, solution_display = :solution_display WHERE id = :id";
@@ -1040,12 +1128,15 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
$query->condition('proposal_id', $proposal_id);
$query->orderBy('id', 'ASC');
$experiment_q = $query->execute();
- for ($counter = 1; $counter <= 15; $counter++) {
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
$experiment_data = $experiment_q->fetchObject();
- if ($experiment_data) {
+ if ($experiment_data)
+ {
$experiment_field_name = 'lab_experiment_update' . $experiment_data->id;
$experiment_description = 'lab_experiment_description_update' . $experiment_data->id;
- if (strlen(trim($form_state['values'][$experiment_field_name])) >= 1) {
+ if (strlen(trim($form_state['values'][$experiment_field_name])) >= 1)
+ {
$query = "UPDATE {lab_migration_experiment} SET title = :title, description= :description WHERE id = :id";
$args = array(
":title" => trim($form_state['values'][$experiment_field_name]),
@@ -1053,18 +1144,21 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
":id" => $experiment_data->id
);
$result2 = db_query($query, $args);
- if (!$result2) {
+ if (!$result2)
+ {
drupal_set_message(t('Could not update Title of the Experiment : ') . trim($form_state['values'][$experiment_field_name]), 'error');
- }
- } else {
+ }
+ }
+ else
+ {
$query = "DELETE FROM {lab_migration_experiment} WHERE id = :id LIMIT 1";
$args = array(
":id" => $experiment_data->id
);
$result3 = db_query($query, $args);
- }
- }
- }
+ }
+ }
+ }
/* foreach ($form_state['values']['lab_experiment']['update'] as $update_id => $update_value) {
if (strlen(trim($update_value)) >= 1) {
$description= $form_state['values']['lab_experiment_description']['update'];
@@ -1094,16 +1188,21 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
$query->orderBy('number', 'DESC');
$query->range(0, 1);
$number_q = $query->execute();
- if ($number_data = $number_q->fetchObject()) {
+ if ($number_data = $number_q->fetchObject())
+ {
$number = (int) $number_data->number;
$number++;
- } else {
+ }
+ else
+ {
$number = 1;
- }
- for ($counter = 1; $counter <= 15; $counter++) {
+ }
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
$lab_experiment_insert = 'lab_experiment_insert' . $counter;
$lab_experiment_description_insert = 'lab_experiment_description_insert' . $counter;
- if (strlen(trim(isset($form_state['values'][$lab_experiment_insert]))) >= 1) {
+ if (strlen(trim(isset($form_state['values'][$lab_experiment_insert]))) >= 1)
+ {
$query = "INSERT INTO {lab_migration_experiment} (proposal_id, number, title, description) VALUES (:proposal_id, :number, :title, :description)";
$args = array(
":proposal_id" => $proposal_id,
@@ -1112,13 +1211,16 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
":description" => trim($form_state['values'][$lab_experiment_description_insert])
);
$result4 = db_query($query, $args);
- if (!$result4) {
+ if (!$result4)
+ {
drupal_set_message(t('Could not insert Title of the Experiment : ') . trim($form_state['values'][$lab_experiment_insert]), 'error');
- } else {
+ }
+ else
+ {
$number++;
- }
- }
- }
+ }
+ }
+ }
/* $query = db_select('lab_migration_experiment');
$query->fields('lab_migration_experiment');
$query->condition('proposal_id', $proposal_id);
@@ -1157,12 +1259,12 @@ function lab_migration_proposal_edit_form_submit($form, &$form_state)
}
}*/
drupal_set_message(t('Proposal Updated'), 'status');
-}
+ }
/******************************************************************************/
/**************************** CATEGORY EDIT FORM ******************************/
/******************************************************************************/
function lab_migration_category_edit_form($form, $form_state)
-{
+ {
/* get current proposal */
$proposal_id = (int) arg(4);
//$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
@@ -1170,19 +1272,25 @@ function lab_migration_category_edit_form($form, $form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
+ }
$form['name'] = array(
'#type' => 'item',
'#markup' => l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid),
@@ -1229,9 +1337,9 @@ function lab_migration_category_edit_form($form, $form_state)
'#markup' => l(t('Cancel'), 'lab-migration/manage-proposal/category')
);
return $form;
-}
+ }
function lab_migration_category_edit_form_submit($form, &$form_state)
-{
+ {
/* get current proposal */
$proposal_id = (int) arg(4);
//$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
@@ -1239,19 +1347,25 @@ function lab_migration_category_edit_form_submit($form, &$form_state)
$query->fields('lab_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
- if ($proposal_q) {
- if ($proposal_data = $proposal_q->fetchObject()) {
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
/* everything ok */
- } else {
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
- } else {
+ }
+ }
+ else
+ {
drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
drupal_goto('lab-migration/manage-proposal');
return;
- }
+ }
$query = "UPDATE {lab_migration_proposal} SET category = :category WHERE id = :proposal_id";
$args = array(
":category" => $form_state['values']['category'],
@@ -1260,9 +1374,9 @@ function lab_migration_category_edit_form_submit($form, &$form_state)
$result = db_query($query, $args);
drupal_set_message(t('Proposal Category Updated'), 'status');
drupal_goto('lab-migration/manage-proposal/category');
-}
+ }
function _lm_list_of_departments()
-{
+ {
$department = array(
0 => '-Select-'
);
@@ -1270,13 +1384,14 @@ function _lm_list_of_departments()
$query->fields('list_of_departments');
$query->orderBy('id', 'DESC');
$department_list = $query->execute();
- while ($department_list_data = $department_list->fetchObject()) {
+ while ($department_list_data = $department_list->fetchObject())
+ {
$department[$department_list_data->department] = $department_list_data->department;
- }
+ }
return $department;
-}
+ }
function _lm_list_of_states()
-{
+ {
$states = array(
0 => '-Select-'
);
@@ -1284,25 +1399,27 @@ function _lm_list_of_states()
$query->fields('list_states_of_india');
//$query->orderBy('', '');
$states_list = $query->execute();
- while ($states_list_data = $states_list->fetchObject()) {
+ while ($states_list_data = $states_list->fetchObject())
+ {
$states[$states_list_data->state] = $states_list_data->state;
- }
+ }
return $states;
-}
+ }
function _lm_list_of_cities()
-{
+ {
$city = array();
$query = db_select('list_cities_of_india');
$query->fields('list_cities_of_india');
$query->orderBy('city', 'ASC');
$city_list = $query->execute();
- while ($city_list_data = $city_list->fetchObject()) {
+ while ($city_list_data = $city_list->fetchObject())
+ {
$city[$city_list_data->city] = $city_list_data->city;
- }
+ }
return $city;
-}
+ }
function CreateReadmeFileLabMigration($proposal_id)
-{
+ {
$result = db_query("
SELECT * from lab_migration_proposal WHERE id = :proposal_id", array(
":proposal_id" => $proposal_id
@@ -1328,4 +1445,4 @@ function CreateReadmeFileLabMigration($proposal_id)
fwrite($readme_file, $txt);
fclose($readme_file);
return $txt;
-}
+ }
diff --git a/manage_solution_proposal.inc b/manage_solution_proposal.inc
index 95a34e7..a2a6259 100755
--- a/manage_solution_proposal.inc
+++ b/manage_solution_proposal.inc
@@ -1,287 +1,292 @@
<?php
// $Id$
-
function lab_migration_solution_proposal_pending()
-{
- /* get list of solution proposal where the solution_provider_uid is set to some userid except 0 and solution_status is also 1 */
- $pending_rows = array();
- //$pending_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid != 0 AND solution_status = 1 ORDER BY id DESC");
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('solution_provider_uid', 0, '!=');
- $query->condition('solution_status', 1);
- $query->orderBy('id', 'DESC');
- $pending_q = $query->execute();
- while ($pending_data = $pending_q->fetchObject())
{
- $pending_rows[$pending_data->id] = array(l($pending_data->name, 'user/' . $pending_data->uid), $pending_data->lab_title, l('Approve', 'lab-migration/manage-proposal/solution-proposal-approve/' . $pending_data->id));
+ /* get list of solution proposal where the solution_provider_uid is set to some userid except 0 and solution_status is also 1 */
+ $pending_rows = array();
+ //$pending_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid != 0 AND solution_status = 1 ORDER BY id DESC");
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('solution_provider_uid', 0, '!=');
+ $query->condition('solution_status', 1);
+ $query->orderBy('id', 'DESC');
+ $pending_q = $query->execute();
+ while ($pending_data = $pending_q->fetchObject())
+ {
+ $pending_rows[$pending_data->id] = array(
+ l($pending_data->name, 'user/' . $pending_data->uid),
+ $pending_data->lab_title,
+ l('Approve', 'lab-migration/manage-proposal/solution-proposal-approve/' . $pending_data->id)
+ );
+ }
+ /* check if there are any pending proposals */
+ if (!$pending_rows)
+ {
+ drupal_set_message(t('There are no pending solution proposals.'), 'status');
+ return '';
+ }
+ $pending_header = array(
+ 'Proposer Name',
+ 'Title of the Lab',
+ 'Action'
+ );
+ $output = theme('table', array(
+ 'header' => $pending_header,
+ 'rows' => $pending_rows
+ ));
+ return $output;
}
-
- /* check if there are any pending proposals */
- if (!$pending_rows)
- {
- drupal_set_message(t('There are no pending solution proposals.'), 'status');
- return '';
- }
-
- $pending_header = array('Proposer Name', 'Title of the Lab', 'Action');
- $output = theme('table', array('header' => $pending_header, 'rows' => $pending_rows ));
- return $output;
-}
-
/******************************************************************************/
/***************** SOLUTION PROPOSAL APPROVAL FORM ****************************/
/******************************************************************************/
-
function lab_migration_solution_proposal_approval_form($form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = (int)arg(3);
- // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- if ($proposal_q)
{
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
- return;
- }
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
- return;
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ }
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
+ return;
+ }
+ }
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
+ return;
+ }
+ $form['name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid),
+ '#title' => t('Proposer Name')
+ );
+ $form['email_id'] = array(
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ $form['contact_ph'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->contact_ph,
+ '#title' => t('Contact No.')
+ );
+ $form['department'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->department,
+ '#title' => t('Department/Branch')
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute')
+ );
+ $form['lab_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->lab_title,
+ '#title' => t('Title of the Lab')
+ );
+ /* get experiment details */
+ $experiment_list = '<ul>';
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY id ASC", $proposal_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $proposal_id);
+ $query->orderBy('id', 'ASC');
+ $experiment_q = $query->execute();
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<li>' . $experiment_data->title . '</li>Description of Experiment : ' . $experiment_data->description . '<br>';
+ ;
+ }
+ $experiment_list .= '</ul>';
+ $form['experiment'] = array(
+ '#type' => 'item',
+ '#markup' => $experiment_list,
+ '#title' => t('Experiments')
+ );
+ $form['solution_display'] = array(
+ '#type' => 'item',
+ '#title' => t('Display the solution on the www.esim.fossee.in website'),
+ '#markup' => ($proposal_data->solution_display == 1) ? "Yes" : "No"
+ );
+ if ($proposal_data->solution_provider_uid == 0)
+ {
+ $solution_provider = "Open";
+ }
+ else if ($proposal_data->solution_provider_uid == $proposal_data->uid)
+ {
+ $solution_provider = "Proposer will provide the solution of the lab";
+ }
+ else
+ {
+ $solution_provider_user_data = user_load($proposal_data->solution_provider_uid);
+ if ($solution_provider_user_data)
+ {
+ $solution_provider .= '<ul>' . '<li><strong>Solution Provider:</strong> ' . l($solution_provider_user_data->name, 'user/' . $proposal_data->solution_provider_uid) . '</li>' . '<li><strong>Solution Provider Name:</strong> ' . $proposal_data->solution_provider_name_title . ' ' . $proposal_data->solution_provider_name . '</li>' . '<li><strong>Department:</strong> ' . $proposal_data->solution_provider_department . '</li>' . '<li><strong>University:</strong> ' . $proposal_data->solution_provider_university . '</li>' . '</ul>';
+ }
+ else
+ {
+ $solution_provider = "User does not exists";
+ }
+ }
+ $form['solution_provider_uid'] = array(
+ '#type' => 'item',
+ '#title' => t('Solution Provider'),
+ '#markup' => $solution_provider
+ );
+ $form['approval'] = array(
+ '#type' => 'radios',
+ '#title' => t('Solution Provider'),
+ '#options' => array(
+ '1' => 'Approve',
+ '2' => 'Disapprove'
+ ),
+ '#required' => TRUE
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reason for disapproval')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#value' => l(t('Cancel'), 'lab-migration/manage-proposal/pending-solution-proposal')
+ );
+ return $form;
}
-
- $form['name'] = array(
- '#type' => 'item',
- '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid),
- '#title' => t('Proposer Name'),
- );
- $form['email_id'] = array(
- '#type' => 'item',
- '#markup' => user_load($proposal_data->uid)->mail,
- '#title' => t('Email'),
- );
- $form['contact_ph'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->contact_ph,
- '#title' => t('Contact No.'),
- );
- $form['department'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->department,
- '#title' => t('Department/Branch'),
- );
- $form['university'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->university,
- '#title' => t('University/Institute'),
- );
- $form['lab_title'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->lab_title,
- '#title' => t('Title of the Lab'),
- );
-
- /* get experiment details */
- $experiment_list = '<ul>';
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY id ASC", $proposal_id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $proposal_id);
- $query->orderBy('id', 'ASC');
- $experiment_q = $query->execute();
- while ($experiment_data = $experiment_q->fetchObject())
+function lab_migration_solution_proposal_approval_form_validate($form, &$form_state)
{
- $experiment_list .= '<li>' . $experiment_data->title . '</li>Description of Experiment : '.$experiment_data->description.'<br>';;
+ $proposal_id = (int) arg(3);
+ // $solution_provider_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $solution_provider_q = $query->execute();
+ $solution_provider_data = $solution_provider_q->fetchObject();
+ // $solution_provider_present_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = %d AND approval_status IN (0, 1) AND id != %d", $solution_provider_data->uid, $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('solution_provider_uid', $solution_provider_data->uid);
+ $query->condition('approval_status', array(
+ 0,
+ 1
+ ), 'IN');
+ $query->condition('id', $proposal_id, '<>');
+ $solution_provider_present_q = $query->execute();
+ if ($x = $solution_provider_present_q->fetchObject())
+ {
+ drupal_set_message($proposal_id);
+ form_set_error('', t('Solution provider has already one proposal active'));
+ }
}
- $experiment_list .= '</ul>';
-
- $form['experiment'] = array(
- '#type' => 'item',
- '#markup' => $experiment_list,
- '#title' => t('Experiments'),
- );
-
- $form['solution_display'] = array(
- '#type' => 'item',
- '#title' => t('Display the solution on the www.esim.fossee.in website'),
- '#markup' => ($proposal_data->solution_display == 1) ? "Yes" : "No",
- );
-
- if ($proposal_data->solution_provider_uid == 0) {
- $solution_provider = "Open";
- } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) {
- $solution_provider = "Proposer will provide the solution of the lab";
- } else {
- $solution_provider_user_data = user_load($proposal_data->solution_provider_uid);
- if ($solution_provider_user_data) {
- $solution_provider .= '<ul>' .
- '<li><strong>Solution Provider:</strong> ' . l($solution_provider_user_data->name, 'user/' . $proposal_data->solution_provider_uid) . '</li>' .
- '<li><strong>Solution Provider Name:</strong> ' . $proposal_data->solution_provider_name_title . ' ' . $proposal_data->solution_provider_name . '</li>' .
- '<li><strong>Department:</strong> ' . $proposal_data->solution_provider_department . '</li>' .
- '<li><strong>University:</strong> ' . $proposal_data->solution_provider_university . '</li>' .
- '</ul>';
- } else {
- $solution_provider = "User does not exists";
- }
- }
- $form['solution_provider_uid'] = array(
- '#type' => 'item',
- '#title' => t('Solution Provider'),
- '#markup' => $solution_provider,
- );
-
- $form['approval'] = array(
- '#type' => 'radios',
- '#title' => t('Solution Provider'),
- '#options' => array('1' => 'Approve', '2' => 'Disapprove'),
- '#required' => TRUE,
- );
-
- $form['message'] = array(
- '#type' => 'textarea',
- '#title' => t('Reason for disapproval'),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'lab-migration/manage-proposal/pending-solution-proposal'),
- );
-
- return $form;
-}
-
-function lab_migration_solution_proposal_approval_form_validate($form, &$form_state)
-{
- $proposal_id = (int)arg(3);
-
- // $solution_provider_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $solution_provider_q = $query->execute();
- $solution_provider_data = $solution_provider_q->fetchObject();
-
- // $solution_provider_present_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = %d AND approval_status IN (0, 1) AND id != %d", $solution_provider_data->uid, $proposal_id);
-
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('solution_provider_uid', $solution_provider_data->uid);
- $query->condition('approval_status', array(0, 1), 'IN');
- $query->condition('id', $proposal_id, '<>');
- $solution_provider_present_q = $query->execute();
- if ($x = $solution_provider_present_q->fetchObject()) {
- drupal_set_message($proposal_id);
- form_set_error('', t('Solution provider has already one proposal active'));
- }
-}
-
function lab_migration_solution_proposal_approval_form_submit($form, &$form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = (int)arg(3);
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- if ($proposal_q)
{
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
- return;
- }
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
- return;
- }
-
- $user_data = user_load($proposal_data->solution_provider_uid);
-
- if ($form_state['values']['approval'] == 1) {
- $query = "UPDATE {lab_migration_proposal} SET solution_status = 2 WHERE id =:proposal_id";
- $args = array(
- ":proposal_id" => $proposal_id
- );
- db_query($query, $args);
-
- /* sending email */
- $email_to = $user_data->mail;
-
- $from = variable_get('lab_migration_from_email', '');
- $bcc= $user->mail . ', ' .variable_get('lab_migration_emails', '');
- $cc=variable_get('lab_migration_cc_emails', '');
-
- $param['solution_proposal_approved']['proposal_id'] = $proposal_id;
- $param['solution_proposal_approved']['user_id'] = $proposal_data->solution_provider_uid;
- $param['solution_proposal_approved']['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', 'solution_proposal_approved', $email_to , language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- /*$email_to = $user->mail . ', ' . variable_get('lab_migration_emails', '');
- if (!drupal_mail('lab_migration', 'solution_proposal_approved', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');*/
-
- drupal_set_message('Lab migration solution proposal approved. User has been notified of the approval.', 'status');
- drupal_goto('lab-migration/manage-proposal/pending-solution_proposal');
- return;
- } else if ($form_state['values']['approval'] == 2) {
- $query = "UPDATE {lab_migration_proposal} SET solution_provider_uid = :solution_provider_uid, solution_status = :solution_status, solution_provider_name_title = '', solution_provider_name = '', solution_provider_contact_ph = '', solution_provider_department = '', solution_provider_university = '' WHERE id = :proposal_id";
-
- $args = array(
- ":solution_provider_uid" => 0,
- ":solution_status" => 0,
- ":proposal_id" => $proposal_id
- );
- db_query($query, $args);
-
- /* sending email */
- $email_to = $user_data->mail;
-
- $from = variable_get('lab_migration_from_email', '');
- $bcc= $user->mail . ', ' .variable_get('lab_migration_emails', '');
- $cc=variable_get('lab_migration_cc_emails', '');
-
- $param['solution_proposal_disapproved']['proposal_id'] = $proposal_id;
- $param['solution_proposal_disapproved']['user_id'] = $proposal_data->solution_provider_uid;
- $param['solution_proposal_disapproved']['message'] = $form_state['values']['message'];
- $param['solution_proposal_disapproved']['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', 'solution_proposal_disapproved', $email_to , language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message('Lab migration solution proposal dis-approved. User has been notified of the dis-approval.', 'status');
- drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
- return;
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ }
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
+ return;
+ }
+ }
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
+ return;
+ }
+ $user_data = user_load($proposal_data->solution_provider_uid);
+ if ($form_state['values']['approval'] == 1)
+ {
+ $query = "UPDATE {lab_migration_proposal} SET solution_status = 2 WHERE id =:proposal_id";
+ $args = array(
+ ":proposal_id" => $proposal_id
+ );
+ db_query($query, $args);
+ /* sending email */
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['solution_proposal_approved']['proposal_id'] = $proposal_id;
+ $param['solution_proposal_approved']['user_id'] = $proposal_data->solution_provider_uid;
+ $param['solution_proposal_approved']['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', 'solution_proposal_approved', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ /*$email_to = $user->mail . ', ' . variable_get('lab_migration_emails', '');
+ if (!drupal_mail('lab_migration', 'solution_proposal_approved', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');*/
+ drupal_set_message('Lab migration solution proposal approved. User has been notified of the approval.', 'status');
+ drupal_goto('lab-migration/manage-proposal/pending-solution_proposal');
+ return;
+ }
+ else if ($form_state['values']['approval'] == 2)
+ {
+ $query = "UPDATE {lab_migration_proposal} SET solution_provider_uid = :solution_provider_uid, solution_status = :solution_status, solution_provider_name_title = '', solution_provider_name = '', solution_provider_contact_ph = '', solution_provider_department = '', solution_provider_university = '' WHERE id = :proposal_id";
+ $args = array(
+ ":solution_provider_uid" => 0,
+ ":solution_status" => 0,
+ ":proposal_id" => $proposal_id
+ );
+ db_query($query, $args);
+ /* sending email */
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['solution_proposal_disapproved']['proposal_id'] = $proposal_id;
+ $param['solution_proposal_disapproved']['user_id'] = $proposal_data->solution_provider_uid;
+ $param['solution_proposal_disapproved']['message'] = $form_state['values']['message'];
+ $param['solution_proposal_disapproved']['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', 'solution_proposal_disapproved', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Lab migration solution proposal dis-approved. User has been notified of the dis-approval.', 'status');
+ drupal_goto('lab-migration/manage-proposal/pending-solution-proposal');
+ return;
+ }
}
-}
-
diff --git a/notes.inc b/notes.inc
index 8b0bc98..8e7c144 100755
--- a/notes.inc
+++ b/notes.inc
@@ -1,119 +1,104 @@
<?php
// $Id$
-
/******************************************************************************/
/***************************** BOOK NOTES *************************************/
/******************************************************************************/
-
-function lab_migration_lab_notes_form($form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = (int)arg(3);
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
+function lab_migration_lab_notes_form($form,$form_state)
{
- drupal_set_message(t('Invalid lab selected. Please try again.'), 'error');
- drupal_goto('lab_migration/code_approval');
- return;
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message(t('Invalid lab selected. Please try again.'), 'error');
+ drupal_goto('lab-migration/code-approval');
+ return;
+ }
+ /* get current notes */
+ $notes = '';
+ //$notes_q = db_query("SELECT * FROM {lab_migration_notes} WHERE proposal_id = %d LIMIT 1", $proposal_id);
+ $query = db_select('lab_migration_notes');
+ $query->fields('lab_migration_notes');
+ $query->condition('proposal_id', $proposal_id);
+ $query->range(0, 1);
+ $notes_q = $query->execute();
+ if ($notes_q)
+ {
+ $notes_data = $notes_q->fetchObject();
+ $notes = $notes_data->notes;
+ }
+ $form['lab_details'] = array(
+ '#type' => 'item',
+ '#value' => '<span style="color: rgb(128, 0, 0);"><strong>About the Lab</strong></span><br />' . '<strong>Proposer:</strong> ' . $proposal_data->name . '<br />' . '<strong>Title of the Lab:</strong> ' . $proposal_data->lab_title . '<br />'
+ );
+ $form['notes'] = array(
+ '#type' => 'textarea',
+ '#rows' => 20,
+ '#title' => t('Notes for Reviewers'),
+ '#default_value' => $notes
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#value' => l(t('Back'), 'lab-migration/code-approval')
+ );
+ return $form;
}
-
- /* get current notes */
- $notes = '';
- //$notes_q = db_query("SELECT * FROM {lab_migration_notes} WHERE proposal_id = %d LIMIT 1", $proposal_id);
- $query = db_select('lab_migration_notes');
- $query->fields('lab_migration_notes');
- $query->condition('proposal_id', $proposal_id);
- $query->range(0, 1);
- $notes_q = $query->execute();
-
- if ($notes_q)
- {
- $notes_data = $notes_q->fetchObject();
- $notes = $notes_data->notes;
- }
-
- $form['lab_details'] = array(
- '#type' => 'item',
- '#value' => '<span style="color: rgb(128, 0, 0);"><strong>About the Lab</strong></span><br />' .
- '<strong>Proposer:</strong> ' . $proposal_data->name . '<br />' .
- '<strong>Title of the Lab:</strong> ' . $proposal_data->lab_title . '<br />'
- );
-
- $form['notes'] = array(
- '#type' => 'textarea',
- '#rows' => 20,
- '#title' => t('Notes for Reviewers'),
- '#default_value' => $notes,
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Back'), 'lab_migration/code_approval'),
- );
- return $form;
-}
-
function lab_migration_lab_notes_form_submit($form, &$form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = (int)arg(3);
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
{
- drupal_set_message(t('Invalid lab selected. Please try again.'), 'error');
- drupal_goto('lab_migration/code_approval');
- return;
- }
-
- /* find existing notes */
- //$notes_q = db_query("SELECT * FROM {lab_migration_notes} WHERE proposal_id = %d LIMIT 1", $proposal_id);
- $query = db_select('lab_migration_notes');
- $query->fields('lab_migration_notes');
- $query->condition('proposal_id', $proposal_id);
- $query->range(0, 1);
- $notes_q = $query->execute();
-
-
- $notes_data = $notes_q->fetchObject();
-
- /* add or update notes in database */
- if ($notes_data) {
- $query = "UPDATE {lab_migration_notes} SET notes = :notes WHERE id = :notes_id";
- $args = array(
- ":notes" => $form_state['values']['notes'],
- ":notes_id" => $notes_data->id,
- );
- db_query($query, $args);
- drupal_set_message('Notes updated successfully.', 'status');
- } else {
- $query = "INSERT INTO {lab_migration_notes} (proposal_id, notes) VALUES (:proposal_id, :notes)";
- $args = array(
- ":proposal_id" => $proposal_id,
- ":notes" =>$form_state['values']['notes'],
- );
- db_query($query, $args);
- drupal_set_message('Notes added successfully.', 'status');
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message(t('Invalid lab selected. Please try again.'), 'error');
+ drupal_goto('lab-migration/code-approval');
+ return;
+ }
+ /* find existing notes */
+ //$notes_q = db_query("SELECT * FROM {lab_migration_notes} WHERE proposal_id = %d LIMIT 1", $proposal_id);
+ $query = db_select('lab_migration_notes');
+ $query->fields('lab_migration_notes');
+ $query->condition('proposal_id', $proposal_id);
+ $query->range(0, 1);
+ $notes_q = $query->execute();
+ $notes_data = $notes_q->fetchObject();
+ /* add or update notes in database */
+ if ($notes_data)
+ {
+ $query = "UPDATE {lab_migration_notes} SET notes = :notes WHERE id = :notes_id";
+ $args = array(
+ ":notes" => $form_state['values']['notes'],
+ ":notes_id" => $notes_data->id
+ );
+ db_query($query, $args);
+ drupal_set_message('Notes updated successfully.', 'status');
+ }
+ else
+ {
+ $query = "INSERT INTO {lab_migration_notes} (proposal_id, notes) VALUES (:proposal_id, :notes)";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":notes" => $form_state['values']['notes']
+ );
+ db_query($query, $args);
+ drupal_set_message('Notes added successfully.', 'status');
+ }
}
-}
-
diff --git a/proposal.inc b/proposal.inc
index 48d60af..66900a8 100755
--- a/proposal.inc
+++ b/proposal.inc
@@ -1,510 +1,569 @@
<?php
// $Id$
-
/*
- Approval Status :
- 0 - Pending
- 1 - Approved
- 2 - Dis-Approved
- 3 - Solved
- Solution Status :
- 0 - Pending
- 1 - Approved
- 2 - Dis-Approved
- Solution Display :
- 0 - No
- 1 - Yes
+Approval Status :
+0 - Pending
+1 - Approved
+2 - Dis-Approved
+3 - Solved
+Solution Status :
+0 - Pending
+1 - Approved
+2 - Dis-Approved
+Solution Display :
+0 - No
+1 - Yes
- Tables :
- lab_migration_solution : approval_status
- 0 - Pending
- 1 - Approved
- 2 - Disapproved (delete it)
+Tables :
+lab_migration_solution : approval_status
+0 - Pending
+1 - Approved
+2 - Disapproved (delete it)
*/
-
-function lab_migration_proposal_form($form,$form_state)
-{
- global $user;
-
- /************************ start approve book details ************************/
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('uid', $user->uid);
- $query->orderBy('id', 'DESC');
- $query->range(0, 1);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if ($proposal_data)
+function lab_migration_proposal_form($form, $form_state)
{
- if ($proposal_data->approval_status == 0 || $proposal_data->approval_status == 1) {
- drupal_set_message(t('We have already received your proposal.'), 'status');
- drupal_goto('');
- return;
- }
- }
-
-
- $form['#attributes'] = array('enctype' => "multipart/form-data");
-
- $form['name_title'] = array(
- '#type' => 'select',
- '#title' => t('Title'),
- '#options' => array('Dr' => 'Dr', 'Prof' => 'Prof'),
- '#required' => TRUE,
- );
- $form['name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of the Proposer'),
- '#size' => 200,
- '#attributes' =>array('placeholder' => t('Enter your full name')),
- '#maxlength' => 200,
- '#required' => TRUE,
- );
- $form['email_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Email'),
- '#size' => 30,
- '#value' => $user->mail,
- '#disabled' => TRUE,
- );
- $form['contact_ph'] = array(
- '#type' => 'textfield',
- '#title' => t('Contact No.'),
- '#size' => 30,
- '#attributes' =>array('placeholder' => t('Enter your contact number')),
- '#maxlength' => 15,
- '#required' => TRUE,
- );
- $form['department'] = array(
- '#type' => 'select',
- '#title' => t('Department/Branch'),
- '#options' => _lm_list_of_departments(),
- '#required' => TRUE,
- );
-
- $form['university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/ Institute'),
- '#size' => 80,
- '#maxlength' => 200,
- '#required' => TRUE,
- '#attributes' =>array('placeholder' =>'Insert full name of your institute/ university.... '),
- );
-
- $form['country'] = array(
- '#type' => 'select',
- '#title' => t('Country'),
- '#options' => array(
- 'India' => 'India',
- 'Others' => 'Others',
+ global $user;
+ /************************ start approve book details ************************/
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if ($proposal_data)
+ {
+ if ($proposal_data->approval_status == 0 || $proposal_data->approval_status == 1)
+ {
+ drupal_set_message(t('We have already received your proposal.'), 'status');
+ drupal_goto('');
+ return;
+ }
+ }
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ $form['name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof'
+ ),
+ '#required' => TRUE
+ );
+ $form['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Proposer'),
+ '#size' => 200,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your full name')
+ ),
+ '#maxlength' => 200,
+ '#required' => TRUE
+ );
+ $form['email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email'),
+ '#size' => 30,
+ '#value' => $user->mail,
+ '#disabled' => TRUE
+ );
+ $form['contact_ph'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Contact No.'),
+ '#size' => 30,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your contact number')
+ ),
+ '#maxlength' => 15,
+ '#required' => TRUE
+ );
+ $form['department'] = array(
+ '#type' => 'select',
+ '#title' => t('Department/Branch'),
+ '#options' => _lm_list_of_departments(),
+ '#required' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/ Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => 'Insert full name of your institute/ university.... '
+ )
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _lm_list_of_states(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _lm_list_of_cities(),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#required' => False,
+ '#attributes' => array(
+ 'placeholder' => 'Enter pincode....'
+ )
+ );
+ /***************************************************************************/
+ $form['hr'] = array(
+ '#type' => 'item',
+ '#markup' => '<hr>'
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#options' => _lm_list_of_software_version(),
+ '#required' => TRUE
+ );
+ $form['older'] = array(
+ '#type' => 'textfield',
+ '#size' => 30,
+ '#maxlength' => 50,
+ //'#required' => TRUE,
+ '#description' => t('Specify the Older version used'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="version"]' => array(
+ 'value' => 'olderversion'
+ )
+ )
+ )
+ );
+ $form['lab_title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of the Lab'),
+ '#size' => 50,
+ '#required' => TRUE
+ );
+ $first_experiemnt = TRUE;
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
+ if ($counter <= 5)
+ {
+ $form['lab_experiment-' . $counter] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of the Experiment ') . $counter,
+ '#size' => 50,
+ '#required' => TRUE
+ );
+ $namefield = "lab_experiment-" . $counter;
+ $form['lab_experiment_description-' . $counter] = array(
+ '#type' => 'textarea',
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => t('Enter Description for your experiment ' . $counter),
+ 'cols' => 50,
+ 'rows' => 4
),
- '#required' => TRUE,
- '#tree' => TRUE,
- '#validated' => TRUE,
- );
- $form['other_country'] = array(
- '#type' => 'textfield',
- '#title' => t('Other than India'),
- '#size' => 100,
- '#attributes' =>array('placeholder' => t('Enter your country name')),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array('value' => 'Others'),
- ),
- ),
- );
- $form['other_state'] = array(
- '#type' => 'textfield',
- '#title' => t('State other than India'),
- '#size' => 100,
- '#attributes' =>array('placeholder' => t('Enter your state/region name')),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array('value' => 'Others'),
- ),
- ),
- );
- $form['other_city'] = array(
- '#type' => 'textfield',
- '#title' => t('City other than India'),
- '#size' => 100,
- '#attributes' =>array('placeholder' => t('Enter your city name')),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array('value' => 'Others'),
- ),
- ),
- );
- $form['all_state'] = array(
- '#type' => 'select',
- '#title' => t('State'),
- '#options' => _lm_list_of_states(),
- '#validated' => TRUE,
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array('value' => 'India'),
- ),
- ),
- );
- $form['city'] = array(
- '#type' => 'select',
- '#title' => t('City'),
- '#options' => _lm_list_of_cities(),
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array('value' => 'India'),
- ),
- ),
- );
- $form['pincode'] = array(
- '#type' => 'textfield',
- '#title' => t('Pincode'),
- '#size' => 30,
- '#maxlength' => 6,
- '#required' => False,
- '#attributes' =>array('placeholder' =>'Enter pincode....'),
- );
- /***************************************************************************/
- $form['hr'] = array(
- '#type' => 'item',
- '#markup' => '<hr>',
- );
- $form['version'] = array(
- '#type' => 'select',
- '#title' => t('Version'),
- '#options' => _lm_list_of_software_version(),
- '#required' => TRUE,
- );
- $form['older'] = array(
- '#type' => 'textfield',
- '#size' => 30,
- '#maxlength' => 50,
- //'#required' => TRUE,
- '#description' => t('Specify the Older version used'),
- '#states' => array(
- 'visible' => array(
- ':input[name="version"]' => array('value' => 'olderversion'),
- ),
- ),
- );
- $form['lab_title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the Lab'),
- '#size' => 50,
- '#required' => TRUE,
- );
-
- $first_experiemnt = TRUE;
- for ($counter = 1; $counter <= 15; $counter++) {
-
- if($counter<=5){
- $form['lab_experiment-' . $counter] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the Experiment ') . $counter,
- '#size' => 50,
- '#required' => TRUE,
- );
- $namefield="lab_experiment-" . $counter;
- $form['lab_experiment_description-' . $counter] = array(
- '#type' => 'textarea',
- '#required' => TRUE,
- '#attributes' =>array('placeholder' => t('Enter Description for your experiment '.$counter), 'cols' => 50, 'rows' => 4),
- '#title' => t('Description for Experiment ') . $counter,
- '#states' => array(
- 'invisible' => array(
- ':input[name='.$namefield.']' => array('value' => ""),
- ),
- ),
- );
- }else{
- $form['lab_experiment-' . $counter] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the Experiment ') . $counter,
- '#size' => 50,
- '#required' => FALSE,
- );
- $namefield="lab_experiment-" . $counter;
- $form['lab_experiment_description-' . $counter] = array(
- '#type' => 'textarea',
- '#required' => FALSE,
- '#attributes' =>array('placeholder' => t('Enter Description for your experiment '.$counter),'cols' => 50, 'rows' => 4),
- '#title' => t('Description for Experiment ') . $counter,
- '#states' => array(
- 'invisible' => array(
- ':input[name='.$namefield.']' => array('value' => ""),
- ),
- ),
- );
- }
- $first_experiemnt = FALSE;
-
- }
-
- $form['solution_provider_uid'] = array(
- '#type' => 'radios',
- '#title' => t('Do you want to provide the solution'),
- '#options' => array('1' => 'Yes', '2' => 'No'),
- '#required' => TRUE,
- '#default_value' => '1',
- '#description' => 'If you dont want to provide the solution then it will be opened for the community, anyone may come forward and provide the solution.',
- );
-
- $form['solution_display'] = array(
- '#type' => 'hidden',
- '#title' => t('Do you want to display the solution on the www.dwsim.fossee.in website'),
- '#options' => array('1' => 'Yes'),
- '#required' => TRUE,
- '#default_value' => '1',
- '#description' => 'If yes, solutions will be made available to everyone for downloading.',
- '#disabled' => FALSE,
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- return $form;
-}
-
+ '#title' => t('Description for Experiment ') . $counter,
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name=' . $namefield . ']' => array(
+ 'value' => ""
+ )
+ )
+ )
+ );
+ }
+ else
+ {
+ $form['lab_experiment-' . $counter] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of the Experiment ') . $counter,
+ '#size' => 50,
+ '#required' => FALSE
+ );
+ $namefield = "lab_experiment-" . $counter;
+ $form['lab_experiment_description-' . $counter] = array(
+ '#type' => 'textarea',
+ '#required' => FALSE,
+ '#attributes' => array(
+ 'placeholder' => t('Enter Description for your experiment ' . $counter),
+ 'cols' => 50,
+ 'rows' => 4
+ ),
+ '#title' => t('Description for Experiment ') . $counter,
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name=' . $namefield . ']' => array(
+ 'value' => ""
+ )
+ )
+ )
+ );
+ }
+ $first_experiemnt = FALSE;
+ }
+ $form['solution_provider_uid'] = array(
+ '#type' => 'radios',
+ '#title' => t('Do you want to provide the solution'),
+ '#options' => array(
+ '1' => 'Yes',
+ '2' => 'No'
+ ),
+ '#required' => TRUE,
+ '#default_value' => '1',
+ '#description' => 'If you dont want to provide the solution then it will be opened for the community, anyone may come forward and provide the solution.'
+ );
+ $form['solution_display'] = array(
+ '#type' => 'hidden',
+ '#title' => t('Do you want to display the solution on the www.dwsim.fossee.in website'),
+ '#options' => array(
+ '1' => 'Yes'
+ ),
+ '#required' => TRUE,
+ '#default_value' => '1',
+ '#description' => 'If yes, solutions will be made available to everyone for downloading.',
+ '#disabled' => FALSE
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+ }
function lab_migration_proposal_form_validate($form, &$form_state)
-{
-
- if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['contact_ph'])){
- form_set_error('contact_ph', t('Invalid contact phone number'));
-
- }
- if($form_state['values']['country']=='Others'){
- if($form_state['values']['other_country']== ''){
+ {
+ if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['contact_ph']))
+ {
+ form_set_error('contact_ph', t('Invalid contact phone number'));
+ }
+ if ($form_state['values']['country'] == 'Others')
+ {
+ if ($form_state['values']['other_country'] == '')
+ {
form_set_error('other_country', t('Enter country name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }else{
- $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- if($form_state['values']['other_state']== ''){
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ else
+ {
+ $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ if ($form_state['values']['other_state'] == '')
+ {
form_set_error('other_state', t('Enter state name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }else{
- $form_state['values']['all_state'] = $form_state['values']['other_state'];
- }
- if($form_state['values']['other_city']== ''){
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ else
+ {
+ $form_state['values']['all_state'] = $form_state['values']['other_state'];
+ }
+ if ($form_state['values']['other_city'] == '')
+ {
form_set_error('other_city', t('Enter city name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }else{
- $form_state['values']['city'] = $form_state['values']['other_city'];
- }
- }else{
- if($form_state['values']['country']== ''){
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ else
+ {
+ $form_state['values']['city'] = $form_state['values']['other_city'];
+ }
+ }
+ else
+ {
+ if ($form_state['values']['country'] == '')
+ {
form_set_error('country', t('Select country name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- if($form_state['values']['all_state']== ''){
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ if ($form_state['values']['all_state'] == '')
+ {
form_set_error('all_state', t('Select state name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
- if($form_state['values']['city']== ''){
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ if ($form_state['values']['city'] == '')
+ {
form_set_error('city', t('Select city name'));
- // $form_state['values']['country'] = $form_state['values']['other_country'];
- }
-
-
- }
-
- for ($counter = 1; $counter <= 15; $counter++) {
- $experiment_field_name = 'lab_experiment-' . $counter;
- $experiment_description='lab_experiment_description-' . $counter;
- if (strlen(trim($form_state['values'][$experiment_field_name])) >= 1) {
- if (strlen(trim($form_state['values'][$experiment_description])) <=49) {
- form_set_error($experiment_description, t('Description should be minimum of 50 characters'));
- }
- }
- }
-
- if($form_state['values']['version'] == 'olderversion'){
- if($form_state['values']['older'] == ''){
- form_set_error('older', t('Please provide valid version'));
- }
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ }
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
+ $experiment_field_name = 'lab_experiment-' . $counter;
+ $experiment_description = 'lab_experiment_description-' . $counter;
+ if (strlen(trim($form_state['values'][$experiment_field_name])) >= 1)
+ {
+ if (strlen(trim($form_state['values'][$experiment_description])) <= 49)
+ {
+ form_set_error($experiment_description, t('Description should be minimum of 50 characters'));
+ }
+ }
+ }
+ if ($form_state['values']['version'] == 'olderversion')
+ {
+ if ($form_state['values']['older'] == '')
+ {
+ form_set_error('older', t('Please provide valid version'));
+ }
+ }
+ return;
}
- return;
-}
-
function lab_migration_proposal_form_submit($form, &$form_state)
-{
- global $user;
-
- if (!$user->uid) {
- drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- return;
- }
-
- $solution_provider_uid = 0;
- $solution_status = 0;
- $solution_provider_name_title = '';
- $solution_provider_name = '';
- $solution_provider_contact_ph = '';
- $solution_provider_department = '';
- $solution_provider_university = '';
- if ($form_state['values']['solution_provider_uid'] == "1") {
- $solution_provider_uid = $user->uid;
- $solution_status = 1;
- $solution_provider_name_title = $form_state['values']['name_title'];
- $solution_provider_name = $form_state['values']['name'];
- $solution_provider_contact_ph = $form_state['values']['contact_ph'];
- $solution_provider_department = $form_state['values']['department'];
- $solution_provider_university = $form_state['values']['university'];
- } else {
- $solution_provider_uid = 0;
- }
-
- $solution_display = 0;
- if ($form_state['values']['solution_display'] == "1")
- $solution_display = 1;
- else
- $solution_display = 1;
-if($form_state['values']['version'] == 'olderversion'){
- $form_state['values']['version'] = $form_state['values']['older'];
- }
- /* inserting the user proposal */
+ {
+ global $user;
+ if (!$user->uid)
+ {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ return;
+ }
+ $solution_provider_uid = 0;
+ $solution_status = 0;
+ $solution_provider_name_title = '';
+ $solution_provider_name = '';
+ $solution_provider_contact_ph = '';
+ $solution_provider_department = '';
+ $solution_provider_university = '';
+ if ($form_state['values']['solution_provider_uid'] == "1")
+ {
+ $solution_provider_uid = $user->uid;
+ $solution_status = 1;
+ $solution_provider_name_title = $form_state['values']['name_title'];
+ $solution_provider_name = $form_state['values']['name'];
+ $solution_provider_contact_ph = $form_state['values']['contact_ph'];
+ $solution_provider_department = $form_state['values']['department'];
+ $solution_provider_university = $form_state['values']['university'];
+ }
+ else
+ {
+ $solution_provider_uid = 0;
+ }
+ $solution_display = 0;
+ if ($form_state['values']['solution_display'] == "1")
+ $solution_display = 1;
+ else
+ $solution_display = 1;
+ if ($form_state['values']['version'] == 'olderversion')
+ {
+ $form_state['values']['version'] = $form_state['values']['older'];
+ }
+ /* 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));
- $result = "INSERT INTO {lab_migration_proposal}
+ $university = ucname($v['university']);
+ $dir_name = $lab_title . " " . $university;
+ $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name));
+ $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,
: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)";
- $args= array(
- ":uid" => $user->uid,
- ":approver_uid" => 0,
- ":name_title" => $v['name_title'],
- ":name" => $v['name'],
- ":contact_ph" => $v['contact_ph'],
- ":department" => $v['department'],
- ":university" => $v['university'],
- ":city" => $v['city'],
- ":pincode" => $v['pincode'],
- ":state" => $v['all_state'],
- ":country" => $v['country'],
- ":version" => $form_state['values']['version'],
- ":lab_title" => $v['lab_title'],
- ":approval_status" => 0,
- ":solution_status" => $solution_status,
- ":solution_provider_uid" => $solution_provider_uid,
- ":solution_display" => $solution_display,
- ":creation_date" => time(),
- ":approval_date" => 0,
- ":solution_date" => 0,
- ":solution_provider_name_title" => $solution_provider_name_title,
- ":solution_provider_name" => $solution_provider_name,
- ":solution_provider_contact_ph" => $solution_provider_contact_ph,
- ":solution_provider_department" => $solution_provider_department,
- ":solution_provider_university" => $solution_provider_university,
- ":directory_name" => $directory_name
- );
- $proposal_id = db_query($result, $args, array('return' => Database::RETURN_INSERT_ID));
- if (!$proposal_id)
+ $args = array(
+ ":uid" => $user->uid,
+ ":approver_uid" => 0,
+ ":name_title" => $v['name_title'],
+ ":name" => $v['name'],
+ ":contact_ph" => $v['contact_ph'],
+ ":department" => $v['department'],
+ ":university" => $v['university'],
+ ":city" => $v['city'],
+ ":pincode" => $v['pincode'],
+ ":state" => $v['all_state'],
+ ":country" => $v['country'],
+ ":version" => $form_state['values']['version'],
+ ":lab_title" => $v['lab_title'],
+ ":approval_status" => 0,
+ ":solution_status" => $solution_status,
+ ":solution_provider_uid" => $solution_provider_uid,
+ ":solution_display" => $solution_display,
+ ":creation_date" => time(),
+ ":approval_date" => 0,
+ ":solution_date" => 0,
+ ":solution_provider_name_title" => $solution_provider_name_title,
+ ":solution_provider_name" => $solution_provider_name,
+ ":solution_provider_contact_ph" => $solution_provider_contact_ph,
+ ":solution_provider_department" => $solution_provider_department,
+ ":solution_provider_university" => $solution_provider_university,
+ ":directory_name" => $directory_name
+ );
+ $proposal_id = db_query($result, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if (!$proposal_id)
+ {
+ drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
+ return;
+ }
+ /* proposal id */
+ //$proposal_id = db_last_insert_id('lab_migration_proposal', 'id');
+ /* adding experiments */
+ $number = 1;
+ for ($counter = 1; $counter <= 15; $counter++)
+ {
+ $experiment_field_name = 'lab_experiment-' . $counter;
+ $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)";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":directory_name" => $directory_name,
+ ":number" => $number,
+ ":experiment_field_name" => trim($form_state['values'][$experiment_field_name]),
+ ":description" => trim($form_state['values'][$experiment_description])
+ );
+ $result = db_query($query, $args);
+ if (!$result)
+ {
+ drupal_set_message(t('Could not insert Title of the Experiment : ') . trim($form_state['values'][$experiment_field_name]), 'error');
+ }
+ else
+ {
+ $number++;
+ }
+ }
+ }
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['proposal_received']['proposal_id'] = $proposal_id;
+ $param['proposal_received']['user_id'] = $user->uid;
+ $param['proposal_received']['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', 'proposal_received', $email_to, user_preferred_language($user), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message(t('We have received you Lab migration proposal. We will get back to you soon.'), 'status');
+ drupal_goto('');
+ }
+function _lm_list_of_states()
{
- drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
- return;
+ $states = array();
+ $query = db_select('list_states_of_india');
+ $query->fields('list_states_of_india');
+ //$query->orderBy('', '');
+ $states_list = $query->execute();
+ while ($states_list_data = $states_list->fetchObject())
+ {
+ $states[$states_list_data->state] = $states_list_data->state;
+ }
+ return $states;
+ }
+function _lm_list_of_cities()
+ {
+ $city = array();
+ $query = db_select('list_cities_of_india');
+ $query->fields('list_cities_of_india');
+ $query->orderBy('city', 'ASC');
+ $city_list = $query->execute();
+ while ($city_list_data = $city_list->fetchObject())
+ {
+ $city[$city_list_data->city] = $city_list_data->city;
+ }
+ return $city;
+ }
+function _lm_list_of_departments()
+ {
+ $department = array();
+ $query = db_select('list_of_departments');
+ $query->fields('list_of_departments');
+ $query->orderBy('id', 'DESC');
+ $department_list = $query->execute();
+ while ($department_list_data = $department_list->fetchObject())
+ {
+ $department[$department_list_data->department] = $department_list_data->department;
+ }
+ return $department;
+ }
+function _lm_list_of_software_version()
+ {
+ $software_version = array();
+ $query = db_select('dwsim_software_version');
+ $query->fields('dwsim_software_version');
+ $query->orderBy('id', 'DESC');
+ $software_version_list = $query->execute();
+ while ($software_version_list_data = $software_version_list->fetchObject())
+ {
+ $software_version[$software_version_list_data->dwsim_version] = $software_version_list_data->dwsim_version;
+ }
+ return $software_version;
}
- /* proposal id */
- //$proposal_id = db_last_insert_id('lab_migration_proposal', 'id');
-
- /* adding experiments */
- $number = 1;
- for ($counter = 1; $counter <= 15; $counter++) {
- $experiment_field_name = 'lab_experiment-' . $counter;
- $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)";
- $args= array(
- ":proposal_id" => $proposal_id,
- ":directory_name" => $directory_name,
- ":number" => $number,
- ":experiment_field_name"=> trim($form_state['values'][$experiment_field_name]),
- ":description"=>trim($form_state['values'][$experiment_description])
- );
- $result = db_query($query, $args);
- if (!$result)
- {
- drupal_set_message(t('Could not insert Title of the Experiment : ') . trim($form_state['values'][$experiment_field_name]), 'error');
- } else {
- $number++;
- }
- }
- }
-
- /* sending email */
- $email_to = $user->mail;
-
- $from = variable_get('lab_migration_from_email', '');
- $bcc= variable_get('lab_migration_emails', '');
- $cc=variable_get('lab_migration_cc_emails', '');
-
- $param['proposal_received']['proposal_id'] = $proposal_id;
- $param['proposal_received']['user_id'] = $user->uid;
- $param['proposal_received']['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', 'proposal_received', $email_to , user_preferred_language($user), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message(t('We have received you Lab migration proposal. We will get back to you soon.'), 'status');
- drupal_goto('');
-}
-
-function _lm_list_of_states(){
- $states = array();
- $query = db_select('list_states_of_india');
- $query->fields('list_states_of_india');
-
- //$query->orderBy('', '');
- $states_list = $query->execute();
- while ($states_list_data = $states_list->fetchObject())
- {
- $states[$states_list_data->state] = $states_list_data->state;
- }
- return $states;
-}
-
-function _lm_list_of_cities(){
- $city = array();
- $query = db_select('list_cities_of_india');
- $query->fields('list_cities_of_india');
- $query->orderBy('city', 'ASC');
- $city_list = $query->execute();
- while ($city_list_data = $city_list->fetchObject())
- {
- $city[$city_list_data->city] = $city_list_data->city;
- }
- return $city;
-}
-
-function _lm_list_of_departments(){
- $department = array();
- $query = db_select('list_of_departments');
- $query->fields('list_of_departments');
- $query->orderBy('id', 'DESC');
- $department_list = $query->execute();
- while ($department_list_data = $department_list->fetchObject())
- {
- $department[$department_list_data->department] = $department_list_data->department;
- }
- return $department;
-}
-function _lm_list_of_software_version(){
- $software_version = array();
- $query = db_select('dwsim_software_version');
- $query->fields('dwsim_software_version');
- $query->orderBy('id', 'DESC');
- $software_version_list = $query->execute();
- while ($software_version_list_data = $software_version_list->fetchObject())
- {
- $software_version[$software_version_list_data->dwsim_version] = $software_version_list_data->dwsim_version;
- }
- return $software_version;
-}
diff --git a/run.inc b/run.inc
index 35bf0ef..f6791a1 100755
--- a/run.inc
+++ b/run.inc
@@ -1,459 +1,507 @@
-<?php
-
- function lab_migration_run_form($form, &$form_state) {
-
- $options_first =_list_of_labs();
- $options_two = _ajax_get_experiment_list();
-
- $select_two = isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] :
- key($options_two);
- $url_lab_id = (int)arg(2);
- if(!$url_lab_id){
- $selected = isset($form_state['values']['lab']) ? $form_state['values']['lab'] : key($options_first);
- }elseif($url_lab_id == ''){
- $selected = 0;
- }else{
- $selected = $url_lab_id;;
- }
-
- $form = array();
- $form['lab'] = array(
- '#type' => 'select',
- '#title' => t('Title of the lab'),
- '#options' => _list_of_labs(),
- '#default_value' => $selected,
- '#ajax' => array(
- 'callback' => 'ajax_experiment_list_callback',
- ),
- );
- if(!$url_lab_id){
- $form['selected_lab'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_selected_lab"></div>',
- );
- $form['selected_lab_dwsim'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_selected_lab_dwsim"></div>',
- );
- $form['selected_lab_pdf'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_selected_lab_pdf"></div>',
- );
- $form['lab_details'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_lab_details"></div>',
- );
- $form['lab_experiment_list'] = array(
- '#type' => 'select',
- '#title' => t('Titile of the experiment'),
- '#options' => _ajax_get_experiment_list($selected),
- //'#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',
- '#ajax' => array(
- 'callback' => 'ajax_solution_list_callback',
- ),
- '#prefix' => '<div id="ajax_selected_experiment">',
- '#suffix' => '</div>',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0),),),
- );
- $form['download_experiment'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_download_experiments"></div>',
- );
- $form['lab_solution_list'] = array(
- '#type' => 'select',
- '#title' => t('Solution'),
- '#options' => _ajax_get_solution_list($select_two),
- //'#default_value' => isset($form_state['values']['lab_solution_list']) ?
- //$form_state['values']['lab_solution_list'] : '',
- '#ajax' => array(
- 'callback' => 'ajax_solution_files_callback',
- ),
- '#prefix' => '<div id="ajax_selected_solution">',
- '#suffix' => '</div>',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0),),),
- );
- $form['download_solution'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_download_experiment_solution"></div>',
- );
- $form['edit_solution'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_edit_experiment_solution"></div>',
- );
- $form['solution_files'] = array(
- '#type' => 'item',
- // '#title' => t('List of solution_files'),
- '#markup' => '<div id="ajax_solution_files"></div>',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0),),),
- );
- }else{
- $lab_default_value = $url_lab_id;
- $form['selected_lab'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_selected_lab">'.l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value).'</div>',
-
- );
- /* $form['selected_lab_pdf'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_selected_lab_pdf">'. l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1') .'</div>',
-
- );*/
-
-if($lab_default_value=='2'){
-$form['selected_lab_dwsim'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_selected_lab_dwsim">'.l('Download Lab Solutions (dwsim Version)', 'lab-migration-uploads/dwsim_Version.zip').'</div>',
-
- );
-}
- $form['lab_details'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_lab_details">'._lab_details($lab_default_value).'</div>',
- );
- $form['lab_experiment_list'] = array(
- '#type' => 'select',
- '#title' => t('Titile of the experiment'),
- '#options' => _ajax_get_experiment_list($selected),
- // '#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',
- '#ajax' => array(
- 'callback' => 'ajax_solution_list_callback',
- ),
- '#prefix' => '<div id="ajax_selected_experiment">',
- '#suffix' => '</div>',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0),),),
- );
- $form['download_experiment'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_download_experiments"></div>',
- );
- $form['lab_solution_list'] = array(
+<?php
+function lab_migration_run_form($form, &$form_state)
+ {
+ $options_first = _list_of_labs();
+ $options_two = _ajax_get_experiment_list();
+ $select_two = isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : key($options_two);
+ $url_lab_id = (int) arg(2);
+ if (!$url_lab_id)
+ {
+ $selected = isset($form_state['values']['lab']) ? $form_state['values']['lab'] : key($options_first);
+ }
+ elseif ($url_lab_id == '')
+ {
+ $selected = 0;
+ }
+ else
+ {
+ $selected = $url_lab_id;
+ ;
+ }
+ $form = array();
+ $form['lab'] = array(
'#type' => 'select',
- '#title' => t('Solution'),
- '#options' => _ajax_get_solution_list($select_two),
- '#default_value' => isset($form_state['values']['lab_solution_list']) ? $form_state['values']['lab_solution_list'] : '',
+ '#title' => t('Title of the lab'),
+ '#options' => _list_of_labs(),
+ '#default_value' => $selected,
'#ajax' => array(
- 'callback' => 'ajax_solution_files_callback',
- ),
- '#prefix' => '<div id="ajax_selected_solution">',
- '#suffix' => '</div>',
- '#states' => array('invisible' => array(':input[name="lab_experiment_list"]' => array('value' => 0),),),
- );
-
- $form['download_solution'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_download_experiment_solution"></div>',
- );
- $form['edit_solution'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_edit_experiment_solution"></div>',
- );
- $form['solution_files'] = array(
+ 'callback' => 'ajax_experiment_list_callback'
+ )
+ );
+ if (!$url_lab_id)
+ {
+ $form['selected_lab'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_lab"></div>'
+ );
+ $form['selected_lab_dwsim'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_lab_dwsim"></div>'
+ );
+ $form['selected_lab_pdf'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_lab_pdf"></div>'
+ );
+ $form['lab_details'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_lab_details"></div>'
+ );
+ $form['lab_experiment_list'] = array(
+ '#type' => 'select',
+ '#title' => t('Titile of the experiment'),
+ '#options' => _ajax_get_experiment_list($selected),
+ //'#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',
+ '#ajax' => array(
+ 'callback' => 'ajax_solution_list_callback'
+ ),
+ '#prefix' => '<div id="ajax_selected_experiment">',
+ '#suffix' => '</div>',
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="lab"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ $form['download_experiment'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_download_experiments"></div>'
+ );
+ $form['lab_solution_list'] = array(
+ '#type' => 'select',
+ '#title' => t('Solution'),
+ '#options' => _ajax_get_solution_list($select_two),
+ //'#default_value' => isset($form_state['values']['lab_solution_list']) ?
+ //$form_state['values']['lab_solution_list'] : '',
+ '#ajax' => array(
+ 'callback' => 'ajax_solution_files_callback'
+ ),
+ '#prefix' => '<div id="ajax_selected_solution">',
+ '#suffix' => '</div>',
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="lab"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ $form['download_solution'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_download_experiment_solution"></div>'
+ );
+ $form['edit_solution'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_edit_experiment_solution"></div>'
+ );
+ $form['solution_files'] = array(
+ '#type' => 'item',
+ // '#title' => t('List of solution_files'),
+ '#markup' => '<div id="ajax_solution_files"></div>',
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="lab"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ }
+ else
+ {
+ $lab_default_value = $url_lab_id;
+ $form['selected_lab'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_lab">' . l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value) . '</div>'
+ );
+ /* $form['selected_lab_pdf'] = array(
'#type' => 'item',
- // '#title' => t('List of solution_files'),
- '#markup' => '<div id="ajax_solution_files"></div>',
- '#states' => array('invisible' => array(':input[name="lab_experiment_list"]' => array('value' => 0),),),
- );
- }
- /*
- $form['message'] = array(
- '#type' => 'textarea',
- '#title' => t('If Dis-Approved please specify reason for Dis-Approval'),
- '#prefix' => '<div id= "message_submit">',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0,),),),
+ '#markup' => '<div id="ajax_selected_lab_pdf">'. l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1') .'</div>',
- );
-
+ );*/
+ if ($lab_default_value == '2')
+ {
+ $form['selected_lab_dwsim'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_lab_dwsim">' . l('Download Lab Solutions (dwsim Version)', 'lab-migration-uploads/dwsim_Version.zip') . '</div>'
+ );
+ }
+ $form['lab_details'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_lab_details">' . _lab_details($lab_default_value) . '</div>'
+ );
+ $form['lab_experiment_list'] = array(
+ '#type' => 'select',
+ '#title' => t('Titile of the experiment'),
+ '#options' => _ajax_get_experiment_list($selected),
+ // '#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',
+ '#ajax' => array(
+ 'callback' => 'ajax_solution_list_callback'
+ ),
+ '#prefix' => '<div id="ajax_selected_experiment">',
+ '#suffix' => '</div>',
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="lab"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ $form['download_experiment'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_download_experiments"></div>'
+ );
+ $form['lab_solution_list'] = array(
+ '#type' => 'select',
+ '#title' => t('Solution'),
+ '#options' => _ajax_get_solution_list($select_two),
+ '#default_value' => isset($form_state['values']['lab_solution_list']) ? $form_state['values']['lab_solution_list'] : '',
+ '#ajax' => array(
+ 'callback' => 'ajax_solution_files_callback'
+ ),
+ '#prefix' => '<div id="ajax_selected_solution">',
+ '#suffix' => '</div>',
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="lab_experiment_list"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ $form['download_solution'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_download_experiment_solution"></div>'
+ );
+ $form['edit_solution'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_edit_experiment_solution"></div>'
+ );
+ $form['solution_files'] = array(
+ '#type' => 'item',
+ // '#title' => t('List of solution_files'),
+ '#markup' => '<div id="ajax_solution_files"></div>',
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="lab_experiment_list"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ }
+ /*
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('If Dis-Approved please specify reason for Dis-Approval'),
+ '#prefix' => '<div id= "message_submit">',
+ '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0,),),),
+
+ );
+
$form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit'),
- '#suffix' => '</div>',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0,),),),
-
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ '#suffix' => '</div>',
+ '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0,),),),
+
);*/
- return $form;
- }
-
-function ajax_experiment_list_callback($form, $form_state) {
-
- $commands = array();
- $lab_default_value = $form_state['values']['lab'];
- if($lab_default_value !=0){
- $form['lab_details']['#markup'] = _lab_details($lab_default_value);
+ return $form;
+ }
+function ajax_experiment_list_callback($form, $form_state)
+ {
+ $commands = array();
+ $lab_default_value = $form_state['values']['lab'];
+ if ($lab_default_value != 0)
+ {
+ $form['lab_details']['#markup'] = _lab_details($lab_default_value);
$lab_details = _lab_information($lab_default_value);
- $user_solution_provider = user_load($lab_details->solution_provider_uid);
- //var_dump($lab_details->solution_provider_uid);
- 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'){
- $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', l('Download Lab Solutions (dwsim Version)', 'lab-migration_uploads/dwsim_Version.zip'));}
- /* $commands[] = ajax_command_html('#ajax_selected_lab_pdf', l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1'));*/
-
- }else{
- $commands[] = ajax_command_html('#ajax_selected_lab', '');
- $commands[] = ajax_command_html('#ajax_selected_lab_pdf', '');
- $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', '');
- }
-
- $commands[] = ajax_command_html('#ajax_lab_details', _lab_details($lab_default_value));
- $form['lab_experiment_list']['#options'] = _ajax_get_experiment_list($lab_default_value);
- $commands[] = ajax_command_replace('#ajax_selected_experiment',drupal_render($form['lab_experiment_list']));
- $commands[] = ajax_command_html('#ajax_selected_solution', '');
- $commands[] = ajax_command_html('#ajax_solution_files', '');
- $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_download_experiments', '');
-
- }else{
- $form['lab_experiment_list']['#options'] = _ajax_get_experiment_list();
- $commands[] = ajax_command_replace('#ajax_selected_experiment',drupal_render($form['lab_experiment_list']));
-
- $commands[] = ajax_command_html('#ajax_lab_details', '');
- $commands[] = ajax_command_html('#ajax_selected_lab', '');
- $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', '');
- $commands[] = ajax_command_html('#ajax_selected_lab_pdf', '');
- $commands[] = ajax_command_data('#ajax_selected_lab', 'form_state_value_select', $form_state['values']['lab']);
- $commands[] = ajax_command_html('#ajax_selected_experiment','');
- $commands[] = ajax_command_html('#ajax_download_experiments', '');
- $commands[] = ajax_command_html('#ajax_selected_solution','');
- $commands[] = ajax_command_html('#ajax_solution_files', '');
- $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
-
+ $user_solution_provider = user_load($lab_details->solution_provider_uid);
+ //var_dump($lab_details->solution_provider_uid);
+ 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')
+ {
+ $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', l('Download Lab Solutions (dwsim Version)', 'lab-migration_uploads/dwsim_Version.zip'));
+ }
+ /* $commands[] = ajax_command_html('#ajax_selected_lab_pdf', l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1'));*/
+ }
+ else
+ {
+ $commands[] = ajax_command_html('#ajax_selected_lab', '');
+ $commands[] = ajax_command_html('#ajax_selected_lab_pdf', '');
+ $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', '');
+ }
+ $commands[] = ajax_command_html('#ajax_lab_details', _lab_details($lab_default_value));
+ $form['lab_experiment_list']['#options'] = _ajax_get_experiment_list($lab_default_value);
+ $commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
+ $commands[] = ajax_command_html('#ajax_selected_solution', '');
+ $commands[] = ajax_command_html('#ajax_solution_files', '');
+ $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
+ $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
+ $commands[] = ajax_command_html('#ajax_download_experiments', '');
}
-
- return array('#type' => 'ajax', '#commands' => $commands);
- }
-
-function ajax_solution_list_callback($form, $form_state){
-
- $commands = array();
- $experiment_list_default_value = $form_state['values']['lab_experiment_list'];
- //var_dump($lab_default_value);
- if($experiment_list_default_value !=0){
-
- $form['lab_solution_list']['#options'] = _ajax_get_solution_list($experiment_list_default_value);
-
- $commands[] = ajax_command_html('#ajax_download_experiments', l('Download Experiment', 'lab-migration/download/experiment/' . $experiment_list_default_value));
-
- $commands[] = ajax_command_html('#ajax_selected_experiment',drupal_render($form['lab_experiment_list']));
-
- $commands[] = ajax_command_html('#ajax_selected_solution',drupal_render($form['lab_solution_list']));
-
- // $commands[] = ajax_command_html('#ajax_solution_files', '');
- // $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
- // $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
-
- }else
+ else
{
- $form['lab_solution_list']['#options'] = _ajax_get_solution_list();
- $commands[] = ajax_command_html('#ajax_selected_solution',drupal_render($form['lab_solution_list']));
-
- $commands[] = ajax_command_html('#ajax_download_experiments', '');
- $commands[] = ajax_command_html('#ajax_selected_solution','');
- $commands[] = ajax_command_html('#ajax_solution_files', '');
- $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
- // $commands[] = ajax_command_replace('#ajax_selected_experiment',drupal_render($form['lab_experiment_list']));
-
+ $form['lab_experiment_list']['#options'] = _ajax_get_experiment_list();
+ $commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
+ $commands[] = ajax_command_html('#ajax_lab_details', '');
+ $commands[] = ajax_command_html('#ajax_selected_lab', '');
+ $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', '');
+ $commands[] = ajax_command_html('#ajax_selected_lab_pdf', '');
+ $commands[] = ajax_command_data('#ajax_selected_lab', 'form_state_value_select', $form_state['values']['lab']);
+ $commands[] = ajax_command_html('#ajax_selected_experiment', '');
+ $commands[] = ajax_command_html('#ajax_download_experiments', '');
+ $commands[] = ajax_command_html('#ajax_selected_solution', '');
+ $commands[] = ajax_command_html('#ajax_solution_files', '');
+ $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
+ $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
}
-
- return array('#type' => 'ajax', '#commands' => $commands);
- }
-
- function ajax_solution_files_callback($form, $form_state){
- $commands = array();
- $solution_list_default_value = $form_state['values']['lab_solution_list'];
- //var_dump($lab_default_value);
- if($solution_list_default_value !=0){
- $commands[] = ajax_command_html('#ajax_selected_lab_experiment_solution_action',drupal_render($form['lab_experiment_solution_actions']));
- /*************************************************************************************/
- //$solution_list_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $form_state['values']['solution']);
- $query = db_select('lab_migration_solution_files');
- $query->fields('lab_migration_solution_files');
- $query->condition('solution_id', $solution_list_default_value);
- $solution_list_q = $query->execute();
- if ($solution_list_q)
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+ }
+function ajax_solution_list_callback($form, $form_state)
+ {
+ $commands = array();
+ $experiment_list_default_value = $form_state['values']['lab_experiment_list'];
+ //var_dump($lab_default_value);
+ if ($experiment_list_default_value != 0)
+ {
+ $form['lab_solution_list']['#options'] = _ajax_get_solution_list($experiment_list_default_value);
+ $commands[] = ajax_command_html('#ajax_download_experiments', l('Download Experiment', 'lab-migration/download/experiment/' . $experiment_list_default_value));
+ $commands[] = ajax_command_html('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
+ $commands[] = ajax_command_html('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
+ // $commands[] = ajax_command_html('#ajax_solution_files', '');
+ // $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
+ // $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
+ }
+ else
+ {
+ $form['lab_solution_list']['#options'] = _ajax_get_solution_list();
+ $commands[] = ajax_command_html('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
+ $commands[] = ajax_command_html('#ajax_download_experiments', '');
+ $commands[] = ajax_command_html('#ajax_selected_solution', '');
+ $commands[] = ajax_command_html('#ajax_solution_files', '');
+ $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
+ $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
+ // $commands[] = ajax_command_replace('#ajax_selected_experiment',drupal_render($form['lab_experiment_list']));
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+ }
+function ajax_solution_files_callback($form, $form_state)
+ {
+ $commands = array();
+ $solution_list_default_value = $form_state['values']['lab_solution_list'];
+ //var_dump($lab_default_value);
+ if ($solution_list_default_value != 0)
{
- $solution_files_rows = array();
- while ($solution_list_data = $solution_list_q->fetchObject())
- {
- $solution_file_type = '';
- switch ($solution_list_data->filetype)
+ $commands[] = ajax_command_html('#ajax_selected_lab_experiment_solution_action', drupal_render($form['lab_experiment_solution_actions']));
+ /*************************************************************************************/
+ //$solution_list_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $form_state['values']['solution']);
+ $query = db_select('lab_migration_solution_files');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_list_default_value);
+ $solution_list_q = $query->execute();
+ if ($solution_list_q)
{
- case 'S' : $solution_file_type = 'Source or Main file'; break;
- case 'R' : $solution_file_type = 'Result file'; break;
- case 'X' : $solution_file_type = 'xcos file'; break;
- default : $solution_file_type = 'Unknown'; break;
+ $solution_files_rows = array();
+ while ($solution_list_data = $solution_list_q->fetchObject())
+ {
+ $solution_file_type = '';
+ switch ($solution_list_data->filetype)
+ {
+ case 'S':
+ $solution_file_type = 'Source or Main file';
+ break;
+ case 'R':
+ $solution_file_type = 'Result file';
+ break;
+ case 'X':
+ $solution_file_type = 'xcos file';
+ break;
+ default:
+ $solution_file_type = 'Unknown';
+ break;
+ }
+ $solution_files_rows[] = array(
+ l($solution_list_data->filename, 'lab-migration/download/file/' . $solution_list_data->id),
+ $solution_file_type
+ );
+ }
+ /* dependency files */
+ //$dependency_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $form_state['values']['solution']);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_solution_dependency');
+ $query->condition('solution_id', $solution_list_default_value);
+ $dependency_q = $query->execute();
+ while ($dependency_data = $dependency_q->fetchObject())
+ {
+ //$dependency_files_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d", $dependency_data->dependency_id);
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $dependency_data->dependency_id);
+ $dependency_files_q = $query->execute();
+ $dependency_files_data = $dependency_files_q->fetchObject();
+ $solution_file_type = 'Dependency file';
+ $solution_files_rows[] = array(
+ l($dependency_files_data->filename, 'lab-migration/download/dependency/' . $dependency_files_data->id),
+ $solution_file_type
+ );
+ }
+ /* creating list of files table */
+ $solution_files_header = array(
+ 'Filename',
+ 'Type'
+ );
+ $solution_files = theme('table', array(
+ 'header' => $solution_files_header,
+ 'rows' => $solution_files_rows
+ ));
}
- $solution_files_rows[] = array(l($solution_list_data->filename, 'lab-migration/download/file/' . $solution_list_data->id), $solution_file_type);
- }
-
- /* dependency files */
- //$dependency_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $form_state['values']['solution']);
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_solution_dependency');
- $query->condition('solution_id', $solution_list_default_value);
- $dependency_q = $query->execute();
- while ($dependency_data = $dependency_q->fetchObject())
- {
- //$dependency_files_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d", $dependency_data->dependency_id);
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_dependency_files');
- $query->condition('id', $dependency_data->dependency_id);
- $dependency_files_q = $query->execute();
- $dependency_files_data = $dependency_files_q->fetchObject();
- $solution_file_type = 'Dependency file';
- $solution_files_rows[] = array(l($dependency_files_data->filename, 'lab-migration/download/dependency/' . $dependency_files_data->id), $solution_file_type);
- }
-
- /* creating list of files table */
- $solution_files_header = array('Filename', 'Type');
- $solution_files = theme('table', array('header' => $solution_files_header, 'rows' => $solution_files_rows));
-
+ $form['solution_files']['#title'] = 'List of solution files';
+ $form['solution_files']['#markup'] = $solution_files;
+ $commands[] = ajax_command_html('#ajax_download_experiment_solution', l('Download Solution', 'lab-migration/download/solution/' . $solution_list_default_value));
+ // $commands[] = ajax_command_html('#ajax_edit_experiment_solution', l('Edit Solution', 'code_approval/editcode/' . $solution_list_default_value));
+ // $commands[] = ajax_command_html('#ajax_solution_files', $solution_files);
+ $commands[] = ajax_command_html('#ajax_solution_files', drupal_render($form['solution_files']));
+ }
+ else
+ {
+ $commands[] = ajax_command_html('#ajax_selected_lab_experiment_solution_action', '');
+ $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
+ $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
+ $commands[] = ajax_command_html('#ajax_solution_files', '');
}
- $form['solution_files']['#title'] = 'List of solution files';
- $form['solution_files']['#markup'] = $solution_files;
- $commands[] = ajax_command_html('#ajax_download_experiment_solution', l('Download Solution', 'lab-migration/download/solution/' . $solution_list_default_value));
- // $commands[] = ajax_command_html('#ajax_edit_experiment_solution', l('Edit Solution', 'code_approval/editcode/' . $solution_list_default_value));
- // $commands[] = ajax_command_html('#ajax_solution_files', $solution_files);
- $commands[] = ajax_command_html('#ajax_solution_files',drupal_render($form['solution_files']));
- }else{
- $commands[] = ajax_command_html('#ajax_selected_lab_experiment_solution_action','');
- $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_solution_files', '');
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+ }
+function bootstrap_table_format($headers, $rows)
+ {
+ $thead = "";
+ $tbody = "";
+ foreach ($headers as $header)
+ {
+ $thead .= "<th>{$header}</th>";
+ }
+ foreach ($rows as $row)
+ {
+ $tbody .= "<tr>";
+ foreach ($row as $data)
+ {
+ $tbody .= "<td>{$data}</td>";
+ }
+ $tbody .= "</tr>";
}
-
- return array('#type' => 'ajax', '#commands' => $commands);
- }
-
- function bootstrap_table_format($headers, $rows) {
- $thead = "";
- $tbody = "";
- foreach($headers as $header) {
- $thead .= "<th>{$header}</th>";
- }
- foreach($rows as $row) {
- $tbody .= "<tr>";
- foreach($row as $data) {
- $tbody .= "<td>{$data}</td>";
- }
- $tbody .= "</tr>";
- }
- $table = "
+ $table = "
<table class='table table-bordered table-hover' style='margin-left:-140px'>
<thead>{$thead}</thead>
<tbody>{$tbody}</tbody>
</table>
";
- return $table;
- }
-
- /*****************************************************/
+ return $table;
+ }
+/*****************************************************/
function _list_of_labs()
- {
- $lab_titles = array('0' => 'Please select...');
- //$lab_titles_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('solution_display', 1);
- $query->condition('approval_status', 3);
- $query->orderBy('lab_title', 'ASC');
- $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 = array(
+ '0' => 'Please select...'
+ );
+ //$lab_titles_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('solution_display', 1);
+ $query->condition('approval_status', 3);
+ $query->orderBy('lab_title', 'ASC');
+ $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 . ')';
+ }
+ return $lab_titles;
}
- return $lab_titles;
-}
-
- function _ajax_get_experiment_list($lab_default_value = ''){
- $experiments = array('0' => 'Please select...');
- //$experiments_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number ASC", $proposal_id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $lab_default_value);
- $query->orderBy('number', 'ASC');
- $experiments_q = $query->execute();
- while ($experiments_data = $experiments_q->fetchObject())
+function _ajax_get_experiment_list($lab_default_value = '')
{
- $experiments[$experiments_data->id] = $experiments_data->number . '. ' . $experiments_data->title;
+ $experiments = array(
+ '0' => 'Please select...'
+ );
+ //$experiments_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number ASC", $proposal_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $lab_default_value);
+ $query->orderBy('number', 'ASC');
+ $experiments_q = $query->execute();
+ while ($experiments_data = $experiments_q->fetchObject())
+ {
+ $experiments[$experiments_data->id] = $experiments_data->number . '. ' . $experiments_data->title;
+ }
+ return $experiments;
+ }
+function _ajax_get_solution_list($lab_experiment_list = '')
+ {
+ $solutions = array(
+ '0' => 'Please select...'
+ );
+ // $solutions_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d ORDER BY
+ // CAST(SUBSTRING_INDEX(code_number, '.', 1) AS BINARY) ASC,
+ // CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', 2), '.', -1) AS UNSIGNED) ASC,
+ // CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', -1), '.', 1) AS UNSIGNED) ASC", $experiment_id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('experiment_id', $lab_experiment_list);
+ //$query->orderBy("CAST(SUBSTRING_INDEX(code_number, '.', 1) AS BINARY", "ASC");
+ // $query->orderBy("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', 2), '.', -1) AS UNSIGNED", "ASC");
+ // $query->orderBy("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', -1), '.', 1) AS UNSIGNED", "ASC");
+ $solutions_q = $query->execute();
+ while ($solutions_data = $solutions_q->fetchObject())
+ {
+ $solutions[$solutions_data->id] = $solutions_data->code_number . ' (' . $solutions_data->caption . ')';
+ }
+ return $solutions;
}
- return $experiments;
- }
-
-
- function _ajax_get_solution_list($lab_experiment_list=''){
- $solutions = array('0' => 'Please select...');
- // $solutions_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d ORDER BY
- // CAST(SUBSTRING_INDEX(code_number, '.', 1) AS BINARY) ASC,
- // CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', 2), '.', -1) AS UNSIGNED) ASC,
- // CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', -1), '.', 1) AS UNSIGNED) ASC", $experiment_id);
-
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $lab_experiment_list);
- //$query->orderBy("CAST(SUBSTRING_INDEX(code_number, '.', 1) AS BINARY", "ASC");
- // $query->orderBy("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', 2), '.', -1) AS UNSIGNED", "ASC");
- // $query->orderBy("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', -1), '.', 1) AS UNSIGNED", "ASC");
- $solutions_q = $query->execute();
- while ($solutions_data = $solutions_q->fetchObject())
+function _lab_information($proposal_id)
{
- $solutions[$solutions_data->id] = $solutions_data->code_number . ' (' . $solutions_data->caption . ')';
+ //$lab_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $lab_q = $query->execute();
+ $lab_data = $lab_q->fetchObject();
+ return $lab_data;
}
- return $solutions;
- }
-
- function _lab_information($proposal_id)
-{
- //$lab_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $lab_q = $query->execute();
- $lab_data = $lab_q->fetchObject();
- return $lab_data;
-}
-
-
- function _lab_details($lab_default_value){
- //$lab_default_value = $form_state['values']['lab'];
- $lab_details = _lab_information($lab_default_value);
- if($lab_default_value !=0){
- if ($lab_details->solution_provider_uid > 0) {
- $user_solution_provider = user_load($lab_details->solution_provider_uid);
- if ($user_solution_provider) {
- $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' .
- '<ul>' .
- '<li><strong>Solution Provider Name:</strong> ' . $lab_details->solution_provider_name_title . ' ' . $lab_details->solution_provider_name . '</li>' .
- '<li><strong>Department:</strong> ' . $lab_details->solution_provider_department . '</li>' .
- '<li><strong>University:</strong> ' . $lab_details->solution_provider_university . '</li>' .
- '</ul>';
-
-
- } else {
- $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' .
- '<ul>' .
- '<li><strong>Solution Provider: </strong> (Open) </li>' .
- '</ul>';
- }
- } else {
- $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' .
- '<ul>' .
- '<li><strong>Solution Provider: </strong> (Open) </li>' .
- '</ul>';
- }
+function _lab_details($lab_default_value)
+ {
+ //$lab_default_value = $form_state['values']['lab'];
+ $lab_details = _lab_information($lab_default_value);
+ if ($lab_default_value != 0)
+ {
+ if ($lab_details->solution_provider_uid > 0)
+ {
+ $user_solution_provider = user_load($lab_details->solution_provider_uid);
+ if ($user_solution_provider)
+ {
+ $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Solution Provider Name:</strong> ' . $lab_details->solution_provider_name_title . ' ' . $lab_details->solution_provider_name . '</li>' . '<li><strong>Department:</strong> ' . $lab_details->solution_provider_department . '</li>' . '<li><strong>University:</strong> ' . $lab_details->solution_provider_university . '</li>' . '</ul>';
+ }
+ else
+ {
+ $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Solution Provider: </strong> (Open) </li>' . '</ul>';
+ }
}
-$form['lab_details']['#markup']= '<span style="color: rgb(128, 0, 0);"><strong>About the Lab</strong></span></td><td style="width: 35%;"><br />' .
- '<ul>' .
- '<li><strong>Proposer Name:</strong> ' . $lab_details->name_title . ' ' . $lab_details->name . '</li>' .
- '<li><strong>Title of the Lab:</strong> ' . $lab_details->lab_title . '</li>' .
- '<li><strong>Department:</strong> ' . $lab_details->department . '</li>' .
- '<li><strong>University:</strong> ' . $lab_details->university . '</li>' .
- '<li><strong>Category:</strong> ' . $lab_details->category . '</li>' .
- '</ul>' .
- $solution_provider;
-
- $details = $form['lab_details']['#markup'];
- return $details;
- }
+ else
+ {
+ $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Solution Provider: </strong> (Open) </li>' . '</ul>';
+ }
+ }
+ $form['lab_details']['#markup'] = '<span style="color: rgb(128, 0, 0);"><strong>About the Lab</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Proposer Name:</strong> ' . $lab_details->name_title . ' ' . $lab_details->name . '</li>' . '<li><strong>Title of the Lab:</strong> ' . $lab_details->lab_title . '</li>' . '<li><strong>Department:</strong> ' . $lab_details->department . '</li>' . '<li><strong>University:</strong> ' . $lab_details->university . '</li>' . '<li><strong>Category:</strong> ' . $lab_details->category . '</li>' . '</ul>' . $solution_provider;
+ $details = $form['lab_details']['#markup'];
+ return $details;
+ }
diff --git a/settings.inc b/settings.inc
index 07bd9b6..1856a25 100755
--- a/settings.inc
+++ b/settings.inc
@@ -1,106 +1,98 @@
<?php
// $Id$
-
-function lab_migration_settings_form($form,$form_state)
-{
- $form['emails'] = array(
- '#type' => 'textfield',
- '#title' => t('(Bcc) Notification emails'),
- '#description' => t('Specify emails id for Bcc option of mail system with comma separated'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_emails', ''),
- );
-
- $form['cc_emails'] = array(
- '#type' => 'textfield',
- '#title' => t('(Cc) Notification emails'),
- '#description' => t('Specify emails id for Cc option of mail system with comma separated'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_cc_emails', ''),
- );
-
- $form['from_email'] = array(
- '#type' => 'textfield',
- '#title' => t('Outgoing from email address'),
- '#description' => t('Email address to be display in the from field of all outgoing messages'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_from_email', ''),
- );
-
- $form['extensions']['source'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed source file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_source_extensions', ''),
- );
- $form['extensions']['dependency'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed dependency file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of dependency file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_dependency_extensions', ''),
- );
- $form['extensions']['result'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed result file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of result file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_result_extensions', ''),
- );
- $form['extensions']['xcos'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed xcos file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of xcos file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_xcos_extensions', ''),
- );
- $form['extensions']['pdf'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed pdf file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_pdf_extensions', ''),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- return $form;
-}
-
+function lab_migration_settings_form($form, $form_state)
+ {
+ $form['emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('(Bcc) Notification emails'),
+ '#description' => t('Specify emails id for Bcc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_emails', '')
+ );
+ $form['cc_emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('(Cc) Notification emails'),
+ '#description' => t('Specify emails id for Cc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_cc_emails', '')
+ );
+ $form['from_email'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Outgoing from email address'),
+ '#description' => t('Email address to be display in the from field of all outgoing messages'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_from_email', '')
+ );
+ $form['extensions']['source'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed source file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_source_extensions', '')
+ );
+ $form['extensions']['dependency'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed dependency file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of dependency file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_dependency_extensions', '')
+ );
+ $form['extensions']['result'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed result file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of result file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_result_extensions', '')
+ );
+ $form['extensions']['xcos'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed xcos file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of xcos file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_xcos_extensions', '')
+ );
+ $form['extensions']['pdf'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed pdf file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_pdf_extensions', '')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+ }
function lab_migration_settings_form_validate($form, &$form_state)
-{
- return;
-}
-
+ {
+ return;
+ }
function lab_migration_settings_form_submit($form, &$form_state)
-{
- variable_set('lab_migration_emails', $form_state['values']['emails']);
- variable_set('lab_migration_cc_emails', $form_state['values']['cc_emails']);
- variable_set('lab_migration_from_email', $form_state['values']['from_email']);
- variable_set('lab_migration_source_extensions', $form_state['values']['source']);
- variable_set('lab_migration_dependency_extensions', $form_state['values']['dependency']);
- variable_set('lab_migration_result_extensions', $form_state['values']['result']);
- variable_set('lab_migration_xcos_extensions', $form_state['values']['xcos']);
- variable_set('lab_migration_pdf_extensions', $form_state['values']['pdf']);
- drupal_set_message(t('Settings updated'), 'status');
-}
-
+ {
+ variable_set('lab_migration_emails', $form_state['values']['emails']);
+ variable_set('lab_migration_cc_emails', $form_state['values']['cc_emails']);
+ variable_set('lab_migration_from_email', $form_state['values']['from_email']);
+ variable_set('lab_migration_source_extensions', $form_state['values']['source']);
+ variable_set('lab_migration_dependency_extensions', $form_state['values']['dependency']);
+ variable_set('lab_migration_result_extensions', $form_state['values']['result']);
+ variable_set('lab_migration_xcos_extensions', $form_state['values']['xcos']);
+ variable_set('lab_migration_pdf_extensions', $form_state['values']['pdf']);
+ drupal_set_message(t('Settings updated'), 'status');
+ }
diff --git a/solution_proposal.inc b/solution_proposal.inc
index f2d1047..53abe30 100755
--- a/solution_proposal.inc
+++ b/solution_proposal.inc
@@ -1,221 +1,236 @@
<?php
// $Id$
-
function lab_migration_proposal_open()
-{
- global $user;
-
- /* get open proposal list */
- $proposal_rows = array();
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 1 AND solution_provider_uid = 0");
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('approval_status', 1);
- $query->condition('solution_provider_uid', 0);
- $proposal_q = $query->execute();
- while ($proposal_data = $proposal_q->fetchObject())
{
- $proposal_rows[] = array(l($proposal_data->lab_title, 'lab-migration/show-proposal/' . $proposal_data->id), l('Apply', 'lab-migration/show-proposal/' . $proposal_data->id));
+ global $user;
+ /* get open proposal list */
+ $proposal_rows = array();
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 1 AND solution_provider_uid = 0");
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('approval_status', 1);
+ $query->condition('solution_provider_uid', 0);
+ $proposal_q = $query->execute();
+ while ($proposal_data = $proposal_q->fetchObject())
+ {
+ $proposal_rows[] = array(
+ l($proposal_data->lab_title, 'lab-migration/show-proposal/' . $proposal_data->id),
+ l('Apply', 'lab-migration/show-proposal/' . $proposal_data->id)
+ );
+ }
+ $proposal_header = array(
+ 'Title of the Lab',
+ 'Actions'
+ );
+ $return_html = theme('table', array(
+ 'header' => $proposal_header,
+ 'rows' => $proposal_rows
+ ));
+ //$return_html = theme_table($proposal_header, $proposal_rows);
+ return $return_html;
}
-
- $proposal_header = array('Title of the Lab', 'Actions');
- $return_html = theme('table', array('header' => $proposal_header, 'rows' => $proposal_rows));
- //$return_html = theme_table($proposal_header, $proposal_rows);
- return $return_html;
-}
-
function lab_migration_solution_proposal_form($form, $form_state)
-{
- global $user;
-
- $proposal_id = (int)arg(2);
-
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
{
- drupal_set_message("Invalid proposal.", 'error');
- drupal_goto('');
- }
+ global $user;
+ $proposal_id = (int) arg(2);
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message("Invalid proposal.", 'error');
+ drupal_goto('');
+ }
//var_dump($proposal_data->name); die;
- $form['name'] = array(
- '#type' => 'item',
- '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid),
- '#title' => t('Proposer Name'),
- );
- $form['lab_title'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->lab_title,
- '#title' => t('Title of the Lab'),
- );
-
- $experiment_html = '';
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $proposal_id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $proposal_id);
- $experiment_q = $query->execute();
- while ($experiment_data = $experiment_q->fetchObject()) {
- $experiment_html .= $experiment_data->title . "<br/>";
- }
- $form['experiment'] = array(
- '#type' => 'item',
- '#markup' => $experiment_html,
- '#title' => t('Experiment List'),
- );
-
- $form['solution_provider_name_title'] = array(
- '#type' => 'select',
- '#title' => t('Title'),
- '#options' => array('Mr' => 'Mr', 'Ms' => 'Ms', 'Mrs' => 'Mrs', 'Dr' => 'Dr', 'Prof' => 'Prof'),
- '#required' => TRUE,
- );
- $form['solution_provider_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of the Solution Provider'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['solution_provider_email_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Email'),
- '#size' => 30,
- '#value' => $user->mail,
- '#disabled' => TRUE,
- );
- $form['solution_provider_contact_ph'] = array(
- '#type' => 'textfield',
- '#title' => t('Contact No.'),
- '#size' => 30,
- '#maxlength' => 15,
- '#required' => TRUE,
- );
- $form['solution_provider_department'] = array(
- '#type' => 'select',
- '#title' => t('Department/Branch'),
- '#options' => _list_of_departments(),
- '#required' => TRUE,
- );
- $form['solution_provider_university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/Institute'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['version'] = array(
- '#type' => 'select',
- '#title' => t('Version'),
- '#options' => _list_of_software_version(),
- '#required' => TRUE,
- );
- $form['older'] = array(
- '#type' => 'textfield',
- '#size' => 30,
- '#maxlength' => 50,
- //'#required' => TRUE,
- '#description' => t('Specify the Older version used'),
- '#states' => array(
- 'visible' => array(
- ':input[name="version"]' => array('value' => 'olderversion'),
- ),
- ),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Apply for Solution'),
- );
- return $form;
-}
-
+ $form['name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid),
+ '#title' => t('Proposer Name')
+ );
+ $form['lab_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->lab_title,
+ '#title' => t('Title of the Lab')
+ );
+ $experiment_html = '';
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $proposal_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('proposal_id', $proposal_id);
+ $experiment_q = $query->execute();
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_html .= $experiment_data->title . "<br/>";
+ }
+ $form['experiment'] = array(
+ '#type' => 'item',
+ '#markup' => $experiment_html,
+ '#title' => t('Experiment List')
+ );
+ $form['solution_provider_name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Mr' => 'Mr',
+ 'Ms' => 'Ms',
+ 'Mrs' => 'Mrs',
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof'
+ ),
+ '#required' => TRUE
+ );
+ $form['solution_provider_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Solution Provider'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE
+ );
+ $form['solution_provider_email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email'),
+ '#size' => 30,
+ '#value' => $user->mail,
+ '#disabled' => TRUE
+ );
+ $form['solution_provider_contact_ph'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Contact No.'),
+ '#size' => 30,
+ '#maxlength' => 15,
+ '#required' => TRUE
+ );
+ $form['solution_provider_department'] = array(
+ '#type' => 'select',
+ '#title' => t('Department/Branch'),
+ '#options' => _list_of_departments(),
+ '#required' => TRUE
+ );
+ $form['solution_provider_university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#options' => _list_of_software_version(),
+ '#required' => TRUE
+ );
+ $form['older'] = array(
+ '#type' => 'textfield',
+ '#size' => 30,
+ '#maxlength' => 50,
+ //'#required' => TRUE,
+ '#description' => t('Specify the Older version used'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="version"]' => array(
+ 'value' => 'olderversion'
+ )
+ )
+ )
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Apply for Solution')
+ );
+ return $form;
+ }
function lab_migration_solution_proposal_form_validate($form, &$form_state)
-{
- global $user;
- if($form_state['values']['version'] == 'olderversion'){
- if($form_state['values']['older'] == ''){
- form_set_error('older', t('Please provide valid version'));
- }
+ {
+ global $user;
+ if ($form_state['values']['version'] == 'olderversion')
+ {
+ if ($form_state['values']['older'] == '')
+ {
+ form_set_error('older', t('Please provide valid version'));
+ }
+ }
+ return;
+ //$solution_provider_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = ".$user->uid." AND approval_status IN (0, 1) AND solution_status IN (0, 1, 2)");
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('solution_provider_uid', $user->uid);
+ $query->condition('approval_status', array(
+ 0,
+ 1
+ ), 'IN');
+ $query->condition('solution_status', array(
+ 0,
+ 1,
+ 2
+ ), 'IN');
+ $solution_provider_q = $query->execute();
+ if ($solution_provider_q->fetchObject())
+ {
+ form_set_error('', t("You have already applied for a solution. Please compelete that before applying for another solution."));
+ drupal_goto('lab-migration/open-proposal');
+ }
}
- return;
- //$solution_provider_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = ".$user->uid." AND approval_status IN (0, 1) AND solution_status IN (0, 1, 2)");
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('solution_provider_uid', $user->uid);
- $query->condition('approval_status', array(0, 1), 'IN');
- $query->condition('solution_status', array(0, 1, 2), 'IN');
- $solution_provider_q = $query->execute();
- if ($solution_provider_q->fetchObject()) {
- form_set_error('', t("You have already applied for a solution. Please compelete that before applying for another solution."));
- drupal_goto('lab-migration/open-proposal');
- }
-}
-
function lab_migration_solution_proposal_form_submit($form, &$form_state)
-{
- global $user;
-
- $proposal_id = (int)arg(2);
- if($form_state['values']['version'] == 'olderversion'){
- $form_state['values']['version'] = $form_state['values']['older'];
- }
- //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
{
- drupal_set_message("Invalid proposal.", 'error');
- drupal_goto('lab-migration/open-proposal');
- }
- if ($proposal_data->solution_provider_uid != 0) {
- drupal_set_message("Someone has already applied for solving this Lab.", 'error');
- drupal_goto('lab-migration/open-proposal');
- }
-
- $query = "UPDATE {lab_migration_proposal} set solution_provider_uid = :uid, solution_status = 1, version = :version, solution_provider_name_title = :solution_provider_name_title, solution_provider_name = :solution_provider_contact_name, solution_provider_contact_ph = :solution_provider_contact_ph, solution_provider_department = :solution_provider_department, solution_provider_university = :solution_provider_university WHERE id = :proposal_id";
+ global $user;
+ $proposal_id = (int) arg(2);
+ if ($form_state['values']['version'] == 'olderversion')
+ {
+ $form_state['values']['version'] = $form_state['values']['older'];
+ }
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message("Invalid proposal.", 'error');
+ drupal_goto('lab-migration/open-proposal');
+ }
+ if ($proposal_data->solution_provider_uid != 0)
+ {
+ drupal_set_message("Someone has already applied for solving this Lab.", 'error');
+ drupal_goto('lab-migration/open-proposal');
+ }
+ $query = "UPDATE {lab_migration_proposal} set solution_provider_uid = :uid, solution_status = 1, version = :version, solution_provider_name_title = :solution_provider_name_title, solution_provider_name = :solution_provider_contact_name, solution_provider_contact_ph = :solution_provider_contact_ph, solution_provider_department = :solution_provider_department, solution_provider_university = :solution_provider_university WHERE id = :proposal_id";
$args = array(
- ":uid" => $user->uid,
- ":version" => $form_state['values']['version'],
- ":solution_provider_name_title" => $form_state['values']['solution_provider_name_title'],
- ":solution_provider_contact_name" => $form_state['values']['solution_provider_name'],
- ":solution_provider_contact_ph" => $form_state['values']['solution_provider_contact_ph'],
- ":solution_provider_department" => $form_state['values']['solution_provider_department'],
- ":solution_provider_university" => $form_state['values']['solution_provider_university'],
- ":proposal_id" => $proposal_id
- );
+ ":uid" => $user->uid,
+ ":version" => $form_state['values']['version'],
+ ":solution_provider_name_title" => $form_state['values']['solution_provider_name_title'],
+ ":solution_provider_contact_name" => $form_state['values']['solution_provider_name'],
+ ":solution_provider_contact_ph" => $form_state['values']['solution_provider_contact_ph'],
+ ":solution_provider_department" => $form_state['values']['solution_provider_department'],
+ ":solution_provider_university" => $form_state['values']['solution_provider_university'],
+ ":proposal_id" => $proposal_id
+ );
$result = db_query($query, $args);
- drupal_set_message("We have received your application. We will get back to you soon.", 'status');
-
- /* sending email */
- $email_to = $user->mail;
-
- $from = variable_get('lab_migration_from_email', '');
- $bcc= variable_get('lab_migration_emails', '');
- $cc=variable_get('lab_migration_cc_emails', '');
-
- $param['solution_proposal_received']['proposal_id'] = $proposal_id;
- $param['solution_proposal_received']['user_id'] = $user->uid;
- $param['solution_proposal_received']['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', 'solution_proposal_received', $email_to , language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- /* sending email */
- /* $email_to = variable_get('lab_migration_emails', '');
- if (!drupal_mail('lab_migration', 'solution_proposal_received', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
+ drupal_set_message("We have received your application. We will get back to you soon.", 'status');
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['solution_proposal_received']['proposal_id'] = $proposal_id;
+ $param['solution_proposal_received']['user_id'] = $user->uid;
+ $param['solution_proposal_received']['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', 'solution_proposal_received', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ /* sending email */
+ /* $email_to = variable_get('lab_migration_emails', '');
+ if (!drupal_mail('lab_migration', 'solution_proposal_received', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');*/
-
- drupal_goto('lab-migration/open-proposal');
-}
-
+ drupal_goto('lab-migration/open-proposal');
+ }
diff --git a/upload_code_delete.inc b/upload_code_delete.inc
index 25059eb..7b23e88 100755
--- a/upload_code_delete.inc
+++ b/upload_code_delete.inc
@@ -90,9 +90,8 @@ function lab_migration_upload_code_delete()
drupal_set_message('Error deleting example.', 'status');
}
- drupal_goto('lab_migration/code');
+ drupal_goto('lab-migration/code');
return;
}
-
?>