From 03bd7ede5f815dfea9b1741a20eba725c50d2c25 Mon Sep 17 00:00:00 2001 From: sashi Date: Tue, 10 Dec 2024 15:48:11 +0530 Subject: [PATCH] Upgrade completed projects, download codes pages to drupal 10 --- abstract_bulk_approval.inc | 440 -------- config/install/om_pssp.settings.yml | 5 + config/schema/om_pssp.schema.yml | 14 + download.inc | 63 -- email.inc | 362 ------ full_download.inc | 131 --- general_deletion.inc | 195 ---- manage_proposal.inc | 1001 ----------------- om_pssp.info | 7 - om_pssp.info.yml | 6 + om_pssp.links.menu.yml | 92 ++ om_pssp.links.task.yml | 10 + om_pssp.module | 175 +-- om_pssp.permissions.yml | 48 + om_pssp.routing.yml | 140 +++ pdf/cert_new.inc | 12 +- pdf/fpdf/FAQ.htm | 28 +- pdf/fpdf/changelog.htm | 27 +- pdf/fpdf/doc/__construct.htm | 6 +- pdf/fpdf/doc/acceptpagebreak.htm | 50 +- pdf/fpdf/doc/addfont.htm | 28 +- pdf/fpdf/doc/addlink.htm | 2 +- pdf/fpdf/doc/addpage.htm | 2 +- pdf/fpdf/doc/aliasnbpages.htm | 20 +- pdf/fpdf/doc/cell.htm | 6 +- pdf/fpdf/doc/close.htm | 2 +- pdf/fpdf/doc/error.htm | 2 +- pdf/fpdf/doc/footer.htm | 20 +- pdf/fpdf/doc/getpageheight.htm | 2 +- pdf/fpdf/doc/getpagewidth.htm | 2 +- pdf/fpdf/doc/getstringwidth.htm | 2 +- pdf/fpdf/doc/getx.htm | 2 +- pdf/fpdf/doc/gety.htm | 2 +- pdf/fpdf/doc/header.htm | 24 +- pdf/fpdf/doc/image.htm | 6 +- pdf/fpdf/doc/index.htm | 6 +- pdf/fpdf/doc/line.htm | 2 +- pdf/fpdf/doc/link.htm | 2 +- pdf/fpdf/doc/ln.htm | 2 +- pdf/fpdf/doc/multicell.htm | 2 +- pdf/fpdf/doc/output.htm | 11 +- pdf/fpdf/doc/pageno.htm | 2 +- pdf/fpdf/doc/rect.htm | 2 +- pdf/fpdf/doc/setauthor.htm | 2 +- pdf/fpdf/doc/setautopagebreak.htm | 2 +- pdf/fpdf/doc/setcompression.htm | 2 +- pdf/fpdf/doc/setcreator.htm | 2 +- pdf/fpdf/doc/setdisplaymode.htm | 2 +- pdf/fpdf/doc/setdrawcolor.htm | 2 +- pdf/fpdf/doc/setfillcolor.htm | 2 +- pdf/fpdf/doc/setfont.htm | 32 +- pdf/fpdf/doc/setfontsize.htm | 2 +- pdf/fpdf/doc/setkeywords.htm | 2 +- pdf/fpdf/doc/setleftmargin.htm | 2 +- pdf/fpdf/doc/setlinewidth.htm | 2 +- pdf/fpdf/doc/setlink.htm | 2 +- pdf/fpdf/doc/setmargins.htm | 2 +- pdf/fpdf/doc/setrightmargin.htm | 2 +- pdf/fpdf/doc/setsubject.htm | 2 +- pdf/fpdf/doc/settextcolor.htm | 2 +- pdf/fpdf/doc/settitle.htm | 2 +- pdf/fpdf/doc/settopmargin.htm | 2 +- pdf/fpdf/doc/setx.htm | 2 +- pdf/fpdf/doc/setxy.htm | 2 +- pdf/fpdf/doc/sety.htm | 2 +- pdf/fpdf/doc/text.htm | 2 +- pdf/fpdf/doc/write.htm | 12 +- pdf/fpdf/fpdf.php | 205 ++-- pdf/fpdf/makefont/ttfparser.php | 15 +- .../tutorial/CevicheOne-Regular-Licence.txt | 94 ++ pdf/fpdf/tutorial/CevicheOne-Regular.php | 25 + pdf/fpdf/tutorial/CevicheOne-Regular.ttf | Bin 0 -> 35576 bytes pdf/fpdf/tutorial/CevicheOne-Regular.z | Bin 0 -> 15498 bytes pdf/fpdf/tutorial/calligra.php | 4 +- pdf/fpdf/tutorial/calligra.ttf | Bin pdf/fpdf/tutorial/calligra.z | Bin 22477 -> 25604 bytes pdf/fpdf/tutorial/index.htm | 2 +- pdf/fpdf/tutorial/makefont.php | 2 +- pdf/fpdf/tutorial/tuto1.htm | 4 +- pdf/fpdf/tutorial/tuto2.htm | 4 +- pdf/fpdf/tutorial/tuto3.htm | 4 +- pdf/fpdf/tutorial/tuto4.htm | 4 +- pdf/fpdf/tutorial/tuto5.htm | 4 +- pdf/fpdf/tutorial/tuto6.htm | 4 +- pdf/fpdf/tutorial/tuto7.htm | 25 +- pdf/fpdf/tutorial/tuto7.php | 7 +- pdf/list_mentor_certificates.inc | 42 +- pdf/list_pssp_certificate.inc | 40 +- pdf/mentor_cert_pdf.inc | 18 +- pdf/temp_prcode/generated_qrcode.png | Bin 448 -> 451 bytes pdf/verify_certificates.inc | 12 +- proposal.inc | 627 ----------- pssp_details.inc | 99 -- run.inc | 152 --- settings.inc | 78 -- src/Controller/DefaultController.php | 577 ++++++++++ .../VerifyCertificatesController.php | 73 ++ src/Form/GeneratePdf.php | 162 +++ src/Form/OmPsspAbstractBulkApprovalForm.php | 349 ++++++ src/Form/OmPsspProposalApprovalForm.php | 313 ++++++ src/Form/OmPsspProposalEditForm.php | 343 ++++++ src/Form/OmPsspProposalForm.php | 621 ++++++++++ src/Form/OmPsspProposalStatusForm.php | 281 +++++ src/Form/OmPsspRunForm.php | 166 +++ src/Form/OmPsspSettingsForm.php | 110 ++ src/Form/OmPsspUploadAbstractCodeForm.php | 437 +++++++ src/Form/VerifyCertificatesForm.php | 54 + upload_code.inc | 550 --------- 108 files changed, 4381 insertions(+), 4177 deletions(-) delete mode 100755 abstract_bulk_approval.inc create mode 100755 config/install/om_pssp.settings.yml create mode 100755 config/schema/om_pssp.schema.yml delete mode 100755 download.inc delete mode 100755 email.inc delete mode 100755 full_download.inc delete mode 100755 general_deletion.inc delete mode 100755 manage_proposal.inc delete mode 100755 om_pssp.info create mode 100755 om_pssp.info.yml create mode 100755 om_pssp.links.menu.yml create mode 100644 om_pssp.links.task.yml create mode 100755 om_pssp.permissions.yml create mode 100755 om_pssp.routing.yml create mode 100644 pdf/fpdf/tutorial/CevicheOne-Regular-Licence.txt create mode 100644 pdf/fpdf/tutorial/CevicheOne-Regular.php create mode 100644 pdf/fpdf/tutorial/CevicheOne-Regular.ttf create mode 100644 pdf/fpdf/tutorial/CevicheOne-Regular.z mode change 100644 => 100755 pdf/fpdf/tutorial/calligra.php mode change 100644 => 100755 pdf/fpdf/tutorial/calligra.ttf mode change 100644 => 100755 pdf/fpdf/tutorial/calligra.z delete mode 100755 proposal.inc delete mode 100755 pssp_details.inc delete mode 100755 run.inc delete mode 100755 settings.inc create mode 100755 src/Controller/DefaultController.php create mode 100644 src/Controller/VerifyCertificatesController.php create mode 100755 src/Form/GeneratePdf.php create mode 100755 src/Form/OmPsspAbstractBulkApprovalForm.php create mode 100755 src/Form/OmPsspProposalApprovalForm.php create mode 100755 src/Form/OmPsspProposalEditForm.php create mode 100755 src/Form/OmPsspProposalForm.php create mode 100755 src/Form/OmPsspProposalStatusForm.php create mode 100755 src/Form/OmPsspRunForm.php create mode 100755 src/Form/OmPsspSettingsForm.php create mode 100755 src/Form/OmPsspUploadAbstractCodeForm.php create mode 100644 src/Form/VerifyCertificatesForm.php delete mode 100755 upload_code.inc diff --git a/abstract_bulk_approval.inc b/abstract_bulk_approval.inc deleted file mode 100755 index a932e27..0000000 --- a/abstract_bulk_approval.inc +++ /dev/null @@ -1,440 +0,0 @@ - 'select', - '#title' => t('Title of the power system simulation project'), - '#options' => _bulk_list_of_om_pssp_project(), - '#default_value' => $selected, - '#ajax' => array( - - 'callback' => 'ajax_bulk_om_pssp_abstract_details_callback' - ), - '#suffix' => '
' - ); - $form['om_pssp_actions'] = array( - '#type' => 'select', - '#title' => t('Please select action for power system simulation project'), - '#options' => _bulk_list_om_pssp_actions(), - '#default_value' => 0, - '#prefix' => '
', - '#suffix' => '
', - '#states' => array( - 'invisible' => array( - ':input[name="om_pssp_project"]' => array( - 'value' => 0 - ) - ) - ) - ); - $form['message'] = array( - '#type' => 'textarea', - '#title' => t('Please specify the reason for marking resubmit/disapproval'), - '#prefix' => '
', - '#states' => array( - 'visible' => array( - array( - ':input[name="om_pssp_actions"]' => array( - 'value' => 3 - ) - ), - 'or', - array( - ':input[name="om_pssp_actions"]' => array( - 'value' => 2 - ) - ) - ) - ) - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Submit'), - '#states' => array( - 'invisible' => array( - ':input[name="lab"]' => array( - 'value' => 0 - ) - ) - ) - ); - return $form; -} -function ajax_bulk_om_pssp_abstract_details_callback($form, $form_state) -{ - $commands = array(); - $om_pssp_project_default_value = $form_state['values']['om_pssp_project']; - if ($om_pssp_project_default_value != 0) - { - $commands[] = ajax_command_html('#ajax_selected_om_pssp', _om_pssp_details($om_pssp_project_default_value)); - $form['om_pssp_actions']['#options'] = _bulk_list_om_pssp_actions(); - $commands[] = ajax_command_replace('#ajax_selected_om_pssp_action', drupal_render($form['om_pssp_actions'])); - } //$om_pssp_project_default_value != 0 - else - { - $commands[] = ajax_command_html('#ajax_selected_om_pssp', ''); - $commands[] = ajax_command_data('#ajax_selected_om_pssp', 'form_state_value_select', $form_state['values']['om_pssp_project']); - } - return array( - '#type' => 'ajax', - '#commands' => $commands - ); -} -/************************************************************/ -function om_pssp_abstract_bulk_approval_form_submit($form, &$form_state) -{ - global $user; - $msg = ''; - $root_path = om_pssp_path(); - if ($form_state['clicked_button']['#value'] == 'Submit') - { - if ($form_state['values']['om_pssp_project']) - // om_pssp_abstract_del_lab_pdf($form_state['values']['om_pssp_project']); - if (user_access('om pssp bulk manage abstract')) - { - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $form_state['values']['om_pssp_project']); - $user_query = $query->execute(); - $user_info = $user_query->fetchObject(); - $user_data = user_load($user_info->uid); - if ($form_state['values']['om_pssp_actions'] == 1) - { - // approving entire project // - $query = db_select('om_pssp_submitted_abstracts'); - $query->fields('om_pssp_submitted_abstracts'); - $query->condition('proposal_id', $form_state['values']['om_pssp_project']); - $abstracts_q = $query->execute(); - $experiment_list = ''; - while ($abstract_data = $abstracts_q->fetchObject()) - { - db_query("UPDATE {om_pssp_submitted_abstracts} SET abstract_approval_status = 1, is_submitted = 1, approver_uid = :approver_uid WHERE id = :id", array( - ':approver_uid' => $user->uid, - ':id' => $abstract_data->id - )); - db_query("UPDATE {om_pssp_submitted_abstracts_file} SET file_approval_status = 1, approvar_uid = :approver_uid WHERE submitted_abstract_id = :submitted_abstract_id", array( - ':approver_uid' => $user->uid, - ':submitted_abstract_id' => $abstract_data->id - )); - } //$abstract_data = $abstracts_q->fetchObject() - drupal_goto('powersystems/pssp/manage-proposal/all'); - drupal_set_message(t('Approved power system simulation project.'), 'status'); - // email - $email_subject = t('[!site_name][power system simulation Project] Your uploaded power system simulation project have been approved', array( - '!site_name' => variable_get('site_name', '') - )); - $email_body = array( - 0 => t(' - -Dear !user_name, - -Congratulations! -Your simulation and abstract for Power Systems Simulation Project at FOSSEE with the following details have been approved. - -Full Name: ' . $user_info->name_title . ' ' . $user_info->contributor_name . ' -Email : ' . $user_data->mail . ' -University/Institute : ' . $user_info->university . ' -City : ' . $user_info->city . ' - -Project Title : ' . $user_info->project_title . ' -Description of the simulation: ' . $user_info->description .' - -Kindly send us the internship forms as early as possible for processing your honorarium on time. In case you have already sent these forms, please share the the consignment number or tracking id with us. - -Note: It will take upto 30 days from the time we receive your forms, to process your honorarium. - - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - )) - ); - /** sending email when everything done **/ - $email_to = $user_data->mail; - $from = variable_get('om_pssp_from_email', ''); - $bcc = variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['standard']['subject'] = $email_subject; - $params['standard']['body'] = $email_body; - $params['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('om_pssp', 'standard', $email_to, language_default(), $params, $from, TRUE)) - { - $msg = drupal_set_message('Error sending email message.', 'error'); - } //!drupal_mail('om_pssp', 'standard', $email_to, language_default(), $params, $from, TRUE) - } //$form_state['values']['om_pssp_actions'] == 1 - elseif ($form_state['values']['om_pssp_actions'] == 2) - { - if (strlen(trim($form_state['values']['message'])) <= 30) - { - form_set_error('message', t('')); - $msg = drupal_set_message("Please mention the reason for marking resubmit. Minimum 30 character required", 'error'); - return $msg; - } - //pending review entire project - $query = db_select('om_pssp_submitted_abstracts'); - $query->fields('om_pssp_submitted_abstracts'); - $query->condition('proposal_id', $form_state['values']['om_pssp_project']); - $abstracts_q = $query->execute(); - $experiment_list = ''; - while ($abstract_data = $abstracts_q->fetchObject()) - { - db_query("UPDATE {om_pssp_submitted_abstracts} SET abstract_approval_status = 0, is_submitted = 0, approver_uid = :approver_uid WHERE id = :id", array( - ':approver_uid' => $user->uid, - ':id' => $abstract_data->id - )); - db_query("UPDATE {om_pssp_proposal} SET is_submitted = 0, approver_uid = :approver_uid WHERE id = :id", array( - ':approver_uid' => $user->uid, - ':id' => $abstract_data->proposal_id - )); - db_query("UPDATE {om_pssp_submitted_abstracts_file} SET file_approval_status = 0, approvar_uid = :approver_uid WHERE submitted_abstract_id = :submitted_abstract_id", array( - ':approver_uid' => $user->uid, - ':submitted_abstract_id' => $abstract_data->id - )); - } //$abstract_data = $abstracts_q->fetchObject() - drupal_set_message(t('Resubmit the project files'), 'status'); - // email - $email_subject = t('[!site_name][power system simulation Project] Your uploaded power system simulation project have been marked as pending', array( - '!site_name' => variable_get('site_name', '') - )); - $email_body = array( - 0 => t(' - -Dear !user_name, - -Kindly resubmit the project files for the project: ' . $user_info->project_title . '. -Description of the simulation: ' . $user_info->description . ' - -Reason: ' . $form_state['values']['message'] . ' - -Looking forward for the re-submission from you with the above suggested changes. - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - )) - ); - /** sending email when everything done **/ - $email_to = $user_data->mail; - $from = variable_get('om_pssp_from_email', ''); - $bcc = variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['standard']['subject'] = $email_subject; - $params['standard']['body'] = $email_body; - $params['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('om_pssp', 'standard', $email_to, language_default(), $params, $from, TRUE)) - { - drupal_set_message('Error sending email message.', 'error'); - } //!drupal_mail('om_pssp', 'standard', $email_to, language_default(), $params, $from, TRUE) - } //$form_state['values']['om_pssp_actions'] == 2 - elseif ($form_state['values']['om_pssp_actions'] == 3) //disapprove and delete entire power system simulation project - { - if (strlen(trim($form_state['values']['message'])) <= 30) - { - form_set_error('message', t('')); - $msg = drupal_set_message("Please mention the reason for disapproval. Minimum 30 character required", 'error'); - return $msg; - } //strlen(trim($form_state['values']['message'])) <= 30 - if (!user_access('om pssp bulk delete code')) - { - $msg = drupal_set_message(t('You do not have permission to Bulk Dis-Approved and Deleted Entire Lab.'), 'error'); - return $msg; - } //!user_access('om_pssp bulk delete code') - if (om_pssp_abstract_delete_project($form_state['values']['om_pssp_project'])) ////// - { - drupal_set_message(t('Dis-Approved and Deleted Entire power system simulation project.'), 'status'); - $email_subject = t('[!site_name][power system simulation Project] Your uploaded power system simulation project have been marked as dis-approved', array( - '!site_name' => variable_get('site_name', '') - )); - $email_body = array( - 0 => t(' -Dear !user_name, - -We regret to inform you that your simulation and abstract for Power Systems Simulation Project at FOSSEE with the following details have been disapproved: - -Full Name: ' . $user_info->name_title . ' ' . $user_info->contributor_name . ' -Email : ' . $user_data->mail . ' -University/Institute : ' . $user_info->university . ' -City : ' . $user_info->city . ' - -Project Title : ' . $user_info->project_title . ' -Description of the simulation: ' . $user_info->description .' - -Reason for dis-approval: ' . $form_state['values']['message'] . ' - -Kindly note that the incorrect files will be deleted from all our databases. - -Thank you for participating in the Power Systems Simulation Project. You are welcome to submit a new proposal. - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - )) - ); - $email_to = $user_data->mail; - $from = variable_get('om_pssp_from_email', ''); - $bcc = variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['standard']['subject'] = $email_subject; - $params['standard']['body'] = $email_body; - $params['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('om_pssp', 'standard', $email_to, language_default(), $params, $from, TRUE)) - { - drupal_set_message('Error sending email message.', 'error'); - } - } //om_pssp_abstract_delete_project($form_state['values']['om_pssp_project']) - else - { - drupal_set_message(t('Error Dis-Approving and Deleting Entire power system simulation project.'), 'error'); - } - // email - - } //$form_state['values']['om_pssp_actions'] == 3 - } //user_access('om_pssp project bulk manage code') - return $msg; - } //$form_state['clicked_button']['#value'] == 'Submit' -} -/**********************************************************/ -function _bulk_list_of_om_pssp_project() -{ - $project_titles = array( - '0' => 'Please select...' - ); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('is_submitted', 1); - $query->condition('approval_status', 1); - $query->orderBy('project_title', 'ASC'); - $project_titles_q = $query->execute(); - while ($project_titles_data = $project_titles_q->fetchObject()) - { - $project_titles[$project_titles_data->id] = $project_titles_data->project_title . ' (Proposed by ' . $project_titles_data->contributor_name . ')'; - } //$project_titles_data = $project_titles_q->fetchObject() - return $project_titles; -} -function _bulk_list_om_pssp_actions() -{ - $om_pssp_actions = array( - 0 => 'Please select...' - ); - $om_pssp_actions[1] = 'Approve Entire power system simulation Project'; - $om_pssp_actions[2] = 'Resubmit Project files'; - $om_pssp_actions[3] = 'Dis-Approve Entire power system simulation Project (This will delete power system simulation Project)'; - //$om_pssp_actions[4] = 'Delete Entire power system simulation Project Including Proposal'; - return $om_pssp_actions; -} -function _om_pssp_details($om_pssp_proposal_id) -{ - $return_html = ""; - $query_pro = db_select('om_pssp_proposal'); - $query_pro->fields('om_pssp_proposal'); - $query_pro->condition('id', $om_pssp_proposal_id); - $abstracts_pro = $query_pro->execute()->fetchObject(); - //var_dump($abstracts_pro);die; - $query_pdf = db_select('om_pssp_submitted_abstracts_file'); - $query_pdf->fields('om_pssp_submitted_abstracts_file'); - $query_pdf->condition('proposal_id', $om_pssp_proposal_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; - } //$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('om_pssp_submitted_abstracts_file'); - $query_process->fields('om_pssp_submitted_abstracts_file'); - $query_process->condition('proposal_id', $om_pssp_proposal_id); - $query_process->condition('filetype', 'S'); - $abstracts_query_process = $query_process->execute()->fetchObject(); - $query = db_select('om_pssp_submitted_abstracts'); - $query->fields('om_pssp_submitted_abstracts'); - $query->condition('proposal_id', $om_pssp_proposal_id); - $abstracts_q = $query->execute()->fetchObject(); - if($abstracts_q->other_libraries_used == 1) - { - $other_libraries_used = "Yes"; - } - else - { - $other_libraries_used = "No"; - } - if ($abstracts_q) - { - if ($abstracts_q->is_submitted == 0) - { - //drupal_set_message(t('Abstract is not submmited yet.'), 'error', $repeat = FALSE); - //return; - } //$abstracts_q->is_submitted == 0 - } //$abstracts_q - //var_dump($abstracts_query_process);die; - 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 != "NULL" || $abstracts_query_process->filename != "" - else - { - $abstracts_query_process_filename = "File not uploaded"; - } - } //$abstracts_query_process == TRUE - else - { - $url = l('Upload abstract', 'powersystems/pssp/abstract-code/upload'); - $abstracts_query_process_filename = "File not uploaded"; - } - $download_om_pssp = l('Download power system simulation project','powersystems/pssp/full-download/project/'.$om_pssp_proposal_id); - $return_html .= 'Proposer Name:
' . $abstracts_pro->name_title . ' ' . $abstracts_pro->contributor_name . '

