You are here

protected function Messaging_Message::process in Messaging 6.4

Same name and namespace in other branches
  1. 6.3 classes/messaging_message.class.inc \Messaging_Message::process()
  2. 7 messaging.message.inc \Messaging_Message::process()

Check whether the message is to be sent / queued

Return value

boolean True if it needs further processing

3 calls to Messaging_Message::process()
Messaging_Message::queue in includes/messaging_message.class.inc
Queue message using the messaging store.
Messaging_Message::send in includes/messaging_message.class.inc
Send message through sending method.
Messaging_Message::send_multiple in includes/messaging_message.class.inc
Send to multiple destinations, same method.

File

includes/messaging_message.class.inc, line 272
Drupal Messaging Framework - Message class file

Class

Messaging_Message
Message class

Code

protected function process() {

  // Preprocess: Build and prepare if not done before
  if (!$this->processed) {
    if (!$this->discard && !$this->prepared) {
      $this
        ->prepare();
    }
  }

  // If everything is ok after preprocessing go for actual send/queue
  if ($this->prepared && !$this->discard && !$this->error) {

    // Mark as processed, so it is actually queued/sent
    $this->processed = TRUE;
    if ($this->test) {
      messaging_message_test($this);
      $this->success = TRUE;
    }
    elseif ($this->queue) {
      $this->success = $this
        ->queue();
      $this
        ->module_invoke('queued');
    }
    else {

      // Send to one or more destinations
      if ($this->destination == self::MULTIPLE_DESTINATION) {
        $this->success = $this
          ->send_multiple();
      }
      else {
        $this->success = $this
          ->send();
      }
      if ($this->success) {
        $message->sent = time();
      }
      $this
        ->send_method()
        ->message_aftersend($this);
      $this
        ->module_invoke('sent');
    }

    // Message done, maybe log and return
    $this
      ->done();
    return $this->success;
  }
  else {
    $this
      ->discard('Failed processing.');
    messaging_debug('Discarded message during processing.', array(
      'message' => $this,
    ));
    return FALSE;
  }
}