You are here

function _privatemsg_limits_get_oldest in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 privatemsg_limits/privatemsg_limits.module \_privatemsg_limits_get_oldest()
  2. 7 privatemsg_limits/privatemsg_limits.module \_privatemsg_limits_get_oldest()

Loads the oldest message a user has written in the specified timeframe.

Parameters

$account: User object

$timeframe: Defines how many seconds back should be considered.

1 call to _privatemsg_limits_get_oldest()
privatemsg_limits_privatemsg_message_validate in privatemsg_limits/privatemsg_limits.module
Implements hook_privatemsg_message_validate().

File

privatemsg_limits/privatemsg_limits.module, line 213
Privatemsg Quota module

Code

function _privatemsg_limits_get_oldest($account, $timeframe) {
  $query = _privatemsg_assemble_query(array(
    'sent',
    'privatemsg_limits',
  ), $account, $timeframe);
  $timestamp = $query
    ->execute()
    ->fetchField();
  $wait_time = $timestamp - (REQUEST_TIME - $timeframe);
  return format_interval($wait_time, 6);
}