function webform_format_email_subject in Webform 7.4
Same name and namespace in other branches
- 6.3 webform.module \webform_format_email_subject()
- 7.3 webform.module \webform_format_email_subject()
Given an email subject, format it with any needed replacements.
3 calls to webform_format_email_subject()
- webform_emails_form in includes/
webform.emails.inc - Overview form of all components for this webform.
- webform_submission_resend in includes/
webform.submissions.inc - Form to resend specific e-mails associated with a submission.
- _webform_submission_prepare_mail in includes/
webform.submissions.inc - Prepare a submission email for use by webform_submission_send_mail()
File
- ./
webform.module, line 4786 - This module provides a simple way to create forms and questionnaires.
Code
function webform_format_email_subject($subject, $node = NULL, $submission = NULL) {
if ($subject == 'default') {
$subject = webform_variable_get('webform_default_subject');
}
elseif (is_numeric($subject) && isset($node->webform['components'][$subject])) {
$component = $node->webform['components'][$subject];
if (isset($submission->data[$subject])) {
$display_function = '_webform_display_' . $component['type'];
$value = $submission->data[$subject];
// Convert the value to a clean text representation if possible.
if (function_exists($display_function)) {
$display = $display_function($component, $value, 'text');
$display['#theme_wrappers'] = array();
$display['#webform_component'] = $component;
$subject = str_replace("\n", ' ', drupal_render($display));
}
else {
$subject = $value;
}
}
else {
$subject = t('Value of "!component"', array(
'!component' => $component['name'],
));
}
}
// Convert arrays to strings (may happen if checkboxes are used as the value).
if (is_array($subject)) {
$subject = reset($subject);
}
return webform_replace_tokens($subject, $node, $submission);
}