function messaging_message_send_user in Messaging 6
Same name and namespace in other branches
- 5 messaging.module \messaging_message_send_user()
- 6.4 messaging.module \messaging_message_send_user()
- 6.2 messaging.module \messaging_message_send_user()
- 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
3 calls to messaging_message_send_user()
- Messaging_API_Tests::testMessagingSendingAPI in tests/
messaging_api.test - Play with creating, retrieving, deleting a pair messages
- messaging_debug_post_form_submit in messaging_debug/
messaging_debug.module - Post test message
- Messaging_Methods_Tests::testMessagingMethods in tests/
messaging_methods.test - Test message sending callbacks for enabled plug-ins
File
- ./
messaging.module, line 168
Code
function messaging_message_send_user($account, &$message, $method = NULL, $queue = 0) {
$message = (object) $message;
// Get default sending method, or default for this user account
$method = $method ? $method : messaging_method_default($account);
$message->account = $account;
// Send the message or, if no destination, abort the message sending
if ($destination = messaging_user_destination($account, $method, $message)) {
return messaging_message_send(array(
$destination,
), $message, $method, $queue);
}
else {
// Save the message, let it there for further reference
$message->method = $method;
$info = messaging_method_info($method, NULL, array());
$message->destination = 'ERROR';
$message = messaging_message_prepare($message, $info);
$message = messaging_message_render($message, $info);
$message->cron = $message->queue = 0;
$message->log = 1;
$message->success = FALSE;
$message = messaging_store('save', $message);
return FALSE;
}
}