function checkVersion($versionInfo, $displayInfo = false)
{
if (!$versionInfo) {
$application = PKPApplication::getApplication();
printf("Failed to load version info from %s\n", $application->getVersionDescriptorUrl());
exit(1);
}
$dbVersion = VersionCheck::getCurrentDBVersion();
$codeVersion = VersionCheck::getCurrentCodeVersion();
$latestVersion = $versionInfo['version'];
printf("Code version: %s\n", $codeVersion->getVersionString(false));
printf("Database version: %s\n", $dbVersion->getVersionString(false));
printf("Latest version: %s\n", $latestVersion->getVersionString(false));
$compare1 = $codeVersion->compare($latestVersion);
$compare2 = $dbVersion->compare($codeVersion);
if (!$displayInfo) {
if ($compare2 < 0) {
printf("Database version is older than code version\n");
printf("Run \"{$this->scriptName} upgrade\" to update\n");
exit(0);
} else {
if ($compare2 > 0) {
printf("Database version is newer than code version!\n");
exit(1);
} else {
if ($compare1 == 0) {
printf("Your system is up-to-date\n");
} else {
if ($compare1 < 0) {
printf("A newer version is available:\n");
$displayInfo = true;
} else {
printf("Current version is newer than latest!\n");
exit(1);
}
}
}
}
}
if ($displayInfo) {
printf(" tag: %s\n", $versionInfo['tag']);
printf(" date: %s\n", $versionInfo['date']);
printf(" info: %s\n", $versionInfo['info']);
printf(" package: %s\n", $versionInfo['package']);
}
return $compare1;
}