function messaging_store_unpack in Messaging 6.2
Same name and namespace in other branches
- 5 messaging.store.inc \messaging_store_unpack()
- 6 messaging.store.inc \messaging_store_unpack()
- 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 And loading the file objects associated too
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 177 - 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]);
}
}
// Load files attached to this message if any
// This will serve as a check of whether the files still exist
if (!empty($message->params['files']) && $full) {
$message->files = array();
$result = db_query('SELECT * FROM {upload} WHERE fid IN (' . db_placeholders($message->params['files']) . ')', $message->params['files']);
while ($file = db_fetch_object($result)) {
$message->files[$file->fid] = $file;
}
}
// 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,
);
}
}
}