function privatemsg_limits_sql_sent in Privatemsg 6.2
Same name and namespace in other branches
- 7.2 privatemsg_limits/privatemsg_limits.module \privatemsg_limits_sql_sent()
- 7 privatemsg_limits/privatemsg_limits.module \privatemsg_limits_sql_sent()
SQL Function for amount of messages/threads a user has written in a timeframe.
Parameters
array $fragments Query array:
user $account User object:
int $timeframe how many seconds to consider.:
File
- privatemsg_limits/
privatemsg_limits.module, line 286 - Privatemsg Quota module
Code
function privatemsg_limits_sql_sent(&$fragments, $account, $timeframe) {
$fragments['primary_table'] = '{pm_message} pm';
if (variable_get('privatemsg_limits_send_object', 'message') == 'thread') {
$fragments['select'][] = 'MAX(pm.timestamp) as timestamp';
$fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON (pmi.mid = pm.mid)';
$fragments['group_by'][] = 'pmi.thread_id';
}
else {
$fragments['select'][] = 'pm.timestamp';
}
$fragments['where'][] = 'pm.author = %d';
$fragments['query_args']['where'][] = $account->uid;
$fragments['where'][] = 'pm.timestamp > %d';
$fragments['query_args']['where'][] = time() - $timeframe;
$fragments['order_by'][] = 'timestamp ASC';
}