You are here

function privatemsg_limits_sql_received in Privatemsg 6.2

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

SQL Function for amount of messages/threads a users has.

Parameters

array $fragments Query array:

user $account User object:

int $timeframe how many seconds to consider.:

File

privatemsg_limits/privatemsg_limits.module, line 328
Privatemsg Quota module

Code

function privatemsg_limits_sql_received(&$fragments, $account) {
  $fragments['primary_table'] = '{pm_index} pmi';
  $fragments['select'][] = 'MAX(pm.timestamp) as timestamp';
  $fragments['inner_join'][] = 'INNER JOIN {pm_message} pm ON (pmi.mid = pm.mid)';
  $fragments['where'][] = 'pmi.recipient = %d';
  $fragments['where'][] = 'pmi.deleted = 0';
  $fragments['where'][] = "pmi.type IN ('hidden', 'user')";
  $fragments['query_args']['where'][] = $account->uid;
  if (variable_get('privatemsg_limits_receive_object', 'message') == 'thread') {
    $fragments['group_by'][] = 'pmi.thread_id';
  }
  else {
    $fragments['group_by'][] = 'pmi.mid';
  }
  $fragments['order_by'][] = 'timestamp ASC';
}