function _l10n_update_source_compare in Localization update 7
Same name and namespace in other branches
- 6 l10n_update.check.inc \_l10n_update_source_compare()
- 7.2 l10n_update.translation.inc \_l10n_update_source_compare()
Compare two update sources, looking for the newer one (bigger timestamp).
This function can be used as a callback to compare two source objects.
Parameters
$current: Source object of current project.
$update: Source object of available update.
Return value
integer
- '-1': $current < $update OR $current is missing
- '0': $current == $update OR both $current and $updated are missing
- '1': $current > $update OR $update is missing
4 calls to _l10n_update_source_compare()
- l10n_update_build_updates in ./
l10n_update.check.inc - Compare available releases with history and get list of downloadable updates.
- l10n_update_check_translations in ./
l10n_update.check.inc - Check updates for active projects and languages.
- l10n_update_flag_history in ./
l10n_update.inc - Flag the file history as up to date.
- l10n_update_source_check in ./
l10n_update.check.inc - Check local and remote sources for the file.
File
- ./
l10n_update.check.inc, line 418 - Reusable API for l10n remote updates using $source objects
Code
function _l10n_update_source_compare($current, $update) {
if ($current && $update) {
if (abs($current->timestamp - $update->timestamp) < L10N_UPDATE_TIMESTAMP_THRESHOLD) {
return 0;
}
else {
return $current->timestamp > $update->timestamp ? 1 : -1;
}
}
elseif ($current && !$update) {
return 1;
}
elseif (!$current && $update) {
return -1;
}
else {
return 0;
}
}