You are here

function notifications_destination_message_send in Notifications 6.4

Send message to destination

Parameters

$message: Message data or message template name ('notifications-' will be prepended)

$destination: Destination object

1 call to notifications_destination_message_send()
notifications_destination_request_form_submit in includes/destination.inc
Process submitted values

File

includes/destination.inc, line 468
Destination management

Code

function notifications_destination_message_send($message, $destination, $send_method = NULL, $objects = array(), $priority = 0) {
  if (is_string($message) && $send_method) {

    // We have a template name, message needs to be built
    $template = 'notifications-' . $message;
    $account = $destination
      ->get_account();
    $objects += array(
      'destination' => $destination,
      'user' => $account,
    );
    $language = user_preferred_language($account);
    $message = messaging_template_build($template, $send_method, $language, $objects);
    $message
      ->set_destination($destination);
    $message->priority = $priority;
  }
  if ($message && $send_method) {
    return messaging_message_send_destination($send_method, $destination, $message);
  }
  else {

    // Something's gone wrong
    return FALSE;
  }
}