function l10n_update_cron_fill_queue in Localization update 7.2
Populate a queue with project to check for translation updates.
1 call to l10n_update_cron_fill_queue()
- l10n_update_cron in ./
l10n_update.module - Implements hook_cron().
File
- ./
l10n_update.translation.inc, line 321 - Common API for interface translation.
Code
function l10n_update_cron_fill_queue() {
$updates = array();
// Determine which project+language should be updated.
$last = REQUEST_TIME - variable_get('l10n_update_check_frequency', '0') * 3600 * 24;
$query = db_select('l10n_update_file', 'f');
$query
->join('l10n_update_project', 'p', 'p.name = f.project');
$query
->condition('f.last_checked', $last, '<');
$query
->fields('f', array(
'project',
'language',
));
// Only currently installed / enabled components should be checked for.
$query
->condition('p.status', 1);
$files = $query
->execute()
->fetchAll();
foreach ($files as $file) {
$updates[$file->project][] = $file->language;
// Update the last_checked timestamp of the project+language that will
// be checked for updates.
db_update('l10n_update_file')
->fields(array(
'last_checked' => REQUEST_TIME,
))
->condition('project', $file->project)
->condition('language', $file->language)
->execute();
}
// For each project+language combination a number of tasks are added to
// the queue.
if ($updates) {
module_load_include('fetch.inc', 'l10n_update');
$options = _l10n_update_default_update_options();
$queue = DrupalQueue::get('l10n_update', TRUE);
foreach ($updates as $project => $languages) {
$batch = l10n_update_batch_update_build(array(
$project,
), $languages, $options);
foreach ($batch['operations'] as $item) {
$queue
->createItem($item);
}
}
}
}