Created
March 31, 2021 03:20
-
-
Save sylus/6f1799cb8ffc719ab8baa647c44c44f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From d42456bb76b9c0347d0543bffcac5f18c2376edc Mon Sep 17 00:00:00 2001 | |
From: William Hearn <[email protected]> | |
Date: Tue, 30 Mar 2021 23:19:39 -0400 | |
Subject: [PATCH] feat(webform): Patch webform | |
--- | |
.../webform/includes/webform.report.inc | 3 +++ | |
.../webform/includes/webform.submissions.inc | 25 ++++++++++++------- | |
.../modules/contrib/webform/webform.api.php | 19 ++++++++++++++ | |
3 files changed, 38 insertions(+), 9 deletions(-) | |
diff --git a/profiles/wetkit/modules/contrib/webform/includes/webform.report.inc b/profiles/wetkit/modules/contrib/webform/includes/webform.report.inc | |
index beb8b32..19a464d 100644 | |
--- a/profiles/wetkit/modules/contrib/webform/includes/webform.report.inc | |
+++ b/profiles/wetkit/modules/contrib/webform/includes/webform.report.inc | |
@@ -1147,6 +1147,7 @@ function webform_results_download_rows($node, array $options, $serial_start = 0, | |
* by the super-global $_GET['page'] variable. | |
*/ | |
function webform_results_download_rows_process($node, array $options, $serial_start, array $submissions) { | |
+ global $user; | |
module_load_include('inc', 'webform', 'includes/webform.components'); | |
$submission_information = webform_results_download_submission_information($node, $options); | |
@@ -1154,10 +1155,12 @@ function webform_results_download_rows_process($node, array $options, $serial_st | |
// Generate a row for each submission. | |
$row_count = 0; | |
$rows = array(); | |
+ $mode = 'download'; | |
foreach ($submissions as $sid => $submission) { | |
$row_count++; | |
$row = array(); | |
+ drupal_alter('webform_submission_pre_render', $submission, $node, $user, $mode); | |
// Add submission information. | |
foreach (array_keys($submission_information) as $token) { | |
$cell = module_invoke_all('webform_results_download_submission_information_data', $token, $submission, $options, $serial_start, $row_count); | |
diff --git a/profiles/wetkit/modules/contrib/webform/includes/webform.submissions.inc b/profiles/wetkit/modules/contrib/webform/includes/webform.submissions.inc | |
index 9d5a436..89ff0b3 100644 | |
--- a/profiles/wetkit/modules/contrib/webform/includes/webform.submissions.inc | |
+++ b/profiles/wetkit/modules/contrib/webform/includes/webform.submissions.inc | |
@@ -287,6 +287,10 @@ function webform_submission_send_mail($node, $submission, $emails = NULL, $send_ | |
function _webform_submission_prepare_mail($node, $submission, &$email) { | |
global $user; | |
+ // Alter submission prior to sending. | |
+ $mode = 'mail'; | |
+ drupal_alter('webform_submission_pre_render', $submission, $node, $user, $mode); | |
+ | |
// Set the HTML property based on availablity of MIME Mail. | |
$email['html'] = ($email['html'] && webform_variable_get('webform_email_html_capable')); | |
@@ -502,15 +506,6 @@ function webform_submission_page($node, $submission, $format) { | |
// Set the correct page title. | |
drupal_set_title(webform_submission_title($node, $submission)); | |
- if ($format == 'form') { | |
- $output = drupal_get_form('webform_client_form_' . $node->nid, $node, $submission); | |
- } | |
- else { | |
- $renderable = webform_submission_render($node, $submission, NULL, $format); | |
- $renderable['#attached']['css'][] = drupal_get_path('module', 'webform') . '/css/webform.css'; | |
- $output = drupal_render($renderable); | |
- } | |
- | |
// Determine the mode in which we're displaying this submission. | |
$mode = ($format != 'form') ? 'display' : 'form'; | |
if (strpos(request_path(), 'print/') !== FALSE) { | |
@@ -520,6 +515,18 @@ function webform_submission_page($node, $submission, $format) { | |
$mode = 'pdf'; | |
} | |
+ // Alter submission prior to sending. | |
+ drupal_alter('webform_submission_pre_render', $submission, $node, $user, $mode); | |
+ | |
+ if ($format == 'form') { | |
+ $output = drupal_get_form('webform_client_form_' . $node->nid, $node, $submission); | |
+ } | |
+ else { | |
+ $renderable = webform_submission_render($node, $submission, NULL, $format); | |
+ $renderable['#attached']['css'][] = drupal_get_path('module', 'webform') . '/css/webform.css'; | |
+ $output = drupal_render($renderable); | |
+ } | |
+ | |
// Add navigation for administrators. | |
if (webform_results_access($node)) { | |
$navigation = theme('webform_submission_navigation', array('node' => $node, 'submission' => $submission, 'mode' => $mode)); | |
diff --git a/profiles/wetkit/modules/contrib/webform/webform.api.php b/profiles/wetkit/modules/contrib/webform/webform.api.php | |
index 58892c2..2b8eb23 100644 | |
--- a/profiles/wetkit/modules/contrib/webform/webform.api.php | |
+++ b/profiles/wetkit/modules/contrib/webform/webform.api.php | |
@@ -231,6 +231,25 @@ function hook_webform_submission_actions($node, $submission) { | |
return $actions; | |
} | |
+/** | |
+ * Modifies a submission prior to rendering for display. | |
+ * | |
+ * @param array $submission | |
+ * Reference to the current Webform submission. | |
+ * @param object $node | |
+ * Reference to the current Webform node. | |
+ * @param object $account | |
+ * Reference to the current Drupal user account. | |
+ * @param string $action | |
+ * Reference to the display action being undertaken. | |
+ * Either 'form', 'display', 'print', 'pdf' or 'mail'. | |
+ */ | |
+function hook_webform_submission_pre_render_alter(&$submission, &$node, &$account, &$action) { | |
+ if ($action == 'display') { | |
+ $submission['foo'] = 'bar'; | |
+ } | |
+} | |
+ | |
/** | |
* Modify the draft to be presented for editing. | |
* | |
-- | |
2.21.0 (Apple Git-122) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment