diff options
author | Sashi20 | 2020-02-03 14:50:20 +0530 |
---|---|---|
committer | Sashi20 | 2020-02-03 14:50:20 +0530 |
commit | ea8664a466b084a09e286aa4200c447b458e6510 (patch) | |
tree | 97cef0c9e7fcfa6dac67639b4598483b7270985d | |
parent | 1eff5287eb5edfb72c61049879ed99ffa925119b (diff) | |
download | dwsim_custom_model-ea8664a466b084a09e286aa4200c447b458e6510.tar.gz dwsim_custom_model-ea8664a466b084a09e286aa4200c447b458e6510.tar.bz2 dwsim_custom_model-ea8664a466b084a09e286aa4200c447b458e6510.zip |
Add form to submit ideas for custom model
-rwxr-xr-x | custom_model.module | 60 | ||||
-rwxr-xr-x | download.inc | 30 | ||||
-rw-r--r-- | idea_proposal.inc | 466 | ||||
-rwxr-xr-x | manage_proposal.inc | 166 | ||||
-rwxr-xr-x | settings.inc | 10 |
5 files changed, 730 insertions, 2 deletions
diff --git a/custom_model.module b/custom_model.module index 5530670..99291ff 100755 --- a/custom_model.module +++ b/custom_model.module @@ -25,6 +25,19 @@ function custom_model_menu() 'type' => MENU_NORMAL_ITEM, 'file' => 'proposal.inc' ); + $items['custom-model/idea-proposal'] = array( + 'title' => 'Custom Model Idea Proposal Form', + 'description' => 'Custom Model Idea Proposal Form', + 'page callback' => 'drupal_get_form', + 'page arguments' => array( + 'custom_model_idea_proposal_form' + ), + 'access arguments' => array( + 'custom model create idea proposal' + ), + 'type' => MENU_NORMAL_ITEM, + 'file' => 'idea_proposal.inc' + ); $items['custom-model/manage-proposal'] = array( 'title' => 'Manage Custom Model Proposals', 'description' => 'Manage Custom Model Proposals', @@ -59,6 +72,18 @@ function custom_model_menu() 'weight' => 4, 'file' => 'manage_proposal.inc' ); + $items['custom-model/manage-proposal/idea-proposals'] = array( + 'title' => 'Idea Proposals', + 'description' => 'Idea Proposals', + 'page callback' => 'custom_model_idea_proposal_all', + 'access callback' => 'user_access', + 'access arguments' => array( + 'custom model manage proposal' + ), + 'type' => MENU_LOCAL_TASK, + 'weight' => 5, + 'file' => 'manage_proposal.inc' + ); $items['custom-model/manage-proposal/approve'] = array( 'title' => 'Approve Proposal', 'description' => 'Approve Proposal', @@ -111,6 +136,19 @@ function custom_model_menu() 'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); + $items['custom-model/manage-proposal/view-ideas'] = array( + 'title' => 'View the Idea Proposal', + 'description' => 'View the Idea Proposal', + 'page callback' => 'drupal_get_form', + 'page arguments' => array( + 'custom_model_view_idea_proposal_form' + ), + 'access arguments' => array( + 'custom model view idea proposal' + ), + 'type' => MENU_CALLBACK, + 'file' => 'manage_proposal.inc' + ); $items['custom-model/show-proposal'] = array( 'title' => 'custom model Solution Proposal', 'page callback' => 'drupal_get_form', @@ -313,6 +351,16 @@ function custom_model_menu() 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); + $items['custom-model/download/idea-reference-file'] = array( + 'title' => 'Download the idea reference file', + 'description' => 'Download the idea reference file', + 'page callback' => 'custom_model_download_idea_reference_file', + 'access arguments' => array( + 'download code' + ), + 'type' => MENU_CALLBACK, + 'file' => 'download.inc' + ); $items['custom-model/download/project-file'] = array( 'title' => 'Download Project file', 'description' => 'Download project file', @@ -436,6 +484,10 @@ function custom_model_permission() 'title' => t('custom model create proposal'), 'restrict access' => TRUE ), + 'custom model create idea proposal' => array( + 'title' => t('custom model create idea proposal'), + 'restrict access' => TRUE + ), 'custom model manage proposal' => array( 'title' => t('custom model manage proposal'), 'restrict access' => TRUE @@ -448,6 +500,10 @@ function custom_model_permission() 'title' => t('custom model approve proposal'), 'restrict access' => TRUE ), + 'custom model view idea proposal' => array( + 'title' => t('custom model view idea proposal'), + 'restrict access' => TRUE + ), 'custom model propose solution' => array( 'title' => t('custom model propose solution'), 'restrict access' => TRUE @@ -590,6 +646,10 @@ function custom_model_path() { return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/custom_model_uploads/'; } +function custom_model_ideas_files_path() +{ + return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/custom_model_uploads/ideas_files/'; +} function _cm_list_of_departments() { $department = array(); diff --git a/download.inc b/download.inc index 10e4eee..e81d822 100755 --- a/download.inc +++ b/download.inc @@ -11,7 +11,6 @@ function custom_model_download_uploaded_file() $result = $query->execute(); $custom_model_uploaded_file = $result->fetchObject(); $samplecodename = $custom_model_uploaded_file->samplefilepath; - //var_dump($root_path . $custom_model_uploaded_file->directory_name . '/' . $samplecodename);die; ob_clean(); header("Pragma: public"); header("Expires: 0"); @@ -62,4 +61,33 @@ function custom_model_project_files() { readfile($root_path . $directory_name . $samplecodename); //ob_end_flush(); //ob_clean(); +} +function custom_model_download_idea_reference_file() +{ + $proposal_id = arg(3); + $root_path = custom_model_ideas_files_path(); + $query = db_select('custom_model_idea_proposal'); + $query->fields('custom_model_idea_proposal'); + $query->condition('id', $proposal_id); + $query->range(0, 1); + $result = $query->execute(); + $uploaded_idea_reference_file = $result->fetchObject(); + $samplecodename = $uploaded_idea_reference_file->reference_file; + //var_dump($root_path . $custom_model_uploaded_file->directory_name . '/' . $samplecodename);die; + ob_clean(); + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: public"); + header("Content-Description: File Transfer"); + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename="' . $samplecodename . '"'); + header('Content-Length: ' . filesize($root_path . $uploaded_idea_reference_file->directory_name . '/' . $samplecodename)); + header("Content-Transfer-Encoding: binary"); + header('Expires: 0'); + header('Pragma: no-cache'); + ob_clean(); + readfile($root_path . $uploaded_idea_reference_file->directory_name . '/' . $samplecodename); + //ob_end_flush(); + //flush(); }
\ No newline at end of file diff --git a/idea_proposal.inc b/idea_proposal.inc new file mode 100644 index 0000000..1b0649e --- /dev/null +++ b/idea_proposal.inc @@ -0,0 +1,466 @@ +<?php +function custom_model_idea_proposal_form($form, &$form_state, $no_js_use = FALSE) +{ + global $user; + /************************ start approve book details ************************/ + if ($user->uid == 0) + { + $msg = drupal_set_message(t('It is mandatory to ' . l('login', 'user') . ' on this website to access the custom model idea proposal form. If you are new user please create a new account first.'), 'error'); + drupal_goto('user'); + return $msg; + } //$user->uid == 0 + /*$query = db_select('custom_model_idea_proposal'); + $query->fields('custom_model_idea_proposal'); + $query->condition('uid', $user->uid); + $query->orderBy('id', 'DESC'); + $query->range(0, 1); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + if ($proposal_data) + { + if ($proposal_data->approval_status == 0 || $proposal_data->approval_status == 1) + { + drupal_set_message(t('We have already received your proposal.'), 'status'); + drupal_goto(''); + return; + } //$proposal_data->approval_status == 0 || $proposal_data->approval_status == 1 + }*/ //$proposal_data + $form['#attributes'] = array( + 'enctype' => "multipart/form-data" + ); + $form['note'] = array( + '#type' => 'item', + '#markup' => t('NOTE: This form is to propose ideas for the custom model which you wish to be modeled/created in DWSIM using Python/Scilab'), + ); + $form['name_title'] = array( + '#type' => 'select', + '#title' => t('Title'), + '#options' => array( + 'Dr' => 'Dr', + 'Prof' => 'Prof', + 'Mr' => 'Mr', + 'Mrs' => 'Mrs', + 'Ms' => 'Ms' + ), + '#required' => TRUE + ); + $form['contributor_name'] = array( + '#type' => 'textfield', + '#title' => t('Name of the contributor'), + '#size' => 250, + '#attributes' => array( + 'placeholder' => t('Enter your full name.....') + ), + '#maxlength' => 250, + '#required' => TRUE + ); + $form['contributor_contact_no'] = array( + '#type' => 'textfield', + '#title' => t('Contact No.'), + '#size' => 10, + '#attributes' => array( + 'placeholder' => t('Enter your contact number') + ), + '#maxlength' => 250, + '#required' => TRUE + ); + $form['contributor_email_id'] = array( + '#type' => 'textfield', + '#title' => t('Email'), + '#size' => 30, + '#value' => $user->mail, + '#disabled' => TRUE + ); + $form['university'] = array( + '#type' => 'textfield', + '#title' => t('University / Institute / Organisation'), + '#size' => 80, + '#maxlength' => 200, + '#required' => TRUE, + '#attributes' => array( + 'placeholder' => 'Insert full name of your institute/ university.... ' + ) + ); + $form['country'] = array( + '#type' => 'select', + '#title' => t('Country'), + '#options' => array( + 'India' => 'India', + 'Others' => 'Others' + ), + '#required' => TRUE, + '#tree' => TRUE, + '#validated' => TRUE + ); + $form['other_country'] = array( + '#type' => 'textfield', + '#title' => t('Other than India'), + '#size' => 100, + '#attributes' => array( + 'placeholder' => t('Enter your country name') + ), + '#states' => array( + 'visible' => array( + ':input[name="country"]' => array( + 'value' => 'Others' + ) + ) + ) + ); + $form['other_state'] = array( + '#type' => 'textfield', + '#title' => t('State other than India'), + '#size' => 100, + '#attributes' => array( + 'placeholder' => t('Enter your state/region name') + ), + '#states' => array( + 'visible' => array( + ':input[name="country"]' => array( + 'value' => 'Others' + ) + ) + ) + ); + $form['other_city'] = array( + '#type' => 'textfield', + '#title' => t('City other than India'), + '#size' => 100, + '#attributes' => array( + 'placeholder' => t('Enter your city name') + ), + '#states' => array( + 'visible' => array( + ':input[name="country"]' => array( + 'value' => 'Others' + ) + ) + ) + ); + $form['all_state'] = array( + '#type' => 'select', + '#title' => t('State'), + '#options' => _cm_list_of_states(), + '#validated' => TRUE, + '#states' => array( + 'visible' => array( + ':input[name="country"]' => array( + 'value' => 'India' + ) + ) + ) + ); + $form['city'] = array( + '#type' => 'select', + '#title' => t('City'), + '#options' => _cm_list_of_cities(), + '#states' => array( + 'visible' => array( + ':input[name="country"]' => array( + 'value' => 'India' + ) + ) + ) + ); + $form['pincode'] = array( + '#type' => 'textfield', + '#title' => t('Pincode'), + '#size' => 6, + '#required' => TRUE + ); + /***************************************************************************/ + $form['hr'] = array( + '#type' => 'item', + '#markup' => '<hr>' + ); + $form['project_title'] = array( + '#type' => 'textarea', + '#title' => t('Title of the Custom Model'), + '#size' => 250, + '#description' => t('Maximum character limit is 250'), + '#required' => TRUE + ); + $form['reference_link'] = array( + '#type' => 'textfield', + '#title' => t('Any Reference Web Link:'), + //'#size' => 500, + '#description' => t('Weblink to be used as a reference to understand and create the custom model'), + //'#required' => TRUE + ); + $form['samplefile'] = array( + '#type' => 'fieldset', + '#title' => t('Any Reference File:'), + '#collapsible' => FALSE, + '#collapsed' => FALSE + ); + $form['samplefile']['reference_file'] = array( + '#type' => 'file', + '#size' => 48, + '#description' => t('Any file/document to be used as a reference to understand and create the custom model. Multiple files can be zipped together as a single file.') . '<br />' . t('<span style="color:red;">Allowed file extensions: ') . variable_get('idea_proposal_resource_upload_extensions', '') . '</span>' + ); + $form['term_condition'] = array( + '#type' => 'checkboxes', + '#title' => t('Terms And Conditions'), + '#options' => array( + 'status' => t('<a href="/term-and-conditions" target="_blank">I agree to the Terms and Conditions</a>') + ), + '#required' => TRUE + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); + return $form; +} +function custom_model_idea_proposal_form_validate($form, &$form_state) +{ + $project_title = $form_state['values']['project_title']; + $query = db_select('custom_model_proposal'); + $query->fields('custom_model_proposal'); + $query->condition('project_title', $project_title); + $query->condition(db_or()->condition('approval_status',1)->condition('approval_status',3)); + $result = $query->execute()->rowCount(); + //var_dump($result);die; + if ($result >= 1) + { + form_set_error('project_title', t('Project title name already exists')); + return; + } + if ($form_state['values']['term_condition'] == '1') + { + form_set_error('term_condition', t('Please check the terms and conditions')); + // $form_state['values']['country'] = $form_state['values']['other_country']; + } //$form_state['values']['term_condition'] == '1' + if ($form_state['values']['country'] == 'Others') + { + if ($form_state['values']['other_country'] == '') + { + form_set_error('other_country', t('Enter country name')); + // $form_state['values']['country'] = $form_state['values']['other_country']; + } //$form_state['values']['other_country'] == '' + else + { + $form_state['values']['country'] = $form_state['values']['other_country']; + } + if ($form_state['values']['other_state'] == '') + { + form_set_error('other_state', t('Enter state name')); + // $form_state['values']['country'] = $form_state['values']['other_country']; + } //$form_state['values']['other_state'] == '' + else + { + $form_state['values']['all_state'] = $form_state['values']['other_state']; + } + if ($form_state['values']['other_city'] == '') + { + form_set_error('other_city', t('Enter city name')); + // $form_state['values']['country'] = $form_state['values']['other_country']; + } //$form_state['values']['other_city'] == '' + else + { + $form_state['values']['city'] = $form_state['values']['other_city']; + } + } //$form_state['values']['country'] == 'Others' + else + { + if ($form_state['values']['country'] == '0') + { + form_set_error('country', t('Select country name')); + // $form_state['values']['country'] = $form_state['values']['other_country']; + } //$form_state['values']['country'] == '' + if ($form_state['values']['all_state'] == '0') + { + form_set_error('all_state', t('Select state name')); + // $form_state['values']['country'] = $form_state['values']['other_country']; + } //$form_state['values']['all_state'] == '' + if ($form_state['values']['city'] == '0') + { + form_set_error('city', t('Select city name')); + // $form_state['values']['country'] = $form_state['values']['other_country']; + } //$form_state['values']['city'] == '' + } + //Validation for project title + $form_state['values']['project_title'] = trim($form_state['values']['project_title']); + if ($form_state['values']['project_title'] != '') + { + if (strlen($form_state['values']['project_title']) > 250) + { + form_set_error('project_title', t('Maximum charater limit is 250 charaters only, please check the length of the project title')); + } //strlen($form_state['values']['project_title']) > 250 + else if (strlen($form_state['values']['project_title']) < 10) + { + form_set_error('project_title', t('Minimum charater limit is 10 charaters, please check the length of the project title')); + } //strlen($form_state['values']['project_title']) < 10 + } //$form_state['values']['project_title'] != '' + else + { + form_set_error('project_title', t('Project title shoud not be empty')); + } +if (isset($_FILES['files'])) + { + /* check if atleast one source or result file is uploaded */ + /*if (!($_FILES['files']['name']['reference_file'])) + form_set_error('reference_file', t('Please upload the abstract'));*/ + /* check for valid filename extensions */ + foreach ($_FILES['files']['name'] as $file_form_name => $file_name) + { + if ($file_name) + { + $allowed_extensions_str = variable_get('idea_proposal_resource_upload_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 (!custom_model_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 custom_model_idea_proposal_form_submit($form, &$form_state) +{ + global $user; + $root_path = custom_model_ideas_files_path(); + if (!$user->uid) + { + drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error'); + return; + } //!$user->uid + /* inserting the user proposal */ + if($form_state['values']['department'] == 'Others') { + $form_state['values']['department'] =$form_state['values']['other_department']; + } + if ($form_state['values']['country'] == 'Others') + { + $form_state['values']['country'] = $form_state['values']['other_country']; + $form_state['values']['all_state'] = $form_state['values']['other_state']; + $form_state['values']['city'] = $form_state['values']['other_city']; + //$form_state['values']['pincode'] = $form_state['values']['other_pincode']; + } + $v = $form_state["values"]; + $project_title = trim($v['project_title']); + $proposar_name = $v['name_title'] . ' ' . $v['contributor_name']; + $university = $v['university']; + $directory_name = _cm_dir_name($project_title, $proposar_name); + $result = "INSERT INTO {custom_model_idea_proposal} + ( + uid, + approver_uid, + name_title, + idea_proposar_name, + contact_no, + university, + country, + state, + city, + pincode, + project_title, + reference_link, + reference_file, + directory_name, + creation_date + ) VALUES + ( + :uid, + :approver_uid, + :name_title, + :contributor_name, + :contact_no, + :university, + :country, + :state, + :city, + :pincode, + :project_title, + :reference_link, + :reference_file, + :directory_name, + :creation_date + )"; + $args = array( + ":uid" => $user->uid, + ":approver_uid" => 0, + ":name_title" => $v['name_title'], + ":contributor_name" => trim($v['contributor_name']), + ":contact_no" => $v['contributor_contact_no'], + ":university" => $v['university'], + ":country" => $v['country'], + ":state" => $v['all_state'], + ":city" => $v['city'], + ":pincode" => $v['pincode'], + ":project_title" => $v['project_title'], + ":reference_link" => $v['reference_link'], + ":reference_file" => "", + ":directory_name" => $directory_name, + ":creation_date" => time() + ); + $proposal_id = db_query($result, $args, array( + 'return' => Database::RETURN_INSERT_ID + )); +//var_dump($args);die; + + $dest_path = $directory_name . '/'; + $dest_path1 = $root_path . $dest_path; + //var_dump($dest_path1);die; + if (!is_dir($root_path . $dest_path)) + mkdir($root_path . $dest_path); + /* uploading files */ + foreach ($_FILES['files']['name'] as $file_form_name => $file_name) + { + if ($file_name) + { + /* checking file type */ + //$file_type = 'S'; + if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) + { + drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name'][$file_form_name])), 'error'); + //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]); + } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]) + /* uploading file */ + if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) + { + $query = "UPDATE {custom_model_idea_proposal} SET reference_file = :reference_file WHERE id = :id"; + $args = array( + ":reference_file" => $_FILES['files']['name'][$file_form_name], + ":id" => $proposal_id + ); + $updateresult = db_query($query, $args); + drupal_set_message($file_name . ' uploaded 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 . $file_name, 'error'); + } + } //$file_name + } //$_FILES['files']['name'] as $file_form_name => $file_name + if (!$proposal_id) + { + drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error'); + return; + } //!$proposal_id + /* sending email */ + $email_to = $user->mail; + $form = variable_get('custom_model_from_email', ''); + $bcc = variable_get('custom_model_emails', ''); + $cc = variable_get('custom_model_cc_emails', ''); + $params['custom_model_idea_proposal_received']['proposal_id'] = $proposal_id; + $params['custom_model_idea_proposal_received']['user_id'] = $user->uid; + $params['custom_model_idea_proposal_received']['headers'] = array( + 'From' => $form, + '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('custom_model', 'custom_model_idea_proposal_received', $email_to, user_preferred_language($user), $params, $form, TRUE)) + drupal_set_message('Error sending email message.', 'error'); + drupal_set_message(t('We have received your custom model proposal.'), 'status'); + drupal_goto(''); +}
\ No newline at end of file diff --git a/manage_proposal.inc b/manage_proposal.inc index c9cfb9b..9b7341e 100755 --- a/manage_proposal.inc +++ b/manage_proposal.inc @@ -92,7 +92,7 @@ function custom_model_proposal_all() $proposal_header = array( 'Date of Submission', 'Contributor Name', - 'Title of the circuit-simulation project', + 'Title of the Custom Model', 'Date of Completion', 'Status', 'Action' @@ -103,6 +103,68 @@ function custom_model_proposal_all() )); return $output; } +function custom_model_idea_proposal_all() +{ + /* get pending proposals to be approved */ + $proposal_rows = array(); + $query = db_select('custom_model_idea_proposal'); + $query->fields('custom_model_idea_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); + } + $proposal_rows[] = array( + date('d-m-Y', $proposal_data->creation_date), + l($proposal_data->idea_proposar_name, 'user/' . $proposal_data->uid), + $proposal_data->project_title, + l('View', 'custom-model/manage-proposal/view-ideas/' . $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', + 'Contributor Name', + 'Title of the Custom Model', + 'Action' + ); + $output = theme('table', array( + 'header' => $proposal_header, + 'rows' => $proposal_rows + )); + return $output; +} /******************************************************************************/ /************************** PROPOSAL APPROVAL FORM ****************************/ /******************************************************************************/ @@ -899,4 +961,106 @@ function custom_model_proposal_edit_form_submit($form, &$form_state) ); $result = db_query($query, $args); drupal_set_message(t('Proposal Updated'), 'status'); +} +function custom_model_view_idea_proposal_form($form, &$form_state) +{ + global $user; + /* get current proposal */ + $proposal_id = (int) arg(3); + $query = db_select('custom_model_idea_proposal'); + $query->fields('custom_model_idea_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('custom-model/manage-proposal'); + return; + } + } //$proposal_q + else + { + drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); + drupal_goto('custom-model/manage-proposal'); + return; + } + if($proposal_data->reference_link) + { + $reference_link = $proposal_data->reference_link; + } + else + { + $reference_link = 'None'; + } + if($proposal_data->reference_file) + { + $reference_file = l($proposal_data->reference_file, 'custom-model/download/idea-reference-file/' . $proposal_data->id); + } + else + { + $reference_file = 'None'; + } + $form['contributor_name'] = array( + '#type' => 'item', + '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->idea_proposar_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['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 Custom Model') + ); + + $form['reference_link'] = array( + '#type' => 'item', + '#markup' => $reference_link, + '#title' => t('Any Reference Web Link') + ); + $form['reference_file'] = array( + '#type' => 'item', + '#markup' => $reference_file, + '#title' => t('Any Reference File') + ); + $form['cancel'] = array( + '#type' => 'markup', + '#markup' => l(t('Cancel'), 'custom-model/manage-proposal/idea-propsosals') + ); + return $form; }
\ No newline at end of file diff --git a/settings.inc b/settings.inc index ad02e99..97c6971 100755 --- a/settings.inc +++ b/settings.inc @@ -38,6 +38,15 @@ function custom_model_settings_form($form, $form_state) '#required' => TRUE, '#default_value' => variable_get('resource_upload_extensions', '') ); + $form['extensions']['idea_proposal_resource_upload'] = array( + '#type' => 'textfield', + '#title' => t('Allowed file extensions for uploading resource files during idea proposal'), + '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'), + '#size' => 50, + '#maxlength' => 255, + '#required' => TRUE, + '#default_value' => variable_get('idea_proposal_resource_upload_extensions', '') + ); $form['extensions']['abstract_upload'] = array( '#type' => 'textfield', '#title' => t('Allowed file extensions for abstract'), @@ -81,6 +90,7 @@ function custom_model_settings_form_submit($form, &$form_state) variable_set('custom_model_cc_emails', $form_state['values']['cc_emails']); variable_set('custom_model_from_email', $form_state['values']['from_email']); variable_set('resource_upload_extensions', $form_state['values']['resource_upload']); + variable_set('idea_proposal_resource_upload_extensions', $form_state['values']['idea_proposal_resource_upload']); variable_set('custom_model_abstract_upload_extensions', $form_state['values']['abstract_upload']); variable_set('custom_model_simulation_file', $form_state['values']['custom_model_upload']); variable_set('custom_model_script_file', $form_state['values']['custom_model_script_upload']); |