You are here

function messaging_message_send_user in Messaging 5

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

Send message to user represented by account

We are applying same output filter for everybody, depending on send method

The final rendering of the message depends on send method too. I.e. a mail messaging method may want to insert '--' before the body footer.

@ TODO Consider whether it makes sense to allow users decide on formatting

Parameters

$account: User object to recieve message.

$message: Array of message parts that will be compiled depending on send method. Mandatory message parts, which may have nexted parts are:

  • 'type'
  • 'subject'
  • 'body'. The message body may have 'header', 'content', 'footer', 'etc'

$method: Optional send method. Defaults to the user account predefined method

$queue: 1 to force queueing instead of sending right away

2 calls to messaging_message_send_user()
Messaging_API_Tests::testMessagingBasicAPI in tests/messaging_api.test
Play with creating, retrieving, deleting a pair messages
Messaging_Methods_Tests::testMessagingMethods in tests/messaging_methods.test
Test message sending callbacks for enabled plug-ins

File

./messaging.module, line 406

Code

function messaging_message_send_user($account, $message, $method = NULL, $queue = 0) {

  // Get default sending method, or default for this user account
  $method = $method ? $method : messaging_method_default($account);
  $message['account'] = $account;

  // If debug module and option enabled, hand over to messaging_debug
  if (variable_get('messaging_debug', 0) && function_exists('messaging_debug_send_user')) {
    return messaging_debug_send_user($account, $message, $method);
  }

  // The sending method may override this function
  if (($function = messaging_method_info($method, 'send_user')) && function_exists($function)) {
    return $function($account, $message, $method);
  }

  // Get destination property from user account, or pass the account itself
  if ($property = messaging_method_info($method, 'destination')) {
    $destination[] = $account->{$property};
  }
  else {
    $destination[] = $account;
  }
  return messaging_message_send($destination, $message, $method, $queue);
}