Commit f481fc89 authored by Bob Vincent's avatar Bob Vincent
Browse files

Removed single-quote character from the middle of a single-quote-delimited text string.

Break out "echo" functionality to separate "echo" module.
parent 3f477cc1
Loading
Loading
Loading
Loading
+2 −19
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ function htmlmail_admin_settings() {
  </dd>
  <dt><code>$directory</code></dt>
  <dd>
    <p>The relative path to the website theme template directory <em>(Again, this is different from the email theme directory, which isn't used for templates)</em>.</p>
    <p>The relative path to the website theme template directory <em>(Again, this is different from the email theme directory, which is not used for templates)</em>.</p>
  </dd>
  <dt><code>$theme_url</code></dt>
  <dd>
@@ -192,20 +192,3 @@ function htmlmail_test_form_submit($form, &$form_state) {
    drupal_set_message(t('HTML Mail test message sent.'));
  }
}

/**
 * Displays the email message body passed via POST as a themed page.
 */
function htmlmail_show_email() {
  if ($css = variable_get('htmlmail_css', '')) {
    drupal_add_css($css, array('type' => 'inline'));
  }
  return isset($_POST['body']) ? $_POST['body'] : '(Empty)';
}

/**
 * Returns the email message subject passed via POST for a title callback.
 */
function htmlmail_get_post_subject($subject) {
  return check_plain(isset($_POST['subject']) ? $_POST['subject'] :  t($subject));
}
+1 −0
Original line number Diff line number Diff line
name = HTML Mail
description = "Enables HTML in system emails."
dependencies[] = echo
dependencies[] = mailsystem
files[] = htmlmail.module
files[] = htmlmail.admin.inc
+3 −3
Original line number Diff line number Diff line
@@ -37,10 +37,10 @@ class HTMLMailMailSystem implements MailSystemInterface {
    }

    // Optionally apply the selected theme via internal http request.
    if ($theme = htmlmail_get_selected_theme($message['theme'])) {
    if ($theme = htmlmail_get_selected_theme($message)) {
      $url = url('admin/config/system/htmlmail/email', array('absolute' => TRUE));
      $data = 'body=' . rawurlencode($message['body'])
        . '&subject=' . rawurlencode($message['subject'])
      $data = 'content=' . rawurlencode($message['body'])
        . '&title=' . rawurlencode($message['subject'])
        . '&theme=' . rawurlencode($theme);
      $options = array(
        'method' => 'POST',
+7 −24
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

/**
 * @file
 * Send system emails in HTML.
 * Sends system emails in HTML.
 */

/**
@@ -45,16 +45,6 @@ function htmlmail_menu() {
    'theme callback' => 'htmlmail_get_selected_theme',
    'file' => 'htmlmail.admin.inc',
  );
  // Callback that receives the message via $_POST and displays it on a themed
  // page.  This is used to format an email message with a Drupal theme.
  $items['admin/config/system/htmlmail/email'] = array(
    'title callback' => 'htmlmail_get_post_subject',
    'page callback' => 'htmlmail_show_email',
    'theme callback' => 'htmlmail_get_selected_theme',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'htmlmail.admin.inc',
  );
  return $items;
}

@@ -133,7 +123,7 @@ function htmlmail_user_presave(&$edit, $account, $category) {
 * machine-readable names and the values are the .info file names.
 * Code shamelessly stolen from the og_theme module.
 */
function htmlmail_get_allowed_themes() {
function &htmlmail_get_allowed_themes() {
  $allowed = &drupal_static(__FUNCTION__);
  if (!isset($allowed)) {
    $allowed = array('' => t('No theme'));
@@ -151,17 +141,10 @@ function htmlmail_get_allowed_themes() {

/**
 * Returns the selected theme to use for outgoing emails.
 * for use in a theme callback function.
 */
function htmlmail_get_selected_theme(&$selected = NULL) {
  if (!isset($selected)) {
    $selected = variable_get('htmlmail_theme', '');
  }
  // Make sure the selected theme is allowed.
  $themes = htmlmail_get_allowed_themes();
  if (isset($themes[$selected])) {
    return $selected;
  }
  // If a theme was specified but not allowed, fall back to site defaults.
  return $GLOBALS['theme'];
function htmlmail_get_selected_theme($message) {
  $themes = &htmlmail_get_allowed_themes();
  return (empty($message['theme']) || empty($themes[$message['theme']]))
    ? variable_get('htmlmail_theme', $GLOBALS['theme'])
    : $message['theme'];
}