You are here

function messaging_tokens_get_list in Messaging 6.2

Same name and namespace in other branches
  1. 5 messaging.module \messaging_tokens_get_list()
  2. 6 messaging.admin.inc \messaging_tokens_get_list()
  3. 6.3 messaging.admin.inc \messaging_tokens_get_list()

Get list of tokens for text replacement

Parameters

$group: Message group to get tokens for

$tokens:

1 call to messaging_tokens_get_list()
messaging_admin_message_form in ./messaging.admin.inc
Edit message formats

File

./messaging.admin.inc, line 188
Messaging Framework - Admin UI

Code

function messaging_tokens_get_list($group) {

  // First compile token types for this message group
  $type_list = module_invoke_all('messaging', 'tokens', $group);

  // Add known global tokens, will be always available
  $type_list[] = 'global';

  // Now get token list from token module for each type
  $return = array();
  foreach ($type_list as $type) {

    // This is a shortcut for single tokens for digests, with the form (token, description)
    if (is_array($type)) {
      list($type, $token) = $type;
      $list = token_get_list($type);
      $return[$token] = $list[$type][$token];
    }
    elseif ($list = token_get_list($type)) {
      foreach ($list as $category => $tokens) {
        foreach ($tokens as $token => $description) {
          $return[$token] = $description;
        }
      }
    }
  }
  return $return;
}