function privatemsg_limits_sql_received in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg_limits/privatemsg_limits.module \privatemsg_limits_sql_received()
- 7.2 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 331 - Privatemsg Quota module
Code
function privatemsg_limits_sql_received($account) {
$query = db_select('pm_index', 'pmi');
$query
->join('pm_message', 'pm', 'pm.mid = pmi.mid');
$query
->addExpression('MAX(pm.timestamp)', 'timestamp');
$query
->condition('pmi.recipient', $account->uid)
->condition('pmi.deleted', 0)
->condition('pmi.type', array(
'hidden',
'user',
))
->orderBy('timestamp', 'ASC');
if (variable_get('privatemsg_limits_receive_object', 'message') == 'thread') {
$query
->groupBy('pmi.thread_id');
}
else {
$query
->groupBy('pmi.mid');
}
return $query;
}