function messaging_debug_post_form_submit in Messaging 6.2
Same name and namespace in other branches
- 6 messaging_debug/messaging_debug.module \messaging_debug_post_form_submit()
- 6.3 messaging_debug/messaging_debug.module \messaging_debug_post_form_submit()
Post test message
File
- messaging_debug/
messaging_debug.module, line 127 - Simple messaging using html page. Messaging method plug-in
Code
function messaging_debug_post_form_submit($form, $form_state) {
global $user;
// Convert body in array of lines
$body = split("\n", $form_state['values']['body']);
$body = array_map('trim', $body);
$message = (object) array(
'type' => 'debug',
'subject' => $form_state['values']['subject'],
'body' => $body,
);
// Destination may be account or plain parameter/s
$destination = $form_state['values']['to'];
if ($account = user_load(array(
'name' => $destination,
))) {
$result = messaging_message_send_user($account, $message, $form_state['values']['method']);
}
else {
$result = messaging_message_send(array(
$destination,
), $message, $form_state['values']['method']);
}
drupal_set_message(t('Sent message with result: %result', array(
'%result' => $result ? 'OK' : 'Error',
)));
}