function piwik_stats_cron in Piwik Statistic Integration 7.2
Same name and namespace in other branches
- 7 piwik_stats.module \piwik_stats_cron()
Implements hook_cron().
Add items to process to cron queue.
File
- ./
piwik_stats.module, line 472 - Integrates piwik statistics as entity fields.
Code
function piwik_stats_cron() {
if (variable_get('piwik_stats_cron_fill', TRUE)) {
// If the queue is empty and we should process them on cron run
// let's add them to our cron queue.
$queue = DrupalQueue::get("piwik_stats_fields_to_fill");
if ($queue
->numberOfItems() == 0) {
$items = piwik_stats_get_queue_items();
foreach ($items as $item) {
$queue
->createItem($item);
}
// We want some fresh statistics, remove cached data.
cache_clear_all('piwik_stats:xml:', 'cache_piwik_stats', TRUE);
}
}
else {
// We should not process any items on cron run, delete the queue.
$queue = DrupalQueue::get("piwik_stats_fields_to_fill");
$queue
->deleteQueue();
}
}