From 9df9d0038d808c88540e3785a3d37d1dc7837d25 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Fri, 2 Feb 2024 17:41:40 +0530 Subject: Update hyperlinks to download files --- cfd_hackathon_submissions.module | 6 +++--- download.inc | 33 +++++++++++++++++++++++++++++++++ run.inc | 4 ++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/cfd_hackathon_submissions.module b/cfd_hackathon_submissions.module index ea5ebbe..bceaafb 100644 --- a/cfd_hackathon_submissions.module +++ b/cfd_hackathon_submissions.module @@ -312,10 +312,10 @@ function cfd_hackathon_submissions_menu() 'type' => MENU_NORMAL_ITEM, 'file' => 'run.inc', ); - $items['cfd-hackathon/download/resource-file'] = array( + $items['cfd-hackathon/download/upgraded-report'] = array( 'title' => 'Download user defined compound file', - 'description' => 'Download resource file', - 'page callback' => 'cfd_hackathon_submissions_download_upload_file', + 'description' => 'Download Upgraded report file', + 'page callback' => 'cfd_hackathon_submissions_download_upgraded_report', 'access arguments' => array( 'download code', ), diff --git a/download.inc b/download.inc index 98153b4..6b1ff51 100644 --- a/download.inc +++ b/download.inc @@ -63,4 +63,37 @@ function cfd_hackathon_submissions_project_files() drupal_set_message("There are no case files to download", 'error'); drupal_goto('cfd-hackathon/all-submissions'); } +} + +function cfd_case_study_project_files() { + $proposal_id = arg(3); + $root_path = cfd_hackathon_submissions_path(); + $query = db_select('cfd_hackathon_submitted_abstracts_file'); + $query->fields('cfd_hackathon_submitted_abstracts_file'); + $query->condition('proposal_id', $proposal_id); + $query->condition('filetype', 'A'); + $result = $query->execute(); + $cfd_case_study_project_files = $result->fetchObject(); + $query1 = db_select('cfd_hackathon_proposal'); + $query1->fields('cfd_hackathon_proposal'); + $query1->condition('id', $proposal_id); + $result1 = $query1->execute(); + $case_study = $result1->fetchObject(); + $directory_name = $case_study->directory_name . '/'; + $abstract_file = $cfd_case_study_project_files->filename; + ob_clean(); + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: public"); + header("Content-Description: File Transfer"); + header("Content-Type: application/pdf"); + header('Content-disposition: attachment; filename="' . $abstract_file . '"'); + header("Content-Length: " . filesize($root_path . $directory_name . $abstract_file)); + header("Content-Transfer-Encoding: binary"); + header("Expires: 0"); + header("Pragma: no-cache"); + readfile($root_path . $directory_name . $abstract_file); + ob_end_flush(); + ob_clean(); } \ No newline at end of file diff --git a/run.inc b/run.inc index 5317308..3cf2068 100644 --- a/run.inc +++ b/run.inc @@ -67,7 +67,7 @@ function cfd_hackathon_project_details_callback($form, $form_state) $cfd_case_study_id = $old_case_study_data->case_study_id; $provider = user_load($cfd_hackathon_details->uid); if ($cfd_hackathon_details->uid > 0) { - $commands[] = ajax_command_html('#ajax_selected_cfd_hackathon', l('Download Report of the Upgraded Case Study', "case-study-project/download/project-file/" . $cfd_hackathon_default_value) . '
' . l('Download Upgraded Case Files', 'case-study-project/full-download/project/' . $cfd_hackathon_default_value) . '

' . l('Download the report of the Case Study', "https://cfd.fossee.in/case-study-project/download/project-file/" . $cfd_case_study_id) . '
' . l('Download Case Files of the Original Case Study', 'https://cfd.fossee.in/case-study-project/full-download/project/' . $cfd_case_study_id)); + $commands[] = ajax_command_html('#ajax_selected_cfd_hackathon', l('Download Report of the Upgraded Case Study', "cfd-hackathon/download/upgraded-report/" . $cfd_hackathon_default_value) . '
' . l('Download Upgraded Case Files', 'cfd-hackathon/download/project-files/' . $cfd_hackathon_default_value) . '

' . l('Download the report of the Case Study', "https://cfd.fossee.in/case-study-project/download/project-file/" . $cfd_case_study_id) . '
' . l('Download Case Files of the Original Case Study', 'https://cfd.fossee.in/case-study-project/full-download/project/' . $cfd_case_study_id)); } //$cfd_hackathon_details->uid > 0 else { $commands[] = ajax_command_html('#ajax_selected_cfd_hackathon', ''); @@ -195,7 +195,7 @@ function _cfd_hackathon_details($cfd_hackathon_default_value, $cfd_case_study_id if ($cfd_hackathon_default_value != 0) { $form['cfd_hackathon_details']['#markup'] = '' . '' . '' . ' -
About the Case Study Contributor details during the hackathon
    ' . '
  • Title of the Case Study: ' . $cfd_hackathon_details->project_title . '
  • ' . '
  • Contributor Name: ' . $case_study_details->name_title . ' ' . $case_study_details->contributor_name . '
  • ' . '
  • Version: ' . $case_study_version . '
  • ' . '
  • Faculty Guide: ' . $faculty_name . '
  • ' . '
  • University: ' . $case_study_details->university . '
  • ' . '
    ' . '
  • Contributor Name: ' . $cfd_hackathon_details->name_title . ' ' . $cfd_hackathon_details->contributor_name . '
  • ' . '
  • Version upgraded to: ' . $cfd_hackathon_details->version . '
  • Faculty Guide: ' . $cfd_hackathon_details->faculty_guide_name . '
  • ' . '
  • University: ' . $cfd_hackathon_details->university . '
  • ' . '
' . l('Download the report of the Case Study', "https://cfd.fossee.in/case-study-project/download/project-file/" . $cfd_case_study_id) . '
' . l('Download Case Files of the Original Case Study', 'https://cfd.fossee.in/case-study-project/full-download/project/' . $cfd_case_study_id) . '
' . l('Download Report of the Upgraded Case Study', "case-study-project/download/project-file/" . $cfd_hackathon_default_value) . '
' . l('Download Upgraded Case Files', 'case-study-project/full-download/project/' . $cfd_hackathon_default_value) . '
'; + ' . l('Download Report of the Upgraded Case Study', "cfd-hackathon/download/upgraded-report/" . $cfd_hackathon_default_value) . '
' . l('Download Upgraded Case Files', 'cfd-hackathon/download/project-files/' . $cfd_hackathon_default_value) . ''; $details = $form['cfd_hackathon_details']['#markup']; return $details; } //$cfd_hackathon_default_value != 0 -- cgit From 5ba1b30e1b22af0750ec0eecb39a7c569b5c36e3 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Fri, 2 Feb 2024 18:22:26 +0530 Subject: Update hyperlinks to download upgraded reports and case files --- cfd_hackathon_submissions.module | 16 +++------------- download.inc | 6 ++++-- run.inc | 8 ++++---- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/cfd_hackathon_submissions.module b/cfd_hackathon_submissions.module index bceaafb..2163e2b 100644 --- a/cfd_hackathon_submissions.module +++ b/cfd_hackathon_submissions.module @@ -313,25 +313,15 @@ function cfd_hackathon_submissions_menu() 'file' => 'run.inc', ); $items['cfd-hackathon/download/upgraded-report'] = array( - 'title' => 'Download user defined compound file', - 'description' => 'Download Upgraded report file', - 'page callback' => 'cfd_hackathon_submissions_download_upgraded_report', + 'title' => 'Download Upgraded report', + 'description' => 'Download Upgraded report', + 'page callback' => 'cfd_hackathon_submissions_upgraded_report', 'access arguments' => array( 'download code', ), 'type' => MENU_CALLBACK, 'file' => 'download.inc', ); - $items['cfd-hackathon/download/project-title-file'] = array( - 'title' => 'Download Project Title file', - 'description' => 'Download Project Title file', - 'page callback' => 'download_case_study_project_title_files', - 'access arguments' => array( - 'download code', - ), - 'type' => MENU_CALLBACK, - 'file' => 'available_project_titles_list.inc', - ); $items['cfd-hackathon/download/project-files'] = array( 'title' => 'Download Project file', 'description' => 'Download project file', diff --git a/download.inc b/download.inc index 6b1ff51..5740571 100644 --- a/download.inc +++ b/download.inc @@ -65,8 +65,10 @@ function cfd_hackathon_submissions_project_files() } } -function cfd_case_study_project_files() { +function cfd_hackathon_submissions_upgraded_report() +{ $proposal_id = arg(3); + //var_dump($proposal_id);die; $root_path = cfd_hackathon_submissions_path(); $query = db_select('cfd_hackathon_submitted_abstracts_file'); $query->fields('cfd_hackathon_submitted_abstracts_file'); @@ -80,7 +82,7 @@ function cfd_case_study_project_files() { $result1 = $query1->execute(); $case_study = $result1->fetchObject(); $directory_name = $case_study->directory_name . '/'; - $abstract_file = $cfd_case_study_project_files->filename; + $abstract_file = $cfd_case_study_project_files->filepath; ob_clean(); header("Pragma: public"); header("Expires: 0"); diff --git a/run.inc b/run.inc index 3cf2068..31bad2e 100644 --- a/run.inc +++ b/run.inc @@ -56,15 +56,15 @@ function cfd_hackathon_project_details_callback($form, $form_state) { $commands = array(); $cfd_hackathon_default_value = $form_state['values']['cfd_hackathon']; - if ($cfd_hackathon_default_value != 0) { - $form['cfd_hackathon_details']['#markup'] = _cfd_hackathon_details($cfd_hackathon_default_value, $cfd_case_study_id); - $cfd_hackathon_details = _cfd_hackathon_information($cfd_hackathon_default_value); - $query = db_select('available_hackathon_project_titles'); + $cfd_hackathon_details = _cfd_hackathon_information($cfd_hackathon_default_value); + $query = db_select('available_hackathon_project_titles'); $query->fields('available_hackathon_project_titles'); $query->condition('project_title', $cfd_hackathon_details->project_title); $old_case_study_q = $query->execute(); $old_case_study_data = $old_case_study_q->fetchObject(); $cfd_case_study_id = $old_case_study_data->case_study_id; + if ($cfd_hackathon_default_value != 0) { + $form['cfd_hackathon_details']['#markup'] = _cfd_hackathon_details($cfd_hackathon_default_value, $cfd_case_study_id); $provider = user_load($cfd_hackathon_details->uid); if ($cfd_hackathon_details->uid > 0) { $commands[] = ajax_command_html('#ajax_selected_cfd_hackathon', l('Download Report of the Upgraded Case Study', "cfd-hackathon/download/upgraded-report/" . $cfd_hackathon_default_value) . '
' . l('Download Upgraded Case Files', 'cfd-hackathon/download/project-files/' . $cfd_hackathon_default_value) . '

' . l('Download the report of the Case Study', "https://cfd.fossee.in/case-study-project/download/project-file/" . $cfd_case_study_id) . '
' . l('Download Case Files of the Original Case Study', 'https://cfd.fossee.in/case-study-project/full-download/project/' . $cfd_case_study_id)); -- cgit