You are here

function messaging_store_unpack in Messaging 6

Same name and namespace in other branches
  1. 5 messaging.store.inc \messaging_store_unpack()
  2. 6.2 messaging.store.inc \messaging_store_unpack()
  3. 6.3 messaging.store.inc \messaging_store_unpack()

Unpack stored messages

Parameters

$message: Array as retrieved from the db store

$full: True for loading the account data if this message is intended for a user

3 calls to messaging_store_unpack()
messaging_store_get in ./messaging.store.inc
Retrieve from messaging database storage
messaging_store_load in ./messaging.store.inc
Load single message from store
messaging_store_queue_process_step in ./messaging.store.inc
Retrieve and send queued messages

File

./messaging.store.inc, line 176
Database storage for the messaging framework

Code

function messaging_store_unpack(&$message, $full = FALSE) {

  // Preprocessing stored parameters
  if ($message->params) {
    $params = unserialize($message->params);
    $message->params = array();

    // Some optional fields that may be into params, may be extended
    foreach (array(
      'destination',
      'sender_name',
      'destinations',
    ) as $field) {
      if (!empty($params[$field])) {
        $message->{$field} = $params[$field];
        unset($params[$field]);
      }
    }

    // We only saved params for current sending method group
    $group = messaging_method_info($message->method, 'group');
    if ($group && empty($message->params[$group])) {
      $message->params[$group] = $params;
    }
    else {
      $message->params = $params;
    }
  }
  if ($message->uid && $full) {
    $message->account = messaging_load_user($message->uid);
  }
  if ($message->sender && $full) {
    $message->sender_account = messaging_load_user($message->sender);
  }

  // Check destinations array, in case it was not properly filled
  if (empty($message->destinations)) {
    if (!empty($message->account) && ($userdest = messaging_user_destination($message->account, $message->method, $message))) {
      $message->destinations = array(
        $userdest,
      );
    }
    elseif (!empty($message->destination)) {
      $message->destinations = array(
        $message->destination,
      );
    }
  }
}