function l10n_update_check_translations in Localization update 6
Same name and namespace in other branches
- 7 l10n_update.check.inc \l10n_update_check_translations()
Check updates for active projects and languages.
Parameters
$count: Number of package translations to check.
$before: Unix timestamp, check only updates that haven't been checked for this time.
$limit: Maximum number of updates to do. We check $count translations but we stop after we do $limit updates.
Return value
array
1 call to l10n_update_check_translations()
- l10n_update_cron in ./
l10n_update.module - Implementation of hook_cron().
File
- ./
l10n_update.check.inc, line 115 - Reusable API for l10n remote updates using $source objects
Code
function l10n_update_check_translations($count, $before, $limit = 1) {
$projects = l10n_update_get_projects();
$updated = $checked = array();
// Select active projects x languages ordered by last checked time
$sql = "SELECT p.name, l.language AS lang, f.* FROM {l10n_update_project} p";
$sql .= " LEFT JOIN {l10n_update_file} f ON p.name = f.project";
$sql .= " INNER JOIN {languages} l ON l.language = f.language";
$sql .= " WHERE p.status = 1 AND l.enabled = 1 AND (f.status IS NULL OR f.status = 1 AND f.last_checked < %d) ORDER BY last_checked";
$result = db_query_range($sql, $before, 0, $count);
if ($result) {
$local = variable_get('l10n_update_check_mode', L10N_UPDATE_CHECK_ALL) & L10N_UPDATE_CHECK_LOCAL;
$remote = variable_get('l10n_update_check_mode', L10N_UPDATE_CHECK_ALL) & L10N_UPDATE_CHECK_REMOTE;
while (($check = db_fetch_object($result)) && count($updated) < $limit) {
$checked[] = $check;
if (!empty($projects[$check->name])) {
$project = $projects[$check->name];
$update = NULL;
$source = l10n_update_source_build($project, $check->lang);
$current = $check->filename ? $check : NULL;
if ($available = l10n_update_source_check($source, $local, $remote)) {
if (!$current || _l10n_update_source_compare($current, $available) == -1 || $current->version != $available->version) {
$update = $available;
}
}
if ($update) {
// The update functions will update data and timestamps too
l10n_update_source_update($update, variable_get('l10n_update_import_mode', LOCALE_IMPORT_KEEP));
$updated[] = $update;
}
elseif ($current) {
// No update available, just update timestamp for this row
db_query("UPDATE {l10n_update_file} SET last_checked = %d WHERE project = '%s' AND language = '%s'", time(), $current->project, $current->language);
}
elseif ($source) {
// Create a new record just for keeping last checked time
$source->last_checked = time();
drupal_write_record('l10n_update_file', $source);
}
}
}
}
return array(
$checked,
$updated,
);
}