You are here

function slack_tokens in Slack 7

Implements hook_tokens().

File

./slack.tokens.inc, line 63
Token integration.

Code

function slack_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  if ($type == 'slack') {
    $sanitize = !empty($options['sanitize']);
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'slack-channel':
          $replacements[$original] = $sanitize ? check_plain(slack_get_default_channel()) : slack_get_default_channel();
          break;
        case 'slack-default-webhook-url':
          $replacements[$original] = $sanitize ? check_plain(slack_get_default_webhook_url()) : slack_get_default_webhook_url();
          break;
        case 'slack-icon-url':
          $replacements[$original] = $sanitize ? check_plain(slack_get_default_icon_url()) : slack_get_default_icon_url();
          break;
        case 'slack-icon-emoji':
          $replacements[$original] = $sanitize ? check_plain(slack_get_default_icon_emoji()) : slack_get_default_icon_emoji();
          break;
        case 'slack-username':
          $replacements[$original] = $sanitize ? check_plain(slack_get_default_username()) : slack_get_default_username();
          break;
      }
    }
  }
  return $replacements;
}