You are here

function workbench_email_tokens in Workbench Email 7.3

Implements hook_tokens().

File

./workbench_email.module, line 1153
Code for the Workbench Email Module.

Code

function workbench_email_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  if ($type == 'workbench-email') {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'email-transition':
          if (isset($data['workbench_email']['email_transition']) && !empty($data['workbench_email']['email_transition'])) {
            $email_transition = $data['workbench_email']['email_transition'];
            $label = ucwords(str_replace('_', ' ', $email_transition->from_name) . ' To ' . str_replace('_', ' ', $email_transition->to_name));
            $replacements[$original] = check_plain($label);
          }
          break;
        case 'name':
          if (isset($data['workbench_email']['account']) && !empty($data['workbench_email']['account'])) {
            $account = $data['workbench_email']['account'];
            $replacements[$original] = check_plain($account->name);
          }
          break;
      }
    }
  }
  return $replacements;
}