summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xarduino_projects_blog.module58
-rwxr-xr-xcode.inc44
-rwxr-xr-xcode_approval.inc238
-rwxr-xr-xeditstep.inc40
-rwxr-xr-xmanage_proposal.inc15
-rw-r--r--my_proposals.inc5
-rwxr-xr-xproject_details.inc98
-rwxr-xr-xproposal.inc5
-rwxr-xr-xrun.inc321
-rwxr-xr-xupload_project.inc110
10 files changed, 855 insertions, 79 deletions
diff --git a/arduino_projects_blog.module b/arduino_projects_blog.module
index 17d3d3d..9b5d02a 100755
--- a/arduino_projects_blog.module
+++ b/arduino_projects_blog.module
@@ -202,6 +202,30 @@ function arduino_projects_blog_menu()
'file' => 'upload_project.inc',
'weight' => 2
);
+ $items['arduino-projects/code-approval'] = array(
+ 'title' => 'Manage Project Approval',
+ 'description' => 'Manage Project Approval',
+ 'page callback' => 'introduction_approval',
+ 'access arguments' => array(
+ 'arduino projects bulk manage code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'code_approval.inc'
+ );
+ $items['arduino-projects/code-approval/introduction'] = array(
+ 'title' => 'Introduction Approval',
+ 'description' => 'Introduction Approval',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'introduction_approval_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects bulk manage code'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'code_approval.inc'
+ );
$items['arduino-projects/code-approval/step'] = array(
'title' => 'Step approval form',
'description' => 'Step approval form',
@@ -212,8 +236,8 @@ function arduino_projects_blog_menu()
'access arguments' => array(
'arduino projects bulk manage code'
),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
'file' => 'code_approval.inc'
);
$items['arduino-projects/code-approval/bulk'] = array(
@@ -227,7 +251,7 @@ function arduino_projects_blog_menu()
'arduino projects bulk manage code'
),
'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
+ 'weight' => 3,
'file' => 'code_approval.inc'
);
$items['arduino-projects/abstract-approval/bulk'] = array(
@@ -295,6 +319,34 @@ function arduino_projects_blog_menu()
'type' => MENU_CALLBACK,
'file' => 'download.inc'
);
+ $items['arduino-projects/projects-in-progress'] = array(
+ 'title' => 'Projects in Progress',
+ 'page callback' => 'arduino_projects_in_progress',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'file' => 'project_details.inc'
+ );
+ $items['arduino-projects/completed-projects'] = array(
+ 'title' => 'Completed Projects',
+ 'page callback' => 'arduino_projects_completed',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'file' => 'project_details.inc'
+ );
+ $items['arduino-projects/project-details'] = array(
+ 'title' => 'Projects Details',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_details'
+ ),
+ //'page callback' => 'arduino_projects_details',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'file' => 'run.inc'
+ );
$items['arduino-projects/full-download/project'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
diff --git a/code.inc b/code.inc
index d9919d6..93c91de 100755
--- a/code.inc
+++ b/code.inc
@@ -19,10 +19,10 @@ function upload_examples_form($form, &$form_state, $no_js_use = FALSE)
$proposal_data = $result->fetchObject();
if (!$proposal_data)
{
- drupal_set_message("Please submit a " . l('proposal', 'textbook-companion/proposal') . ".", 'error');
+ drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
drupal_goto('');
}
- if ($proposal_data->approval_status != 1 && $proposal_data->approval_status != 4)
+ if ($proposal_data->approval_status != 1)
{
switch ($proposal_data->approval_status)
{
@@ -32,19 +32,19 @@ function upload_examples_form($form, &$form_state, $no_js_use = FALSE)
return;
break;
case 2:
- drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'error');
- drupal_goto('');
+ drupal_set_message(t('Your proposal has been marked for resubmission. Please update your proposal' . l('here', 'arduino-projects/my-proposals') . 'and submit.'), 'status');
+ drupal_goto('arduino-projects/my-proposals');
return;
break;
case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'status');
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'status');
drupal_goto('');
return;
break;
-case 5:
- drupal_set_message(t('You have submitted your all codes.'), 'status');
- drupal_goto('');
- return;
+ case 5:
+ drupal_set_message(t('You have submitted your all codes.'), 'status');
+ drupal_goto('');
+ return;
default:
drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
drupal_goto('');
@@ -273,7 +273,7 @@ $form['proposal_id'] = array(
);
$form['cancel'] = array(
'#type' => 'markup',
- '#value' => l(t('Cancel'), 'textbook-companion/code')
+ '#value' => l(t('Cancel'), 'arduino-projects/code')
);
return $form;
}
@@ -376,7 +376,7 @@ function upload_examples_form_submit($form, &$form_state)
$proposal_data = $result->fetchObject();
if (!$proposal_data)
{
- drupal_set_message("Please submit a " . l('proposal', 'textbook-companion/proposal') . ".", 'error');
+ drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
drupal_goto('');
}
if ($proposal_data->approval_status != 1 && $proposal_data->approval_status != 4)
@@ -389,12 +389,12 @@ function upload_examples_form_submit($form, &$form_state)
return;
break;
case 2:
- drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'error');
+ drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'error');
drupal_goto('');
return;
break;
case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'status');
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'status');
drupal_goto('');
return;
break;
@@ -477,19 +477,19 @@ case 5:
if ($cur_example_d->approval_status == 1)
{
drupal_set_message(t("Example already approved. Cannot overwrite it."), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
else if ($cur_example_d->approval_status == 0)
{
drupal_set_message(t("Example is under pending review. Delete the example and reupload it."), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
else
{
drupal_set_message(t("Error uploading example. Please contact administrator."), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
}
@@ -653,13 +653,13 @@ function _upload_examples_delete()
if (!$example_data)
{
drupal_set_message('Invalid example.', 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
if ($example_data->approval_status != 0)
{
drupal_set_message('You cannnot delete an example after it has been approved. Please contact site administrator if you want to delete this example.', 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/*$step_q = db_query("SELECT * FROM {arduino_projects_blog_step} WHERE id = %d LIMIT 1", $example_data->step_id);
@@ -673,7 +673,7 @@ function _upload_examples_delete()
if (!$step_data)
{
drupal_set_message('You do not have permission to delete this example.', 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/*$preference_q = db_query("SELECT * FROM {arduino_projects_blog_preference} WHERE id = %d LIMIT 1", $step_data->preference_id);
@@ -687,7 +687,7 @@ function _upload_examples_delete()
if (!$proposal_data)
{
drupal_set_message('You do not have permission to delete this example.', 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/*$proposal_q = db_query("SELECT * FROM {arduino_projects_blog_proposal} WHERE id = %d AND uid = %d LIMIT 1", $proposal_data->proposal_id, $user->uid);
@@ -702,7 +702,7 @@ function _upload_examples_delete()
if (!$proposal_data)
{
drupal_set_message('You do not have permission to delete this example.', 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/* deleting example files */
@@ -737,7 +737,7 @@ function _upload_examples_delete()
{
drupal_set_message('Error deleting example.', 'status');
}
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/******************************************************************************/
diff --git a/code_approval.inc b/code_approval.inc
index 74f01d5..7682210 100755
--- a/code_approval.inc
+++ b/code_approval.inc
@@ -1,10 +1,223 @@
<?php
+function introduction_approval()
+{
+ /* get a list of unapproved introductions */
+ $rows = array();
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('approval_status', 1);
+ $query->condition('submitted_steps', 1);
+ $proposal_q = $query->execute();
+ while($proposal_data = $proposal_q->fetchObject()){
+ $intro_query = db_select('arduino_projects_blog_introduction_step');
+ $intro_query->fields('arduino_projects_blog_introduction_step');
+ $intro_query->condition('proposal_id', $proposal_data->id);
+ $intro_query->condition('is_submitted', 1);
+ $intro_query->condition('approval_status', 0);
+ $intro_query_result = $intro_query->execute();
+ $intro_query_data = $intro_query_result->fetchObject();
+ $rows[] = array(
+ $proposal_data->project_title,
+ $proposal_data->contributor_name,
+ l('Edit', 'arduino-projects/code-approval/introduction/' . $intro_query_data->id)
+ );
+ }
+
+ /* check if there are any pending proposals */
+ if (!$rows) {
+ drupal_set_message(t('There are no pending proposals'), 'status');
+ return '';
+ }
+ $header = array(
+ 'Title of the Book',
+ 'Contributor Name',
+ 'Actions'
+ );
+ $output = theme('table', array(
+ 'header' => $header,
+ 'rows' => $rows
+ ));
+ return $output;
+}
+
+function introduction_approval_form($form, &$form_state)
+{
+ /* get a list of unapproved chapters */
+ $id = arg(3);
+
+ /* $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $id);
+ $result = $query->execute();
+ $preference_data = $result->fetchObject();*/
+ //var_dump($preference_data);die;
+ /* get proposal data */
+ /*$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d", $preference_data->proposal_id);
+ $proposal_data = db_fetch_object($proposal_q);*/
+ $query = db_select('arduino_projects_blog_introduction_step');
+ $query->fields('arduino_projects_blog_introduction_step');
+ $query->condition('id', $id);
+ $result = $query->execute();
+ $intro_data = $result->fetchObject();
+ $query_proposal = db_select('arduino_projects_blog_proposal');
+ $query_proposal->fields('arduino_projects_blog_proposal');
+ $query_proposal->condition('id', $intro_data->proposal_id);
+ $proposal_data = $query_proposal->execute()->fetchObject();
+ $form['#tree'] = TRUE;
+ $form['contributor'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->contributor_name,
+ '#title' => t('Contributor Name')
+ );
+ $form['book_details']['book'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Book')
+ );
+
+ /* get example data */
+ /*$example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE chapter_id = %d AND approval_status = 0", $chapter_id);*/
+
+ /*$form['example_details'][$example_data->id] = array(
+ '#type' => 'fieldset',
+ '#collapsible' => FALSE,
+ '#collapsed' => TRUE
+ );*/
+ $form['description'] = array(
+ '#type' => 'item',
+ '#markup' => $intro_data->description,
+ '#title' => t('Description')
+ );
+ $form['video'] =array(
+ '#type' => 'item',
+ '#markup' => convertLinkToEmbed($intro_data->demo_video, 450, 250),
+ '#title' => t('Demo Video')
+ );
+ /*$form['download_file'] = array(
+ '#type' => 'item',
+ '#title' => t('Click to download the file with list of codable examples'),
+ '#markup' => l('Download Example', 'arduino-projects/download/codable-example/' . $example_data->proposal_id)
+ );*/
+ $form['intro_status'] = array(
+ '#type' => 'radios',
+ '#options' => array(
+ 'Approved',
+ 'Dis-approved'
+ )
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#size' => 2500,
+ '#maxlength' => 2500,
+ '#title' => t('Reason for dis-approval')
+ );
+ $form['proposal_id'] = array(
+ '#type' => 'hidden',
+ '#value' => $proposal_data->id
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['back_to_list'] = array(
+ '#type' => 'item',
+ '#markup' => l('Back to Code Approval List', 'arduino-projects/code-approval')
+ );
+ return $form;
+}
+
+function introduction_approval_form_submit($form, &$form_state){
+ global $user;
+ $proposal_id = $form_state['values']['proposal_id'];
+ $query = db_select('arduino_projects_blog_introduction_step');
+ $query->fields('arduino_projects_blog_introduction_step');
+ $query->condition('proposal_id', $proposal_id);
+ $result = $query->execute();
+ $intro_data = $result->fetchObject();
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $intro_data->proposal_id);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ $user_data = user_load($proposal_data->uid);
+ $ex_data = $form_state['values'];
+ if ($ex_data['intro_status'] == "0") {
+ /*db_query("UPDATE {textbook_companion_example} SET approval_status = 1, approver_uid = %d, approval_date = %d WHERE id = %d", $user->uid, time(), $ex_data['example_id']);*/
+ $query = db_update('arduino_projects_blog_introduction_step');
+ $query->fields(array(
+ 'approval_status' => 1,
+ ));
+ $query->condition('proposal_id', $ex_data['proposal_id']);
+ $num_updated = $query->execute();
+ /* sending email */
+ $email_to = $user_data->mail;
+ $from = variable_get('textbook_companion_from_email', '');
+ $bcc = variable_get('textbook_companion_emails', '');
+ $cc = variable_get('textbook_companion_cc_emails', '');
+ $param['codable_example_approved']['proposal_id'] = $ex_data['proposal_id'];
+ $param['codable_example_approved']['user_id'] = $user_data->uid;
+ $param['codable_example_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('textbook_companion', 'intro_approved', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Introduction approved.', 'status');
+ drupal_goto('arduino-projects/code-approval/');
+ } else if ($ex_data['intro_status'] == "1") {
+
+ /* sending email */
+ $query = db_update('arduino_projects_blog_introduction_step');
+ $query->fields(array(
+ 'approval_status' => 0,
+ 'disapproval_message' => $ex_data['message']
+ ));
+ $query->condition('proposal_id', $ex_data['proposal_id']);
+ $num_updated = $query->execute();
+ $pro_query = db_update('arduino_projects_blog_proposal');
+ $pro_query->fields(array(
+ 'submitted_steps' => 0
+ ));
+ $pro_query->condition('id', $ex_data['proposal_id']);
+ $pro_updated = $pro_query->execute();
+ $email_to = $user_data->mail;
+ $from = variable_get('textbook_companion_from_email', '');
+ $bcc = variable_get('textbook_companion_emails', '');
+ $cc = variable_get('textbook_companion_cc_emails', '');
+ $param['codable_example_disapproved']['proposal_id'] = $ex_data['proposal_id'];
+ $param['codable_example_disapproved']['user_id'] = $user_data->uid;
+ $param['codable_example_disapproved']['message'] = $ex_data['message'];
+ $param['codable_example_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('textbook_companion', 'intro_disapproved', $email_to, language_default(), $param, $from, TRUE))
+ // drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Introduction disapproved and user has been notified.', 'status');
+ drupal_goto('arduino-projects/code-approval');
+ }
+ else {
+ drupal_set_message('Error in updating the status. Please contact administrator.', 'error');
+ }
+}
+
/********************************* BULK APPROVAL ******************************/
function step_approval_form($form, &$form_state)
{
$options_first = _step_list_of_projects();
$options_two = _ajax_bulk_get_step_list();
$selected = isset($form_state['values']['project_title']) ? $form_state['values']['project_title'] : key($options_first);
+
$select_two = isset($form_state['values']['step']) ? $form_state['values']['step'] : key($options_two);
$form['project_title'] = array(
'#type' => 'select',
@@ -197,8 +410,9 @@ function step_approval_form_submit($form, &$form_state)
$query = db_select('arduino_projects_blog_step');
$query->fields('arduino_projects_blog_step');
$query->condition('number', $form_state['values']['step']);
+ $query->condition('proposal_id', $user_info->id);
$result = $query->execute();
- $step_data = $result->fetchObject();
+ while($step_data = $result->fetchObject()){
$query = db_select('arduino_projects_blog_step_information');
$query->fields('arduino_projects_blog_step_information');
$query->condition('step_id', $step_data->id);
@@ -223,6 +437,7 @@ function step_approval_form_submit($form, &$form_state)
));
} //$abstract_data = $abstracts_q->fetchObject()
drupal_set_message(t('Approved step no. ' . $step_data->number), 'status');
+ }
// email
/*$email_subject = t('[!site_name][power system simulation Project] Your uploaded power system simulation project have been approved', array(
'!site_name' => variable_get('site_name', '')
@@ -580,7 +795,8 @@ function ajax_bulk_step_list_callback($form, $form_state)
function ajax_bulk_step_details_list_callback($form, $form_state)
{
$commands = array();
- $step_default_value = $form_state['values']['step'];
+ $step_default_value = $form_state['values']['project_title'];
+ //var_dump($step_default_value);die;
if ($step_default_value != 0)
{
$commands[] = ajax_command_html('#ajax_selected_step', _step_details($step_default_value));
@@ -628,7 +844,7 @@ function ajax_bulk_example_files_callback($form, $form_state)
break;
}
$example_files_rows[] = array(
- l($example_list_data->filename, 'textbook-companion/download/file/' . $example_list_data->id),
+ l($example_list_data->filename, 'arduino-projects/download/file/' . $example_list_data->id),
$example_file_type
);
}
@@ -668,8 +884,8 @@ function ajax_bulk_example_files_callback($form, $form_state)
$form['example_files']['#title'] = 'List of example files';
$form['example_files']['#markup'] = $example_files;
$commands[] = ajax_command_replace('#ajax_example_files_list', drupal_render($form['example_files']));
- $commands[] = ajax_command_html('#ajax_download_selected_example', l('Download Example', 'textbook-companion/download/example/' . $example_list_default_value));
- $commands[] = ajax_command_html('#ajax_edit_selected_example', l('Edit Example', 'textbook-companion/code-approval/editcode/' . $example_list_default_value));
+ $commands[] = ajax_command_html('#ajax_download_selected_example', l('Download Example', 'arduino-projects/download/example/' . $example_list_default_value));
+ $commands[] = ajax_command_html('#ajax_edit_selected_example', l('Edit Example', 'arduino-projects/code-approval/editcode/' . $example_list_default_value));
$form['example_actions']['#options'] = _bulk_list_example_actions();
$commands[] = ajax_command_replace('#ajax_selected_example_action', drupal_render($form['example_actions']));
//$commands[] = ajax_command_html('#ajax_selected_example_action', '' );
@@ -704,15 +920,17 @@ function ajax_bulk_chapter_actions_callback()
function _step_details($step_id)
{
$return_html = "";
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $step_id);
+ $proposal_data = $query->execute()->fetchObject();
$query = db_select('arduino_projects_blog_step');
$query->fields('arduino_projects_blog_step');
- $query->condition('number', $step_id);
+ $query->condition('proposal_id', $proposal_data->id);
+ $query->condition('approval_status', 0);
$step_data = $query->execute()->fetchObject();
//var_dump($step_data);die;
- $query = db_select('arduino_projects_blog_proposal');
- $query->fields('arduino_projects_blog_proposal');
- $query->condition('id', $step_data->proposal_id);
- $proposal_data = $query->execute()->fetchObject();
+
$query = db_select('arduino_projects_blog_step_information');
$query->fields('arduino_projects_blog_step_information');
$query->condition('step_id', $step_data->id);
diff --git a/editstep.inc b/editstep.inc
index a4af74d..608e371 100755
--- a/editstep.inc
+++ b/editstep.inc
@@ -115,7 +115,7 @@ function upload_step_edit_form($form, &$form_state, $no_js_use = FALSE)
return;
}
$user_data = user_load($proposal_data->uid);
- $form['#redirect'] = 'textbook-companion/code';
+ $form['#redirect'] = 'arduino-projects/code';
$form['#attributes'] = array(
'enctype' => "multipart/form-data"
);
@@ -498,7 +498,7 @@ function upload_step_edit_form($form, &$form_state, $no_js_use = FALSE)
);
$form['cancel'] = array(
'#type' => 'item',
- '#markup' => l(t('Cancel'), 'textbook-companion/code')
+ '#markup' => l(t('Cancel'), 'arduino-projects/code')
);
return $form;
}
@@ -835,8 +835,8 @@ function edit_chapter_title_form($form, $form_state)
$proposal_data = $result->fetchObject();
if (!$proposal_data)
{
- drupal_set_message("Please submit a " . l('proposal', 'textbook-companion/proposal') . ".", 'error');
- drupal_goto('textbook-companion/code');
+ drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
+ drupal_goto('arduino-projects/code');
}
if ($proposal_data->proposal_status != 1 && $proposal_data->proposal_status != 4)
{
@@ -844,22 +844,22 @@ function edit_chapter_title_form($form, $form_state)
{
case 0:
drupal_set_message(t('We have already received your proposal. We will get back to you soon.'), 'status');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
break;
case 2:
drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'proposal') . '.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
break;
case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'status');
- drupal_goto('textbook-companion/code');
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'status');
+ drupal_goto('arduino-projects/code');
return;
break;
default:
drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
break;
}
@@ -876,7 +876,7 @@ function edit_chapter_title_form($form, $form_state)
if (!$preference_data)
{
drupal_set_message(t('Invalid Book Preference status. Please contact site administrator for further information.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/************************ end approve book details **************************/
@@ -892,10 +892,10 @@ function edit_chapter_title_form($form, $form_state)
if (!$chapter_data)
{
drupal_set_message(t('Invalid chapter.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
- $form['#redirect'] = 'textbook-companion/code';
+ $form['#redirect'] = 'arduino-projects/code';
$form['book_details']['book'] = array(
'#type' => 'item',
'#markup' => $preference_data->book,
@@ -949,8 +949,8 @@ function edit_chapter_title_form_submit($form, &$form_state)
$proposal_data = $result->fetchObject();
if (!$proposal_data)
{
- drupal_set_message("Please submit a " . l('proposal', 'textbook-companion/proposal') . ".", 'error');
- drupal_goto('textbook-companion/code');
+ drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
+ drupal_goto('arduino-projects/code');
}
if ($proposal_data->proposal_status != 1 && $proposal_data->proposal_status != 4)
{
@@ -958,22 +958,22 @@ function edit_chapter_title_form_submit($form, &$form_state)
{
case 0:
drupal_set_message(t('We have already received your proposal. We will get back to you soon.'), 'status');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
break;
case 2:
drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'proposal') . '.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
break;
case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'status');
- drupal_goto('textbook-companion/code');
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'status');
+ drupal_goto('arduino-projects/code');
return;
break;
default:
drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
break;
}
@@ -990,7 +990,7 @@ function edit_chapter_title_form_submit($form, &$form_state)
if (!$preference_data)
{
drupal_set_message(t('Invalid Book Preference status. Please contact site administrator for further information.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/************************ end approve book details **************************/
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 0eefd43..1d710db 100755
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -555,7 +555,14 @@ function arduino_projects_blog_proposal_status_form($form, &$form_state)
'#title' => t('Approve')
);
} //$proposal_data->approval_status == 0
- if ($proposal_data->approval_status == 1)
+
+ $query_step = db_select('arduino_projects_blog_step');
+ $query_step->fields('arduino_projects_blog_step');
+ $query_step->condition('proposal_id', $proposal_data->id);
+ $query_step->condition('approval_status', 1);
+ $query_step_count = $query_step->execute()->rowCount();
+ //$project_titles_data = $query_step->execute()->fetchObject();
+ if ($query_step_count == $proposal_data->no_of_steps_approved && $proposal_data->approval_status == 1)
{
$form['completed'] = array(
'#type' => 'checkbox',
@@ -627,14 +634,14 @@ function arduino_projects_blog_proposal_status_form_submit($form, &$form_state)
":expected_completion_date" => time()
);
$result = db_query($up_query, $args);
- CreateReadmeFileOmPSSPProject($proposal_id);
+ //CreateReadmeFileOmPSSPProject($proposal_id);
if (!$result)
{
drupal_set_message('Error in update status', 'error');
return;
} //!$result
/* sending email */
- $user_data = user_load($proposal_data->uid);
+ /*$user_data = user_load($proposal_data->uid);
$email_to = $user_data->mail;
$from = variable_get('arduino_projects_blog_from_email', '');
$bcc = $user->mail . ', ' . variable_get('arduino_projects_blog_bcc_emails', '');
@@ -651,7 +658,7 @@ function arduino_projects_blog_proposal_status_form_submit($form, &$form_state)
'Bcc' => $bcc
);
if (!drupal_mail('arduino_projects_blog', 'arduino_projects_blog_proposal_completed', $email_to, language_default(), $params, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Error sending email message.', 'error');*/
drupal_set_message('Congratulations! proposal has been marked as completed. User has been notified of the completion.', 'status');
}
drupal_goto('arduino-projects/manage-proposal');
diff --git a/my_proposals.inc b/my_proposals.inc
index 4c3ff5f..7c7e3aa 100644
--- a/my_proposals.inc
+++ b/my_proposals.inc
@@ -339,11 +339,13 @@ function arduino_projects_blog_my_proposal_edit_form_submit($form, &$form_state)
$v = $form_state['values'];
$query = "UPDATE arduino_projects_blog_proposal SET
abstract=:abstract,
- reference=:reference
+ reference=:reference,
+ approval_status = :approval_status
WHERE id=:proposal_id";
$args = array(
':abstract' => $v['abstract'],
':reference' => $v['reference'],
+ ':approval_status' => 0,
':proposal_id' => $proposal_id
);
$result = db_query($query, $args);
@@ -430,6 +432,7 @@ function arduino_projects_blog_my_proposal_edit_form_submit($form, &$form_state)
}
drupal_set_message(t('Proposal Updated'), 'status');
+ drupal_goto('arduino-projects/my-proposals');
}
function arduino_projects_blog_my_proposal_view_form($form, &$form_state)
diff --git a/project_details.inc b/project_details.inc
new file mode 100755
index 0000000..df6cfa6
--- /dev/null
+++ b/project_details.inc
@@ -0,0 +1,98 @@
+<?php
+function arduino_projects_completed()
+{
+ $output = "";
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('approval_status', 3);
+ $query->orderBy('actual_completion_date', 'DESC');
+ //$query->condition('is_completed', 1);
+ $result = $query->execute();
+
+ if ($result->rowCount() == 0)
+ {
+ $output .= "We welcome your contributions." ."<hr>";
+
+ } //$result->rowCount() == 0
+ else
+ {
+ $output .= "Work has been completed for the following projects. We welcome your contributions." . "<hr>";
+ $preference_rows = array();
+ $i = 1;
+ while ($row = $result->fetchObject())
+ {
+ $proposal_id = $row->id;
+ /*$query1 = db_select('om_pssp_submitted_abstracts_file');
+ $query1->fields('om_pssp_submitted_abstracts_file');
+ $query1->condition('file_approval_status', 1);
+ $query1->condition('proposal_id', $proposal_id);
+ $project_files = $query1->execute();
+ $project_abstract = $project_files->fetchObject();*/
+ $completion_date = date("Y", $row->actual_completion_date);
+ $preference_rows[] = array(
+ $i,
+ l($row->project_title, "arduino-projects/project-details/" . $row->id),
+ $row->contributor_name,
+ $row->university,
+ $completion_date
+ );
+ $i++;
+ } //$row = $result->fetchObject()
+ $preference_header = array(
+ 'No',
+ 'Title of the Project',
+ 'Contributor Name',
+ 'University / Institute',
+ 'Year of Completion'
+ );
+ $output .= theme('table', array(
+ 'header' => $preference_header,
+ 'rows' => $preference_rows
+ ));
+ }
+ return $output;
+}
+// eSim power system simulation display in progress proposals
+function arduino_projects_in_progress()
+{
+ $page_content = "";
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('approval_status', 1);
+ $query->condition('is_completed', 0);
+ $result = $query->execute();
+ if ($result->rowCount() == 0)
+ {
+ $page_content .= "You are welcome to submit projects<hr>";
+ } //$result->rowCount() == 0
+ else
+ {
+ $page_content .= "Work is in progress for the following projects<hr>";
+ $preference_rows = array();
+ $i = 1;
+ while ($row = $result->fetchObject())
+ {
+ $approval_date = date("Y", $row->approval_date);
+ $preference_rows[] = array(
+ $i,
+ $row->project_title,
+ $row->contributor_name,
+ $row->university,
+ $approval_date
+ );
+ $i++;
+ } //$row = $result->fetchObject()
+ $preference_header = array(
+ 'No',
+ 'Title of the Project',
+ 'Contributor Name',
+ 'University / Institute',
+ 'Year'
+ );
+ $page_content .= theme('table', array(
+ 'header' => $preference_header,
+ 'rows' => $preference_rows
+ ));
+ }
+ return $page_content;
+} \ No newline at end of file
diff --git a/proposal.inc b/proposal.inc
index 69b883b..695a598 100755
--- a/proposal.inc
+++ b/proposal.inc
@@ -522,7 +522,7 @@ function arduino_projects_blog_proposal_form_submit($form, &$form_state)
":position" => $v['position'],
":how_did_you_hear_about_us" => $v['how_did_you_hear_about_us'],
":project_title" => $v['project_title'],
- ":abstract" => _df_sentence_case($v['abstract']),
+ ":abstract" => $v['abstract'],
":reference" => $v['reference'],
":directory_name" => $directory_name,
":approval_status" => 0,
@@ -632,6 +632,9 @@ function arduino_projects_blog_my_proposal()
else if($my_proposals_data->approval_status == 1 or $my_proposals_data->approval_status == 3){
$action = l('View', 'arduino-projects/my-proposals/view/' . $my_proposals_data->id);
}
+ else if($my_proposals_data->approval_status == 0){
+ $action = 'Proposal pending for review';
+ }
$my_proposal_rows[$my_proposals_data->id] = array(
date('d-m-Y', $my_proposals_data->creation_date),
l($my_proposals_data->contributor_name, 'user/' . $my_proposals_data->uid),
diff --git a/run.inc b/run.inc
new file mode 100755
index 0000000..880bcb0
--- /dev/null
+++ b/run.inc
@@ -0,0 +1,321 @@
+<?php
+function arduino_projects_details($form, &$form_state)
+{
+ $options_first = _list_of_project_titles();
+ $url_project_id = (int) arg(2);
+ //var_dump($url_project_id);die;
+ $project_data = _project_information($url_project_id);
+ if ($project_data == 'Not found') {
+ $url_project_id = '';
+ } //$project_data == 'Not found'
+ if (!$url_project_id) {
+ $selected = isset($form_state['values']['arduino_project']) ? $form_state['values']['arduino_project'] : key($options_first);
+ } //!$url_project_id
+ elseif ($url_project_id == '') {
+ $selected = 0;
+ } //$url_project_id == ''
+ else {
+ $selected = $url_project_id;
+ }
+ //var_dump($selected);die;
+ $form = array();
+ $form['arduino_project'] = array(
+ '#type' => 'select',
+ '#title' => t('Title of the Project'),
+ '#options' => _list_of_project_titles(),
+ '#default_value' => $selected,
+ '#ajax' => array(
+ 'callback' => 'arduino_project_details_callback'
+ )
+ );
+ if (!$url_project_id) {
+ $form['arduino_project_details'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_project_details"></div>'
+ );
+ $form['intro_selected_project'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_project"></div>'
+ );
+ $form['step'] = array(
+ '#type' => 'select',
+ '#title' => t('Title of the Step'),
+ '#options' => _step_information($selected),
+ //'#default_value' => $chapter_default_value,
+ '#prefix' => '<div id="ajax_select_step_list">',
+ '#suffix' => '</div>',
+ '#validated' => TRUE,
+ '#tree' => TRUE,
+ '#ajax' => array(
+ 'callback' => 'ajax_bulk_step_details_list_callback'
+ ),
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="arduino_project"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ $form['step_selected_project'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_step_selected_project"></div>'
+ );
+ $form['selected_step_images'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_step_images"></div>'
+ );
+
+ } //!$url_project_id
+ else {
+ $project_default_value = $url_project_id;
+ $form['arduino_project_details'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_project_details">' . _project_details($project_default_value) . '</div>'
+ );
+ $form['intro_selected_project'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_project">' . _project_intro_information($project_default_value) . '</div>'
+ );
+ $form['step'] = array(
+ '#type' => 'select',
+ '#title' => t('Title of the Step'),
+ '#options' => _step_information($project_default_value),
+ //'#default_value' => $chapter_default_value,
+ '#prefix' => '<div id="ajax_select_step_list">',
+ '#suffix' => '</div>',
+ '#validated' => TRUE,
+ '#tree' => TRUE,
+ '#ajax' => array(
+ 'callback' => 'ajax_bulk_step_details_list_callback'
+ ),
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="arduino_project"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ $form['step_selected_project'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_step_selected_project"></div>'
+ );
+ $form['selected_step_images'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_step_images"></div>'
+ );
+ }
+ return $form;
+}
+function ajax_bulk_step_details_list_callback($form, $form_state)
+{
+ $commands = array();
+ $project_default_value = $form_state['values']['arduino_project'];
+ $step_default_value = $form_state['values']['step'];
+ if ($step_default_value != 0)
+ {
+ $commands[] = ajax_command_html('#ajax_step_selected_project', _step_project_details($project_default_value, $step_default_value));
+ $commands[] = ajax_command_html('#ajax_selected_step_images', _selected_step_image_details($step_default_value));
+ } //$step_default_value != 0
+ else
+ {
+ $commands[] = ajax_command_html('#ajax_selected_step', '');
+ $commands[] = ajax_command_data('#ajax_selected_step', 'form_state_value_select', $form_state['values']['step']);
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+}
+function _step_information($project_default_value)
+{
+ $proposal_id = $project_default_value;
+ $steps_list = array(
+ '0' => 'Please select...'
+ );
+ /*$book_chapters_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE preference_id = %d ORDER BY number ASC", $preference_id);*/
+ $query = db_select('arduino_projects_blog_step');
+ $query->fields('arduino_projects_blog_step');
+ $query->condition('proposal_id', $proposal_id);
+ $query->condition('approval_status', 1);
+ $query->orderBy('number', 'ASC');
+ $steps_q = $query->execute();
+ while ($steps_data = $steps_q->fetchObject()) {
+ $steps_list[$steps_data->number] = $steps_data->number . '. ' . $steps_data->name;
+ }
+ return $steps_list;
+}
+function arduino_project_details_callback($form, $form_state)
+{
+ $commands = array();
+ $project_default_value = $form_state['values']['arduino_project'];
+ if ($project_default_value != 0) {
+ $form['arduino_project_details']['#markup'] = _project_details($project_default_value);
+ $arduino_project_details = _project_information($project_default_value);
+ $provider = user_load($arduino_project_details->uid);
+ if ($arduino_project_details->uid > 0) {
+ $commands[] = ajax_command_html('#ajax_selected_project', _project_intro_information($project_default_value));
+
+ $form['step']['#options'] = _step_information($project_default_value);
+ $commands[] = ajax_command_replace('#ajax_select_step_list', drupal_render($form['step']));
+ } //$arduino_project_details->uid > 0
+ else {
+ $commands[] = ajax_command_html('#ajax_selected_project', _project_intro_information($project_default_value));
+
+ $form['step']['#options'] = _step_information($project_default_value);
+ $commands[] = ajax_command_replace('#ajax_select_step_list', drupal_render($form['step']));
+ //$commands[] = ajax_command_html('#ajax_selected_project', '');
+ }
+ $commands[] = ajax_command_html('#ajax_project_details', _project_details($project_default_value));
+ $form['step']['#options'] = _step_information($project_default_value);
+ $commands[] = ajax_command_replace('#ajax_select_step_list', drupal_render($form['step']));
+ //$commands[] = ajax_command_html('#ajax_step_selected_project', _step_project_details($project_default_value));
+ $commands[] = ajax_command_html('#ajax_selected_project', _project_intro_information($project_default_value));
+ } //$project_default_value != 0
+ 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_project_details', '');
+ $commands[] = ajax_command_html('#ajax_selected_project', '');
+
+ //$commands[] = ajax_command_html('#ajax_selected_project', '');
+ //$commands[] = ajax_command_html('#ajax_selected_project', '');
+ //$commands[] = ajax_command_data('#ajax_selected_project', 'form_state_value_select', $form_state['values']['arduino_project']);
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+}
+function bootstrap_table_format($headers, $rows)
+{
+ $thead = "";
+ $tbody = "";
+ foreach ($headers as $header) {
+ $thead .= "<th>{$header}</th>";
+ } //$headers as $header
+ foreach ($rows as $row) {
+ $tbody .= "<tr>";
+ foreach ($row as $data) {
+ $tbody .= "<td>{$data}</td>";
+ } //$row as $data
+ $tbody .= "</tr>";
+ } //$rows as $row
+ $table = "
+ <table class='table table-bordered table-hover' style='margin-left:-140px'>
+ <thead>{$thead}</thead>
+ <tbody>{$tbody}</tbody>
+ </table>
+ ";
+ return $table;
+}
+/*****************************************************/
+function _list_of_project_titles()
+{
+ $arduino_project_titles = array(
+ '0' => 'Please select...'
+ );
+ //$lab_titles_q = db_query("SELECT * FROM {arduino_projects_blog_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('approval_status', 3);
+ $query->orderBy('project_title', 'ASC');
+ $arduino_project_titles_q = $query->execute();
+ while ($arduino_project_titles_data = $arduino_project_titles_q->fetchObject()) {
+ $arduino_project_titles[$arduino_project_titles_data->id] = $arduino_project_titles_data->project_title . ' (Proposed by ' . $arduino_project_titles_data->contributor_name . ')';
+ } //$arduino_project_titles_data = $arduino_project_titles_q->fetchObject()
+ return $arduino_project_titles;
+}
+function _project_information($proposal_id)
+{
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $query->condition('approval_status', 3);
+ $arduino_project_q = $query->execute();
+ $project_data = $arduino_project_q->fetchObject();
+ if ($project_data) {
+ return $project_data;
+ } //$project_data
+ else {
+ return 'Not found';
+ }
+}
+
+function _project_details($project_default_value)
+{
+ $arduino_project_details = _project_information($project_default_value);
+ if ($project_default_value != 0) {
+ if($arduino_project_details->reference != NULL){
+ $url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i';
+ $reference = preg_replace($url, '<a href="$0" target="_blank" title="$0">$0</a>', $arduino_project_details->reference);
+ }else{
+ $reference = 'Not provided';
+ }
+ $form['arduino_project_details']['#markup'] = '<span style="color: rgb(128, 0, 0);"><strong>About the Project</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Proposer Name:</strong> ' . $arduino_project_details->contributor_name . '</li>' . '<li><strong>Title of the Project:</strong> ' . $arduino_project_details->project_title . '</li>' . '<li><strong>University:</strong> ' . $arduino_project_details->university . '</li>' . '<li>'.'<strong>Reference:</strong> ' . $reference .'</li>'.'</ul>';
+ $details = $form['arduino_project_details']['#markup'];
+ return $details;
+ } //$project_default_value != 0
+}
+
+function _project_intro_information($project_default_value){
+ $proposal_id = $project_default_value;
+ $intro_query = db_select('arduino_projects_blog_introduction_step');
+ $intro_query->fields('arduino_projects_blog_introduction_step');
+ $intro_query->condition('proposal_id', $proposal_id);
+ $intro_query_result = $intro_query->execute();
+ $intro_query_data = $intro_query_result->fetchObject();
+ $form['intro_selected_project']['#markup'] = convertLinkToEmbed($intro_query_data->demo_video, 750, 350) . '<br/>' . $intro_query_data->description;
+ $details = $form['intro_selected_project']['#markup'];
+ return $details;
+}
+
+function _step_project_details($project_default_value, $step_default_value)
+{
+ $proposal_id = $project_default_value;
+ $step_id = $step_default_value;
+ //var_dump($proposal_id);die;
+ $query = db_select('arduino_projects_blog_step');
+ $query->fields('arduino_projects_blog_step');
+ $query->condition('proposal_id', $proposal_id);
+ $query->condition('number', $step_id);
+ $query->orderBy('number', 'ASC');
+ $steps_q = $query->execute();
+ $steps_data = $steps_q->fetchObject();
+ $step_info_query = db_select('arduino_projects_blog_step_information');
+ $step_info_query->fields('arduino_projects_blog_step_information');
+ $step_info_query->condition('step_id', $steps_data->id);
+ $step_info_query->condition('approval_status', 1);
+ $steps_info_data = $step_info_query->execute()->fetchObject();
+ if($steps_info_data->video) {
+ $form['step_selected_project']['#markup'] = '<p>Step ' . $steps_data->number . ': ' . $steps_data->name . '</p><p> Description: ' . $steps_info_data->description . '</p>' . convertLinkToEmbed($steps_info_data->video, 750, 350);
+ }
+ else{
+ $form['step_selected_project']['#markup'] = '<p>Step ' . $steps_data->number . ': ' . $steps_data->name . '</p><p> Description: ' . $steps_info_data->description . '</p>';
+ }
+ $details = $form['step_selected_project']['#markup'];
+ return $details;
+}
+
+function _selected_step_image_details($step_default_value){
+ $id = $step_default_value;
+ $query = db_select('arduino_projects_blog_step');
+ $query->fields('arduino_projects_blog_step');
+ $query->condition('proposal_id', $id);
+ $query->orderBy('number', 'ASC');
+ $steps_q = $query->execute();
+ $steps_data = $steps_q->fetchObject();
+ $step_images_query = db_select('arduino_projects_blog_step_files');
+ $step_images_query->fields('arduino_projects_blog_step_files');
+ $step_images_query->condition('step_id', $steps_data->id);
+ $step_images_result = $step_images_query->execute();
+ //var_dump($step_images_result->rowCount());die;
+ while($step_images_data = $step_images_result->fetchObject()){
+ if($step_images_data){
+ $form['selected_step_images' . $step_images_data->id]['#markup'] = '<img style="padding-left :20px;width: 90%" src=' . $GLOBALS['base_url'] . "/project_uploads/" . $step_images_data->filepath . ' />';
+ }
+ }
+ $details = $form['selected_step_images']['#markup'];
+ return $details;
+ } \ No newline at end of file
diff --git a/upload_project.inc b/upload_project.inc
index ca7f604..ab92f0b 100755
--- a/upload_project.inc
+++ b/upload_project.inc
@@ -23,7 +23,7 @@ function list_steps()
drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
drupal_goto('');
}
- if ($proposal_data->approval_status != 1 && $proposal_data->approval_status != 4 && $proposal_data->approval_status != 2)
+ if ($proposal_data->approval_status != 1 && $proposal_data->approval_status != 4)
{
switch ($proposal_data->approval_status)
{
@@ -33,8 +33,8 @@ function list_steps()
return;
break;
case 2:
- drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'error');
- drupal_goto('');
+ drupal_set_message(t('Your proposal has been marked for resubmission. Please update your proposal and submit.'), 'status');
+ drupal_goto('arduino-projects/my-proposals');
return;
break;
case 3:
@@ -82,11 +82,13 @@ function list_steps()
$return_html = '';
$return_html .= '<strong>Title of the Book:</strong><br />' . $proposal_data->project_title . '<br /><br />';
$return_html .= '<strong>Contributor Name:</strong><br />' . $proposal_data->contributor_name . '<br /><br />';
+ if($intro_query_data){
if($intro_query_data->is_submitted == 1){
$return_html .= '<strong>Introduction</strong><br />';
$return_html .= '<strong>Description:</strong>' . $intro_query_data->description;
$return_html .= '<strong>Demo Video:</strong><br />' . convertLinkToEmbed($intro_query_data->demo_video, 450, 350) . '<br />';
}
+ }
else{
$return_html .= l('Update Introduction', 'arduino-projects/code/update-introduction') . '<br />';
}
@@ -161,7 +163,7 @@ function update_introduction_form($form, &$form_state)
$proposal_data = $result->fetchObject();
if (!$proposal_data)
{
- drupal_set_message("Please submit a " . l('proposal', 'textbook-companion/proposal') . ".", 'error');
+ drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
drupal_goto('');
}
if ($proposal_data->approval_status != 1 && $proposal_data->approval_status != 4)
@@ -174,12 +176,12 @@ function update_introduction_form($form, &$form_state)
return;
break;
case 2:
- drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'error');
+ drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'error');
drupal_goto('');
return;
break;
case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'status');
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'status');
drupal_goto('');
return;
break;
@@ -195,6 +197,12 @@ function update_introduction_form($form, &$form_state)
break;
}
}
+ $query_intro = db_select('arduino_projects_blog_introduction_step');
+ $query_intro->fields('arduino_projects_blog_introduction_step');
+ $query_intro->condition('proposal_id', $proposal_data->id);
+ $query_intro->condition('approval_status', 0);
+ $query_intro_q = $query_intro->execute();
+ $query_intro_data = $query_intro_q->fetchObject();
/*$preference_q = db_query("SELECT * FROM {arduino_projects_blog_preference} WHERE proposal_id = %d AND approval_status = 1 LIMIT 1", $proposal_data->id);
$proposal_data = db_fetch_object($preference_q);*/
/*$query = db_select('arduino_projects_blog_preference');
@@ -210,7 +218,46 @@ function update_introduction_form($form, &$form_state)
drupal_goto('');
return;
}*/
- $form['#attributes'] = array(
+ if($query_intro_data){
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ $form['proposal_id'] =array(
+ '#type' => 'hidden',
+ '#default_value' => $proposal_data->id
+ );
+ $form['title'] = array(
+ '#type' => 'item',
+ '#markup' => t('Introduction'),
+ '#title' => t('Title'),
+ '#default_value' => t('Introduction')
+ );
+ $form['description'] = array(
+ '#type' => 'text_format',
+ '#title' => t('Description'),
+ '#required' => TRUE,
+ '#format' => $query_intro_data->description_type,
+ '#default_value' => $query_intro_data->description
+ );
+ $form['demo_video'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Demo video'),
+ '#size' => 600,
+ '#maxlength' => 600,
+ '#required' => TRUE,
+ '#default_value' => $query_intro_data->demo_video
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l('Cancel', 'arduino-projects/code')
+ );
+ }
+ else{
+ $form['#attributes'] = array(
'enctype' => "multipart/form-data"
);
$form['proposal_id'] =array(
@@ -244,6 +291,7 @@ function update_introduction_form($form, &$form_state)
'#type' => 'item',
'#markup' => l('Cancel', 'arduino-projects/code')
);
+}
return $form;
}
@@ -255,8 +303,33 @@ function update_introduction_form($form, &$form_state)
drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
return;
} //!$user->uid
- /* inserting the user proposal */
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ $query_intro = db_select('arduino_projects_blog_introduction_step');
+ $query_intro->fields('arduino_projects_blog_introduction_step');
+ $query_intro->condition('proposal_id', $proposal_data->id);
+ $query_intro_q = $query_intro->execute();
+ $query_intro_data = $query_intro_q->fetchObject();
$v = $form_state["values"];
+ if($query_intro_data){
+ $query = "UPDATE {arduino_projects_blog_introduction_step} SET description = :description, description_type = :description_type, demo_video = :demo_video, creation_date = :creation_date, is_submitted = :is_submitted WHERE id = :id";
+ $args = array(
+ ":description" => $v['description']['value'],
+ ":description_type" => $v['description']['format'],
+ ":demo_video" => $v['demo_video'],
+ ":creation_date" => time(),
+ ":is_submitted" => 1,
+ ":id" => $query_intro_data->id
+ );
+ $result = db_query($query, $args);
+ }
+ /* inserting the user proposal */
+ else{
$result = "INSERT INTO {arduino_projects_blog_introduction_step}
(
uid,
@@ -291,6 +364,7 @@ function update_introduction_form($form, &$form_state)
$intro_id = db_query($result, $args, array(
'return' => Database::RETURN_INSERT_ID
));
+ }
drupal_set_message(t('Introduction update successfully.'), 'status');
drupal_goto('arduino-projects/code');
}
@@ -312,7 +386,7 @@ function update_introduction_form($form, &$form_state)
$proposal_data = $result->fetchObject();
if (!$proposal_data)
{
- drupal_set_message("Please submit a " . l('proposal', 'textbook-companion/proposal') . ".", 'error');
+ drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
drupal_goto('');
}
if ($proposal_data->approval_status != 1 && $proposal_data->approval_status != 4 && $proposal_data->approval_status != 2)
@@ -325,12 +399,12 @@ function update_introduction_form($form, &$form_state)
return;
break;
case 2:
- drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'error');
+ drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'error');
drupal_goto('');
return;
break;
case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'status');
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'status');
drupal_goto('');
return;
break;
@@ -361,7 +435,7 @@ function update_introduction_form($form, &$form_state)
else
{
drupal_set_message(t('Invalid step.'), 'error');
- drupal_goto('textbook-companion/code');
+ drupal_goto('arduino-projects/code');
return;
}
/* get example list */
@@ -407,7 +481,7 @@ function update_introduction_form($form, &$form_state)
break;
default:
}
- $example_files .= l($example_files_data->filename, 'textbook-companion/download/file/' . $example_files_data->id) . ' (' . $file_type . ')<br />';
+ $example_files .= l($example_files_data->filename, 'arduino-projects/download/file/' . $example_files_data->id) . ' (' . $file_type . ')<br />';
}
if ($example_data->approval_status == 0)
{
@@ -417,7 +491,7 @@ function update_introduction_form($form, &$form_state)
// $video,
$approval_status,
$example_files,
- /*l('Edit', 'textbook-companion/code/edit/' . $example_data->id) . ' | ' . l('Delete', 'textbook-companion/code/delete/' . $example_data->id, array(
+ /*l('Edit', 'arduino-projects/code/edit/' . $example_data->id) . ' | ' . l('Delete', 'arduino-projects/code/delete/' . $example_data->id, array(
'attributes' => array(
'onClick' => 'return confirm("Are you sure you want to delete the example?")'
)
@@ -434,7 +508,7 @@ function update_introduction_form($form, &$form_state)
// $video,
$approval_status,
$example_files,
- l('Download', 'textbook-companion/download/example/' . $example_data->id)
+ l('Download', 'arduino-projects/download/example/' . $example_data->id)
),
'valign' => 'top'
);
@@ -504,7 +578,7 @@ function all_steps_submitted_check_form_submit($form,&$form_state){
$proposal_data = $result->fetchObject();
if (!$proposal_data)
{
- drupal_set_message("Please submit a " . l('proposal', 'textbook-companion/proposal') . ".", 'error');
+ drupal_set_message("Please submit a " . l('proposal', 'arduino-projects/proposal') . ".", 'error');
drupal_goto('');
}
if ($proposal_data->approval_status != 1 && $proposal_data->approval_status != 4 && $proposal_data->approval_status != 2)
@@ -517,12 +591,12 @@ function all_steps_submitted_check_form_submit($form,&$form_state){
return;
break;
case 2:
- drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'error');
+ drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'error');
drupal_goto('');
return;
break;
case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'textbook-companion/proposal') . '.'), 'status');
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You have to create another proposal ' . l('here', 'arduino-projects/proposal') . '.'), 'status');
drupal_goto('');
return;
break;