'; - $return_html .= 'Title of the power system simulation Project:
' . $abstracts_pro->project_title . '

'; - $return_html .= 'Other libraries used:
' . $other_libraries_used . '

'; - $return_html .= 'Uploaded an abstract (brief outline) of the project:
' . $abstract_filename . '

'; - $return_html .= 'Upload the power system simulation for the developed process:
' . $abstracts_query_process_filename . '

'; - $return_html .= $download_om_pssp; - return $return_html; -} \ No newline at end of file diff --git a/config/install/om_pssp.settings.yml b/config/install/om_pssp.settings.yml new file mode 100755 index 0000000..fb75e6b --- /dev/null +++ b/config/install/om_pssp.settings.yml @@ -0,0 +1,5 @@ +om_pssp_emails: '' +om_pssp_cc_emails: '' +om_pssp_from_email: '' +om_pssp_abstract_upload_extensions: '' +om_pssp_project_files_extensions: '' diff --git a/config/schema/om_pssp.schema.yml b/config/schema/om_pssp.schema.yml new file mode 100755 index 0000000..4155983 --- /dev/null +++ b/config/schema/om_pssp.schema.yml @@ -0,0 +1,14 @@ +om_pssp.settings: + type: mapping + label: Settings + mapping: + om_pssp_emails: + type: string + om_pssp_cc_emails: + type: string + om_pssp_from_email: + type: string + om_pssp_abstract_upload_extensions: + type: string + om_pssp_project_files_extensions: + type: string diff --git a/download.inc b/download.inc deleted file mode 100755 index 60774a1..0000000 --- a/download.inc +++ /dev/null @@ -1,63 +0,0 @@ -fields('om_pssp_proposal'); - $query->condition('id', $proposal_id); - $query->range(0, 1); - $result = $query->execute(); - $om_pssp_upload_file = $result->fetchObject(); - $samplecodename = substr($om_pssp_upload_file->samplefilepath, strrpos($om_pssp_upload_file->samplefilepath, '/') + 1); - ob_clean(); - header("Pragma: public"); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - header('Content-Type: application/pdf'); - header('Content-disposition: attachment; filename="' . $samplecodename . '"'); - header('Content-Length: ' . filesize($root_path . $om_pssp_upload_file->samplefilepath)); - header("Content-Transfer-Encoding: binary"); - header('Expires: 0'); - header('Pragma: no-cache'); - readfile($root_path . $om_pssp_upload_file->samplefilepath); - ob_end_flush(); - ob_clean(); - flush(); -} -function om_pssp_project_files() { - $proposal_id = arg(4); - $root_path = om_pssp_path(); - $query = db_select('om_pssp_submitted_abstracts_file'); - $query->fields('om_pssp_submitted_abstracts_file'); - $query->condition('proposal_id', $proposal_id); - $query->condition('filetype', A); - $result = $query->execute(); - $om_pssp_project_files = $result->fetchObject(); - //var_dump($om_pssp_project_files);die; - $query1 = db_select('om_pssp_proposal'); - $query1->fields('om_pssp_proposal'); - $query1->condition('id', $proposal_id); - $result1 = $query1->execute(); - $om_pssp = $result1->fetchObject(); - $directory_name = $om_pssp->directory_name . '/project_files/'; - $samplecodename = $om_pssp_project_files->filename; - ob_clean(); - header("Pragma: public"); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - header("Content-Type: application/pdf"); - header('Content-disposition: attachment; filename="' . $samplecodename . '"'); - header("Content-Length: " . filesize($root_path . $directory_name . $samplecodename)); - header("Content-Transfer-Encoding: binary"); - header("Expires: 0"); - header("Pragma: no-cache"); - readfile($root_path . $directory_name . $samplecodename); - ob_end_flush(); - ob_clean(); -} diff --git a/email.inc b/email.inc deleted file mode 100755 index daa38d7..0000000 --- a/email.inc +++ /dev/null @@ -1,362 +0,0 @@ -fields('om_pssp_proposal'); - $query->condition('id', $params['om_pssp_proposal_received']['proposal_id']); - $query->range(0, 1); - $proposal_data = $query->execute()->fetchObject(); - $phpdate = time( $proposal_data->creation_date ); - $user_data = user_load($params['om_pssp_proposal_received']['user_id']); - if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "") - { - $project_guide_name = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $project_guide_name = $proposal_data->project_guide_name; - } - if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "") - { - $project_guide_email_id = "Not Entered"; - } //$proposal_data->project_guide_email_id == NULL - else - { - $project_guide_email_id = $proposal_data->project_guide_email_id; - } - - $message['headers'] = $params['om_pssp_proposal_received']['headers']; - $message['subject'] = t('[!site_name][Power System Simulation Project] Your Power System Simulation Project proposal has been received', array( - '!site_name' => variable_get('site_name', '') - ), array( - 'language' => $language->language - )); - $message['body'] = array( - 'body' => t(' -Dear !user_name, - -Thank you for submitting proposal for the Power Systems Simulation Project. The details of your proposal are as below : - -Full Name: ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . ' -Email: ' . $user_data->mail . ' -University/Institute: ' . $proposal_data->university . ' -City: ' . $proposal_data->city . ' -Project Title: ' . $proposal_data->project_title . ' -Description of the simulation: ' . $proposal_data->description . ' - - -Your proposal is under review. You will be notified via email about the approval/disapproval within ten working days. - - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - ), array( - 'language' => $language->language - )) - ); - break; - case 'om_pssp_proposal_disapproved': - /* initializing data */ - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $params['om_pssp_proposal_disapproved']['proposal_id']); - $query->range(0, 1); - $proposal_data = $query->execute()->fetchObject(); - $phpdate = time( $proposal_data->creation_date ); - $user_data = user_load($params['om_pssp_proposal_disapproved']['user_id']); - if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "") - { - $project_guide_name = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $project_guide_name = $proposal_data->project_guide_name; - } - if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "") - { - $project_guide_email_id = "Not Entered"; - } //$proposal_data->project_guide_email_id == NULL - else - { - $project_guide_email_id = $proposal_data->project_guide_email_id; - } - $message['headers'] = $params['om_pssp_proposal_disapproved']['headers']; - $message['subject'] = t('[!site_name][Power System Simulation Project] Your Power System Simulation 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 Power Systems Simulation Project proposal, with following details, has been disapproved. - -Full Name: ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . ' -Email: ' . $user_data->mail . ' -University/Institute: ' . $proposal_data->university . ' -City: ' . $proposal_data->city . ' - -Project Title: ' . $proposal_data->project_title . ' -Description of the simulation: ' . $proposal_data->description . ' - -Reason(s) / Feedback: ' . $proposal_data->dissapproval_reason . ' - -Please note that any files that were uploaded along with the proposal form will be deleted from all our database(s). - -Thank you for participating in the Power Systems Simulation Project. You are welcome to submit a new proposal. - - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - ), array( - 'language' => $language->language - )) - ); - break; - case 'om_pssp_proposal_approved': - /* initializing data */ - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $params['om_pssp_proposal_approved']['proposal_id']); - $query->range(0, 1); - $proposal_data = $query->execute()->fetchObject(); - $user_data = user_load($params['om_pssp_proposal_approved']['user_id']); - $url = 'https://om.fossee.in/powersystems/pssp/coding-guidelines'; - if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "") - { - $project_guide_name = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $project_guide_name = $proposal_data->project_guide_name; - } - if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "") - { - $project_guide_email_id = "Not Entered"; - } //$proposal_data->project_guide_email_id == NULL - else - { - $project_guide_email_id = $proposal_data->project_guide_email_id; - } - $message['headers'] = $params['om_pssp_proposal_approved']['headers']; - $message['subject'] = t('[!site_name][Power Simulation Simulation Project] Your Power Simulation Simulation Project proposal has been approved', array( - '!site_name' => variable_get('site_name', '') - ), array( - 'language' => $language->language - )); - $message['body'] = array( - 'body' => t(' -Dear !user_name, - -Congratulations! Your proposal for Power Systems Simulation Project with the following details is approved. - -Full Name: ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . ' -Email: ' . $user_data->mail . ' -University/Institute: ' . $proposal_data->university . ' -City: ' . $proposal_data->city . ' - -Project Title: ' . $proposal_data->project_title . ' -Description of the simulation: ' . $proposal_data->description . ' - - -Please ensure that ALL the guidelines for coding at https://om.fossee.in/powersystems/pssp/coding-guidelines are strictly followed. Refer https://om.fossee.in/powersystems/pssp/internship for the further procedure for submission of the project. Kindly ensure that the completed model and abstract are submitted within 1 month. - - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - ), array( - 'language' => $language->language - )) - ); - break; - case 'om_pssp_proposal_completed': - /* initializing data */ - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $params['om_pssp_proposal_completed']['proposal_id']); - $query->range(0, 1); - $proposal_data = $query->execute()->fetchObject(); - $user_data = user_load($params['om_pssp_proposal_completed']['user_id']); - if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "") - { - $project_guide_name = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $project_guide_name = $proposal_data->project_guide_name; - } - if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "") - { - $project_guide_email_id = "Not Entered"; - } //$proposal_data->project_guide_email_id == NULL - else - { - $project_guide_email_id = $proposal_data->project_guide_email_id; - } - $message['headers'] = $params['om_pssp_proposal_completed']['headers']; - $message['subject'] = t('[!site_name][Power System Simulation Project] Your OpenModelica Power System Simulation 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 simulation and abstract for Power Systems Simulation Project at FOSSEE on the following process have been published successfully. - - -Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . ' -Project Title : ' . $proposal_data->project_title . ' - -Kindly access this link to download the same. -https://om.fossee.in/powersystems/pssp/completed-pssp - - -Thank you for participating in the Power System Simulation Project. You are welcome to propose a new proposal. - - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - ), array( - 'language' => $language->language - )) - ); - break; - case 'om_pssp_proposal_deleted': - /* initializing data */ - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $params['om_pssp_proposal_deleted']['proposal_id']); - $query->range(0, 1); - $proposal_data = $query->execute()->fetchObject(); - $user_data = user_load($params['om_pssp_proposal_deleted']['user_id']); - - if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "") - { - $project_guide_name = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $project_guide_name = $proposal_data->project_guide_name; - } - if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "") - { - $project_guide_email_id = "Not Entered"; - } //$proposal_data->project_guide_email_id == NULL - else - { - $project_guide_email_id = $proposal_data->project_guide_email_id; - } - $message['headers'] = $params['om_pssp_proposal_deleted']['headers']; - $message['subject'] = t('[!site_name][Power System Simulation Project] Your OpenModelica Power System Simulation 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 Power Systems Simulation Project proposal with the following details has been deleted: - -Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . ' -Email : ' . $user_data->mail . ' -University/Institute : ' . $proposal_data->university . ' -City : ' . $proposal_data->city . ' - -Project Title : ' . $proposal_data->project_title . ' -Description of the simulation: ' . $proposal_data->description .' - - - -You can propose a new Power Systems Simulation project. - -Best Wishes, - -!site_name Power Systems 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 {om_pssp_solution} WHERE id = %d LIMIT 1", $params['abstract_uploaded']['solution_id']); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $params['abstract_uploaded']['proposal_id']); - $query->range(0, 1); - $proposal_data = $query->execute()->fetchObject(); - - $user_data = user_load($params['abstract_uploaded']['user_id']); - $message['subject'] = t('[!site_name][Power System Simulation Project] You have uploaded OpenModelica model and abstract', 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 successfully uploaded your simulation and abstract for Power Systems Simulation Project with the following details. - -Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . ' -Email : ' . $user_data->mail . ' -University/Institute : ' . $proposal_data->university . ' -City : ' . $proposal_data->city . ' - -Project Title : ' . $proposal_data->project_title . ' -Description of the simulation: ' . $proposal_data->description .' - -You shall be notified via email after the model and abstract are reviewed and approved / disapproved. This may take upto 30 working days. - -Best Wishes, - -!site_name Power Systems Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - ), array( - 'language' => $language->language - )) - ); - break; - case 'standard': - $message['subject'] = $params['standard']['subject']; - $message['body'] = $params['standard']['body']; - $message['headers'] = $params['standard']['headers']; - break; - } //$key -} diff --git a/full_download.inc b/full_download.inc deleted file mode 100755 index 6dace72..0000000 --- a/full_download.inc +++ /dev/null @@ -1,131 +0,0 @@ -fields('om_pssp_proposal'); - $query->condition('id', $id); - $om_pssp_q = $query->execute(); - $om_pssp_data = $om_pssp_q->fetchObject(); - $PSSP_PATH = $om_pssp_data->directory_name . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive(); - $zip->open($zip_filename, ZipArchive::CREATE); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $id); - $om_pssp_udc_q = $query->execute(); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $id); - $query = db_select('om_pssp_submitted_abstracts_file'); - $query->fields('om_pssp_submitted_abstracts_file'); - $query->condition('proposal_id', $id); - $project_files = $query->execute(); - while ($pssp_project_files = $project_files->fetchObject()) { - $zip->addFile($root_path . $PSSP_PATH . 'project_files/' . $pssp_project_files->filepath, $PSSP_PATH . str_replace(' ', '_', basename($pssp_project_files->filename))); - } - $zip_file_count = $zip->numFiles; - //var_dump($zip_file_count);die; - $zip->close(); - if ($zip_file_count > 0) { - if ($user->uid) { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $om_pssp_data->project_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_end_flush(); - ob_clean(); - flush(); - readfile($zip_filename); - unlink($zip_filename); - } //$user->uid - else { - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $om_pssp_data->project_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - header("Content-Transfer-Encoding: binary"); - header('Expires: 0'); - header('Pragma: no-cache'); - ob_end_flush(); - ob_clean(); - flush(); - readfile($zip_filename); - unlink($zip_filename); - } - } //$zip_file_count > 0 - else { - drupal_set_message("There are no power system simulation project in this proposal to download", 'error'); - drupal_goto('powersystems'); - } -} -function om_pssp_download_completed_project() -{ - global $user; - $id = arg(4); - $root_path = om_pssp_path(); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $id); - $om_pssp_q = $query->execute(); - $om_pssp_data = $om_pssp_q->fetchObject(); - $PSSP_PATH = $om_pssp_data->directory_name . '/'; - /* zip filename */ - $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip'; - /* creating zip archive on the server */ - $zip = new ZipArchive(); - $zip->open($zip_filename, ZipArchive::CREATE); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $id); - $om_pssp_udc_q = $query->execute(); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $id); - $query = db_select('om_pssp_submitted_abstracts_file'); - $query->fields('om_pssp_submitted_abstracts_file'); - $query->condition('proposal_id', $id); - $project_files = $query->execute(); - //var_dump($root_path . $PSSP_PATH . 'project_files/');die; - while ($pssp_project_files = $project_files->fetchObject()) { - $zip->addFile($root_path . $PSSP_PATH . 'project_files/' . $pssp_project_files->filepath, $PSSP_PATH . str_replace(' ', '_', basename($pssp_project_files->filename))); - } - $zip_file_count = $zip->numFiles; - $zip->close(); - if ($zip_file_count > 0) { - if ($user->uid) { - /* download zip file */ - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $om_pssp_data->project_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - ob_end_flush(); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } //$user->uid - else { - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $om_pssp_data->project_title) . '.zip"'); - header('Content-Length: ' . filesize($zip_filename)); - header("Content-Transfer-Encoding: binary"); - header('Expires: 0'); - header('Pragma: no-cache'); - ob_end_flush(); - ob_clean(); - //flush(); - readfile($zip_filename); - unlink($zip_filename); - } - } //$zip_file_count > 0 - else { - drupal_set_message("There are no power system simulation project in this proposal to download", 'error'); - drupal_goto('powersystems'); - } -} \ No newline at end of file diff --git a/general_deletion.inc b/general_deletion.inc deleted file mode 100755 index e944c45..0000000 --- a/general_deletion.inc +++ /dev/null @@ -1,195 +0,0 @@ -fields('om_pssp_proposal'); - $query->condition('id', $proposal_id); - $proposal_q = $query->execute(); - $proposal_data = $proposal_q->fetchObject(); - if (!$proposal_data) - { - drupal_set_message('Invalid power system simulation Project.', 'error'); - return FALSE; - } //!$proposal_data - $query = db_select('om_pssp_submitted_abstracts_file'); - $query->fields('om_pssp_submitted_abstracts_file'); - $query->condition('proposal_id', $proposal_id); - $abstract_q = $query->execute(); - $dir_project_files = $root_path . $proposal_data->directory_name . '/project_files'; - while ($abstract_data = $abstract_q->fetchObject()) - { - if (is_dir($dir_project_files)){ - - unlink($root_path . $proposal_data->directory_name . '/project_files/' . $abstract_data->filepath); - } - else - { - drupal_set_message('Invalid power system simulation project abstract.', 'error'); - } - db_delete('om_pssp_submitted_abstracts_file')->condition('proposal_id', $proposal_id)->execute(); - //!om_pssp_delete_abstract_file($abstract_data->id) - } - $res = rmdir($root_path . $proposal_data->directory_name . '/project_files'); - $dir_path_udc = $root_path . $proposal_data->directory_name; - if (is_dir($dir_path_udc)) - { - unlink($root_path . $proposal_data->samplefilepath); - $res = rmdir($dir_path_udc); - } //is_dir($dir_path_udc) - db_delete('om_pssp_proposal')->condition('id', $proposal_data->id)->execute(); - - db_delete('om_pssp_submitted_abstracts')->condition('proposal_id', $proposal_id)->execute(); - return $status; -} -/*function om_pssp_delete_abstract_file($abstract_id) -{ - //var_dump($abstract_id);die; - $status = TRUE; - $root_path = om_pssp_path(); - $abstract_q = db_query("SELECT * from om_pssp_proposal dfp -LEFT JOIN om_pssp_submitted_abstracts dfsa ON dfp.id = dfsa.proposal_id -WHERE dfsa.id = :abstract_id", array( - ":abstract_id" => $abstract_id - )); - $abstract_data = $abstract_q->fetchObject(); - if (!$abstract_data) - { - drupal_set_message('Invalid power system simualation project abstract.', 'error'); - return FALSE; - } //!$abstract_data - /* deleting solutions */ - /*$query = db_select('om_pssp_submitted_abstracts_file'); - $query->fields('om_pssp_submitted_abstracts_file'); - $query->condition('submitted_abstract_id', $abstract_id); - $abstract_f_q = $query->execute(); - $delete_project_folder = FALSE; - while ($abstract_f_data = $abstract_f_q->fetchObject()) - { - $delete_project_folder = TRUE; - if (!_om_pssp_delete_abstract_file($abstract_f_data->id)) - $status = FALSE; - } //$abstract_f_data = $abstract_f_q->fetchObject() - if (!$delete_project_folder) - { - return TRUE; - } //!$delete_project_folder - if ($status) - { - $dir_path_udc = $root_path . $abstract_f_data->directory_name; - if (is_dir($dir_path_udc)) - { - unlink($root_path . $abstract_f_data->samplefilepath); - //$res = rmdir($dir_path_udc); - /*if (!$res) - { - drupal_set_message(t('Error in deleting user defiend folder !folder', array( - '!folder' => $abstract_f_data->directory_name - )), 'error'); - /* sending email to admins */ - /* $email_to = variable_get('om_pssp_emails', ''); - $from = variable_get('om_pssp_from_email', ''); - $bcc = ""; - $cc = variable_get('om_pssp_cc_emails', ''); - $params['standard']['subject'] = "[ERROR] Error deleting experiment folder"; - $params['standard']['body'] = "Error deleting folder " . $dir_path; - $params['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('om_pssp', 'standard', $email_to, language_default(), $params, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - return FALSE; - } //!$res - else - { - return TRUE; - } - }*/ //is_dir($dir_path_udc) - /*} //$status - return FALSE; -} -} -function _om_pssp_delete_abstract_file($abstract_id) -{ - global $user; - $root_path = om_pssp_path(); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_proposal'); - $query->condition('id', $abstract_id); - $abstract_q = $query->execute(); - $abstract_data = $abstract_q->fetchObject(); - $abstract_q = db_query("SELECT * from om_pssp_proposal dfp -LEFT JOIN om_pssp_submitted_abstracts dfsa ON dfp.id = dfsa.proposal_id -WHERE dfsa.id = :abstract_id", array( - ":abstract_id" => $abstract_id - )); - $abstract_data = $abstract_q->fetchObject(); - if (!$abstract_data) - { - drupal_set_message('Invalid power system simulation project abstract.', 'error'); - return FALSE; - } //!$abstract_data - /* deleting abstract files - $query = db_select('om_pssp_submitted_abstracts_file'); - $query->fields('om_pssp_submitted_abstracts_file'); - $query->condition('submitted_abstract_id', $abstract_id); - $abstract_f_q = $query->execute(); - while ($abstract_f_data = $abstract_f_q->fetchObject()) - { - unlink($root_path . $abstract_data->directory_name . '/project_files/' . $abstract_f_data->filepath); - $res = rmdir($root_path . $abstract_data->directory_name . '/project_files'); - /*if (!file_exists($root_path . $abstract_data->directory_name . '/project_files/' . $abstract_f_data->filepath)) - { - $status = FALSE; - drupal_set_message(t('Error deleting !file. File does not exists.', array( - '!file' => $abstract_data->directory_name . '/project_files' . $abstract_f_data->filepath - )), 'error'); - continue; - } //!file_exists($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath) - /* removing solution file */ - /*if (!unlink($root_path . $abstract_data->directory_name . '/project_files/' . $abstract_f_data->filepath)) - { - $status = FALSE; - drupal_set_message(t('Error deleting !file', array( - '!file' => $abstract_data->directory_name . '/project_files/' . $abstract_f_data->filepath - )), 'error'); - /* sending email to admins */ - /* $from = variable_get('om_pssp_from_email', ''); - $bcc = variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['standard']['subject'] = "[ERROR] Error deleting example file"; - $params['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " : - file id : " . $abstract_data->id . " - file path : " . $abstract_data->directory_name . '/project_files/' . $abstract_f_data->filepath; - $params['standard']['headers'] = array( - 'From' => $from, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', - 'Content-Transfer-Encoding' => '8Bit', - 'X-Mailer' => 'Drupal', - 'Cc' => $cc, - 'Bcc' => $bcc - ); - if (!drupal_mail('om_pssp', 'standard', $email_to, language_default(), $params, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - } *///!unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath) - -/* } - /* deleting example files database entries */ - //db_delete('om_pssp_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute();//$abstract_f_data = $abstract_f_q->fetchObject() -/* if (!$status) - { - return FALSE; - } //!$status - return $status; -}*/ \ No newline at end of file diff --git a/manage_proposal.inc b/manage_proposal.inc deleted file mode 100755 index 7e7103a..0000000 --- a/manage_proposal.inc +++ /dev/null @@ -1,1001 +0,0 @@ -fields('om_pssp_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', 'powersystems/pssp/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'powersystems/pssp/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 Power systems simulation Project', - 'Action' - ); - //$output = theme_table($pending_header, $pending_rows); - $output = theme('table', array( - 'header' => $pending_header, - 'rows' => $pending_rows - )); - return $output; -} -function om_pssp_proposal_all() -{ - /* get pending proposals to be approved */ - $proposal_rows = array(); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_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->contributor_name, 'user/' . $proposal_data->uid), - $proposal_data->project_title, - $actual_completion_date, - $approval_status, - l('Status', 'powersystems/pssp/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'powersystems/pssp/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 power systems simulation project', - 'Date of Completion', - 'Status', - 'Action' - ); - $output = theme('table', array( - 'header' => $proposal_header, - 'rows' => $proposal_rows - )); - return $output; -} -/******************************************************************************/ -/************************** PROPOSAL APPROVAL FORM ****************************/ -/******************************************************************************/ -function om_pssp_proposal_approval_form($form, &$form_state) -{ - global $user; - /* get current proposal */ - $proposal_id = (int) arg(4); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_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('powersystems/pssp/manage-proposal'); - return; - } - } //$proposal_q - else - { - drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); - drupal_goto('powersystems/pssp/manage-proposal'); - return; - } - if ($proposal_data->contact_no == "NULL" || $proposal_data->contact_no == "") - { - $contact_no = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $contact_no = $proposal_data->contact_no; - } - if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "") - { - $project_guide_name = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $project_guide_name = $proposal_data->project_guide_name; - } - if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "") - { - $project_guide_email_id = "Not Entered"; - } //$proposal_data->project_guide_email_id == NULL - else - { - $project_guide_email_id = $proposal_data->project_guide_email_id; - } - if ($proposal_data->project_guide_university == "NULL" || $proposal_data->project_guide_university == "") - { - $project_guide_university = "Not Entered"; - } //$proposal_data->project_guide_email_id == NULL - else - { - $project_guide_university = $proposal_data->project_guide_university; - } - $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' => $contact_no, - ); - $form['month_year_of_degree'] = array( - '#type' => 'date_popup', - '#title' => t('Month and year of award of degree'), - '#date_label_position' => '', - '#description' => '', - '#default_value' => $proposal_data->month_year_of_degree, - '#date_format' => 'M-Y', - '#date_increment' => 0, - '#date_year_range' => '1960:+0', - '#datepicker_options' => array( - 'maxDate' => 0 - ), - '#disabled' => TRUE - ); - $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_guide_name'] = array( - '#type' => 'item', - '#title' => t('Project guide'), - '#markup' => $project_guide_name - ); - $form['project_guide_email_id'] = array( - '#type' => 'item', - '#title' => t('Project guide email'), - '#markup' => $project_guide_email_id - ); - $form['project_guide_university'] = array( - '#type' => 'item', - '#title' => t('Project guide university'), - '#markup' => $project_guide_university - ); - $form['project_title'] = array( - '#type' => 'item', - '#markup' => $proposal_data->project_title, - '#title' => t('Title of the Power systems simulation Project') - ); - $form['description'] = array( - '#type' => 'item', - '#markup' => $proposal_data->description, - '#title' => t('Description of the Power systems simulation Project') - ); - if (($proposal_data->samplefilepath != "") && ($proposal_data->samplefilepath != 'NULL')) - { - $str = substr($proposal_data->samplefilepath,strrpos($proposal_data->samplefilepath, '/')); - $resource_file =ltrim($str, '/'); - - $form['samplefilepath'] = array( - '#type' => 'item', - '#title' => t('Abstract file '), - '#markup' => l($resource_file, 'powersystems/pssp/download/resource-file/' . $proposal_id) . "" - ); - } //$proposal_data->user_defined_compound_filepath != "" - else - { - $form['samplefilepath'] = array( - '#type' => 'item', - '#title' => t('Abstract file '), - '#markup' => "Not uploaded

