function gplib_version_check in Grammar Parser Library 7
Same name and namespace in other branches
- 7.2 gplib.module \gplib_version_check()
Indicates whether the installed library code is of the correct version.
Return value
boolean Whether a valid version was found.
File
- ./
gplib.module, line 69 - Provides primary Drupal hook implementations.
Code
function gplib_version_check() {
$version_state = variable_get('gplib_grammar_parser_version_state', GPLIB_VERSION_UNKNOWN);
if ($version_state == GPLIB_VERSION_VALID) {
return TRUE;
}
$info = gplib_libraries_info();
$info = $info['grammar_parser'];
$keys = array_keys($info['versions']);
$version = reset($keys);
$url = l('here', $info['download url']);
$message = t('Install version @version of the Grammar Parser library code (from !url) in a libraries directory such as "sites/all/libraries." For easy installation, use the drush make file in the Grammar Parser Library project.', array(
'@version' => $version,
'!url' => $url,
));
if ($version_state == GPLIB_VERSION_INVALID) {
drupal_set_message($message, 'error');
return FALSE;
}
$info = libraries_detect('grammar_parser');
if ($info === FALSE || empty($info['version']) || !version_compare($info['version'], $version, '=')) {
drupal_set_message($message, 'error');
variable_set('gplib_grammar_parser_version_state', $info === FALSE ? GPLIB_VERSION_UNKNOWN : GPLIB_VERSION_INVALID);
return FALSE;
}
variable_set('gplib_grammar_parser_version_state', GPLIB_VERSION_VALID);
return TRUE;
}