summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcfd_case_study.module1247
-rwxr-xr-xemail.inc353
-rwxr-xr-xmanage_proposal.inc1991
-rwxr-xr-xupload_code.inc937
4 files changed, 2404 insertions, 2124 deletions
diff --git a/cfd_case_study.module b/cfd_case_study.module
index 89cf6df..dde2929 100755
--- a/cfd_case_study.module
+++ b/cfd_case_study.module
@@ -3,699 +3,710 @@
/*error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);*/
-require_once('general_deletion.inc');
-require_once('email.inc');
+require_once 'general_deletion.inc';
+require_once 'email.inc';
/**
* Implementation of hook_menu().
*/
function cfd_case_study_menu()
{
- $items = array();
- /* PROPOSAL */
- $items['case-study-project/add-project-title'] = array(
- 'title'=> 'Add new project titles',
- 'description'=> 'Add new project titles',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'add_project_title_form'
- ),
- 'access arguments'=> array(
- 'Case Study add project titles'
- ),
- 'type'=> MENU_NORMAL_ITEM,
- 'file'=> 'add_project_titles.inc'
- );
- $items['case-study-project/proposal'] = array(
- 'title'=> 'Case Study Proposal Form',
- 'description'=> 'Case Study Proposal Form',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'cfd_case_study_proposal_form'
- ),
- 'access arguments'=> array(
- 'Case Study create proposal'
- ),
- 'type'=> MENU_NORMAL_ITEM,
- 'file'=> 'proposal.inc'
- );
- $items['case-study-project/manage-proposal'] = array(
- 'title'=> 'Manage Case Study Proposals',
- 'description'=> 'Manage Case StudyProposals',
- 'page callback'=> 'cfd_case_study_proposal_pending',
- 'access callback'=> 'user_access',
- 'access arguments'=> array(
- 'Case Study manage proposal'
- ),
- 'file'=> 'manage_proposal.inc'
- );
- $items['case-study-project/manage-proposal/pending'] = array(
- 'title'=> 'Pending Proposals',
- 'description'=> 'Pending Case Study Proposals Queue',
- 'page callback'=> 'cfd_case_study_proposal_pending',
- 'access callback'=> 'user_access',
- 'access arguments'=> array(
- 'Case Study manage proposal'
- ),
- 'type'=> MENU_DEFAULT_LOCAL_TASK,
- 'weight'=> 1,
- 'file'=> 'manage_proposal.inc'
- );
- $items['case-study-project/manage-proposal/all'] = array(
- 'title'=> 'All Proposals',
- 'description'=> 'All Proposals',
- 'page callback'=> 'cfd_case_study_proposal_all',
- 'access callback'=> 'user_access',
- 'access arguments'=> array(
- 'Case Study manage proposal'
- ),
- 'type'=> MENU_LOCAL_TASK,
- 'weight'=> 4,
- 'file'=> 'manage_proposal.inc'
- );
- $items['case-study-project/manage-proposal/approve'] = array(
- 'title'=> 'Approve Proposal',
- 'description'=> 'Approve Proposal',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'cfd_case_study_proposal_approval_form'
- ),
- 'access arguments'=> array(
- 'Case Study manage proposal'
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'manage_proposal.inc'
- );
- $items['case-study-project/manage-proposal/edit'] = array(
- 'title'=> 'Edit Proposal',
- 'description'=> 'Edit Proposal',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'cfd_case_study_proposal_edit_form'
- ),
- 'access arguments'=> array(
- 'Case Study manage proposal'
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'manage_proposal.inc'
- );
- $items['case-study-project/manage-proposal/status'] = array(
- 'title'=> 'Proposal Status',
- 'description'=> 'Proposal Status',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'cfd_case_study_proposal_status_form'
- ),
- 'access arguments'=> array(
- 'Case Study approve proposal'
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'manage_proposal.inc'
- );
- $items['case-study-project/abstract-approval/bulk'] = array(
- 'title'=> 'CS Manage Code',
- 'description'=> 'Bulk Mangage',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'cfd_case_study_abstract_bulk_approval_form'
- ),
- 'access arguments'=> array(
- 'Case Study bulk manage abstract'
- ),
- 'type'=> MENU_LOCAL_TASK,
- 'weight'=> 2,
- 'file'=> 'abstract_bulk_approval.inc'
- );
- /* CODE UPLOAD */
- /* CODE UPLOAD */
- $items['case-study-project/abstract-code'] = array(
- 'title'=> 'Case Study Project Directory Submission',
- 'description'=> 'Abstract Submission',
- 'page callback'=> 'cfd_case_study_abstract',
- 'access callback'=> 'user_access',
- 'access arguments'=> array(
- 'Case Study upload abstract'
- ),
- 'file'=> 'upload_code.inc'
- );
- $items['case-study-project/abstract-code/upload'] = array(
- 'title'=> 'Case Study Project Directory Submission',
- 'description'=> 'Project Upload',
- 'page callback'=> 'drupal_get_form',
- 'access callback'=> 'user_access',
- 'page arguments'=> array(
- 'cfd_case_study_upload_abstract_code_form'
- ),
- 'access arguments'=> array(
- 'Case Study upload abstract'
- ),
- 'type'=> MENU_LOCAL_TASK,
- 'file'=> 'upload_code.inc',
- 'weight'=> 2
- );
- $items['case-study-project/abstract-code/delete'] = array(
- 'title'=> 'Delete Solution',
- 'description'=> 'Delete Solution',
- 'page callback'=> 'cfd_case_study_upload_code_delete',
- 'access arguments'=> array(
- 'Case Study upload code'
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'upload_code_delete.inc'
- );
- /* CODE DOWNLOADS */
- $items['case-study-project/full-download/project'] = array(
- 'title'=> 'Code Download',
- 'description'=> 'Code Download',
- 'page callback'=> 'cfd_case_study_download_full_project',
- 'access arguments'=> array(
- 'Case Study download code'
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'full_download.inc'
- );
- /* COMPLETED Case studies */
- $items['case-study-project/completed-case-studies'] = array(
- 'title'=> 'Completed Case studies',
- 'page callback'=> 'cfd_case_study_completed_proposals_all',
- 'access arguments'=> array(
- 'Case Study download code'
- ),
- 'file'=> 'cfd_case_study_details.inc'
- );
- /* LABS IN PROGRESS */
- $items['case-study-project/case-study-progress'] = array(
- 'title'=> 'Case studies in Progress',
- 'page callback'=> 'cfd_case_study_progress_all',
- 'access arguments'=> array(
- 'Case Study download code'
- ),
- 'file'=> 'cfd_case_study_details.inc'
- );
- $items['case-study-project/list-of-project-titles'] = array(
- 'title'=> 'List of available Project titles',
- 'page callback'=> 'list_of_available_project_titles',
- 'access arguments'=> array(
- 'Case Study Project titles list'
- ),
- 'file'=> 'available_project_titles_list.inc'
- );
- /* DOWNLOAD FOR EVERYONE */
- $items['case-study-project/case-study-run'] = array(
- 'title'=> 'Download Codes',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'cfd_case_study_run_form'
- ),
- 'access arguments'=> array(
- 'Case Study download code'
- ),
- 'type'=> MENU_NORMAL_ITEM,
- 'file'=> 'run.inc'
- );
- $items['case-study-project/download/resource-file'] = array(
- 'title'=> 'Download user defined compound file',
- 'description'=> 'Download resource file',
- 'page callback'=> 'cfd_case_study_download_upload_file',
- 'access arguments'=> array(
- 'download code'
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'download.inc'
- );
- $items['case-study-project/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['case-study-project/download/project-file'] = array(
- 'title'=> 'Download Project file',
- 'description'=> 'Download project file',
- 'page callback'=> 'cfd_case_study_project_files',
- 'access arguments'=> array(
- 'download code'
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'download.inc'
- );
- /* ADMIN SETTINGS */
- $items['admin/settings/case-study'] = array(
- 'title'=> 'Case Study Settings',
- 'description'=> 'Case Study Settings',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'cfd_case_study_settings_form'
- ),
- 'access arguments'=> array(
- 'administer Case Study'
- ),
- 'type'=> MENU_NORMAL_ITEM,
- 'file'=> 'settings.inc'
- );
- /* AJAX REQUEST */
- $items['case-study-project/certificates'] = array(
- 'title'=> 'List of Case Study Certificates',
- 'description'=> 'List of Case Study Certificates',
- 'page callback'=> '_list_case_study_certificates',
- 'access arguments'=> array(
- 'list Case Study certificates'
- ),
- 'file'=> 'pdf/list_case_study_certificate.inc'
- );
- $items['case-study-project/certificates/generate-pdf'] = array(
- 'title'=> 'Download Certificate',
- 'description'=> 'Download Certificate',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'generate_pdf'
- ),
- 'type'=> MENU_CALLBACK,
- 'access arguments'=> array(
- 'generate pdf'
- ),
- 'file'=> 'pdf/cert_new.inc'
- );
- /*$items['case-study-project/certificates-custom'] = array(
- 'title'=> 'List of Case Study Custom Certificates',
- 'description'=> 'List of Case Study Custom Certificates',
- 'page callback'=> '_list_cfd_case_study_custom_certificates',
- 'access arguments'=> array(
- 'list Case Study custom certificates'
- ),
- 'file'=> 'pdf/list_mentor_certificates.inc'
- );
- $items['case-study-project/certificates-custom/pdf'] = array(
- 'title'=> 'Download Certificate',
- 'description'=> 'Download Certificate',
- 'page callback'=> 'drupal_get_form',
- 'page arguments'=> array(
- 'generate_pdf'
- ),
- 'type'=> MENU_CALLBACK,
- 'access arguments'=> array(
- 'generate pdf'
- ),
- 'file'=> 'pdf/mentor_cert_pdf.inc'
- ); */
- $items['case-study-project/certificates/verify'] = array(
- "title" => "Certificate Verification",
- "page callback" => "verify_certificates",
- 'page arguments'=> array(
- 'verify_certificates'
- ),
- "access arguments" => array(
- "verify certificates"
- ),
- 'type'=> MENU_CALLBACK,
- 'file'=> 'pdf/verify_certificates.inc'
- );
- return $items;
+ $items = array();
+ /* PROPOSAL */
+ $items['case-study-project/add-project-title'] = array(
+ 'title' => 'Add new project titles',
+ 'description' => 'Add new project titles',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'add_project_title_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study add project titles',
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'add_project_titles.inc',
+ );
+ $items['case-study-project/proposal'] = array(
+ 'title' => 'Case Study Proposal Form',
+ 'description' => 'Case Study Proposal Form',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'cfd_case_study_proposal_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study create proposal',
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'proposal.inc',
+ );
+ $items['case-study-project/manage-proposal'] = array(
+ 'title' => 'Manage Case Study Proposals',
+ 'description' => 'Manage Case StudyProposals',
+ 'page callback' => 'cfd_case_study_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'Case Study manage proposal',
+ ),
+ 'file' => 'manage_proposal.inc',
+ );
+ $items['case-study-project/manage-proposal/pending'] = array(
+ 'title' => 'Pending Proposals',
+ 'description' => 'Pending Case Study Proposals Queue',
+ 'page callback' => 'cfd_case_study_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'Case Study manage proposal',
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'manage_proposal.inc',
+ );
+ $items['case-study-project/manage-proposal/all'] = array(
+ 'title' => 'All Proposals',
+ 'description' => 'All Proposals',
+ 'page callback' => 'cfd_case_study_proposal_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'Case Study manage proposal',
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4,
+ 'file' => 'manage_proposal.inc',
+ );
+ $items['case-study-project/manage-proposal/edit-upload-file'] = array(
+ 'title' => 'Edit code files',
+ 'description' => 'Edit code files',
+ 'page callback' => 'cfd_case_study_proposal_edit_file_all',
+ 'access callback' => 'Case Study approve abstract',
+ 'access arguments' => array(
+ 'Case Study manage proposal',
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4,
+ 'file' => 'manage_proposal.inc',
+ );
+ $items['case-study-project/manage-proposal/approve'] = array(
+ 'title' => 'Approve Proposal',
+ 'description' => 'Approve Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'cfd_case_study_proposal_approval_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study manage proposal',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc',
+ );
+ $items['case-study-project/manage-proposal/edit'] = array(
+ 'title' => 'Edit Proposal',
+ 'description' => 'Edit Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'cfd_case_study_proposal_edit_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study manage proposal',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc',
+ );
+ $items['case-study-project/manage-proposal/status'] = array(
+ 'title' => 'Proposal Status',
+ 'description' => 'Proposal Status',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'cfd_case_study_proposal_status_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study approve proposal',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc',
+ );
+ $items['case-study-project/abstract-approval/bulk'] = array(
+ 'title' => 'CS Manage Code',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'cfd_case_study_abstract_bulk_approval_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study bulk manage abstract',
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'abstract_bulk_approval.inc',
+ );
+ /* CODE UPLOAD */
+ $items['case-study-project/abstract-code/edit-upload-files'] = array(
+ 'title' => 'Case Study Project Directory edit uploaded files for proposal',
+ 'description' => 'Project Edit Upload',
+ 'page callback' => 'drupal_get_form',
+ 'access callback' => 'Case Study approve abstract',
+ 'page arguments' => array(
+ 'cfd_case_study_edit_upload_abstract_code_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study upload abstract',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 2,
+ );
+ $items['case-study-project/abstract-code'] = array(
+ 'title' => 'Case Study Project Directory Submission',
+ 'description' => 'Abstract Submission',
+ 'page callback' => 'cfd_case_study_abstract',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'Case Study upload abstract',
+ ),
+ 'file' => 'upload_code.inc',
+ );
+ $items['case-study-project/abstract-code/upload'] = array(
+ 'title' => 'Case Study Project Directory Submission',
+ 'description' => 'Project Upload',
+ 'page callback' => 'drupal_get_form',
+ 'access callback' => 'user_access',
+ 'page arguments' => array(
+ 'cfd_case_study_upload_abstract_code_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study upload abstract',
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 2,
+ );
+ $items['case-study-project/abstract-code/delete'] = array(
+ 'title' => 'Delete Solution',
+ 'description' => 'Delete Solution',
+ 'page callback' => 'cfd_case_study_upload_code_delete',
+ 'access arguments' => array(
+ 'Case Study upload code',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'upload_code_delete.inc',
+ );
+ /* CODE DOWNLOADS */
+ $items['case-study-project/full-download/project'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'cfd_case_study_download_full_project',
+ 'access arguments' => array(
+ 'Case Study download code',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc',
+ );
+ /* COMPLETED Case studies */
+ $items['case-study-project/completed-case-studies'] = array(
+ 'title' => 'Completed Case studies',
+ 'page callback' => 'cfd_case_study_completed_proposals_all',
+ 'access arguments' => array(
+ 'Case Study download code',
+ ),
+ 'file' => 'cfd_case_study_details.inc',
+ );
+ /* LABS IN PROGRESS */
+ $items['case-study-project/case-study-progress'] = array(
+ 'title' => 'Case studies in Progress',
+ 'page callback' => 'cfd_case_study_progress_all',
+ 'access arguments' => array(
+ 'Case Study download code',
+ ),
+ 'file' => 'cfd_case_study_details.inc',
+ );
+ $items['case-study-project/list-of-project-titles'] = array(
+ 'title' => 'List of available Project titles',
+ 'page callback' => 'list_of_available_project_titles',
+ 'access arguments' => array(
+ 'Case Study Project titles list',
+ ),
+ 'file' => 'available_project_titles_list.inc',
+ );
+ /* DOWNLOAD FOR EVERYONE */
+ $items['case-study-project/case-study-run'] = array(
+ 'title' => 'Download Codes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'cfd_case_study_run_form',
+ ),
+ 'access arguments' => array(
+ 'Case Study download code',
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'run.inc',
+ );
+ $items['case-study-project/download/resource-file'] = array(
+ 'title' => 'Download user defined compound file',
+ 'description' => 'Download resource file',
+ 'page callback' => 'cfd_case_study_download_upload_file',
+ 'access arguments' => array(
+ 'download code',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc',
+ );
+ $items['case-study-project/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['case-study-project/download/project-file'] = array(
+ 'title' => 'Download Project file',
+ 'description' => 'Download project file',
+ 'page callback' => 'cfd_case_study_project_files',
+ 'access arguments' => array(
+ 'download code',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc',
+ );
+ /* ADMIN SETTINGS */
+ $items['admin/settings/case-study'] = array(
+ 'title' => 'Case Study Settings',
+ 'description' => 'Case Study Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'cfd_case_study_settings_form',
+ ),
+ 'access arguments' => array(
+ 'administer Case Study',
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'settings.inc',
+ );
+ /* AJAX REQUEST */
+ $items['case-study-project/certificates'] = array(
+ 'title' => 'List of Case Study Certificates',
+ 'description' => 'List of Case Study Certificates',
+ 'page callback' => '_list_case_study_certificates',
+ 'access arguments' => array(
+ 'list Case Study certificates',
+ ),
+ 'file' => 'pdf/list_case_study_certificate.inc',
+ );
+ $items['case-study-project/certificates/generate-pdf'] = array(
+ 'title' => 'Download Certificate',
+ 'description' => 'Download Certificate',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'generate_pdf',
+ ),
+ 'type' => MENU_CALLBACK,
+ 'access arguments' => array(
+ 'generate pdf',
+ ),
+ 'file' => 'pdf/cert_new.inc',
+ );
+ /*$items['case-study-project/certificates-custom'] = array(
+ 'title'=> 'List of Case Study Custom Certificates',
+ 'description'=> 'List of Case Study Custom Certificates',
+ 'page callback'=> '_list_cfd_case_study_custom_certificates',
+ 'access arguments'=> array(
+ 'list Case Study custom certificates'
+ ),
+ 'file'=> 'pdf/list_mentor_certificates.inc'
+ );
+ $items['case-study-project/certificates-custom/pdf'] = array(
+ 'title'=> 'Download Certificate',
+ 'description'=> 'Download Certificate',
+ 'page callback'=> 'drupal_get_form',
+ 'page arguments'=> array(
+ 'generate_pdf'
+ ),
+ 'type'=> MENU_CALLBACK,
+ 'access arguments'=> array(
+ 'generate pdf'
+ ),
+ 'file'=> 'pdf/mentor_cert_pdf.inc'
+ ); */
+ $items['case-study-project/certificates/verify'] = array(
+ "title" => "Certificate Verification",
+ "page callback" => "verify_certificates",
+ 'page arguments' => array(
+ 'verify_certificates',
+ ),
+ "access arguments" => array(
+ "verify certificates",
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'pdf/verify_certificates.inc',
+ );
+ return $items;
}
/**
* Implementation of hook_perm().
*/
function cfd_case_study_permission()
{
- return array(
- 'Case Study add project titles'=> array(
- 'title'=> t('Case Study add project titles'),
- 'restrict access'=> TRUE
- ),
- 'Case Study create proposal'=> array(
- 'title'=> t('Case Study create proposal'),
- 'restrict access'=> TRUE
- ),
- 'Case Study manage proposal'=> array(
- 'title'=> t('Case Study manage proposal'),
- 'restrict access'=> TRUE
- ),
- 'Case Study edit proposal'=> array(
- 'title'=> t('Case Study edit proposal'),
- 'restrict access'=> TRUE
- ),
- 'Case Study approve proposal'=> array(
- 'title'=> t('Case Study approve proposal'),
- 'restrict access'=> TRUE
- ),
- 'Case Study propose solution'=> array(
- 'title'=> t('Case Study propose solution'),
- 'restrict access'=> TRUE
- ),
- 'Case Study Project titles list'=> array(
- 'title'=> t('Case Study Project titles list'),
- 'restrict access'=> TRUE
- ),
- 'Case Study approve abstract'=> array(
- 'title'=> t('Case Study approve code'),
- 'restrict access'=> TRUE
- ),
- 'Case Study bulk manage abstract'=> array(
- 'title'=> t('Case Study bulk manage abstract'),
- 'restrict access'=> TRUE
- ),
- 'Case Study bulk delete abstract'=> array(
- 'title'=> t('Case Study bulk delete code'),
- 'restrict access'=> TRUE
- ),
- 'Case Study upload abstract'=> array(
- 'title'=> t('Case Study upload code'),
- 'restrict access'=> TRUE
- ),
- 'Case Study download code'=> array(
- 'title'=> t('Case Study download code'),
- 'restrict access'=> TRUE
- ),
- 'administer Case Study'=> array(
- 'title'=> t('administer Case Study'),
- 'restrict access'=> TRUE
- ),
- 'Case Study generate abstract'=> array(
- 'title'=> t('Case Study generate abstract'),
- 'restrict access'=> TRUE
- ),
- "list Case Study certificates" => array(
- "title" => t("list the certificates"),
- "description" => t("list the certificates"),
- 'restrict access'=> TRUE
- ),
- "list Case Study custom certificates" => array(
- "title" => t("list the mentor certificates"),
- "description" => t("list the mentor certificates"),
- 'restrict access'=> TRUE
- ),
- "verify certificates" => array(
- "title" => t("verify the certificates"),
- "description" => t("verify the certificates"),
- 'restrict access'=> TRUE
- )
+ return array(
+ 'Case Study add project titles' => array(
+ 'title' => t('Case Study add project titles'),
+ 'restrict access' => true,
+ ),
+ 'Case Study create proposal' => array(
+ 'title' => t('Case Study create proposal'),
+ 'restrict access' => true,
+ ),
+ 'Case Study manage proposal' => array(
+ 'title' => t('Case Study manage proposal'),
+ 'restrict access' => true,
+ ),
+ 'Case Study edit proposal' => array(
+ 'title' => t('Case Study edit proposal'),
+ 'restrict access' => true,
+ ),
+ 'Case Study approve proposal' => array(
+ 'title' => t('Case Study approve proposal'),
+ 'restrict access' => true,
+ ),
+ 'Case Study propose solution' => array(
+ 'title' => t('Case Study propose solution'),
+ 'restrict access' => true,
+ ),
+ 'Case Study Project titles list' => array(
+ 'title' => t('Case Study Project titles list'),
+ 'restrict access' => true,
+ ),
+ 'Case Study approve abstract' => array(
+ 'title' => t('Case Study approve code'),
+ 'restrict access' => true,
+ ),
+ 'Case Study bulk manage abstract' => array(
+ 'title' => t('Case Study bulk manage abstract'),
+ 'restrict access' => true,
+ ),
+ 'Case Study bulk delete abstract' => array(
+ 'title' => t('Case Study bulk delete code'),
+ 'restrict access' => true,
+ ),
+ 'Case Study upload abstract' => array(
+ 'title' => t('Case Study upload code'),
+ 'restrict access' => true,
+ ),
+ 'Case Study download code' => array(
+ 'title' => t('Case Study download code'),
+ 'restrict access' => true,
+ ),
+ 'administer Case Study' => array(
+ 'title' => t('administer Case Study'),
+ 'restrict access' => true,
+ ),
+ 'Case Study generate abstract' => array(
+ 'title' => t('Case Study generate abstract'),
+ 'restrict access' => true,
+ ),
+ "list Case Study certificates" => array(
+ "title" => t("list the certificates"),
+ "description" => t("list the certificates"),
+ 'restrict access' => true,
+ ),
+ "list Case Study custom certificates" => array(
+ "title" => t("list the mentor certificates"),
+ "description" => t("list the mentor certificates"),
+ 'restrict access' => true,
+ ),
+ "verify certificates" => array(
+ "title" => t("verify the certificates"),
+ "description" => t("verify the certificates"),
+ 'restrict access' => true,
+ ),
- );
+ );
}
/*************************** VALIDATION FUNCTIONS *****************************/
function cfd_case_study_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;
+ if (!preg_match('/^[0-9a-zA-Z\.\_]+$/', $file_name)) {
+ return false;
+ } else if (substr_count($file_name, ".") > 1) {
+ return false;
+ } else {
+ return true;
+ }
+
}
function cfd_case_study_check_name($name = '')
{
- if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
- return FALSE;
- else
- return TRUE;
+ if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name)) {
+ return false;
+ } else {
+ return true;
+ }
+
}
function cfd_case_study_check_code_number($number = '')
{
- if (!preg_match('/^[0-9]+$/', $number))
- return FALSE;
- else
- return TRUE;
+ if (!preg_match('/^[0-9]+$/', $number)) {
+ return false;
+ } else {
+ return true;
+ }
+
}
function cfd_case_study_path()
{
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/case_study_uploads/';
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/case_study_uploads/';
}
-function cfd_case_study_file_path($value='')
+function cfd_case_study_file_path($value = '')
{
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/';
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/';
}
-function cfd_case_study_project_titles_resource_file_path() {
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/case_project_titles_resource_files/';
+function cfd_case_study_project_titles_resource_file_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/case_project_titles_resource_files/';
}
/************************* USER VERIFICATION FUNCTIONS ************************/
function cfd_case_study_get_proposal()
{
- global $user;
- $query = db_select('case_study_proposal');
- $query->fields('case_study_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)
- {
- drupal_set_message("You do not have any approved Case Study proposal. Please propose a Case Study", 'error');
- drupal_goto('');
- } //!$proposal_data
- 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;
- } //$proposal_data->approval_status
- return FALSE;
+ global $user;
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_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) {
+ drupal_set_message("You do not have any approved Case Study proposal. Please propose a Case Study", 'error');
+ drupal_goto('');
+ } //!$proposal_data
+ 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;
+ } //$proposal_data->approval_status
+ return false;
}
/*************************************************************************/
/***** 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)));
- } //strpos($string, $delimiter) !== false
- } //array( '-', '\'') as $delimiter
- return $string;
+$string = ucwords(strtolower($string));
+foreach (array(
+'-',
+'\''
+) as $delimiter)
+{
+if (strpos($string, $delimiter) !== false)
+{
+$string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+} //strpos($string, $delimiter) !== false
+} //array( '-', '\'') as $delimiter
+return $string;
}*/
function _df_sentence_case($string)
{
- $string = ucwords(strtolower($string));
- foreach (array(
- '-',
- '\''
- ) as $delimiter)
- {
- if (strpos($string, $delimiter) !== false)
- {
- $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
- } //strpos($string, $delimiter) !== false
- } //array( '-', '\'') as $delimiter
- return $string;
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\'',
+ ) as $delimiter) {
+ if (strpos($string, $delimiter) !== false) {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ } //strpos($string, $delimiter) !== false
+ } //array( '-', '\'') as $delimiter
+ return $string;
}
function _df_list_of_states()
{
- $states = array(
- 0 => '-Select-'
- );
- $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;
- } //$states_list_data = $states_list->fetchObject()
- return $states;
+ $states = array(
+ 0 => '-Select-',
+ );
+ $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;
+ } //$states_list_data = $states_list->fetchObject()
+ return $states;
}
function _df_list_of_cities()
{
- $city = array(
- 0 => '-Select-'
- );
- $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;
- } //$city_list_data = $city_list->fetchObject()
- return $city;
+ $city = array(
+ 0 => '-Select-',
+ );
+ $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;
+ } //$city_list_data = $city_list->fetchObject()
+ return $city;
}
function _df_list_of_pincodes()
{
- $pincode = array(
- 0 => '-Select-'
- );
- $query = db_select('list_of_all_india_pincode');
- $query->fields('list_of_all_india_pincode');
- $query->orderBy('pincode', 'ASC');
- $pincode_list = $query->execute();
- while ($pincode_list_data = $pincode_list->fetchObject())
- {
- $pincode[$pincode_list_data->pincode] = $pincode_list_data->pincode;
- } //$pincode_list_data = $pincode_list->fetchObject()
- return $pincode;
+ $pincode = array(
+ 0 => '-Select-',
+ );
+ $query = db_select('list_of_all_india_pincode');
+ $query->fields('list_of_all_india_pincode');
+ $query->orderBy('pincode', 'ASC');
+ $pincode_list = $query->execute();
+ while ($pincode_list_data = $pincode_list->fetchObject()) {
+ $pincode[$pincode_list_data->pincode] = $pincode_list_data->pincode;
+ } //$pincode_list_data = $pincode_list->fetchObject()
+ return $pincode;
}
function _df_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;
- } //$department_list_data = $department_list->fetchObject()
- return $department;
+ $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;
+ } //$department_list_data = $department_list->fetchObject()
+ return $department;
}
function _cs_list_of_case_studies()
{
- $existing_case_studies = array();
- $result = db_query("SELECT * from list_of_project_titles WHERE {project_title_name} NOT IN( SELECT project_title from case_study_proposal WHERE approval_status = 0 OR approval_status = 1 OR approval_status = 3)");
- while ($case_study_list_data = $result->fetchObject())
- {
- $existing_case_studies[$case_study_list_data->project_title_name] = $case_study_list_data->project_title_name;
- }
- return $existing_case_studies;
+ $existing_case_studies = array();
+ $result = db_query("SELECT * from list_of_project_titles WHERE {project_title_name} NOT IN( SELECT project_title from case_study_proposal WHERE approval_status = 0 OR approval_status = 1 OR approval_status = 3)");
+ while ($case_study_list_data = $result->fetchObject()) {
+ $existing_case_studies[$case_study_list_data->project_title_name] = $case_study_list_data->project_title_name;
+ }
+ return $existing_case_studies;
}
function _df_dir_name($project, $proposar_name)
{
- $project_title = ucname($project);
- $proposar_name = ucname($proposar_name);
- $dir_name = $project_title . ' By '. $proposar_name;
- $directory_name = str_replace("__", "_", str_replace(" ", "_", str_replace("/","_", trim($dir_name))));
- return $directory_name;
+ $project_title = ucname($project);
+ $proposar_name = ucname($proposar_name);
+ $dir_name = $project_title . ' By ' . $proposar_name;
+ $directory_name = str_replace("__", "_", str_replace(" ", "_", str_replace("/", "_", trim($dir_name))));
+ return $directory_name;
}
function cfd_case_study_document_path()
{
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/case_study_uploads/';
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/case_study_uploads/';
}
function DF_RenameDir($proposal_id, $dir_name)
{
- $proposal_id = $proposal_id;
- $dir_name = $dir_name;
- $query = db_query("SELECT directory_name,id FROM case_study_proposal WHERE id = :proposal_id", array(
- ':proposal_id'=> $proposal_id
- ));
- $result = $query->fetchObject();
- if ($result != NULL)
- {
- $files = scandir(cfd_case_study_path());
- $files_id_dir = cfd_case_study_path() . $result->id;
- //var_dump($files);die;
- $file_dir = cfd_case_study_path() . $result->directory_name;
- if (is_dir($file_dir))
- {
- $new_directory_name = rename(cfd_case_study_path() . $result->directory_name, cfd_case_study_path() . $dir_name);
- return $new_directory_name;
- } //is_dir($file_dir)
- else if (is_dir($files_id_dir))
- {
- $new_directory_name = rename(cfd_case_study_path() . $result->id, cfd_case_study_path() . $dir_name);
- return $new_directory_name;
- } //is_dir($files_id_dir)
- else
- {
- drupal_set_message('Directory not available for rename.');
- return;
- }
- } //$result != NULL
- else
- {
- drupal_set_message('Project directory name not present in databse');
- return;
- }
- return;
+ $proposal_id = $proposal_id;
+ $dir_name = $dir_name;
+ $query = db_query("SELECT directory_name,id FROM case_study_proposal WHERE id = :proposal_id", array(
+ ':proposal_id' => $proposal_id,
+ ));
+ $result = $query->fetchObject();
+ if ($result != null) {
+ $files = scandir(cfd_case_study_path());
+ $files_id_dir = cfd_case_study_path() . $result->id;
+ //var_dump($files);die;
+ $file_dir = cfd_case_study_path() . $result->directory_name;
+ if (is_dir($file_dir)) {
+ $new_directory_name = rename(cfd_case_study_path() . $result->directory_name, cfd_case_study_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($file_dir)
+ else if (is_dir($files_id_dir)) {
+ $new_directory_name = rename(cfd_case_study_path() . $result->id, cfd_case_study_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($files_id_dir)
+ else {
+ drupal_set_message('Directory not available for rename.');
+ return;
+ }
+ } //$result != NULL
+ else {
+ drupal_set_message('Project directory name not present in databse');
+ return;
+ }
+ return;
}
function CreateReadmeFileCaseStudyProject($proposal_id)
{
- $result = db_query("
+ $result = db_query("
SELECT * from case_study_proposal WHERE id = :proposal_id", array(
- ":proposal_id" => $proposal_id
- ));
- $proposal_data = $result->fetchObject();
- $root_path = cfd_case_study_path();
- $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!");
- $txt = "";
- $txt .= "About the Case Study";
- $txt .= "\n" . "\n";
- $txt .= "Title Of The Case Study Project: " . $proposal_data->project_title . "\n";
- $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->contributor_name . "\n";
- $txt .= "University: " . $proposal_data->university . "\n";
- $txt .= "\n" . "\n";
- $txt .= " Case Study Project By FOSSEE, IIT Bombay" . "\n";
- fwrite($readme_file, $txt);
- fclose($readme_file);
- return $txt;
+ ":proposal_id" => $proposal_id,
+ ));
+ $proposal_data = $result->fetchObject();
+ $root_path = cfd_case_study_path();
+ $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!");
+ $txt = "";
+ $txt .= "About the Case Study";
+ $txt .= "\n" . "\n";
+ $txt .= "Title Of The Case Study Project: " . $proposal_data->project_title . "\n";
+ $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->contributor_name . "\n";
+ $txt .= "University: " . $proposal_data->university . "\n";
+ $txt .= "\n" . "\n";
+ $txt .= " Case Study Project By FOSSEE, IIT Bombay" . "\n";
+ fwrite($readme_file, $txt);
+ fclose($readme_file);
+ return $txt;
}
function rrmdir_project($prop_id)
{
- $proposal_id = $prop_id;
- $result = db_query("SELECT * from case_study_proposal WHERE id = :proposal_id", array(
- ":proposal_id" => $proposal_id
- ));
- $proposal_data = $result->fetchObject();
- $root_path = cfd_case_study_document_path();
- $dir = $root_path . $proposal_data->directory_name;
- if ($proposal_data->id == $prop_id)
- {
- if (is_dir($dir))
- {
- $objects = scandir($dir);
- foreach ($objects as $object)
- {
- if ($object != "." && $object != "..")
- {
- if (filetype($dir . "/" . $object) == "dir")
- {
- rrmdir($dir . "/" . $object);
- } //filetype($dir . "/" . $object) == "dir"
- else
- {
- unlink($dir . "/" . $object);
- }
- } //$object != "." && $object != ".."
- } //$objects as $object
- reset($objects);
- rmdir($dir);
- $msg = drupal_set_message("Directory deleted successfully");
- return $msg;
- } //is_dir($dir)
- $msg = drupal_set_message("Directory not present");
- return $msg;
- } //$proposal_data->id == $prop_id
- else
- {
- $msg = drupal_set_message("Data not found");
- return $msg;
- }
+ $proposal_id = $prop_id;
+ $result = db_query("SELECT * from case_study_proposal WHERE id = :proposal_id", array(
+ ":proposal_id" => $proposal_id,
+ ));
+ $proposal_data = $result->fetchObject();
+ $root_path = cfd_case_study_document_path();
+ $dir = $root_path . $proposal_data->directory_name;
+ if ($proposal_data->id == $prop_id) {
+ if (is_dir($dir)) {
+ $objects = scandir($dir);
+ foreach ($objects as $object) {
+ if ($object != "." && $object != "..") {
+ if (filetype($dir . "/" . $object) == "dir") {
+ rrmdir($dir . "/" . $object);
+ } //filetype($dir . "/" . $object) == "dir"
+ else {
+ unlink($dir . "/" . $object);
+ }
+ } //$object != "." && $object != ".."
+ } //$objects as $object
+ reset($objects);
+ rmdir($dir);
+ $msg = drupal_set_message("Directory deleted successfully");
+ return $msg;
+ } //is_dir($dir)
+ $msg = drupal_set_message("Directory not present");
+ return $msg;
+ } //$proposal_data->id == $prop_id
+ else {
+ $msg = drupal_set_message("Data not found");
+ return $msg;
+ }
}
function rrmdir($dir)
{
- if (is_dir($dir))
- {
- $objects = scandir($dir);
- foreach ($objects as $object)
- {
- if ($object != "." && $object != "..")
- {
- if (filetype($dir . "/" . $object) == "dir")
- rrmdir($dir . "/" . $object);
- else
- unlink($dir . "/" . $object);
- } //$object != "." && $object != ".."
- } //$objects as $object
- reset($objects);
- rmdir($dir);
- } //is_dir($dir)
+ if (is_dir($dir)) {
+ $objects = scandir($dir);
+ foreach ($objects as $object) {
+ if ($object != "." && $object != "..") {
+ if (filetype($dir . "/" . $object) == "dir") {
+ rrmdir($dir . "/" . $object);
+ } else {
+ unlink($dir . "/" . $object);
+ }
+
+ } //$object != "." && $object != ".."
+ } //$objects as $object
+ reset($objects);
+ rmdir($dir);
+ } //is_dir($dir)
}
diff --git a/email.inc b/email.inc
index fd355f5..6dc2a64 100755
--- a/email.inc
+++ b/email.inc
@@ -4,27 +4,26 @@
*/
function case_study_mail($key, &$message, $params)
{
- global $user;
- $language = $message['language'];
- //$language = user_preferred_language($user);
- switch ($key)
- {
- case 'case_study_proposal_received':
- /* initializing data */
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $params['case_study_proposal_received']['result1']);
- $query->range(0, 1);
- $proposal_data = $query->execute()->fetchObject();
- $user = user_load($params['case_study_proposal_received']['user_id']);
- $message['headers'] = $params['case_study_proposal_received']['headers'];
- $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been received', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 'body' => t('
+ global $user;
+ $language = $message['language'];
+ //$language = user_preferred_language($user);
+ switch ($key) {
+ case 'case_study_proposal_received':
+ /* initializing data */
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $params['case_study_proposal_received']['result1']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user = user_load($params['case_study_proposal_received']['user_id']);
+ $message['headers'] = $params['case_study_proposal_received']['headers'];
+ $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project 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 Case Study Project proposal with the following details:
@@ -36,7 +35,7 @@ City: ' . $proposal_data->city . '
State: ' . $proposal_data->state . '
Country: ' . $proposal_data->country . '
Project Title: ' . $proposal_data->project_title . '
-Date of Proposal: ' . date('d/m/Y' , $proposal_data->creation_date) . '
+Date of Proposal: ' . date('d/m/Y', $proposal_data->creation_date) . '
Expected Date of Completion: ' . date('d/m/Y', $proposal_data->expected_date_of_completion) . '
Your proposal is under review. You will soon receive an email when same has been approved/disapproved.
@@ -45,30 +44,30 @@ Best Wishes,
!site_name Team,
FOSSEE,IIT Bombay', array(
- '!site_name' => variable_get('site_name', ''),
- '!user_name' => $user->name
- ), array(
- 'language' => $language->language
- ))
- );
- break;
- case 'case_study_proposal_disapproved':
- /* initializing data */
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $params['case_study_proposal_disapproved']['proposal_id']);
- $query->range(0, 1);
- $proposal_data = $query->execute()->fetchObject();
- $user_data = user_load($params['case_study_proposal_disapproved']['user_id']);
- //$user = user_load($params['case_study_proposal']['name']);
- $message['headers'] = $params['case_study_proposal_disapproved']['headers'];
- $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been disapproved', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 'body' => t('
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user->name,
+ ), array(
+ 'language' => $language->language,
+ )),
+ );
+ break;
+ case 'case_study_proposal_disapproved':
+ /* initializing data */
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $params['case_study_proposal_disapproved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['case_study_proposal_disapproved']['user_id']);
+ //$user = user_load($params['case_study_proposal']['name']);
+ $message['headers'] = $params['case_study_proposal_disapproved']['headers'];
+ $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project 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 your Case Study proposal with following details have been disapproved:
@@ -80,7 +79,7 @@ City: ' . $proposal_data->city . '
State: ' . $proposal_data->state . '
Country: ' . $proposal_data->country . '
Project Title: ' . $proposal_data->project_title . '
-Date of Proposal: ' . date('d/m/Y' , $proposal_data->creation_date) . '
+Date of Proposal: ' . date('d/m/Y', $proposal_data->creation_date) . '
Expected Date of Completion: ' . date('d/m/Y', $proposal_data->expected_date_of_completion) . '
Reason for rejection: ' . $proposal_data->dissapproval_reason . '
@@ -92,30 +91,30 @@ 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 'case_study_proposal_approved':
- /* initializing data */
- $url = 'http://cfd.fossee.in/case-study-project/abstract-code';
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $params['case_study_proposal_approved']['proposal_id']);
- $query->range(0, 1);
- $proposal_data = $query->execute()->fetchObject();
- $user_data = user_load($params['case_study_proposal_approved']['user_id']);
- $message['headers'] = $params['case_study_proposal_approved']['headers'];
- $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been approved', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 'body' => t('
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name,
+ ), array(
+ 'language' => $language->language,
+ )),
+ );
+ break;
+ case 'case_study_proposal_approved':
+ /* initializing data */
+ $url = 'http://cfd.fossee.in/case-study-project/abstract-code';
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $params['case_study_proposal_approved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['case_study_proposal_approved']['user_id']);
+ $message['headers'] = $params['case_study_proposal_approved']['headers'];
+ $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been approved', array(
+ '!site_name' => variable_get('site_name', ''),
+ ), array(
+ 'language' => $language->language,
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your Case Study Project proposal with the following details has been approved:
@@ -127,7 +126,7 @@ City: ' . $proposal_data->city . '
State: ' . $proposal_data->state . '
Country: ' . $proposal_data->country . '
Project Title: ' . $proposal_data->project_title . '
-Date of Proposal: ' . date('d/m/Y' , $proposal_data->creation_date) . '
+Date of Proposal: ' . date('d/m/Y', $proposal_data->creation_date) . '
Expected Date of Completion: ' . date('d/m/Y', $proposal_data->expected_date_of_completion) . '
@@ -136,29 +135,29 @@ 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 'case_study_proposal_completed':
- /* initializing data */
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $params['case_study_proposal_completed']['proposal_id']);
- $query->range(0, 1);
- $proposal_data = $query->execute()->fetchObject();
- $user_data = user_load($params['case_study_proposal_completed']['user_id']);
- $message['headers'] = $params['case_study_proposal_completed']['headers'];
- $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been completed', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 'body' => t('
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name,
+ ), array(
+ 'language' => $language->language,
+ )),
+ );
+ break;
+ case 'case_study_proposal_completed':
+ /* initializing data */
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $params['case_study_proposal_completed']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['case_study_proposal_completed']['user_id']);
+ $message['headers'] = $params['case_study_proposal_completed']['headers'];
+ $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been completed', array(
+ '!site_name' => variable_get('site_name', ''),
+ ), array(
+ 'language' => $language->language,
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your Case Study and abstract on the following process have been completed successfully.
@@ -174,29 +173,29 @@ 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 'case_study_proposal_deleted':
- /* initializing data */
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $params['case_study_proposal_deleted']['proposal_id']);
- $query->range(0, 1);
- $proposal_data = $query->execute()->fetchObject();
- $user_data = user_load($params['case_study_proposal_deleted']['user_id']);
- $message['headers'] = $params['case_study_proposal_deleted']['headers'];
- $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been deleted', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['body'] = array(
- 'body' => t('
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name,
+ ), array(
+ 'language' => $language->language,
+ )),
+ );
+ break;
+ case 'case_study_proposal_deleted':
+ /* initializing data */
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $params['case_study_proposal_deleted']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['case_study_proposal_deleted']['user_id']);
+ $message['headers'] = $params['case_study_proposal_deleted']['headers'];
+ $message['subject'] = t('[!site_name][Case Study Project] Your Case Study Project proposal has been deleted', array(
+ '!site_name' => variable_get('site_name', ''),
+ ), array(
+ 'language' => $language->language,
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your Case Study Project proposal with the following details has been deleted :
@@ -215,31 +214,31 @@ 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 'abstract_uploaded':
- // $solution_q = db_query("SELECT * FROM {case_study_solution} WHERE id = %d LIMIT 1", $params['abstract_uploaded']['solution_id']);
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $params['abstract_uploaded']['proposal_id']);
- $query->range(0, 1);
- $proposal_data = $query->execute()->fetchObject();
-
- $user = user_load($params['abstract_uploaded']['user_id']);
- $message['subject'] = t('[!site_name][Case Study Project] You have uploaded Case Study project files', array(
- '!site_name' => variable_get('site_name', '')
- ), array(
- 'language' => $language->language
- ));
- $message['headers'] = $params['abstract_uploaded']['headers'];
- $message['body'] = array(
- 'body' => t('
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name,
+ ), array(
+ 'language' => $language->language,
+ )),
+ );
+ break;
+ /**************************************************************/
+ case 'abstract_uploaded':
+ // $solution_q = db_query("SELECT * FROM {case_study_solution} WHERE id = %d LIMIT 1", $params['abstract_uploaded']['solution_id']);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $params['abstract_uploaded']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+
+ $user = user_load($params['abstract_uploaded']['user_id']);
+ $message['subject'] = t('[!site_name][Case Study Project] You have uploaded Case Study project files', array(
+ '!site_name' => variable_get('site_name', ''),
+ ), array(
+ 'language' => $language->language,
+ ));
+ $message['headers'] = $params['abstract_uploaded']['headers'];
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
You have uploaded the following Abstract and Project files:
@@ -253,17 +252,59 @@ Best Wishes,
!site_name Team,
FOSSEE,IIT Bombay', array(
- '!site_name' => variable_get('site_name', ''),
- '!user_name' => $user->name
- ), array(
- 'language' => $language->language
- ))
- );
- break;
- case 'standard':
- $message['subject'] = $params['standard']['subject'];
- $message['body'] = $params['standard']['body'];
- $message['headers'] = $params['standard']['headers'];
- break;
- } //$key
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user->name,
+ ), array(
+ 'language' => $language->language,
+ )),
+ );
+ break;
+/**************************************************************/
+ case 'abstract_edit_file_uploaded':
+ // $solution_q = db_query("SELECT * FROM {case_study_solution} WHERE id = %d LIMIT 1", $params['abstract_uploaded']['solution_id']);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $params['abstract_edit_file_uploaded']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+
+ $user = user_load($params['abstract_edit_file_uploaded']['user_id']);
+ $abs_file_name = $params['abstract_edit_file_uploaded']['abs_file'];
+ $proj_file_name = $params['abstract_edit_file_uploaded']['proj_file'];
+
+ $message['subject'] = t('[!site_name][Case Study Project] You have updated project files/abstract of a case study', array(
+ '!site_name' => variable_get('site_name', ''),
+ ), array(
+ 'language' => $language->language,
+ ));
+ $message['headers'] = $params['abstract_edit_file_uploaded']['headers'];
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+You have updated the following abstract/ project files for case studies:
+
+Project Title: ' . $proposal_data->project_title . '
+
+Abstract File: ' . $abs_file_name . '
+
+Project File: ' . $proj_file_name . '
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user->name,
+ ), array(
+ 'language' => $language->language,
+ )),
+ );
+ break;
+ case 'standard':
+ $message['subject'] = $params['standard']['subject'];
+ $message['body'] = $params['standard']['body'];
+ $message['headers'] = $params['standard']['headers'];
+ break;
+ } //$key
}
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 1d74562..cd4fb87 100755
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -2,1002 +2,1029 @@
// $Id$
function cfd_case_study_proposal_pending()
{
- /* get pending proposals to be approved */
- $pending_rows = array();
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('approval_status', 0);
- $query->orderBy('id', 'DESC');
- $pending_q = $query->execute();
- while ($pending_data = $pending_q->fetchObject())
- {
- $pending_rows[$pending_data->id] = array(
- date('d-m-Y', $pending_data->creation_date),
- l($pending_data->name_title . ' ' . $pending_data->contributor_name, 'user/' . $pending_data->uid),
- $pending_data->project_title,
- l('Approve', 'case-study-project/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'case-study-project/manage-proposal/edit/' . $pending_data->id)
- );
- } //$pending_data = $pending_q->fetchObject()
- /* check if there are any pending proposals */
- if (!$pending_rows)
- {
- drupal_set_message(t('There are no pending proposals.'), 'status');
- return '';
- } //!$pending_rows
- $pending_header = array(
- 'Date of Submission',
- 'Student Name',
- 'Title of the Case Study Project',
- 'Action'
- );
- //$output = theme_table($pending_header, $pending_rows);
- $output = theme('table', array(
- 'header' => $pending_header,
- 'rows' => $pending_rows
- ));
- return $output;
+ /* get pending proposals to be approved */
+ $pending_rows = array();
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('approval_status', 0);
+ $query->orderBy('id', 'DESC');
+ $pending_q = $query->execute();
+ while ($pending_data = $pending_q->fetchObject()) {
+ $pending_rows[$pending_data->id] = array(
+ date('d-m-Y', $pending_data->creation_date),
+ l($pending_data->name_title . ' ' . $pending_data->contributor_name, 'user/' . $pending_data->uid),
+ $pending_data->project_title,
+ l('Approve', 'case-study-project/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'case-study-project/manage-proposal/edit/' . $pending_data->id),
+ );
+ } //$pending_data = $pending_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$pending_rows) {
+ drupal_set_message(t('There are no pending proposals.'), 'status');
+ return '';
+ } //!$pending_rows
+ $pending_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the Case Study Project',
+ 'Action',
+ );
+ //$output = theme_table($pending_header, $pending_rows);
+ $output = theme('table', array(
+ 'header' => $pending_header,
+ 'rows' => $pending_rows,
+ ));
+ return $output;
}
function cfd_case_study_proposal_all()
{
- /* get pending proposals to be approved */
- $proposal_rows = array();
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->orderBy('id', 'DESC');
- $proposal_q = $query->execute();
- while ($proposal_data = $proposal_q->fetchObject())
- {
- $approval_status = '';
- switch ($proposal_data->approval_status)
- {
- case 0:
- $approval_status = 'Pending';
- break;
- case 1:
- $approval_status = 'Approved';
- break;
- case 2:
- $approval_status = 'Dis-approved';
- break;
- case 3:
- $approval_status = 'Completed';
- break;
- default:
- $approval_status = 'Unknown';
- break;
- } //$proposal_data->approval_status
- if ($proposal_data->actual_completion_date == 0)
- {
- $actual_completion_date = "Not Completed";
- } //$proposal_data->actual_completion_date == 0
- else
- {
- $actual_completion_date = date('d-m-Y', $proposal_data->actual_completion_date);
- }
- if ($proposal_data->approval_date == 0)
- {
- $approval_date = "Not Approved";
- } //$proposal_data->actual_completion_date == 0
- else
- {
- $approval_date = date('d-m-Y', $proposal_data->approval_date);
- }
- $proposal_rows[] = array(
- date('d-m-Y', $proposal_data->creation_date),
- l($proposal_data->contributor_name, 'user/' . $proposal_data->uid),
- $proposal_data->project_title,
- $approval_date,
- $actual_completion_date,
- $approval_status,
- l('Status', 'case-study-project/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'case-study-project/manage-proposal/edit/' . $proposal_data->id)
- );
- } //$proposal_data = $proposal_q->fetchObject()
- /* check if there are any pending proposals */
- if (!$proposal_rows)
- {
- drupal_set_message(t('There are no proposals.'), 'status');
- return '';
- } //!$proposal_rows
- $proposal_header = array(
- 'Date of Submission',
- 'Student Name',
- 'Title of the case-study project',
- 'Date of Approval',
- 'Date of Project Completion',
- 'Status',
- 'Action'
- );
- $output = theme('table', array(
- 'header' => $proposal_header,
- 'rows' => $proposal_rows
- ));
- return $output;
+ /* get pending proposals to be approved */
+ $proposal_rows = array();
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->orderBy('id', 'DESC');
+ $proposal_q = $query->execute();
+ while ($proposal_data = $proposal_q->fetchObject()) {
+ $approval_status = '';
+ switch ($proposal_data->approval_status) {
+ case 0:
+ $approval_status = 'Pending';
+ break;
+ case 1:
+ $approval_status = 'Approved';
+ break;
+ case 2:
+ $approval_status = 'Dis-approved';
+ break;
+ case 3:
+ $approval_status = 'Completed';
+ break;
+ default:
+ $approval_status = 'Unknown';
+ break;
+ } //$proposal_data->approval_status
+ if ($proposal_data->actual_completion_date == 0) {
+ $actual_completion_date = "Not Completed";
+ } //$proposal_data->actual_completion_date == 0
+ else {
+ $actual_completion_date = date('d-m-Y', $proposal_data->actual_completion_date);
+ }
+ if ($proposal_data->approval_date == 0) {
+ $approval_date = "Not Approved";
+ } //$proposal_data->actual_completion_date == 0
+ else {
+ $approval_date = date('d-m-Y', $proposal_data->approval_date);
+ }
+ $proposal_rows[] = array(
+ date('d-m-Y', $proposal_data->creation_date),
+ l($proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ $proposal_data->project_title,
+ $approval_date,
+ $actual_completion_date,
+ $approval_status,
+ l('Status', 'case-study-project/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'case-study-project/manage-proposal/edit/' . $proposal_data->id),
+ );
+ } //$proposal_data = $proposal_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$proposal_rows) {
+ drupal_set_message(t('There are no proposals.'), 'status');
+ return '';
+ } //!$proposal_rows
+ $proposal_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the case-study project',
+ 'Date of Approval',
+ 'Date of Project Completion',
+ 'Status',
+ 'Action',
+ );
+ $output = theme('table', array(
+ 'header' => $proposal_header,
+ 'rows' => $proposal_rows,
+ ));
+ return $output;
+}
+function cfd_case_study_proposal_edit_file_all()
+{
+ /* get pending proposals to be approved */
+ $proposal_rows = array();
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->orderBy('id', 'DESC');
+ $query->condition('approval_status', '0', '<>');
+ $query->condition('approval_status', '1', '<>');
+ $query->condition('approval_status', '2', '<>');
+ $query->orderBy('approval_status', 'DESC');
+ $proposal_q = $query->execute();
+ while ($proposal_data = $proposal_q->fetchObject()) {
+ $approval_status = '';
+ switch ($proposal_data->approval_status) {
+ case 0:
+ $approval_status = 'Pending';
+ break;
+ case 1:
+ $approval_status = 'Approved';
+ break;
+ case 2:
+ $approval_status = 'Dis-approved';
+ break;
+ case 3:
+ $approval_status = 'Completed';
+ break;
+ case 5:
+ $approval_status = 'On Hold';
+ break;
+ default:
+ $approval_status = 'Unknown';
+ break;
+ } //$proposal_data->approval_status
+ if ($proposal_data->actual_completion_date == 0) {
+ $actual_completion_date = "Not Completed";
+ } //$proposal_data->actual_completion_date == 0
+ else {
+ $actual_completion_date = date('d-m-Y', $proposal_data->actual_completion_date);
+ }
+ if ($proposal_data->approval_date == 0) {
+ $approval_date = "Not Approved";
+ } //$proposal_data->actual_completion_date == 0
+ else {
+ $approval_date = date('d-m-Y', $proposal_data->approval_date);
+ }
+ $proposal_rows[] = array(
+ date('d-m-Y', $proposal_data->creation_date),
+ l($proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ $proposal_data->project_title,
+ $approval_date,
+ $actual_completion_date,
+ $approval_status,
+ l('Edit', 'case-study-project/abstract-code/edit-upload-files/' . $proposal_data->id),
+ );
+ } //$proposal_data = $proposal_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$proposal_rows) {
+ drupal_set_message(t('There are no proposals.'), 'status');
+ return '';
+ } //!$proposal_rows
+ $proposal_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the case-study project',
+ 'Date of Approval',
+ 'Date of Project Completion',
+ 'Status',
+ 'Action',
+ );
+ $output = theme('table', array(
+ 'header' => $proposal_header,
+ 'rows' => $proposal_rows,
+ ));
+ return $output;
}
/******************************************************************************/
/************************** PROPOSAL APPROVAL FORM ****************************/
/******************************************************************************/
function cfd_case_study_proposal_approval_form($form, &$form_state)
{
- global $user;
- /* get current proposal */
- $proposal_id = (int) arg(3);
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- $query_abstract = db_select('case_study_submitted_abstracts_file');
- $query_abstract->fields('case_study_submitted_abstracts_file');
- $query_abstract->condition('proposal_id', $proposal_id);
- $query_abstract->condition('filetype', 'A');
- $query_abstract_pdf = $query_abstract->execute()->fetchObject();
- if ($proposal_q)
- {
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } //$proposal_data = $proposal_q->fetchObject()
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- } //$proposal_q
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- if($proposal_data->faculty_name == ''){
- $faculty_name = 'NA';
- }
- else{
- $faculty_name = $proposal_data->faculty_name;
- }
- if($proposal_data->faculty_department == ''){
- $faculty_department = 'NA';
- }
- else{
- $faculty_department = $proposal_data->faculty_department;
- }
- if($proposal_data->faculty_email == ''){
- $faculty_email = 'NA';
- }
- else{
- $faculty_email = $proposal_data->faculty_email;
- }
- $form['contributor_name'] = array(
- '#type' => 'item',
- '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid),
- '#title' => t('Student name')
- );
- $form['student_email_id'] = array(
- '#title' => t('Student Email'),
- '#type' => 'item',
- '#markup' => user_load($proposal_data->uid)->mail,
- '#title' => t('Email')
- );
- $form['contributor_contact_no'] = array(
- '#title' => t('Contact No.'),
- '#type' => 'item',
- '#markup' => $proposal_data->contact_no,
- );
- $form['university'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->university,
- '#title' => t('University/Institute')
- );
- $form['how_did_you_know_about_project'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->how_did_you_know_about_project,
- '#title' => t('How did you know about the project')
- );
- $form['faculty_name'] = array(
- '#type' => 'item',
- '#markup' => $faculty_name,
- '#title' => t('Name of the faculty')
- );
- $form['faculty_department'] = array(
- '#type' => 'item',
- '#markup' => $faculty_department,
- '#title' => t('Department of the faculty')
- );
- $form['faculty_email'] = array(
- '#type' => 'item',
- '#markup' => $faculty_email,
- '#title' => t('Email of the faculty')
- );
- $form['country'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->country,
- '#title' => t('Country')
- );
- $form['all_state'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->state,
- '#title' => t('State')
- );
- $form['city'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->city,
- '#title' => t('City')
- );
- $form['pincode'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->pincode,
- '#title' => t('Pincode/Postal code')
- );
- $form['project_title'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->project_title,
- '#title' => t('Title of the Case Study Project')
- );
- $form['solver_used'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->solver_used,
- '#title' => t('Solver used')
- );
- $form['date_of_proposal'] = array(
- '#type' => 'textfield',
- '#title' => t('Date of Proposal'),
- '#default_value' => date('d/m/Y', $proposal_data->creation_date),
- '#disabled' => TRUE,
- );
- $form['expected_completion_date'] =array(
- '#type' => 'textfield',
- '#title' => t('Expected Date of Completion'),
- '#default_value' => date('d/m/Y', $proposal_data->expected_date_of_completion),
- '#disabled' => TRUE,
- );
- if (($query_abstract_pdf->filename != "") && ($query_abstract_pdf->filename != 'NULL'))
- {
- $str = substr($query_abstract_pdf->filename,strrpos($query_abstract_pdf->filename, '/'));
- $resource_file =ltrim($str, '/');
-
- $form['abstract_file_path'] = array(
- '#type' => 'item',
- '#title' => t('Abstract file '),
- '#markup' => l($resource_file, 'case-study-project/download/project-file/' . $proposal_id) . ""
- );
- } //$proposal_data->user_defined_compound_filepath != ""
- else
- {
- $form['abstract_file_path'] = array(
- '#type' => 'item',
- '#title' => t('Abstract file '),
- '#markup' => "Not uploaded<br><br>"
- );
- }
- $form['approval'] = array(
- '#type' => 'radios',
- '#title' => t('CFD Case Study proposal'),
- '#options' => array(
- '1' => 'Approve',
- '2' => 'Disapprove'
- ),
- '#required' => TRUE
- );
- $form['message'] = array(
- '#type' => 'textarea',
- '#title' => t('Reason for disapproval'),
- '#attributes' => array(
- 'placeholder' => t('Enter reason for disapproval in minimum 30 characters '),
- 'cols' => 50,
- 'rows' => 4
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="approval"]' => array(
- 'value' => '2'
- )
- )
- )
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- $form['cancel'] = array(
- '#type' => 'item',
- '#markup' => l(t('Cancel'), 'case-study-project/manage-proposal')
- );
- return $form;
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ $query_abstract = db_select('case_study_submitted_abstracts_file');
+ $query_abstract->fields('case_study_submitted_abstracts_file');
+ $query_abstract->condition('proposal_id', $proposal_id);
+ $query_abstract->condition('filetype', 'A');
+ $query_abstract_pdf = $query_abstract->execute()->fetchObject();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ if ($proposal_data->faculty_name == '') {
+ $faculty_name = 'NA';
+ } else {
+ $faculty_name = $proposal_data->faculty_name;
+ }
+ if ($proposal_data->faculty_department == '') {
+ $faculty_department = 'NA';
+ } else {
+ $faculty_department = $proposal_data->faculty_department;
+ }
+ if ($proposal_data->faculty_email == '') {
+ $faculty_email = 'NA';
+ } else {
+ $faculty_email = $proposal_data->faculty_email;
+ }
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ '#title' => t('Student name'),
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email'),
+ );
+ $form['contributor_contact_no'] = array(
+ '#title' => t('Contact No.'),
+ '#type' => 'item',
+ '#markup' => $proposal_data->contact_no,
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute'),
+ );
+ $form['how_did_you_know_about_project'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->how_did_you_know_about_project,
+ '#title' => t('How did you know about the project'),
+ );
+ $form['faculty_name'] = array(
+ '#type' => 'item',
+ '#markup' => $faculty_name,
+ '#title' => t('Name of the faculty'),
+ );
+ $form['faculty_department'] = array(
+ '#type' => 'item',
+ '#markup' => $faculty_department,
+ '#title' => t('Department of the faculty'),
+ );
+ $form['faculty_email'] = array(
+ '#type' => 'item',
+ '#markup' => $faculty_email,
+ '#title' => t('Email of the faculty'),
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country'),
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State'),
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City'),
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code'),
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Case Study Project'),
+ );
+ $form['solver_used'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->solver_used,
+ '#title' => t('Solver used'),
+ );
+ $form['date_of_proposal'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Date of Proposal'),
+ '#default_value' => date('d/m/Y', $proposal_data->creation_date),
+ '#disabled' => true,
+ );
+ $form['expected_completion_date'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Expected Date of Completion'),
+ '#default_value' => date('d/m/Y', $proposal_data->expected_date_of_completion),
+ '#disabled' => true,
+ );
+ if (($query_abstract_pdf->filename != "") && ($query_abstract_pdf->filename != 'NULL')) {
+ $str = substr($query_abstract_pdf->filename, strrpos($query_abstract_pdf->filename, '/'));
+ $resource_file = ltrim($str, '/');
+
+ $form['abstract_file_path'] = array(
+ '#type' => 'item',
+ '#title' => t('Abstract file '),
+ '#markup' => l($resource_file, 'case-study-project/download/project-file/' . $proposal_id) . "",
+ );
+ } //$proposal_data->user_defined_compound_filepath != ""
+ else {
+ $form['abstract_file_path'] = array(
+ '#type' => 'item',
+ '#title' => t('Abstract file '),
+ '#markup' => "Not uploaded<br><br>",
+ );
+ }
+ $form['approval'] = array(
+ '#type' => 'radios',
+ '#title' => t('CFD Case Study proposal'),
+ '#options' => array(
+ '1' => 'Approve',
+ '2' => 'Disapprove',
+ ),
+ '#required' => true,
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reason for disapproval'),
+ '#attributes' => array(
+ 'placeholder' => t('Enter reason for disapproval in minimum 30 characters '),
+ 'cols' => 50,
+ 'rows' => 4,
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="approval"]' => array(
+ 'value' => '2',
+ ),
+ ),
+ ),
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'case-study-project/manage-proposal'),
+ );
+ return $form;
}
function cfd_case_study_proposal_approval_form_validate($form, &$form_state)
{
- if ($form_state['values']['approval'] == 2)
- {
- if ($form_state['values']['message'] == '')
- {
- form_set_error('message', t('Reason for disapproval could not be empty'));
- } //$form_state['values']['message'] == ''
- } //$form_state['values']['approval'] == 2
+ if ($form_state['values']['approval'] == 2) {
+ if ($form_state['values']['message'] == '') {
+ form_set_error('message', t('Reason for disapproval could not be empty'));
+ } //$form_state['values']['message'] == ''
+ } //$form_state['values']['approval'] == 2
}
function cfd_case_study_proposal_approval_form_submit($form, &$form_state)
{
- global $user;
- /* get current proposal */
- $proposal_id = (int) arg(3);
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- if ($proposal_q)
- {
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } //$proposal_data = $proposal_q->fetchObject()
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- } //$proposal_q
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- if ($form_state['values']['approval'] == 1)
- {
- $query = "UPDATE {case_study_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 1 WHERE id = :proposal_id";
- $args = array(
- ":uid" => $user->uid,
- ":date" => time(),
- ":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('case_study_from_email', '');
- $bcc = $user->mail . ', ' . variable_get('case_study_emails', '');
- $cc = variable_get('case_study_cc_emails', '');
- $params['case_study_proposal_approved']['proposal_id'] = $proposal_id;
- $params['case_study_proposal_approved']['user_id'] = $proposal_data->uid;
- $params['case_study_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('case_study', 'case_study_proposal_approved', $email_to, language_default(), $params, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- drupal_set_message('CFD Case Study proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status');
- drupal_goto('case-study-project/manage-proposal');
- return;
- } //$form_state['values']['approval'] == 1
- else if ($form_state['values']['approval'] == 2)
- {
- $query = "UPDATE {case_study_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, dissapproval_reason = :dissapproval_reason WHERE id = :proposal_id";
- $args = array(
- ":uid" => $user->uid,
- ":date" => time(),
- ":dissapproval_reason" => $form_state['values']['message'],
- ":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('case_study_from_email', '');
- $bcc = $user->mail . ', ' . variable_get('case_study_emails', '');
- $cc = variable_get('case_study_cc_emails', '');
- $params['case_study_proposal_disapproved']['proposal_id'] = $proposal_id;
- $params['case_study_proposal_disapproved']['user_id'] = $proposal_data->uid;
- $params['case_study_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('case_study', 'case_study_proposal_disapproved', $email_to, language_default(), $params, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- drupal_set_message('CFD Case Study proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- } //$form_state['values']['approval'] == 2
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ if ($form_state['values']['approval'] == 1) {
+ $query = "UPDATE {case_study_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 1 WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":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('case_study_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('case_study_emails', '');
+ $cc = variable_get('case_study_cc_emails', '');
+ $params['case_study_proposal_approved']['proposal_id'] = $proposal_id;
+ $params['case_study_proposal_approved']['user_id'] = $proposal_data->uid;
+ $params['case_study_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('case_study', 'case_study_proposal_approved', $email_to, language_default(), $params, $from, true)) {
+ drupal_set_message('Error sending email message.', 'error');
+ }
+
+ drupal_set_message('CFD Case Study proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 1
+ else if ($form_state['values']['approval'] == 2) {
+ $query = "UPDATE {case_study_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, dissapproval_reason = :dissapproval_reason WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":dissapproval_reason" => $form_state['values']['message'],
+ ":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('case_study_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('case_study_emails', '');
+ $cc = variable_get('case_study_cc_emails', '');
+ $params['case_study_proposal_disapproved']['proposal_id'] = $proposal_id;
+ $params['case_study_proposal_disapproved']['user_id'] = $proposal_data->uid;
+ $params['case_study_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('case_study', 'case_study_proposal_disapproved', $email_to, language_default(), $params, $from, true)) {
+ drupal_set_message('Error sending email message.', 'error');
+ }
+
+ drupal_set_message('CFD Case Study proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 2
}
/******************************************************************************/
/*************************** PROPOSAL STATUS FORM *****************************/
/******************************************************************************/
function cfd_case_study_proposal_status_form($form, &$form_state)
{
- global $user;
- /* get current proposal */
- $proposal_id = (int) arg(3);
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- $query_abstract = db_select('case_study_submitted_abstracts_file');
- $query_abstract->fields('case_study_submitted_abstracts_file');
- $query_abstract->condition('proposal_id', $proposal_id);
- $query_abstract->condition('filetype', 'A');
- $query_abstract_pdf = $query_abstract->execute()->fetchObject();
- if ($proposal_q)
- {
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } //$proposal_data = $proposal_q->fetchObject()
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- } //$proposal_q
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- if($proposal_data->faculty_name == ''){
- $faculty_name = 'NA';
- }
- else{
- $faculty_name = $proposal_data->faculty_name;
- }
- if($proposal_data->faculty_department == ''){
- $faculty_department = 'NA';
- }
- else{
- $faculty_department = $proposal_data->faculty_department;
- }
- if($proposal_data->faculty_email == ''){
- $faculty_email = 'NA';
- }
- else{
- $faculty_email = $proposal_data->faculty_email;
- }
- $form['contributor_name'] = array(
- '#type' => 'item',
- '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid),
- '#title' => t('Student name')
- );
- $form['student_email_id'] = array(
- '#title' => t('Student Email'),
- '#type' => 'item',
- '#markup' => user_load($proposal_data->uid)->mail,
- '#title' => t('Email')
- );
- $form['university'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->university,
- '#title' => t('University/Institute')
- );
- $form['how_did_you_know_about_project'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->how_did_you_know_about_project,
- '#title' => t('How did you know about the project')
- );
- $form['faculty_name'] = array(
- '#type' => 'item',
- '#markup' => $faculty_name,
- '#title' => t('Name of the faculty')
- );
- $form['faculty_department'] = array(
- '#type' => 'item',
- '#markup' => $faculty_department,
- '#title' => t('Department of the faculty')
- );
- $form['faculty_email'] = array(
- '#type' => 'item',
- '#markup' => $faculty_email,
- '#title' => t('Email of the faculty')
- );
- $form['country'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->country,
- '#title' => t('Country')
- );
- $form['all_state'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->state,
- '#title' => t('State')
- );
- $form['city'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->city,
- '#title' => t('City')
- );
- $form['pincode'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->pincode,
- '#title' => t('Pincode/Postal code')
- );
- $form['project_title'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->project_title,
- '#title' => t('Title of the Case Study Project')
- );
- $form['solver_used'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->solver_used,
- '#title' => t('Solver used')
- );
- /************************** reference link filter *******************/
- $url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i';
- $reference = preg_replace($url, '<a href="$0" target="_blank" title="$0">$0</a>', $proposal_data->reference);
- /******************************/
- /*$form['reference'] = array(
- '#type' => 'item',
- '#markup' => $reference,
- '#title' => t('References')
- );*/
- if (($query_abstract_pdf->filename != "") && ($query_abstract_pdf->filename != 'NULL'))
- {
- $str = substr($query_abstract_pdf->filename,strrpos($query_abstract_pdf->filename, '/'));
- $resource_file =ltrim($str, '/');
-
- $form['abstract_file_path'] = array(
- '#type' => 'item',
- '#title' => t('Abstract file '),
- '#markup' => l($resource_file, 'case-study-project/download/project-file/' . $proposal_id) . ""
- );
- } //$proposal_data->user_defined_compound_filepath != ""
- else
- {
- $form['abstract_file_path'] = array(
- '#type' => 'item',
- '#title' => t('Abstract file '),
- '#markup' => "Not uploaded<br><br>"
- );
- }
- $proposal_status = '';
- switch ($proposal_data->approval_status)
- {
- case 0:
- $proposal_status = t('Pending');
- break;
- case 1:
- $proposal_status = t('Approved');
- break;
- case 2:
- $proposal_status = t('Dis-approved');
- break;
- case 3:
- $proposal_status = t('Completed');
- break;
- default:
- $proposal_status = t('Unkown');
- break;
- }
- $form['proposal_status'] = array(
- '#type' => 'item',
- '#markup' => $proposal_status,
- '#title' => t('Proposal Status')
- );
- if ($proposal_data->approval_status == 0)
- {
- $form['approve'] = array(
- '#type' => 'item',
- '#markup' => l('Click here', 'case-study-project/manage-proposal/approve/' . $proposal_id),
- '#title' => t('Approve')
- );
- } //$proposal_data->approval_status == 0
- if ($proposal_data->approval_status == 1)
- {
- $form['completed'] = array(
- '#type' => 'checkbox',
- '#title' => t('Completed'),
- '#description' => t('Check if user has provided all the required files and pdfs.')
- );
- } //$proposal_data->approval_status == 1
- if ($proposal_data->approval_status == 2)
- {
- $form['message'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->message,
- '#title' => t('Reason for disapproval')
- );
- } //$proposal_data->approval_status == 2
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- $form['cancel'] = array(
- '#type' => 'markup',
- '#markup' => l(t('Cancel'), 'case-study-project/manage-proposal/all')
- );
- return $form;
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ $query_abstract = db_select('case_study_submitted_abstracts_file');
+ $query_abstract->fields('case_study_submitted_abstracts_file');
+ $query_abstract->condition('proposal_id', $proposal_id);
+ $query_abstract->condition('filetype', 'A');
+ $query_abstract_pdf = $query_abstract->execute()->fetchObject();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ if ($proposal_data->faculty_name == '') {
+ $faculty_name = 'NA';
+ } else {
+ $faculty_name = $proposal_data->faculty_name;
+ }
+ if ($proposal_data->faculty_department == '') {
+ $faculty_department = 'NA';
+ } else {
+ $faculty_department = $proposal_data->faculty_department;
+ }
+ if ($proposal_data->faculty_email == '') {
+ $faculty_email = 'NA';
+ } else {
+ $faculty_email = $proposal_data->faculty_email;
+ }
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ '#title' => t('Student name'),
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email'),
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute'),
+ );
+ $form['how_did_you_know_about_project'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->how_did_you_know_about_project,
+ '#title' => t('How did you know about the project'),
+ );
+ $form['faculty_name'] = array(
+ '#type' => 'item',
+ '#markup' => $faculty_name,
+ '#title' => t('Name of the faculty'),
+ );
+ $form['faculty_department'] = array(
+ '#type' => 'item',
+ '#markup' => $faculty_department,
+ '#title' => t('Department of the faculty'),
+ );
+ $form['faculty_email'] = array(
+ '#type' => 'item',
+ '#markup' => $faculty_email,
+ '#title' => t('Email of the faculty'),
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country'),
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State'),
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City'),
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code'),
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Case Study Project'),
+ );
+ $form['solver_used'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->solver_used,
+ '#title' => t('Solver used'),
+ );
+ /************************** reference link filter *******************/
+ $url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i';
+ $reference = preg_replace($url, '<a href="$0" target="_blank" title="$0">$0</a>', $proposal_data->reference);
+ /******************************/
+ /*$form['reference'] = array(
+ '#type' => 'item',
+ '#markup' => $reference,
+ '#title' => t('References')
+ );*/
+ if (($query_abstract_pdf->filename != "") && ($query_abstract_pdf->filename != 'NULL')) {
+ $str = substr($query_abstract_pdf->filename, strrpos($query_abstract_pdf->filename, '/'));
+ $resource_file = ltrim($str, '/');
+
+ $form['abstract_file_path'] = array(
+ '#type' => 'item',
+ '#title' => t('Abstract file '),
+ '#markup' => l($resource_file, 'case-study-project/download/project-file/' . $proposal_id) . "",
+ );
+ } //$proposal_data->user_defined_compound_filepath != ""
+ else {
+ $form['abstract_file_path'] = array(
+ '#type' => 'item',
+ '#title' => t('Abstract file '),
+ '#markup' => "Not uploaded<br><br>",
+ );
+ }
+ $proposal_status = '';
+ switch ($proposal_data->approval_status) {
+ case 0:
+ $proposal_status = t('Pending');
+ break;
+ case 1:
+ $proposal_status = t('Approved');
+ break;
+ case 2:
+ $proposal_status = t('Dis-approved');
+ break;
+ case 3:
+ $proposal_status = t('Completed');
+ break;
+ default:
+ $proposal_status = t('Unkown');
+ break;
+ }
+ $form['proposal_status'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_status,
+ '#title' => t('Proposal Status'),
+ );
+ if ($proposal_data->approval_status == 0) {
+ $form['approve'] = array(
+ '#type' => 'item',
+ '#markup' => l('Click here', 'case-study-project/manage-proposal/approve/' . $proposal_id),
+ '#title' => t('Approve'),
+ );
+ } //$proposal_data->approval_status == 0
+ if ($proposal_data->approval_status == 1) {
+ $form['completed'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Completed'),
+ '#description' => t('Check if user has provided all the required files and pdfs.'),
+ );
+ } //$proposal_data->approval_status == 1
+ if ($proposal_data->approval_status == 2) {
+ $form['message'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->message,
+ '#title' => t('Reason for disapproval'),
+ );
+ } //$proposal_data->approval_status == 2
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#markup' => l(t('Cancel'), 'case-study-project/manage-proposal/all'),
+ );
+ return $form;
}
function cfd_case_study_proposal_status_form_submit($form, &$form_state)
{
- global $user;
- /* get current proposal */
- $proposal_id = (int) arg(3);
- //$proposal_q = db_query("SELECT * FROM {case_study_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- if ($proposal_q)
- {
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } //$proposal_data = $proposal_q->fetchObject()
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- } //$proposal_q
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- /* set the book status to completed */
- if ($form_state['values']['completed'] == 1)
- {
- $up_query = "UPDATE case_study_proposal SET approval_status = :approval_status , actual_completion_date = :expected_completion_date WHERE id = :proposal_id";
- $args = array(
- ":approval_status" => '3',
- ":proposal_id" => $proposal_id,
- ":expected_completion_date" => time()
- );
- $result = db_query($up_query, $args);
- CreateReadmeFileCaseStudyProject($proposal_id);
- if (!$result)
- {
- drupal_set_message('Error in update status', 'error');
- return;
- } //!$result
- /* sending email */
- $user_data = user_load($proposal_data->uid);
- $email_to = $user_data->mail;
- $from = variable_get('case_study_from_email', '');
- $bcc = $user->mail . ', ' . variable_get('case_study_emails', '');
- $cc = variable_get('case_study_cc_emails', '');
- $params['case_study_proposal_completed']['proposal_id'] = $proposal_id;
- $params['case_study_proposal_completed']['user_id'] = $proposal_data->uid;
- $params['case_study_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('case_study', 'case_study_proposal_completed', $email_to, language_default(), $params, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- drupal_set_message('Congratulations! CFD Case Study proposal has been marked as completed. User has been notified of the completion.', 'status');
- }
- drupal_goto('case-study-project/manage-proposal');
- return;
-
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {case_study_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ /* set the book status to completed */
+ if ($form_state['values']['completed'] == 1) {
+ $up_query = "UPDATE case_study_proposal SET approval_status = :approval_status , actual_completion_date = :expected_completion_date WHERE id = :proposal_id";
+ $args = array(
+ ":approval_status" => '3',
+ ":proposal_id" => $proposal_id,
+ ":expected_completion_date" => time(),
+ );
+ $result = db_query($up_query, $args);
+ CreateReadmeFileCaseStudyProject($proposal_id);
+ if (!$result) {
+ drupal_set_message('Error in update status', 'error');
+ return;
+ } //!$result
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('case_study_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('case_study_emails', '');
+ $cc = variable_get('case_study_cc_emails', '');
+ $params['case_study_proposal_completed']['proposal_id'] = $proposal_id;
+ $params['case_study_proposal_completed']['user_id'] = $proposal_data->uid;
+ $params['case_study_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('case_study', 'case_study_proposal_completed', $email_to, language_default(), $params, $from, true)) {
+ drupal_set_message('Error sending email message.', 'error');
+ }
+
+ drupal_set_message('Congratulations! CFD Case Study proposal has been marked as completed. User has been notified of the completion.', 'status');
+ }
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+
}
/******************************************************************************/
/**************************** PROPOSAL EDIT FORM ******************************/
/******************************************************************************/
function cfd_case_study_proposal_edit_form($form, &$form_state)
{
- global $user;
- /* get current proposal */
- $proposal_id = (int) arg(3);
- //$proposal_q = db_query("SELECT * FROM {case_study_proposal} WHERE id = %d", $proposal_id);
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- if ($proposal_q)
- {
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } //$proposal_data = $proposal_q->fetchObject()
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- } //$proposal_q
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- $user_data = user_load($proposal_data->uid);
- $form['name_title'] = array(
- '#type' => 'select',
- '#title' => t('Title'),
- '#options' => array(
- 'Dr' => 'Dr',
- 'Prof' => 'Prof',
- 'Mr' => 'Mr',
- 'Ms' => 'Ms'
- ),
- '#required' => TRUE,
- '#default_value' => $proposal_data->name_title
- );
- $form['contributor_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of the Proposer'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $proposal_data->contributor_name
- );
- $form['student_email_id'] = array(
- '#type' => 'item',
- '#title' => t('Email'),
- '#markup' => $user_data->mail
- );
- $form['university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/Institute'),
- '#size' => 200,
- '#maxlength' => 200,
- '#required' => TRUE,
- '#default_value' => $proposal_data->university
- );
- $form['institute'] = array(
- '#type' => 'textfield',
- '#title' => t('Institute'),
- '#size' => 80,
- '#maxlength' => 200,
- '#required' => TRUE,
- '#default_value' => $proposal_data->institute
- );
- $form['how_did_you_know_about_project'] = array(
- '#type' => 'textfield',
- '#title' => t('How did you come to know about the Case Study Project?'),
- '#default_value' => $proposal_data->how_did_you_know_about_project,
- '#required' => TRUE
- );
- $form['faculty_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of the Faculty'),
- '#size' => 50,
- '#maxlength' => 50,
- '#validated' => TRUE,
- '#default_value' => $proposal_data->faculty_name
- );
- $form['faculty_department'] = array(
- '#type' => 'textfield',
- '#title' => t('Department of the Faculty'),
- '#size' => 50,
- '#maxlength' => 50,
- '#validated' => TRUE,
- '#default_value' => $proposal_data->faculty_department
- );
- $form['faculty_email'] = array(
- '#type' => 'textfield',
- '#title' => t('Email id of the Faculty'),
- '#size' => 255,
- '#maxlength' => 255,
- '#validated' => TRUE,
- '#default_value' => $proposal_data->faculty_email
- );
- $form['country'] = array(
- '#type' => 'select',
- '#title' => t('Country'),
- '#options' => array(
- 'India' => 'India',
- 'Others' => 'Others'
- ),
- '#default_value' => $proposal_data->country,
- '#required' => TRUE,
- '#tree' => TRUE,
- '#validated' => TRUE
- );
- $form['other_country'] = array(
- '#type' => 'textfield',
- '#title' => t('Other than India'),
- '#size' => 100,
- '#default_value' => $proposal_data->country,
- '#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')
- ),
- '#default_value' => $proposal_data->state,
- '#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')
- ),
- '#default_value' => $proposal_data->city,
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'Others'
- )
- )
- )
- );
- $form['all_state'] = array(
- '#type' => 'select',
- '#title' => t('State'),
- '#options' => _df_list_of_states(),
- '#default_value' => $proposal_data->state,
- '#validated' => TRUE,
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'India'
- )
- )
- )
- );
- $form['city'] = array(
- '#type' => 'select',
- '#title' => t('City'),
- '#options' => _df_list_of_cities(),
- '#default_value' => $proposal_data->city,
- '#states' => array(
- 'visible' => array(
- ':input[name="country"]' => array(
- 'value' => 'India'
- )
- )
- )
- );
- $form['pincode'] = array(
- '#type' => 'textfield',
- '#title' => t('Pincode'),
- '#size' => 30,
- '#maxlength' => 6,
- '#default_value' => $proposal_data->pincode,
- '#attributes' => array(
- 'placeholder' => 'Insert pincode of your city/ village....'
- )
- );
- $form['project_title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the Case Study Project'),
- '#size' => 300,
- '#maxlength' => 350,
- '#required' => TRUE,
- '#default_value' => $proposal_data->project_title
- );
- $form['solver_used'] = array(
- '#type' => 'textfield',
- '#title' => t('Solver to be used'),
- '#size' => 50,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $proposal_data->solver_used
- );
- $form['date_of_proposal'] = array(
- '#type' => 'textfield',
- '#title' => t('Date of Proposal'),
- '#default_value' => date('d/m/Y', $proposal_data->creation_date),
- '#disabled' => TRUE,
- );
- $form['delete_proposal'] = array(
- '#type' => 'checkbox',
- '#title' => t('Delete Proposal')
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- $form['cancel'] = array(
- '#type' => 'item',
- '#markup' => l(t('Cancel'), 'case-study-project/manage-proposal')
- );
- return $form;
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {case_study_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ $user_data = user_load($proposal_data->uid);
+ $form['name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof',
+ 'Mr' => 'Mr',
+ 'Ms' => 'Ms',
+ ),
+ '#required' => true,
+ '#default_value' => $proposal_data->name_title,
+ );
+ $form['contributor_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Proposer'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => true,
+ '#default_value' => $proposal_data->contributor_name,
+ );
+ $form['student_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Email'),
+ '#markup' => $user_data->mail,
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute'),
+ '#size' => 200,
+ '#maxlength' => 200,
+ '#required' => true,
+ '#default_value' => $proposal_data->university,
+ );
+ $form['institute'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#required' => true,
+ '#default_value' => $proposal_data->institute,
+ );
+ $form['how_did_you_know_about_project'] = array(
+ '#type' => 'textfield',
+ '#title' => t('How did you come to know about the Case Study Project?'),
+ '#default_value' => $proposal_data->how_did_you_know_about_project,
+ '#required' => true,
+ );
+ $form['faculty_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Faculty'),
+ '#size' => 50,
+ '#maxlength' => 50,
+ '#validated' => true,
+ '#default_value' => $proposal_data->faculty_name,
+ );
+ $form['faculty_department'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Department of the Faculty'),
+ '#size' => 50,
+ '#maxlength' => 50,
+ '#validated' => true,
+ '#default_value' => $proposal_data->faculty_department,
+ );
+ $form['faculty_email'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email id of the Faculty'),
+ '#size' => 255,
+ '#maxlength' => 255,
+ '#validated' => true,
+ '#default_value' => $proposal_data->faculty_email,
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others',
+ ),
+ '#default_value' => $proposal_data->country,
+ '#required' => true,
+ '#tree' => true,
+ '#validated' => true,
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#default_value' => $proposal_data->country,
+ '#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'),
+ ),
+ '#default_value' => $proposal_data->state,
+ '#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'),
+ ),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others',
+ ),
+ ),
+ ),
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#default_value' => $proposal_data->state,
+ '#validated' => true,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India',
+ ),
+ ),
+ ),
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India',
+ ),
+ ),
+ ),
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#default_value' => $proposal_data->pincode,
+ '#attributes' => array(
+ 'placeholder' => 'Insert pincode of your city/ village....',
+ ),
+ );
+ $form['project_title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of the Case Study Project'),
+ '#size' => 300,
+ '#maxlength' => 350,
+ '#required' => true,
+ '#default_value' => $proposal_data->project_title,
+ );
+ $form['solver_used'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Solver to be used'),
+ '#size' => 50,
+ '#maxlength' => 50,
+ '#required' => true,
+ '#default_value' => $proposal_data->solver_used,
+ );
+ $form['date_of_proposal'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Date of Proposal'),
+ '#default_value' => date('d/m/Y', $proposal_data->creation_date),
+ '#disabled' => true,
+ );
+ $form['delete_proposal'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Delete Proposal'),
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'case-study-project/manage-proposal'),
+ );
+ return $form;
}
function cfd_case_study_proposal_edit_form_submit($form, &$form_state)
{
- global $user;
- /* get current proposal */
- $proposal_id = (int) arg(3);
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('id', $proposal_id);
- $proposal_q = $query->execute();
- if ($proposal_q)
- {
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } //$proposal_data = $proposal_q->fetchObject()
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- } //$proposal_q
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/manage-proposal');
- return;
- }
- /* delete proposal */
- if ($form_state['values']['delete_proposal'] == 1)
- {
- /* sending email */
- $user_data = user_load($proposal_data->uid);
- $email_to = $user_data->mail;
- $from = variable_get('case_study_from_email', '');
- $bcc = variable_get('case_study_emails', '');
- $cc = variable_get('case_study_cc_emails', '');
- $params['case_study_proposal_deleted']['proposal_id'] = $proposal_id;
- $params['case_study_proposal_deleted']['user_id'] = $proposal_data->uid;
- $params['case_study_proposal_deleted']['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('case_study', 'case_study_proposal_deleted', $email_to, user_preferred_language($user), $params, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- drupal_set_message(t('Case Study proposal has been deleted.'), 'status');
- if (rrmdir_project($proposal_id) == TRUE)
- {
- $query = db_delete('case_study_proposal');
- $query->condition('id', $proposal_id);
- $num_deleted = $query->execute();
- drupal_set_message(t('Proposal Deleted'), 'status');
- drupal_goto('case-study-project/manage-proposal');
- return;
- } //rrmdir_project($proposal_id) == TRUE
- } //$form_state['values']['delete_proposal'] == 1
- /* update proposal */
- $v = $form_state['values'];
- $project_title = $v['project_title'];
- $solver_used = $v['solver_used'];
- $proposar_name = $v['name_title'] . ' ' . $v['contributor_name'];
- $university = $v['university'];
- $directory_names = _df_dir_name($project_title, $proposar_name);
- if (DF_RenameDir($proposal_id, $directory_names))
- {
- $directory_name = $directory_names;
- } //LM_RenameDir($proposal_id, $directory_names)
- else
- {
- return;
- }
- $query = "UPDATE case_study_proposal SET
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ }
+ /* delete proposal */
+ if ($form_state['values']['delete_proposal'] == 1) {
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('case_study_from_email', '');
+ $bcc = variable_get('case_study_emails', '');
+ $cc = variable_get('case_study_cc_emails', '');
+ $params['case_study_proposal_deleted']['proposal_id'] = $proposal_id;
+ $params['case_study_proposal_deleted']['user_id'] = $proposal_data->uid;
+ $params['case_study_proposal_deleted']['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('case_study', 'case_study_proposal_deleted', $email_to, user_preferred_language($user), $params, $from, true)) {
+ drupal_set_message('Error sending email message.', 'error');
+ }
+
+ drupal_set_message(t('Case Study proposal has been deleted.'), 'status');
+ if (rrmdir_project($proposal_id) == true) {
+ $query = db_delete('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $num_deleted = $query->execute();
+ drupal_set_message(t('Proposal Deleted'), 'status');
+ drupal_goto('case-study-project/manage-proposal');
+ return;
+ } //rrmdir_project($proposal_id) == TRUE
+ } //$form_state['values']['delete_proposal'] == 1
+ /* update proposal */
+ $v = $form_state['values'];
+ $project_title = $v['project_title'];
+ $solver_used = $v['solver_used'];
+ $proposar_name = $v['name_title'] . ' ' . $v['contributor_name'];
+ $university = $v['university'];
+ $directory_names = _df_dir_name($project_title, $proposar_name);
+ if (DF_RenameDir($proposal_id, $directory_names)) {
+ $directory_name = $directory_names;
+ } //LM_RenameDir($proposal_id, $directory_names)
+ else {
+ return;
+ }
+ $query = "UPDATE case_study_proposal SET
name_title=:name_title,
contributor_name=:contributor_name,
university=:university,
@@ -1013,23 +1040,23 @@ function cfd_case_study_proposal_edit_form_submit($form, &$form_state)
solver_used=:solver_used,
directory_name=:directory_name
WHERE id=:proposal_id";
- $args = array(
- ':name_title' => $v['name_title'],
- ':contributor_name' => $v['contributor_name'],
- ':university' => $v['university'],
- ":institute" => $v['institute'],
- ":how_did_you_know_about_project" => $v['how_did_you_know_about_project'],
- ":faculty_name" => $v['faculty_name'],
- ":faculty_department" => $v['faculty_department'],
- ":faculty_email" => $v['faculty_email'],
- ':city' => $v['city'],
- ':pincode' => $v['pincode'],
- ':state' => $v['all_state'],
- ':project_title' => $project_title,
- ":solver_used" => $solver_used,
- ':directory_name' => $directory_name,
- ':proposal_id' => $proposal_id
- );
- $result = db_query($query, $args);
- drupal_set_message(t('Proposal Updated'), 'status');
+ $args = array(
+ ':name_title' => $v['name_title'],
+ ':contributor_name' => $v['contributor_name'],
+ ':university' => $v['university'],
+ ":institute" => $v['institute'],
+ ":how_did_you_know_about_project" => $v['how_did_you_know_about_project'],
+ ":faculty_name" => $v['faculty_name'],
+ ":faculty_department" => $v['faculty_department'],
+ ":faculty_email" => $v['faculty_email'],
+ ':city' => $v['city'],
+ ':pincode' => $v['pincode'],
+ ':state' => $v['all_state'],
+ ':project_title' => $project_title,
+ ":solver_used" => $solver_used,
+ ':directory_name' => $directory_name,
+ ':proposal_id' => $proposal_id,
+ );
+ $result = db_query($query, $args);
+ drupal_set_message(t('Proposal Updated'), 'status');
}
diff --git a/upload_code.inc b/upload_code.inc
index 42efe22..0cfa27f 100755
--- a/upload_code.inc
+++ b/upload_code.inc
@@ -2,400 +2,601 @@
// $Id$
function cfd_case_study_abstract()
{
- global $user;
- $return_html = "";
- $proposal_data = cfd_case_study_get_proposal();
- if (!$proposal_data)
- {
- drupal_goto('');
- return;
- } //!$proposal_data
- //$return_html .= l('Upload abstract', 'case-study-project/abstract-code/upload') . '<br />';
- /* get experiment list */
- $query = db_select('case_study_submitted_abstracts');
- $query->fields('case_study_submitted_abstracts');
- $query->condition('proposal_id', $proposal_data->id);
- $abstracts_q = $query->execute()->fetchObject();
- $query_pro = db_select('case_study_proposal');
- $query_pro->fields('case_study_proposal');
- $query_pro->condition('id', $proposal_data->id);
- $abstracts_pro = $query_pro->execute()->fetchObject();
- $query_pdf = db_select('case_study_submitted_abstracts_file');
- $query_pdf->fields('case_study_submitted_abstracts_file');
- $query_pdf->condition('proposal_id', $proposal_data->id);
- $query_pdf->condition('filetype', 'A');
- $abstracts_pdf = $query_pdf->execute()->fetchObject();
- if ($abstracts_pdf == TRUE)
- {
- if ($abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != "")
- {
- $abstract_filename = $abstracts_pdf->filename;
- //$abstract_filename = l($abstracts_pdf->filename, 'case-study-project/download/project-file/' . $proposal_data->id);
- } //$abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != ""
- else
- {
- $abstract_filename = "File not uploaded";
- }
- } //$abstracts_pdf == TRUE
- else
- {
- $abstract_filename = "File not uploaded";
- }
- $query_process = db_select('case_study_submitted_abstracts_file');
- $query_process->fields('case_study_submitted_abstracts_file');
- $query_process->condition('proposal_id', $proposal_data->id);
- $query_process->condition('filetype', 'S');
- $abstracts_query_process = $query_process->execute()->fetchObject();
- if ($abstracts_query_process == TRUE)
- {
- if ($abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != "")
- {
- $abstracts_query_process_filename = $abstracts_query_process->filename;
- //$abstracts_query_process_filename = l($abstracts_query_process->filename, 'case-study-project/download/project-file/' . $proposal_data->id);
- } //$abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != ""
- else
- {
- $abstracts_query_process_filename = "File not uploaded";
- }
- if ($abstracts_q->is_submitted == '')
- {
- $url = l('Upload Case Directory', 'case-study-project/abstract-code/upload');
- } //$abstracts_q->is_submitted == ''
- else if ($abstracts_q->is_submitted == 1)
- {
- $url = "";
- } //$abstracts_q->is_submitted == 1
- else if ($abstracts_q->is_submitted == 0)
- {
- $url = l('Edit', 'case-study-project/abstract-code/upload');
- } //$abstracts_q->is_submitted == 0
- } //$abstracts_query_process == TRUE
- else
- {
- $url = l('Upload Case Directory', 'case-study-project/abstract-code/upload');
- $abstracts_query_process_filename = "File not uploaded";
- }
- $return_html .= '<strong>Contributor Name:</strong><br />' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '<br /><br />';
- $return_html .= '<strong>Title of the Case Study Project:</strong><br />' . $proposal_data->project_title . '<br /><br />';
- $return_html .= '<strong>Uploaded abstract of the project:</strong><br />' . $abstract_filename . '<br /><br />';
- $return_html .= '<strong>Uploaded Case Directory:</strong><br />' . $abstracts_query_process_filename . '<br /><br />';
- $return_html .= $url . '<br />';
- return $return_html;
+ global $user;
+ $return_html = "";
+ $proposal_data = cfd_case_study_get_proposal();
+ if (!$proposal_data) {
+ drupal_goto('');
+ return;
+ } //!$proposal_data
+ //$return_html .= l('Upload abstract', 'case-study-project/abstract-code/upload') . '<br />';
+ /* get experiment list */
+ $query = db_select('case_study_submitted_abstracts');
+ $query->fields('case_study_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_data->id);
+ $abstracts_q = $query->execute()->fetchObject();
+ $query_pro = db_select('case_study_proposal');
+ $query_pro->fields('case_study_proposal');
+ $query_pro->condition('id', $proposal_data->id);
+ $abstracts_pro = $query_pro->execute()->fetchObject();
+ $query_pdf = db_select('case_study_submitted_abstracts_file');
+ $query_pdf->fields('case_study_submitted_abstracts_file');
+ $query_pdf->condition('proposal_id', $proposal_data->id);
+ $query_pdf->condition('filetype', 'A');
+ $abstracts_pdf = $query_pdf->execute()->fetchObject();
+ if ($abstracts_pdf == true) {
+ if ($abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != "") {
+ $abstract_filename = $abstracts_pdf->filename;
+ //$abstract_filename = l($abstracts_pdf->filename, 'case-study-project/download/project-file/' . $proposal_data->id);
+ } //$abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != ""
+ else {
+ $abstract_filename = "File not uploaded";
+ }
+ } //$abstracts_pdf == TRUE
+ else {
+ $abstract_filename = "File not uploaded";
+ }
+ $query_process = db_select('case_study_submitted_abstracts_file');
+ $query_process->fields('case_study_submitted_abstracts_file');
+ $query_process->condition('proposal_id', $proposal_data->id);
+ $query_process->condition('filetype', 'S');
+ $abstracts_query_process = $query_process->execute()->fetchObject();
+ if ($abstracts_query_process == true) {
+ if ($abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != "") {
+ $abstracts_query_process_filename = $abstracts_query_process->filename;
+ //$abstracts_query_process_filename = l($abstracts_query_process->filename, 'case-study-project/download/project-file/' . $proposal_data->id);
+ } //$abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != ""
+ else {
+ $abstracts_query_process_filename = "File not uploaded";
+ }
+ if ($abstracts_q->is_submitted == '') {
+ $url = l('Upload Case Directory', 'case-study-project/abstract-code/upload');
+ } //$abstracts_q->is_submitted == ''
+ else if ($abstracts_q->is_submitted == 1) {
+ $url = "";
+ } //$abstracts_q->is_submitted == 1
+ else if ($abstracts_q->is_submitted == 0) {
+ $url = l('Edit', 'case-study-project/abstract-code/upload');
+ } //$abstracts_q->is_submitted == 0
+ } //$abstracts_query_process == TRUE
+ else {
+ $url = l('Upload Case Directory', 'case-study-project/abstract-code/upload');
+ $abstracts_query_process_filename = "File not uploaded";
+ }
+ $return_html .= '<strong>Contributor Name:</strong><br />' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '<br /><br />';
+ $return_html .= '<strong>Title of the Case Study Project:</strong><br />' . $proposal_data->project_title . '<br /><br />';
+ $return_html .= '<strong>Uploaded abstract of the project:</strong><br />' . $abstract_filename . '<br /><br />';
+ $return_html .= '<strong>Uploaded Case Directory:</strong><br />' . $abstracts_query_process_filename . '<br /><br />';
+ $return_html .= $url . '<br />';
+ return $return_html;
}
function cfd_case_study_upload_abstract_code_form($form, &$form_state)
{
- global $user;
- $form['#attributes'] = array(
- 'enctype' => "multipart/form-data"
- );
- /* get current proposal */
- //$proposal_id = (int) arg(3);
- $uid = $user->uid;
- $query = db_select('case_study_proposal');
- $query->fields('case_study_proposal');
- $query->condition('uid', $uid);
- $query->condition('approval_status', '1');
- $proposal_q = $query->execute();
- if ($proposal_q)
- {
- if ($proposal_data = $proposal_q->fetchObject())
- {
- /* everything ok */
- } //$proposal_data = $proposal_q->fetchObject()
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/abstract-code');
- return;
- }
- } //$proposal_q
- else
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('case-study-project/abstract-code');
- return;
- }
- $query = db_select('case_study_submitted_abstracts');
- $query->fields('case_study_submitted_abstracts');
- $query->condition('proposal_id', $proposal_data->id);
- $abstracts_q = $query->execute()->fetchObject();
- if ($abstracts_q)
- {
- if ($abstracts_q->is_submitted == 1)
- {
- drupal_set_message(t('You have already submited your Case Directory, hence you can not upload any more, for any query please write to us.'), 'error', $repeat = FALSE);
- drupal_goto('case-study-project/abstract-code');
- //return;
- } //$abstracts_q->is_submitted == 1
- } //$abstracts_q->is_submitted == 1
- $form['project_title'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->project_title,
- '#title' => t('Title of the Case Study Project')
- );
- $form['contributor_name'] = array(
- '#type' => 'item',
- '#markup' => $proposal_data->contributor_name,
- '#title' => t('Contributor Name')
- );
- $existing_uploaded_S_file = default_value_for_uploaded_files("S", $proposal_data->id);
- if (!$existing_uploaded_S_file)
- {
- $existing_uploaded_S_file = new stdClass();
- $existing_uploaded_S_file->filename = "No file uploaded";
- } //!$existing_uploaded_S_file
- $form['upload_case_study_developed_process'] = array(
- '#type' => 'file',
- '#title' => t('Upload the Case Directory'),
- //'#required' => TRUE,
- '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_S_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('case_study_project_files_extensions', '') . '</span>'
- );
- $form['prop_id'] = array(
- '#type' => 'hidden',
- '#value' => $proposal_data->id
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit'),
- '#submit' => array(
- 'cfd_case_study_upload_abstract_code_form_submit'
- )
- );
- $form['cancel'] = array(
- '#type' => 'item',
- '#markup' => l(t('Cancel'), 'case-study-project/abstract-code')
- );
- return $form;
+ global $user;
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data",
+ );
+ /* get current proposal */
+ //$proposal_id = (int) arg(3);
+ $uid = $user->uid;
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('uid', $uid);
+ $query->condition('approval_status', '1');
+ $proposal_q = $query->execute();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/abstract-code');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/abstract-code');
+ return;
+ }
+ $query = db_select('case_study_submitted_abstracts');
+ $query->fields('case_study_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_data->id);
+ $abstracts_q = $query->execute()->fetchObject();
+ if ($abstracts_q) {
+ if ($abstracts_q->is_submitted == 1) {
+ drupal_set_message(t('You have already submited your Case Directory, hence you can not upload any more, for any query please write to us.'), 'error', $repeat = false);
+ drupal_goto('case-study-project/abstract-code');
+ //return;
+ } //$abstracts_q->is_submitted == 1
+ } //$abstracts_q->is_submitted == 1
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Case Study Project'),
+ );
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->contributor_name,
+ '#title' => t('Contributor Name'),
+ );
+ $existing_uploaded_S_file = default_value_for_uploaded_files("S", $proposal_data->id);
+ if (!$existing_uploaded_S_file) {
+ $existing_uploaded_S_file = new stdClass();
+ $existing_uploaded_S_file->filename = "No file uploaded";
+ } //!$existing_uploaded_S_file
+ $form['upload_case_study_developed_process'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload the Case Directory'),
+ //'#required' => TRUE,
+ '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_S_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('case_study_project_files_extensions', '') . '</span>',
+ );
+ $form['prop_id'] = array(
+ '#type' => 'hidden',
+ '#value' => $proposal_data->id,
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ '#submit' => array(
+ 'cfd_case_study_upload_abstract_code_form_submit',
+ ),
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'case-study-project/abstract-code'),
+ );
+ return $form;
}
///////////////////////////////////////////////////////////////
function cfd_case_study_upload_abstract_code_form_validate($form, &$form_state)
{
- //var_dump($form);die;
- if (isset($_FILES['files']))
- {
- /* check if atleast one source or result file is uploaded */
- if (!($_FILES['files']['name']['upload_case_study_developed_process']))
- form_set_error('upload_case_study_developed_process', t('Please upload the abstract file'));
- /* check for valid filename extensions */
- foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
- {
- if ($file_name)
- {
- /* checking file type */
- $allowed_extensions_str = variable_get('case_study_project_files_extensions', '');
- $allowed_extensions = explode(',', $allowed_extensions_str);
- $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
- $temp_extension = end($fnames);
- if (!in_array($temp_extension, $allowed_extensions))
- form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' 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 valid file name */
- if (!cfd_case_study_check_valid_filename($_FILES['files']['name'][$file_form_name]))
- form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
- } //$file_name
- } //$_FILES['files']['name'] as $file_form_name => $file_name
- }
- return $form_state;
+ //var_dump($form);die;
+ if (isset($_FILES['files'])) {
+ /* check if atleast one source or result file is uploaded */
+ if (!($_FILES['files']['name']['upload_case_study_developed_process'])) {
+ form_set_error('upload_case_study_developed_process', t('Please upload the abstract file'));
+ }
+
+ /* check for valid filename extensions */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+ if ($file_name) {
+ /* checking file type */
+ $allowed_extensions_str = variable_get('case_study_project_files_extensions', '');
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($fnames);
+ if (!in_array($temp_extension, $allowed_extensions)) {
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' 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 valid file name */
+ if (!cfd_case_study_check_valid_filename($_FILES['files']['name'][$file_form_name])) {
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
+ }
+
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ }
+ return $form_state;
}
function cfd_case_study_upload_abstract_code_form_submit($form, &$form_state)
{
- global $user;
- $v = $form_state['values'];
- $root_path = cfd_case_study_path();
- $proposal_data = cfd_case_study_get_proposal();
- $proposal_id = $proposal_data->id;
- if (!$proposal_data)
- {
- drupal_goto('');
- return;
- } //!$proposal_data
- $proposal_id = $proposal_data->id;
- $proposal_directory = $proposal_data->directory_name;
- /* create proposal folder if not present */
- //$dest_path = $proposal_directory . '/';
- $dest_path_project_files = $proposal_directory . '/';
- $proposal_id = $proposal_data->id;
- $query_s = "SELECT * FROM {case_study_submitted_abstracts} WHERE proposal_id = :proposal_id";
- $args_s = array(
- ":proposal_id" => $proposal_id
- );
- $query_s_result = db_query($query_s, $args_s)->fetchObject();
- if (!$query_s_result)
- {
- /* creating solution database entry */
- $query = "INSERT INTO {case_study_submitted_abstracts} (
+ global $user;
+ $v = $form_state['values'];
+ $root_path = cfd_case_study_path();
+ $proposal_data = cfd_case_study_get_proposal();
+ $proposal_id = $proposal_data->id;
+ if (!$proposal_data) {
+ drupal_goto('');
+ return;
+ } //!$proposal_data
+ $proposal_id = $proposal_data->id;
+ $proposal_directory = $proposal_data->directory_name;
+ /* create proposal folder if not present */
+ //$dest_path = $proposal_directory . '/';
+ $dest_path_project_files = $proposal_directory . '/';
+ $proposal_id = $proposal_data->id;
+ $query_s = "SELECT * FROM {case_study_submitted_abstracts} WHERE proposal_id = :proposal_id";
+ $args_s = array(
+ ":proposal_id" => $proposal_id,
+ );
+ $query_s_result = db_query($query_s, $args_s)->fetchObject();
+ if (!$query_s_result) {
+ /* creating solution database entry */
+ $query = "INSERT INTO {case_study_submitted_abstracts} (
proposal_id,
approver_uid,
abstract_approval_status,
abstract_upload_date,
abstract_approval_date,
is_submitted) VALUES (:proposal_id, :approver_uid, :abstract_approval_status,:abstract_upload_date, :abstract_approval_date, :is_submitted)";
- $args = array(
- ":proposal_id" => $proposal_id,
- ":approver_uid" => 0,
- ":abstract_approval_status" => 0,
- ":abstract_upload_date" => time(),
- ":abstract_approval_date" => 0,
- ":is_submitted" => 1
- );
- $submitted_abstract_id = db_query($query, $args, array(
- 'return' => Database::RETURN_INSERT_ID
- ));
- $query1 = "UPDATE {case_study_proposal} SET is_submitted = :is_submitted WHERE id = :id";
- $args1 = array(
- ":is_submitted" => 1,
- ":id" => $proposal_id
- );
- db_query($query1,$args1);
- drupal_set_message('Abstract uploaded successfully.', 'status');
- } //!$query_s_result
- else
- {
- $query = "UPDATE {case_study_submitted_abstracts} SET
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":approver_uid" => 0,
+ ":abstract_approval_status" => 0,
+ ":abstract_upload_date" => time(),
+ ":abstract_approval_date" => 0,
+ ":is_submitted" => 1,
+ );
+ $submitted_abstract_id = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID,
+ ));
+ $query1 = "UPDATE {case_study_proposal} SET is_submitted = :is_submitted WHERE id = :id";
+ $args1 = array(
+ ":is_submitted" => 1,
+ ":id" => $proposal_id,
+ );
+ db_query($query1, $args1);
+ drupal_set_message('Abstract uploaded successfully.', 'status');
+ } //!$query_s_result
+ else {
+ $query = "UPDATE {case_study_submitted_abstracts} SET
+
-
abstract_upload_date =:abstract_upload_date,
- is_submitted= :is_submitted
+ is_submitted= :is_submitted
WHERE proposal_id = :proposal_id
";
- $args = array(
-
- ":abstract_upload_date" => time(),
- ":is_submitted" => 1,
- ":proposal_id" => $proposal_id
- );
- $submitted_abstract_id = db_query($query, $args, array(
- 'return' => Database::RETURN_INSERT_ID
- ));
- $query1 = "UPDATE {case_study_proposal} SET is_submitted = :is_submitted WHERE id = :id";
- $args1 = array(
- ":is_submitted" => 1,
- ":id" => $proposal_id
- );
- db_query($query1,$args1);
- drupal_set_message('Abstract updated successfully.', 'status');
- }
- foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
- {
- if ($file_name)
- {
- /* checking file type */
- if (strstr($file_form_name, 'upload_case_study_developed_process'))
- {
- $file_type = 'S';
- } //strstr($file_form_name, 'upload_case_study_developed_process')
- switch ($file_type)
- {
- case 'S':
+ $args = array(
+
+ ":abstract_upload_date" => time(),
+ ":is_submitted" => 1,
+ ":proposal_id" => $proposal_id,
+ );
+ $submitted_abstract_id = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID,
+ ));
+ $query1 = "UPDATE {case_study_proposal} SET is_submitted = :is_submitted WHERE id = :id";
+ $args1 = array(
+ ":is_submitted" => 1,
+ ":id" => $proposal_id,
+ );
+ db_query($query1, $args1);
+ drupal_set_message('Abstract updated successfully.', 'status');
+ }
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+ if ($file_name) {
+ /* checking file type */
+ if (strstr($file_form_name, 'upload_case_study_developed_process')) {
+ $file_type = 'S';
+ } //strstr($file_form_name, 'upload_case_study_developed_process')
+ switch ($file_type) {
+ case 'S':
- if (file_exists($root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name]))
- {
- //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
- drupal_set_message(t("File !filename already exists hence overwirtten the exisitng file ", array(
- '!filename' => $_FILES['files']['name'][$file_form_name]
- )), 'error');
- } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
- /* uploading file */
- else if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name]))
- {
- /* for uploaded files making an entry in the database */
- $query_abstracts = "SELECT * FROM case_study_submitted_abstracts WHERE proposal_id = :proposal_id";
- $query_abstracts_args = array(
- ":proposal_id" => $proposal_id
- );
- $query_abstracts_result = db_query($query_abstracts, $query_abstracts_args)->fetchObject();
- $submitted_abstract_id = $query_abstracts_result->id;
- $query_ab_f = "SELECT * FROM case_study_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype =
+ if (file_exists($root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name])) {
+ //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ drupal_set_message(t("File !filename already exists hence overwirtten the exisitng file ", array(
+ '!filename' => $_FILES['files']['name'][$file_form_name],
+ )), 'error');
+ } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ /* uploading file */
+ else if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name])) {
+ /* for uploaded files making an entry in the database */
+ $query_abstracts = "SELECT * FROM case_study_submitted_abstracts WHERE proposal_id = :proposal_id";
+ $query_abstracts_args = array(
+ ":proposal_id" => $proposal_id,
+ );
+ $query_abstracts_result = db_query($query_abstracts, $query_abstracts_args)->fetchObject();
+ $submitted_abstract_id = $query_abstracts_result->id;
+ $query_ab_f = "SELECT * FROM case_study_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype =
:filetype";
- $args_ab_f = array(
- ":proposal_id" => $proposal_id,
- ":filetype" => $file_type
- );
- $query_ab_f_result = db_query($query_ab_f, $args_ab_f)->fetchObject();
- if (!$query_ab_f_result)
- {
- $query = "INSERT INTO {case_study_submitted_abstracts_file} (submitted_abstract_id, proposal_id, uid, approvar_uid, filename, filepath, filemime, filesize, filetype, timestamp)
+ $args_ab_f = array(
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type,
+ );
+ $query_ab_f_result = db_query($query_ab_f, $args_ab_f)->fetchObject();
+ if (!$query_ab_f_result) {
+ $query = "INSERT INTO {case_study_submitted_abstracts_file} (submitted_abstract_id, proposal_id, uid, approvar_uid, filename, filepath, filemime, filesize, filetype, timestamp)
VALUES (:submitted_abstract_id, :proposal_id, :uid, :approvar_uid, :filename, :filepath, :filemime, :filesize, :filetype, :timestamp)";
- $args = array(
- ":submitted_abstract_id" => $submitted_abstract_id,
- ":proposal_id" => $proposal_id,
- ":uid" => $user->uid,
- ":approvar_uid" => 0,
- ":filename" => $_FILES['files']['name'][$file_form_name],
- ":filepath" => $_FILES['files']['name'][$file_form_name],
- ":filemime" => mime_content_type($root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name]),
- ":filesize" => $_FILES['files']['size'][$file_form_name],
- ":filetype" => $file_type,
- ":timestamp" => time()
- );
- db_query($query, $args, array('return' => Database::RETURN_INSERT_ID));
- drupal_set_message($file_name . ' uploaded successfully.', 'status');
- } //!$query_ab_f_result
- else
- {
- unlink($root_path . $dest_path_project_files . $query_ab_f_result->filename);
- $query = "UPDATE {case_study_submitted_abstracts_file} SET filename = :filename, filepath=:filepath, filemime=:filemime, filesize=:filesize, timestamp=:timestamp WHERE proposal_id = :proposal_id AND filetype = :filetype";
- $args = array(
- ":filename" => $_FILES['files']['name'][$file_form_name],
- ":filepath" => $file_path . $_FILES['files']['name'][$file_form_name],
- ":filemime" => mime_content_type($root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name]),
- ":filesize" => $_FILES['files']['size'][$file_form_name],
- ":timestamp" => time(),
- ":proposal_id" => $proposal_id,
- ":filetype" => $file_type
- );
- db_query($query, $args, array('return' => Database::RETURN_INSERT_ID
- ));
+ $args = array(
+ ":submitted_abstract_id" => $submitted_abstract_id,
+ ":proposal_id" => $proposal_id,
+ ":uid" => $user->uid,
+ ":approvar_uid" => 0,
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":filetype" => $file_type,
+ ":timestamp" => time(),
+ );
+ db_query($query, $args, array('return' => Database::RETURN_INSERT_ID));
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ } //!$query_ab_f_result
+ else {
+ unlink($root_path . $dest_path_project_files . $query_ab_f_result->filename);
+ $query = "UPDATE {case_study_submitted_abstracts_file} SET filename = :filename, filepath=:filepath, filemime=:filemime, filesize=:filesize, timestamp=:timestamp WHERE proposal_id = :proposal_id AND filetype = :filetype";
+ $args = array(
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $file_path . $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":timestamp" => time(),
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type,
+ );
+ db_query($query, $args, array('return' => Database::RETURN_INSERT_ID,
+ ));
- drupal_set_message($file_name . ' file updated successfully.', 'status');
- }
- } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
- else
- {
- drupal_set_message('Error uploading file : ' . $dest_path_project_files . $file_name, 'error');
- }
- break;
- } //$file_type
- } //$file_name
- } //$_FILES['files']['name'] as $file_form_name => $file_name
- /* sending email */
- $email_to = $user->mail;
- $from = variable_get('case_study_from_email', '');
- $bcc = variable_get('case_study_emails', '');
- $cc = variable_get('case_study_cc_emails', '');
- $params['abstract_uploaded']['proposal_id'] = $proposal_id;
- $params['abstract_uploaded']['submitted_abstract_id'] = $submitted_abstract_id;
- $params['abstract_uploaded']['user_id'] = $user->uid;
- $params['abstract_uploaded']['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('case_study', 'abstract_uploaded', $email_to, language_default(), $params, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- drupal_goto('case-study-project/abstract-code');
+ drupal_set_message($file_name . ' file updated successfully.', 'status');
+ }
+ } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ else {
+ drupal_set_message('Error uploading file : ' . $dest_path_project_files . $file_name, 'error');
+ }
+ break;
+ } //$file_type
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('case_study_from_email', '');
+ $bcc = variable_get('case_study_emails', '');
+ $cc = variable_get('case_study_cc_emails', '');
+ $params['abstract_uploaded']['proposal_id'] = $proposal_id;
+ $params['abstract_uploaded']['submitted_abstract_id'] = $submitted_abstract_id;
+ $params['abstract_uploaded']['user_id'] = $user->uid;
+ $params['abstract_uploaded']['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('case_study', 'abstract_uploaded', $email_to, language_default(), $params, $from, true)) {
+ drupal_set_message('Error sending email message.', 'error');
+ }
+
+ drupal_goto('case-study-project/abstract-code');
}
function default_value_for_uploaded_files($filetype, $proposal_id)
{
- $query = db_select('case_study_submitted_abstracts_file');
- $query->fields('case_study_submitted_abstracts_file');
- $query->condition('proposal_id', $proposal_id);
- $selected_files_array = "";
- if ($filetype == "S")
- {
- $query->condition('filetype', $filetype);
- $filetype_q = $query->execute()->fetchObject();
- return $filetype_q;
- }
- else
- {
- return;
- }
- return;
+ $query = db_select('case_study_submitted_abstracts_file');
+ $query->fields('case_study_submitted_abstracts_file');
+ $query->condition('proposal_id', $proposal_id);
+ $selected_files_array = "";
+ if ($filetype == "S") {
+ $query->condition('filetype', $filetype);
+ $filetype_q = $query->execute()->fetchObject();
+ return $filetype_q;
+ } elseif ($filetype == "A") {
+ $query->condition('filetype', $filetype);
+ $filetype_q = $query->execute()->fetchObject();
+ return $filetype_q;
+ }
+ return;
+}
+function cfd_case_study_edit_upload_abstract_code_form($form, &$form_state)
+{
+ global $user;
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data",
+ );
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $uid = $user->uid;
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q) {
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal/edit-upload-file');
+ return;
+ }
+ } //$proposal_q
+ else {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('case-study-project/manage-proposal/edit-upload-file');
+ return;
+ }
+ $query = db_select('case_study_submitted_abstracts');
+ $query->fields('case_study_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_data->id);
+ $abstracts_q = $query->execute()->fetchObject();
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Case Study Project'),
+ );
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->contributor_name,
+ '#title' => t('Contributor Name'),
+ );
+ $existing_uploaded_A_file = default_value_for_uploaded_files("A", $proposal_data->id);
+ if (!$existing_uploaded_A_file) {
+ $existing_uploaded_A_file = new stdClass();
+ $existing_uploaded_A_file->filename = "No file uploaded";
+ } //!$existing_uploaded_A_file
+ $form['upload_case_study_abstract'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload the Case study abstract'),
+ //'#required' => TRUE,
+ '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_A_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('resource_upload_extensions', '') . '</span>',
+ );
+ $existing_uploaded_S_file = default_value_for_uploaded_files("S", $proposal_data->id);
+ if (!$existing_uploaded_S_file) {
+ $existing_uploaded_S_file = new stdClass();
+ $existing_uploaded_S_file->filename = "No file uploaded";
+ } //!$existing_uploaded_S_file
+ $form['upload_case_study_developed_process'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload the Case Directory'),
+ //'#required' => TRUE,
+ '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_S_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('case_study_project_files_extensions', '') . '</span>',
+ );
+ $form['prop_id'] = array(
+ '#type' => 'hidden',
+ '#value' => $proposal_data->id,
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ '#submit' => array(
+ 'cfd_case_study_edit_upload_abstract_code_form_submit',
+ ),
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'case-study-project/manage-proposal/edit-upload-file'),
+ );
+ return $form;
+}
+///////////////////////////////////////////////////////////////
+function cfd_case_study_edit_upload_abstract_code_form_validate($form, &$form_state)
+{
+
+ if (!($_FILES['files']['name']['upload_case_study_abstract'] || $_FILES['files']['name']['upload_case_study_developed_process'])) {
+ drupal_set_message('No files uploaded', 'error');
+ return;
+ }
+ if (isset($_FILES['files'])) {
+ /* check for valid filename extensions */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+ if ($file_name) {
+ /* checking file type */
+ if (strstr($file_form_name, 'upload_case_study_abstract')) {
+ $file_type = 'A';
+ } else if (strstr($file_form_name, 'upload_case_study_developed_process')) {
+ $file_type = 'S';
+ } else {
+ $file_type = 'U';
+ }
+
+ $allowed_extensions_str = '';
+ switch ($file_type) {
+ case 'A':
+ $allowed_extensions_str = variable_get('resource_upload_extensions', '');
+ break;
+ case 'S':
+ $allowed_extensions_str = variable_get('case_study_project_files_extensions', '');
+ break;
+ } //$file_type
+ /* checking file type */
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($fnames);
+ if (!in_array($temp_extension, $allowed_extensions)) {
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' 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 valid file name */
+ if (!cfd_case_study_check_valid_filename($_FILES['files']['name'][$file_form_name])) {
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
+ }
+
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ } else {
+ drupal_set_message('No files uploaded', 'error');
+ return $form_state;
+ }
+
+}
+function cfd_case_study_edit_upload_abstract_code_form_submit($form, &$form_state)
+{
+ global $user;
+ $v = $form_state['values'];
+ $root_path = cfd_case_study_path();
+ $query = db_select('case_study_proposal');
+ $query->fields('case_study_proposal');
+ $query->condition('id', $v['prop_id']);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ $proposal_id = $proposal_data->id;
+ if (!$proposal_data) {
+ drupal_goto('');
+ return;
+ } //!$proposal_data
+ $proposal_id = $proposal_data->id;
+ $proposal_directory = $proposal_data->directory_name;
+ /* create proposal folder if not present */
+ //$dest_path = $proposal_directory . '/';
+ $dest_path_project_files = $proposal_directory . '/';
+ $proposal_id = $proposal_data->id;
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+
+ if ($file_name) {
+ /* uploading file */
+ /* checking file type */
+ if (strstr($file_form_name, 'upload_case_study_abstract')) {
+ $file_type = 'A';
+ $abs_file_name = $_FILES['files']['name'][$file_form_name];
+ } else {
+ $abs_file_name = "Not updated";
+ }
+ if (strstr($file_form_name, 'upload_case_study_developed_process')) {
+ $file_type = 'S';
+ $proj_file_name = $_FILES['files']['name'][$file_form_name];
+ } else {
+ $proj_file_name = "Not updated";
+ }
+ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name])) {
+ $query_ab_f = "SELECT * FROM case_study_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype =
+ :filetype";
+ $args_ab_f = array(
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type,
+ );
+ $query_ab_f_result = db_query($query_ab_f, $args_ab_f)->fetchObject();
+ unlink($root_path . $dest_path_project_files . $query_ab_f_result->filename);
+ $query = "UPDATE {case_study_submitted_abstracts_file} SET filename = :filename, filepath=:filepath, filemime=:filemime, filesize=:filesize, timestamp=:timestamp WHERE proposal_id = :proposal_id AND filetype = :filetype";
+ $args = array(
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $file_path . $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path_project_files . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":timestamp" => time(),
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type,
+ );
+ db_query($query, $args, array('return' => Database::RETURN_INSERT_ID,
+ ));
+
+ drupal_set_message($file_name . ' file updated successfully.', 'status');
+
+ } else {
+ drupal_set_message($file_name . ' file not updated successfully.', 'error');
+ }
+ }
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('case_study_from_email', '');
+ $bcc = variable_get('case_study_emails', '');
+ $cc = variable_get('case_study_cc_emails', '');
+ $params['abstract_edit_file_uploaded']['proposal_id'] = $proposal_id;
+ $params['abstract_edit_file_uploaded']['user_id'] = $user->uid;
+ $params['abstract_edit_file_uploaded']['abs_file'] = $abs_file_name;
+ $params['abstract_edit_file_uploaded']['proj_file'] = $proj_file_name;
+ $params['abstract_edit_file_uploaded']['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('case_study', 'abstract_edit_file_uploaded', $email_to, language_default(), $params, $from, true)) {
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ drupal_goto('case-study-project/abstract-code/edit-upload-files');
}