" - ); - } - $form['approval'] = array( - '#type' => 'radios', - '#title' => t('power systems simulation 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'), 'powersystems/pssp/manage-proposal') - ); - return $form; -} -function om_pssp_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 -} -function om_pssp_proposal_approval_form_submit($form, &$form_state) -{ - global $user; - /* get current proposal */ - $proposal_id = (int) arg(4); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_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('powersystems/pssp/manage-proposal'); - return; - } - } //$proposal_q - else - { - drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); - drupal_goto('powersystems/pssp/manage-proposal'); - return; - } - if ($form_state['values']['approval'] == 1) - { - $query = "UPDATE {om_pssp_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('om_pssp_from_email', ''); - $bcc = $user->mail . ', ' . variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['om_pssp_proposal_approved']['proposal_id'] = $proposal_id; - $params['om_pssp_proposal_approved']['user_id'] = $proposal_data->uid; - $params['om_pssp_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('om_pssp', 'om_pssp_proposal_approved', $email_to, language_default(), $params, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('power systems simulation proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status'); - drupal_goto('powersystems/pssp/manage-proposal'); - return; - } //$form_state['values']['approval'] == 1 - else if ($form_state['values']['approval'] == 2) - { - $query = "UPDATE {om_pssp_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('om_pssp_from_email', ''); - $bcc = $user->mail . ', ' . variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['om_pssp_proposal_disapproved']['proposal_id'] = $proposal_id; - $params['om_pssp_proposal_disapproved']['user_id'] = $proposal_data->uid; - $params['om_pssp_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('om_pssp', 'om_pssp_proposal_disapproved', $email_to, language_default(), $params, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('Power systems simulation proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error'); - drupal_goto('powersystems/pssp/manage-proposal'); - return; - } //$form_state['values']['approval'] == 2 -} -/******************************************************************************/ -/*************************** PROPOSAL STATUS FORM *****************************/ -/******************************************************************************/ -function om_pssp_proposal_status_form($form, &$form_state) -{ - global $user; - /* get current proposal */ - $proposal_id = (int) arg(4); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_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('powersystems/pssp/manage-proposal'); - return; - } - } //$proposal_q - else - { - drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); - drupal_goto('powersystems/pssp/manage-proposal'); - return; - } - if ($proposal_data->contact_no == "NULL" || $proposal_data->contact_no == "") - { - $contact_no = "Not Entered"; - } //$proposal_data->project_guide_name == NULL - else - { - $contact_no = $proposal_data->contact_no; - } - $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' => $contact_no, - ); - /*$form['month_year_of_degree'] = array( - '#type' => 'date_popup', - '#title' => t('Month and year of award of degree'), - '#date_label_position' => '', - '#description' => '', - '#default_value' => $proposal_data->month_year_of_degree, - '#date_format' => 'M-Y', - '#date_increment' => 0, - '#date_year_range' => '1960:+0', - '#datepicker_options' => array( - 'maxDate' => 0 - ), - '#disabled' => TRUE - );*/ - $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_guide_name'] = array( - '#type' => 'item', - '#title' => t('Project guide'), - '#markup' => $proposal_data->project_guide_name - ); - $form['project_guide_email_id'] = array( - '#type' => 'item', - '#title' => t('Project guide email'), - '#markup' => $proposal_data->project_guide_email_id - ); - $form['project_title'] = array( - '#type' => 'item', - '#markup' => $proposal_data->project_title, - '#title' => t('Title of the Power systems simulation Project') - ); - if (($proposal_data->samplefilepath != "") && ($proposal_data->samplefilepath != 'NULL')) - { - $str = substr($proposal_data->samplefilepath,strrpos($proposal_data->samplefilepath, '/')); - $resource_file =ltrim($str, '/'); - - $form['samplefilepath'] = array( - '#type' => 'item', - '#title' => t('Abstract file '), - '#markup' => l($resource_file, 'powersystems/pssp/download/resource-file/' . $proposal_id) . "" - ); - } //$proposal_data->user_defined_compound_filepath != "" - else - { - $form['samplefilepath'] = array( - '#type' => 'item', - '#title' => t('Abstract file '), - '#markup' => "Not uploaded

" - ); - } - /************************** reference link filter *******************/ - $url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?$0', $proposal_data->reference); - /******************************/ - $form['reference'] = array( - '#type' => 'item', - '#markup' => $reference, - '#title' => t('References') - ); - $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', 'powersystems/pssp/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'), 'powersystems/pssp/manage-proposal/all') - ); - return $form; -} -function om_pssp_proposal_status_form_submit($form, &$form_state) -{ - global $user; - /* get current proposal */ - $proposal_id = (int) arg(4); - //$proposal_q = db_query("SELECT * FROM {om_pssp_proposal} WHERE id = %d", $proposal_id); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_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('powersystems/pssp/manage-proposal'); - return; - } - } //$proposal_q - else - { - drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); - drupal_goto('powersystems/pssp/manage-proposal'); - return; - } - /* set the book status to completed */ - if ($form_state['values']['completed'] == 1) - { - $up_query = "UPDATE om_pssp_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); - CreateReadmeFileOmPSSPProject($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('om_pssp_from_email', ''); - $bcc = $user->mail . ', ' . variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['om_pssp_proposal_completed']['proposal_id'] = $proposal_id; - $params['om_pssp_proposal_completed']['user_id'] = $proposal_data->uid; - $params['om_pssp_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('om_pssp', 'om_pssp_proposal_completed', $email_to, language_default(), $params, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('Congratulations! Power systems simulation proposal has been marked as completed. User has been notified of the completion.', 'status'); - } - drupal_goto('powersystems/pssp/manage-proposal'); - return; - -} -/******************************************************************************/ -/**************************** PROPOSAL EDIT FORM ******************************/ -/******************************************************************************/ -function om_pssp_proposal_edit_form($form, &$form_state) -{ - global $user; - /* get current proposal */ - $proposal_id = (int) arg(4); - //$proposal_q = db_query("SELECT * FROM {om_pssp_proposal} WHERE id = %d", $proposal_id); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_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('powersystems/pssp/manage-proposal'); - return; - } - } //$proposal_q - else - { - drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); - drupal_goto('powersystems/pssp/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', - 'Mrs' => 'Mrs', - 'Ms' => 'Ms' - ), - '#required' => TRUE, - '#default_value' => $proposal_data->name_title - ); - $form['contributor_name'] = array( - '#type' => 'textfield', - '#title' => t('Name of the Proposer'), - '#size' => 350, - '#maxlength' => 350, - '#required' => TRUE, - '#default_value' => $proposal_data->contributor_name - ); - $form['student_email_id'] = array( - '#type' => 'item', - '#title' => t('Email'), - '#markup' => $user_data->mail - ); - $form['month_year_of_degree'] = array( - '#type' => 'date_popup', - '#title' => t('Month and year of award of degree'), - '#date_label_position' => '', - '#description' => '', - '#default_value' => $proposal_data->month_year_of_degree, - '#date_format' => 'M-Y', - '#date_increment' => 0, - '#date_year_range' => '1960:+0', - '#datepicker_options' => array( - 'maxDate' => 0 - ), - '#required' => FALSE - ); - $form['university'] = array( - '#type' => 'textfield', - '#title' => t('University/Institute'), - '#size' => 200, - '#maxlength' => 200, - '#required' => TRUE, - '#default_value' => $proposal_data->university - ); - if($proposal_data->country == 'India'){ - $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['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' - ) - ) - ) - ); -} -else{ - $form['other_country'] = array( - '#type' => 'textfield', - '#title' => t('Country(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['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' => 'textarea', - '#title' => t('Title of the Power systems simulation Project'), - '#size' => 300, - '#maxlength' => 350, - '#required' => TRUE, - '#default_value' => $proposal_data->project_title - ); - $form['description'] = array( - '#type' => 'textarea', - '#title' => t('Description of the Project'), - '#size' => 250, - '#maxlength' => 250, - '#required' => TRUE, - '#default_value' => $proposal_data->description - ); - $form['reference'] = array( - '#type' => 'textarea', - '#title' => t('Reference'), - '#size' => 10000, - '#attributes' => array( - 'placeholder' => 'Links of must be provided....' - ), - '#default_value' => $proposal_data->reference - ); - $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'), 'powersystems/pssp/manage-proposal') - ); - return $form; -} -function om_pssp_proposal_edit_form_submit($form, &$form_state) -{ - global $user; - /* get current proposal */ - $proposal_id = (int) arg(4); - $query = db_select('om_pssp_proposal'); - $query->fields('om_pssp_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('powersystems/pssp/manage-proposal'); - return; - } - } //$proposal_q - else - { - drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); - drupal_goto('powersystems/pssp/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('om_pssp_from_email', ''); - $bcc = variable_get('om_pssp_emails', ''); - $cc = variable_get('om_pssp_cc_emails', ''); - $params['om_pssp_proposal_deleted']['proposal_id'] = $proposal_id; - $params['om_pssp_proposal_deleted']['user_id'] = $proposal_data->uid; - $params['om_pssp_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('om_pssp', 'om_pssp_proposal_deleted', $email_to, user_preferred_language($user), $params, $from, TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message(t('Power system simulation proposal has been deleted.'), 'status'); - if (rrmdir_project($proposal_id) == TRUE) - { - $query = db_delete('om_pssp_proposal'); - $query->condition('id', $proposal_id); - $num_deleted = $query->execute(); - drupal_set_message(t('Proposal Deleted'), 'status'); - drupal_goto('powersystems/pssp/manage-proposal'); - return; - } //rrmdir_project($proposal_id) == TRUE - } //$form_state['values']['delete_proposal'] == 1 - /* update proposal */ - $v = $form_state['values']; - $str = substr($proposal_data->samplefilepath,strrpos($proposal_data->samplefilepath, '/')); - $resource_file =ltrim($str, '/'); - $project_title = $v['project_title']; - $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; - } - $samplefilepath = $directory_name . '/' . $resource_file; - $query = "UPDATE om_pssp_proposal SET - name_title=:name_title, - contributor_name=:contributor_name, - university=:university, - city=:city, - pincode=:pincode, - state=:state, - project_title=:project_title, - description=:description, - reference=:reference, - directory_name=:directory_name, - samplefilepath=:samplefilepath - WHERE id=:proposal_id"; - $args = array( - ':name_title' => $v['name_title'], - ':contributor_name' => $v['contributor_name'], - ':university' => $v['university'], - ':city' => $v['city'], - ':pincode' => $v['pincode'], - ':state' => $v['all_state'], - ':project_title' => $project_title, - ':description' => $v['description'], - ':reference' => $v['reference'], - ':directory_name' => $directory_name, - ':samplefilepath' => $samplefilepath, - ':proposal_id' => $proposal_id - ); - $result = db_query($query, $args); - drupal_set_message(t('Proposal Updated'), 'status'); -} \ No newline at end of file diff --git a/om_pssp.info b/om_pssp.info deleted file mode 100755 index febdd42..0000000 --- a/om_pssp.info +++ /dev/null @@ -1,7 +0,0 @@ -name = "OM PSSP" -description = "PSSP Project, FOSSEE, IIT Bombay" -package = FOSSEE -version = "7.x" -core = "7.x" - -;scripts[] = js/jquery-1.4.1.min.js diff --git a/om_pssp.info.yml b/om_pssp.info.yml new file mode 100755 index 0000000..3be398b --- /dev/null +++ b/om_pssp.info.yml @@ -0,0 +1,6 @@ +name: 'OM PSSP' +description: 'PSSP Project, FOSSEE, IIT Bombay' +package: FOSSEE +core_version_requirement: ^9 || ^10 +type: module +dependencies: { } diff --git a/om_pssp.links.menu.yml b/om_pssp.links.menu.yml new file mode 100755 index 0000000..6fdad70 --- /dev/null +++ b/om_pssp.links.menu.yml @@ -0,0 +1,92 @@ +om_pssp.proposal_form: + route_name: om_pssp.proposal_form + title: 'Power System Simulation Proposal Form' + description: 'Power System Simulation Proposal Form' +om_pssp.proposal_pending: + route_name: om_pssp.proposal_pending + title: 'Manage Power System Simulation Proposals' + description: 'Manage Power System Simulation Proposals' +om_pssp.proposal_pending_0: + route_name: om_pssp.proposal_pending + title: 'Pending Proposals' + weight: 1 + description: 'Pending om pssp Proposals Queue' +om_pssp.proposal_all: + route_name: om_pssp.proposal_all + title: 'All Proposals' + weight: 4 + description: 'All Proposals' +om_pssp.proposal_approval_form: + route_name: om_pssp.proposal_approval_form + title: 'Approve Proposal' + description: 'Approve Proposal' +om_pssp.proposal_edit_form: + route_name: om_pssp.proposal_edit_form + title: 'Edit Proposal' + description: 'Edit Proposal' +om_pssp.proposal_status_form: + route_name: om_pssp.proposal_status_form + title: 'Proposal Status' + description: 'Proposal Status' +om_pssp.abstract_bulk_approval_form: + route_name: om_pssp.abstract_bulk_approval_form + title: 'Bulk Manage' + weight: 2 + description: 'Bulk Mangage' +om_pssp.abstract: + route_name: om_pssp.abstract + title: 'Abstract and Power System Simulation Submission' + description: 'Abstract Submission' +om_pssp.upload_abstract_code_form: + route_name: om_pssp.upload_abstract_code_form + title: 'Abstract and Power System Simulation Submission' + weight: 2 + description: 'Abstract Submission' + parent: om_pssp.abstract +om_pssp.download_upload_file: + route_name: om_pssp.download_upload_file + title: 'Download resource file' + description: 'Download resource file' +om_pssp.project_files: + route_name: om_pssp.project_files + title: 'Download abstract file' + description: 'Download abstract file' +om_pssp.download_full_project: + route_name: om_pssp.download_full_project + title: 'Code Download' + description: 'Code Download' +om_pssp.completed_proposals_all: + route_name: om_pssp.completed_proposals_all + title: 'Completed Power System Simulations' +om_pssp.progress_all: + route_name: om_pssp.progress_all + title: 'Power System Simulations in Progress' +om_pssp.run_form: + route_name: om_pssp.run_form + title: 'Download Codes' +om_pssp.settings_form: + route_name: om_pssp.settings_form + title: 'OM PSSP Settings' + description: 'OM PSSP Settings' +om_pssp._list_pssp_certificates: + route_name: om_pssp._list_pssp_certificates + title: 'List of Power System Simulation Certificates' + description: 'List of Power System Simulation Certificates' +om_pssp.generate_pdf: + route_name: om_pssp.generate_pdf + title: 'Download Certificate' + description: 'Download Certificate' + parent: om_pssp._list_pssp_custom_certificates +om_pssp._list_pssp_custom_certificates: + route_name: om_pssp._list_pssp_custom_certificates + title: 'List of Power System Simulation Custom Certificates' + description: 'List of Power System Simulation Custom Certificates' +om_pssp.generate_pdf_0: + route_name: om_pssp.generate_pdf + title: 'Download Certificate' + description: 'Download Certificate' + parent: om_pssp._list_pssp_custom_certificates +om_pssp.verify_certificates: + route_name: om_pssp.verify_certificates + title: 'Certificate Verification' + parent: om_pssp._list_pssp_certificates diff --git a/om_pssp.links.task.yml b/om_pssp.links.task.yml new file mode 100644 index 0000000..af7d193 --- /dev/null +++ b/om_pssp.links.task.yml @@ -0,0 +1,10 @@ +om_pssp.proposal_pending: + route_name: om_pssp.proposal_pending + title: 'Pending Proposals' + weight: 1 + base_route: om_pssp.proposal_pending +om_pssp.proposal_all: + route_name: om_pssp.proposal_all + title: 'All Proposals' + weight: 2 + base_route: om_pssp.proposal_pending \ No newline at end of file diff --git a/om_pssp.module b/om_pssp.module index 065dd6b..dd494b2 100755 --- a/om_pssp.module +++ b/om_pssp.module @@ -3,9 +3,9 @@ /*error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE);*/ -require_once('general_deletion.inc'); +/*require_once('general_deletion.inc'); require_once('email.inc'); -/** +*//** * Implementation of hook_menu(). */ function om_pssp_menu() @@ -22,7 +22,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp create proposal' ), - 'type' => MENU_NORMAL_ITEM, + //'type' => MENU_NORMAL_ITEM, 'file' => 'proposal.inc' ); $items['powersystems/pssp/manage-proposal'] = array( @@ -43,7 +43,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp manage proposal' ), - 'type' => MENU_DEFAULT_LOCAL_TASK, + //'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 1, 'file' => 'manage_proposal.inc' ); @@ -55,7 +55,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp manage proposal' ), - 'type' => MENU_LOCAL_TASK, + //'type' => MENU_LOCAL_TASK, 'weight' => 4, 'file' => 'manage_proposal.inc' ); @@ -69,7 +69,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp manage proposal' ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); $items['powersystems/pssp/manage-proposal/edit'] = array( @@ -82,7 +82,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp manage proposal' ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); $items['powersystems/pssp/manage-proposal/status'] = array( @@ -95,46 +95,9 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp approve proposal' ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); - /*$items['powersystems/pssp/show-proposal'] = array( - 'title' => 'om pssp Solution Proposal', - 'page callback' => 'drupal_get_form', - 'page arguments' => array( - 'om_pssp_solution_proposal_form' - ), - 'access arguments' => array( - 'om pssp propose solution' - ), - 'type' => MENU_CALLBACK, - 'file' => 'solution_proposal.inc' - );*/ - /* CODE REVIEW */ - /*$items['powersystems/pssp/code-approval'] = array( - 'title' => 'LM Manage Code Approval', - 'description' => 'Manage Code Approval', - 'page callback' => 'om_pssp_code_approval', - 'access arguments' => array( - 'om pssp approve code' - ), - 'type' => MENU_NORMAL_ITEM, - 'file' => 'code_approval.inc' - ); - $items['powersystems/pssp/abstract-approval/approve'] = array( - 'title' => 'Code Approval', - 'description' => 'Code Approval', - 'page callback' => 'drupal_get_form', - 'page arguments' => array( - 'om_pssp_abstract_approval_form' - ), - 'access arguments' => array( - 'om pssp approve code' - ), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => 1, - 'file' => 'code_approval.inc' - );*/ $items['powersystems/pssp/abstract-approval/bulk'] = array( 'title' => 'Bulk Manage', 'description' => 'Bulk Mangage', @@ -145,7 +108,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp bulk manage abstract' ), - 'type' => MENU_LOCAL_TASK, + //'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'abstract_bulk_approval.inc' ); @@ -170,7 +133,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp upload code' ), - 'type' => MENU_LOCAL_TASK, + //'type' => MENU_LOCAL_TASK, 'file' => 'upload_code.inc', 'weight' => 2 ); @@ -182,7 +145,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp download code' ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['powersystems/pssp/download/abstract-file'] = array( @@ -192,17 +155,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp download code' ), - 'type' => MENU_CALLBACK, - 'file' => 'download.inc' - ); - $items['powersystems/pssp/download/file'] = array( - 'title' => 'Code Download', - 'description' => 'Code Download', - 'page callback' => 'om_pssp_download_solution_file', - 'access arguments' => array( - 'om pssp download code' - ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['powersystems/pssp/full-download/project'] = array( @@ -212,7 +165,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp download code' ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'file' => 'full_download.inc' ); /* COMPLETED om psspS */ @@ -243,7 +196,7 @@ function om_pssp_menu() 'access arguments' => array( 'om pssp download code' ), - 'type' => MENU_NORMAL_ITEM, + //'type' => MENU_NORMAL_ITEM, 'file' => 'run.inc' ); /* ADMIN SETTINGS */ @@ -257,7 +210,7 @@ function om_pssp_menu() 'access arguments' => array( 'administer om pssp' ), - 'type' => MENU_NORMAL_ITEM, + //'type' => MENU_NORMAL_ITEM, 'file' => 'settings.inc' ); /* AJAX REQUEST */ @@ -277,7 +230,7 @@ function om_pssp_menu() 'page arguments' => array( 'generate_pdf' ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'access arguments' => array( 'generate pdf' ), @@ -299,7 +252,7 @@ function om_pssp_menu() 'page arguments' => array( 'generate_pdf' ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'access arguments' => array( 'generate pdf' ), @@ -311,7 +264,7 @@ function om_pssp_menu() "access arguments" => array( "verify certificates" ), - 'type' => MENU_CALLBACK, + //'type' => MENU_CALLBACK, 'file' => 'pdf/verify_certificates.inc' ); return $items; @@ -383,7 +336,6 @@ function om_pssp_permission() "description" => t("Allows users to Generate pdf.") ) ); - // return array('om pssp create proposal', 'om pssp manage proposal', 'om pssp edit proposal', 'om pssp approve proposal', 'om pssp propose solution', 'om pssp approve code', 'om pssp bulk manage abstract', 'om pssp bulk delete code', 'om pssp upload code', 'om pssp download code', 'administer om pssp', 'om pssp generate lab'); } /*************************** VALIDATION FUNCTIONS *****************************/ @@ -417,9 +369,9 @@ function om_pssp_path() /************************* USER VERIFICATION FUNCTIONS ************************/ function om_pssp_get_proposal() { - global $user; + $user = \Drupal::currentUser(); //$proposal_q = db_query("SELECT * FROM {om_pssp_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1"); - $query = db_select('om_pssp_proposal'); + $query = \Drupal::database()->select('om_pssp_proposal'); $query->fields('om_pssp_proposal'); $query->condition('uid', $user->uid); $query->orderBy('id', 'DESC'); @@ -428,24 +380,24 @@ function om_pssp_get_proposal() $proposal_data = $proposal_q->fetchObject(); if (!$proposal_data) { - drupal_set_message("You do not have any approved om pssp proposal. Please propose the Power System Simulation proposal", 'error'); + \Drupal::messenger()->addError("You do not have any approved om pssp proposal. Please propose the Power System Simulation proposal"); drupal_goto('powersystems'); } //!$proposal_data switch ($proposal_data->approval_status) { case 0: - drupal_set_message(t('Proposal is awaiting approval.'), 'status'); + \Drupal::messenger()->addStatus(t('Proposal is awaiting approval.')); return FALSE; case 1: return $proposal_data; case 2: - drupal_set_message(t('Proposal has been dis-approved.'), 'error'); + \Drupal::messenger()->addError(t('Proposal has been dis-approved.')); return FALSE; case 3: - drupal_set_message(t('Proposal has been marked as completed.'), 'status'); + \Drupal::messenger()->addStatus(t('Proposal has been marked as completed.')); return FALSE; default: - drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error'); + \Drupal::messenger()->addError(t('Invalid proposal state. Please contact site administrator for further information.')); return FALSE; } //$proposal_data->approval_status return FALSE; @@ -468,7 +420,7 @@ function om_pssp_ucname($string) } //array( '-', '\'' ) as $delimiter return $string; } -function _df_sentence_case($string) +function _pssp_sentence_case($string) { $string = ucwords(strtolower($string)); foreach (array( @@ -484,12 +436,12 @@ function _df_sentence_case($string) return $string; } -function _df_list_of_states() +function _pssp_list_of_states() { $states = array( 0 => '-Select-' ); - $query = db_select('list_states_of_india'); + $query = \Drupal::database()->select('list_states_of_india'); $query->fields('list_states_of_india'); //$query->orderBy('', ''); $states_list = $query->execute(); @@ -499,12 +451,12 @@ function _df_list_of_states() } //$states_list_data = $states_list->fetchObject() return $states; } -function _df_list_of_cities() +function _pssp_list_of_cities() { $city = array( 0 => '-Select-' ); - $query = db_select('list_cities_of_india'); + $query = \Drupal::database()->select('list_cities_of_india'); $query->fields('list_cities_of_india'); $query->orderBy('city', 'ASC'); $city_list = $query->execute(); @@ -514,12 +466,12 @@ function _df_list_of_cities() } //$city_list_data = $city_list->fetchObject() return $city; } -function _df_list_of_pincodes() +function _pssp_list_of_pincodes() { $pincode = array( 0 => '-Select-' ); - $query = db_select('list_of_all_india_pincode'); + $query = \Drupal::database()->select('list_of_all_india_pincode'); $query->fields('list_of_all_india_pincode'); $query->orderBy('pincode', 'ASC'); $pincode_list = $query->execute(); @@ -529,10 +481,10 @@ function _df_list_of_pincodes() } //$pincode_list_data = $pincode_list->fetchObject() return $pincode; } -function _df_list_of_departments() +function _pssp_list_of_departments() { $department = array(); - $query = db_select('list_of_departments'); + $query = \Drupal::database()->select('list_of_departments'); $query->fields('list_of_departments'); $query->orderBy('id', 'DESC'); $department_list = $query->execute(); @@ -542,10 +494,10 @@ function _df_list_of_departments() } //$department_list_data = $department_list->fetchObject() return $department; } -function _df_list_of_software_version() +function _pssp_list_of_software_version() { $software_version = array(); - $query = db_select('om_software_version'); + $query = \Drupal::database()->select('om_software_version'); $query->fields('om_software_version'); $query->orderBy('id', 'ASC'); $software_version_list = $query->execute(); @@ -555,7 +507,7 @@ function _df_list_of_software_version() } //$software_version_list_data = $software_version_list->fetchObject() return $software_version; } -function _df_dir_name($project, $proposar_name) +function _pssp_dir_name($project, $proposar_name) { $project_title = ucname($project); @@ -568,11 +520,11 @@ function om_pssp_document_path() { return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'openmodelica_uploads/om_pssp_uploads/'; } -function DF_RenameDir($proposal_id, $dir_name) +function PSSP_RenameDir($proposal_id, $dir_name) { $proposal_id = $proposal_id; $dir_name = $dir_name; - $query = db_query("SELECT directory_name,id FROM om_pssp_proposal WHERE id = :proposal_id", array( + $query = \Drupal::database()->query("SELECT directory_name,id FROM om_pssp_proposal WHERE id = :proposal_id", array( ':proposal_id' => $proposal_id )); $result = $query->fetchObject(); @@ -594,13 +546,13 @@ function DF_RenameDir($proposal_id, $dir_name) } //is_dir($files_id_dir) else { - drupal_set_message('Directory not available for rename.'); + \Drupal::messenger()->addMessage('Directory not available for rename.'); return; } } //$result != NULL else { - drupal_set_message('Project directory name not present in databse'); + \Drupal::messenger()->addMessage('Project directory name not present in databse'); return; } //var_dump($files);die; @@ -616,7 +568,7 @@ function DF_RenameDir($proposal_id, $dir_name) } function CreateReadmeFileOmPSSPProject($proposal_id) { - $result = db_query(" + $result = \Drupal::database()->query(" SELECT * from om_pssp_proposal WHERE id = :proposal_id", array( ":proposal_id" => $proposal_id )); @@ -638,7 +590,7 @@ function CreateReadmeFileOmPSSPProject($proposal_id) function rrmdir_project($prop_id) { $proposal_id = $prop_id; - $result = db_query(" + $result = \Drupal::database()->query(" SELECT * from om_pssp_proposal WHERE id = :proposal_id", array( ":proposal_id" => $proposal_id )); @@ -666,15 +618,15 @@ function rrmdir_project($prop_id) } //$objects as $object reset($objects); rmdir($dir); - $msg = drupal_set_message("Directory deleted successfully"); + $msg = \Drupal::messenger()->addMessage("Directory deleted successfully"); return $msg; } //is_dir($dir) - $msg = drupal_set_message("Directory not present"); + $msg = \Drupal::messenger()->addMessage("Directory not present"); return $msg; } //$proposal_data->id == $prop_id else { - $msg = drupal_set_message("Data not found"); + $msg = \Drupal::messenger()->addMessage("Data not found"); return $msg; } } @@ -696,37 +648,4 @@ function rrmdir($dir) reset($objects); rmdir($dir); } //is_dir($dir) -} -function _om_pssp_list_of_user_defined_compound($proposal_id) -{ - $data = ""; - //$query = db_select('om_pssp_user_defined_compound'); - //$query->fields('om_pssp_user_defined_compound'); - //$query->condition('proposal_id', $proposal_id, '='); - //$query->orderBy('user_defined_compound', 'ASC'); - $user_defined_compound_list = db_query("SELECT * FROM om_pssp_user_defined_compound WHERE proposal_id = :proposal_id", array(":proposal_id" => $proposal_id)); - $headers = array( - "List of user defined compounds used in process Power System Simulation", - "CAS No." - ); - if($user_defined_compound_list){ - $rows = array(); - while ($row = $user_defined_compound_list->fetchObject()) - { - $item = array( - "{$row->user_defined_compound}", - "{$row->cas_no}" - ); - array_push($rows, $item); - } //$row = $user_defined_compound_list->fetchObject() - - $data .= theme('table', array( - 'header' => $headers, - 'rows' => $rows - )); - }else{ - $data .= "Not entered"; - } - return $data; -} - +} \ No newline at end of file diff --git a/om_pssp.permissions.yml b/om_pssp.permissions.yml new file mode 100755 index 0000000..c647f0d --- /dev/null +++ b/om_pssp.permissions.yml @@ -0,0 +1,48 @@ +'om pssp create proposal': + title: 'om pssp create proposal' + 'restrict access': true +'om pssp manage proposal': + title: 'om pssp manage proposal' + 'restrict access': true +'om pssp edit proposal': + title: 'om pssp edit proposal' + 'restrict access': true +'om pssp approve proposal': + title: 'om pssp approve proposal' + 'restrict access': true +'om pssp propose solution': + title: 'om pssp propose solution' + 'restrict access': true +'om pssp approve abstract': + title: 'om pssp approve code' + 'restrict access': true +'om pssp bulk manage abstract': + title: 'om pssp bulk manage abstract' + 'restrict access': true +'om pssp bulk delete code': + title: 'om pssp bulk delete code' + 'restrict access': true +'om pssp upload code': + title: 'om pssp upload code' + 'restrict access': true +'om pssp download code': + title: 'om pssp download code' + 'restrict access': true +'administer om pssp': + title: 'administer om pssp' + 'restrict access': true +'om pssp generate abstract': + title: 'om pssp generate abstract' + 'restrict access': true +'list Power System Simulation certificates': + title: 'list Power System Simulation certificates' + description: 'Allows users to list Power System Simulation certificates.' +'list Power System Simulation custom certificates': + title: 'list Power System Simulation custom certificates' + description: 'Allows users to list Power System Simulation custom certificates.' +'PSSP generate pdf': + title: 'PSSP Generate pdf' + description: 'Allows users to Generate pdf.' +'PSSP verify certificates': + title: 'PSSP verify certificates' + description: 'Allows users to verify the contribution.' \ No newline at end of file diff --git a/om_pssp.routing.yml b/om_pssp.routing.yml new file mode 100755 index 0000000..d9ffe9d --- /dev/null +++ b/om_pssp.routing.yml @@ -0,0 +1,140 @@ +om_pssp.proposal_form: + path: /powersystems/pssp/proposal + defaults: + _title: 'Power System Simulation Proposal Form' + _form: \Drupal\om_pssp\Form\OmPsspProposalForm + requirements: + _permission: 'om pssp create proposal' +om_pssp.proposal_pending: + path: /powersystems/pssp/manage-proposal/pending + defaults: + _title: 'Pending Proposals' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_proposal_pending' + requirements: + _permission: 'om pssp manage proposal' +om_pssp.proposal_all: + path: /powersystems/pssp/manage-proposal/all + defaults: + _title: 'All Proposals' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_proposal_all' + requirements: + _permission: 'om pssp manage proposal' +om_pssp.proposal_approval_form: + path: /powersystems/pssp/manage-proposal/approve/{proposal_id} + defaults: + _title: 'Approve Proposal' + _form: \Drupal\om_pssp\Form\OmPsspProposalApprovalForm + requirements: + _permission: 'om pssp manage proposal' +om_pssp.proposal_edit_form: + path: /powersystems/pssp/manage-proposal/edit + defaults: + _title: 'Edit Proposal' + _form: \Drupal\om_pssp\Form\OmPsspProposalEditForm + requirements: + _permission: 'om pssp manage proposal' +om_pssp.proposal_status_form: + path: /powersystems/pssp/manage-proposal/status + defaults: + _title: 'Proposal Status' + _form: \Drupal\om_pssp\Form\OmPsspProposalStatusForm + requirements: + _permission: 'om pssp approve proposal' +om_pssp.abstract_bulk_approval_form: + path: /powersystems/pssp/abstract-approval/bulk + defaults: + _title: 'Bulk Manage' + _form: \Drupal\om_pssp\Form\OmPsspAbstractBulkApprovalForm + requirements: + _permission: 'om pssp bulk manage abstract' +om_pssp.abstract: + path: /powersystems/pssp/abstract-code + defaults: + _title: 'Abstract and Power System Simulation Submission' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_abstract' + requirements: + _permission: 'om pssp upload code' +om_pssp.upload_abstract_code_form: + path: /powersystems/pssp/abstract-code/upload + defaults: + _title: 'Abstract and Power System Simulation Submission' + _form: \Drupal\om_pssp\Form\OmPsspUploadAbstractCodeForm + requirements: + _permission: 'om pssp upload code' +om_pssp.download_upload_file: + path: /powersystems/pssp/download/resource-file + defaults: + _title: 'Download resource file' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_download_upload_file' + requirements: + _permission: 'om pssp download code' +om_pssp.project_files: + path: /powersystems/pssp/download/abstract-file/{proposal_id} + defaults: + _title: 'Download abstract file' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_project_files' + requirements: + _permission: 'om pssp download code' +om_pssp.download_full_project: + path: /powersystems/pssp/full-download/project/{proposal_id} + defaults: + _title: 'Code Download' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_download_full_project' + requirements: + _permission: 'om pssp download code' +om_pssp.completed_proposals_all: + path: /powersystems/pssp/completed-pssp + defaults: + _title: 'Completed Power System Simulations' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_completed_proposals_all' + requirements: + _permission: 'om pssp download code' +om_pssp.progress_all: + path: /powersystems/pssp/pssp-progress + defaults: + _title: 'Power System Simulations in Progress' + _controller: '\Drupal\om_pssp\Controller\DefaultController::om_pssp_progress_all' + requirements: + _permission: 'om pssp download code' +om_pssp.run_form: + path: /powersystems/pssp/om-pssp-run/{proposal_id?} + defaults: + _title: 'Download Codes' + _form: \Drupal\om_pssp\Form\OmPsspRunForm + requirements: + _permission: 'om pssp download code' +om_pssp.settings_form: + path: /admin/settings/om-pssp + defaults: + _title: 'OM PSSP Settings' + _form: \Drupal\om_pssp\Form\OmPsspSettingsForm + requirements: + _permission: 'administer om pssp' +om_pssp._list_pssp_certificates: + path: /powersystems/pssp/certificates + defaults: + _title: 'List of Power System Simulation Certificates' + _controller: '\Drupal\om_pssp\Controller\DefaultController::_list_pssp_certificates' + requirements: + _permission: 'list Power System Simulation certificates' +om_pssp.generate_pdf: + path: /powersystems/pssp/certificates/generate-pdf/{proposal_id} + defaults: + _title: 'Download Certificate' + _form: \Drupal\om_pssp\Form\GeneratePdf + requirements: + _permission: 'PSSP generate pdf' +om_pssp._list_pssp_custom_certificates: + path: /powersystems/pssp/certificates-custom + defaults: + _title: 'List of Power System Simulation Custom Certificates' + _controller: '\Drupal\om_pssp\Controller\DefaultController::_list_pssp_custom_certificates' + requirements: + _permission: 'list Power System Simulation custom certificates' +om_pssp.verify_certificates: + path: /powersystems/pssp/certificates/verify/{qr_code?} + defaults: + _title: 'Certificate Verification' + _controller: '\Drupal\om_pssp\Controller\VerifyCertificatesController::verifyCertificates' + requirements: + _permission: 'PSSP verify certificates' diff --git a/pdf/cert_new.inc b/pdf/cert_new.inc index ed37dee..70a64f6 100755 --- a/pdf/cert_new.inc +++ b/pdf/cert_new.inc @@ -4,17 +4,17 @@ function generate_pdf() $mpath = drupal_get_path('module', 'om_pssp'); require($mpath.'/pdf/fpdf/fpdf.php'); require($mpath.'/pdf/phpqrcode/qrlib.php'); - global $user; + $user = \Drupal::currentUser(); $x = $user->uid; $proposal_id = arg(4); - $query3 = db_query("SELECT * FROM om_pssp_proposal WHERE approval_status=3 AND uid= :uid AND id=:proposal_id", array( + $query3 = \Drupal::database()->query("SELECT * FROM om_pssp_proposal WHERE approval_status=3 AND uid= :uid AND id=:proposal_id", array( ':uid' => $user->uid, ':proposal_id'=>$proposal_id )); $data3 = $query3->fetchObject(); if($data3){ if($data3->uid != $x){ - drupal_set_message('Certificate is not available','error'); + \Drupal::messenger()->addError('Certificate is not available'); return; } } @@ -78,7 +78,7 @@ function generate_pdf() $proposal_get_id = 0; $UniqueString = ""; $tempDir = $path . "/pdf/temp_prcode/"; - $query = db_select('om_pssp_qr_code'); + $query = \Drupal::database()->select('om_pssp_qr_code'); $query->fields('om_pssp_qr_code'); $query->condition('proposal_id', $proposal_id); $result = $query->execute(); @@ -97,9 +97,7 @@ function generate_pdf() ":proposal_id" => $proposal_id, ":qr_code" => $UniqueString ); - $result = db_query($query, $args, array( - 'return' => Database::RETURN_INSERT_ID - )); + $result = \Drupal::database()->query($query, $args, $query); } //$DBString == "" || $DBString == "null" else { $UniqueString = $DBString; diff --git a/pdf/fpdf/FAQ.htm b/pdf/fpdf/FAQ.htm index f41ad8a..dd263ec 100644 --- a/pdf/fpdf/FAQ.htm +++ b/pdf/fpdf/FAQ.htm @@ -1,7 +1,7 @@ - + FAQ