You are here

function messaging_pull_pending in Messaging 6

Same name and namespace in other branches
  1. 5 messaging.module \messaging_pull_pending()
  2. 6.2 messaging.module \messaging_pull_pending()
  3. 6.3 messaging.module \messaging_pull_pending()

Pull pending messages for given methods and user accounts

Each returned message will be an array with the following elements

  • 'uid', destination uid
  • 'sender', originating uid
  • 'subject', message subject to be rendered
  • 'body', message body to be rendered

Parameters

$method: Send method

$users: User id or array of user id's

$limit: Optional limit for number of messages

$delete: Optional whether to delete messages when fetching

Return value

array() Array of pending messages.

2 calls to messaging_pull_pending()
Messaging_API_Tests::testMessagingBasicAPI in tests/messaging_api.test
Exercise basic API functions
Messaging_API_Tests::testMessagingSendingAPI in tests/messaging_api.test
Play with creating, retrieving, deleting a pair messages

File

./messaging.module, line 427

Code

function messaging_pull_pending($method, $users = NULL, $limit = 0, $delete = TRUE) {
  $params['method'] = $method;
  $params['queue'] = 1;
  if (!is_null($users)) {
    $params['uid'] = $users;
  }
  $messages = messaging_store_get($params);

  // Not exactly delete but mark as sent
  if ($messages && $delete) {
    messaging_store('sent', array_keys($messages));
  }
  return $messages;
}