You are here

function messaging_token_values in Messaging 6.4

Same name and namespace in other branches
  1. 6 messaging.module \messaging_token_values()
  2. 6.2 messaging.module \messaging_token_values()
  3. 6.3 messaging.module \messaging_token_values()

Implementation of hook_token_values()

File

./messaging.module, line 735

Code

function messaging_token_values($type, $object = NULL, $options = array()) {
  $language = isset($options['language']) ? $options['language'] : $GLOBALS['language'];
  switch ($type) {
    case 'message':
      if ($message = messaging_check_object($object, 'Messaging_Message')) {
        $values['message-subject'] = check_plain($message
          ->get_subject());
        $values['message-body'] = filter_xss($message
          ->get_body());
        $values['message-author-name'] = check_plain($message
          ->get_sender_name());
        $values['message-method'] = messaging_method_info($message->method, 'name');
        $timezone = isset($options['timezone']) ? $options['timezone'] : variable_get('date_default_timezone', 0);
        $values['message-date'] = format_date($message->sent, 'medium', '', $timezone, $language->language);
        return $values;
      }
      break;
    case 'destination':

      // Messaging destinations
      if ($destination = messaging_check_object($object, 'Messaging_Destination')) {
        $values['destination-address'] = $destination
          ->format_address(FALSE);
        $values['destination-type'] = $destination
          ->address_name();
        return $values;
      }
      break;
  }
}