You are here

function _messaging_template_message_part in Messaging 6.4

Load message parts from db or get defaults from module

1 call to _messaging_template_message_part()
messaging_template_message_part in messaging_template/messaging_template.module
Returns parts of messages, that may be formatted for each sending method

File

messaging_template/messaging_template.module, line 183
Drupal Messaging Framework - Messaging template

Code

function _messaging_template_message_part($group, $method, $language) {
  $templates = array();
  $result = db_query("SELECT * FROM {messaging_message_parts} WHERE type = '%s' AND method = '%s' AND language = '%s'", $group, $method, $language->language);
  while ($part = db_fetch_object($result)) {
    $templates[$part->msgkey] = $part;
  }

  // If not in db and method is default, get values from modules
  if (empty($templates) && $method == 'default') {
    foreach (messaging_template_message_defaults($group, $language) as $key => $text) {
      $part = (object) array(
        'type' => $group,
        'msgkey' => $key,
        'default' => $text,
        'format' => 0,
        'message' => is_array($text) ? implode("\n", $text) : $text,
      );
      $templates[$key] = $part;
    }
  }
  return $templates;
}