You are here

function subscriptions_mail_template_load in Subscriptions 6

Same name and namespace in other branches
  1. 7 subscriptions_mail.templates.inc \subscriptions_mail_template_load()
  2. 2.0.x subscriptions_mail/subscriptions_mail.templates.inc \subscriptions_mail_template_load()

Retrieve a mail template, either from the mail_edit table or take our default template in this file, passing it through t().

Parameters

string $mailkey: the full mailkey, used as id in the mail_edit table

string $langcode: the language code, used as language in the mail_edit table or for translating out default template

string $part: either 'subject' or 'body', used to indicate the column to retrieve from the mail_edit table

string $key: the key for calling subscriptions_mail_template() to retrieve the default template, if there's no match in the mail_edit table

4 calls to subscriptions_mail_template_load()
subscriptions_content_form_mail_edit_trans_alter in ./subscriptions_content.module
Implementation of hook_form_alter().
_subscriptions_content_node_mailvars in ./subscriptions_content.module
Fill given array of mailvars with given node values.
_subscriptions_mail_cron in ./subscriptions_mail.cron.inc
Implementation of hook_cron().
_subscriptions_mail_form_mail_edit_trans_alter in ./subscriptions_mail.admin.inc
Implementation of hook_form_alter().

File

./subscriptions_mail.templates.inc, line 109
Subscriptions module mail templates constants.

Code

function subscriptions_mail_template_load($mailkey, $langcode, $part, $key) {
  if (module_exists('mail_edit')) {
    static $cache = array();
    if (!isset($cache[$langcode][$mailkey])) {
      $cache[$langcode][$mailkey] = db_fetch_object(db_query("SELECT * FROM {mail_edit} WHERE id = '%s' and language = '%s'", $mailkey, $langcode));
    }
    if (isset($cache[$langcode][$mailkey]->{$part})) {
      return $cache[$langcode][$mailkey]->{$part};
    }
  }
  return subscriptions_mail_template($key, $langcode);
}