function privatemsg_cron in Privatemsg 6
Same name and namespace in other branches
- 5.3 privatemsg.module \privatemsg_cron()
- 5 privatemsg.module \privatemsg_cron()
- 6.2 privatemsg.module \privatemsg_cron()
- 7.2 privatemsg.module \privatemsg_cron()
- 7 privatemsg.module \privatemsg_cron()
Implements hook_cron().
If the flush feature is enabled, a given amount of deleted messages that are old enough are flushed.
1 call to privatemsg_cron()
- PrivatemsgTestCase::testPrivatemsgFlush in ./
privatemsg.test - Tests for the flush feature
File
- ./
privatemsg.module, line 536 - Allows users to send private messages to other users.
Code
function privatemsg_cron() {
if (variable_get('privatemsg_flush_enabled', FALSE)) {
$query = _privatemsg_assemble_query('deleted', variable_get('privatemsg_flush_days', 30));
$result = db_query($query['query']);
$flushed = 0;
while (($row = db_fetch_array($result)) && $flushed < variable_get('privatemsg_flush_max', 200)) {
$message = privatemsg_message_load($row['mid']);
module_invoke_all('privatemsg_message_flush', $message);
// Delete recipients of the message.
db_query('DELETE FROM {pm_index} WHERE mid = %d', $row['mid']);
// Delete message itself.
db_query('DELETE FROM {pm_message} WHERE mid = %d', $row['mid']);
$flushed++;
}
}
}