function webform_protected_downloads_send_mail in Webform Protected Downloads 6
Same name and namespace in other branches
- 7 webform_protected_downloads.module \webform_protected_downloads_send_mail()
Send mail to the user with a valid hash so that he can access the download page
Parameters
string $mail :
string $hash :
Return value
void
2 calls to webform_protected_downloads_send_mail()
- webform_protected_downloads_configuration_form_submit in ./
webform_protected_downloads.form.inc - Implementation of hook_submit().
- webform_protected_downloads_process_submissions in ./
webform_protected_downloads.module - Process unprocessed webform submissions
File
- ./
webform_protected_downloads.module, line 728 - This file contains hook declarations and functions for the Webform Protected Downloads module.
Code
function webform_protected_downloads_send_mail($sid = NULL, $nid, $mail, $hash) {
global $user;
// include the webform inc file
module_load_include('inc', 'webform', 'includes/webform.submissions');
// load the webform node, needed for token replacement
$node = node_load($nid);
// get the submission, including all it's data
// NOTE: for test mails, triggered in
// webform_protected_downloads_configuration_form_submit() $sid will be NULL
$submission = $sid !== NULL ? webform_get_submission($nid, $sid) : FALSE;
// the sender address
$from = webform_protected_downloads_get_configuration($nid, 'mail_from', variable_get('site_mail', NULL));
// build the subject
$subject = webform_protected_downloads_get_configuration($nid, 'mail_subject');
$subject = _webform_protected_downloads_token_replace($subject, $node, $hash);
// build the body
$body = webform_protected_downloads_get_configuration($nid, 'mail_body');
$body = _webform_protected_downloads_token_replace($body, $node, $hash);
if ($submission) {
$subject = _webform_filter_values($subject, $node, $submission, $email = NULL, $strict = FALSE, $allow_anonymous = TRUE);
$body = _webform_filter_values($body, $node, $submission, $email = NULL, $strict = FALSE, $allow_anonymous = TRUE);
}
$params = array(
'subject' => $subject,
'body' => $body,
'From' => $from,
);
// send the mail
drupal_mail('webform_protected_downloads', 'confirmation', $mail, $user->language, $params, $from);
}