You are here

function _email_file_download in Ubercart 5

Email a user with download links for a product file download

@return: Sends result of drupal_mail

Parameters

$user: The Drupal user object

$order: The order object associated with message

$file_user: An array for user file downloads (uc_file_user row) associated with message

1 call to _email_file_download()
uc_file_order in uc_file/uc_file.module
Implementation of hook_order().

File

uc_file/uc_file.module, line 974
Allows products to be associated with downloadable files.

Code

function _email_file_download($user, $order, $file_users) {
  if (!variable_get('uc_file_download_notification', FALSE)) {
    return;
  }
  $token_filters = array(
    'global' => NULL,
    'user' => $user,
    'order' => $order,
    'uc_file' => $file_users,
  );
  $key = 'uc_file_download_notify';
  $to = $order->primary_email;
  $from = uc_store_email_from();
  $subject = token_replace_multiple(variable_get('uc_file_download_notification_subject', uc_get_message('uc_file_download_subject')), $token_filters);
  $body = token_replace_multiple(variable_get('uc_file_download_notification_message', uc_get_message('uc_file_download_message')), $token_filters);
  $body = check_markup($body, variable_get('uc_file_download_notification_format', 3), FALSE);

  //drupal_set_message("Mail Sent<br />key: $key, <br />to: $to, <br />subject: $subject, <br />body: $body, <br />from: $from, <br />");
  return drupal_mail($key, $to, $subject, $body, $from, array(
    'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
  ));
}