function hierarchical_select_requirements in Hierarchical Select 7.3
Same name and namespace in other branches
- 5.3 hierarchical_select.module \hierarchical_select_requirements()
- 6.3 hierarchical_select.module \hierarchical_select_requirements()
Implements hook_requirements().
File
- ./
hierarchical_select.module, line 155 - This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.
Code
function hierarchical_select_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
// Check if all hook_update_n() hooks have been executed.
require_once DRUPAL_ROOT . '/' . 'includes/install.inc';
drupal_load_updates();
$updates = drupal_get_schema_versions('hierarchical_select');
$current = drupal_get_installed_schema_version('hierarchical_select');
$up_to_date = end($updates) == $current;
$hierarchical_select_weight = db_query("SELECT weight FROM {system} WHERE type = :type AND name = :name", array(
':type' => 'module',
':name' => 'hierarchical_select',
))
->fetchField();
$core_overriding_modules = array(
'hs_book',
'hs_menu',
'hs_taxonomy',
);
$path_errors = array();
foreach ($core_overriding_modules as $module) {
$filename = db_query("SELECT filename FROM {system} WHERE type = :type AND name = :name", array(
':type' => 'module',
':name' => $module,
))
->fetchField();
if (strpos($filename, 'modules/') === 0) {
$module_info = drupal_parse_info_file(dirname($filename) . "/{$module}.info");
$path_errors[] = t('!module', array(
'!module' => $module_info['name'],
));
}
}
if ($up_to_date && !count($path_errors)) {
$value = t('All updates installed. HS API implementation modules correctly installed.');
$description = '';
$severity = REQUIREMENT_OK;
}
elseif ($path_errors) {
$value = t('Modules incorrectly installed!');
$description = t("The following modules implement Hierarchical Select module for Drupal\n core modules, but are installed in the wrong location. They're\n installed in core's <code>modules</code> directory, but should be\n installed in either the <code>sites/all/modules</code> directory or a\n <code>sites/yoursite.com/modules</code> directory") . ':' . theme('item_list', array(
'items' => $path_errors,
));
$severity = REQUIREMENT_ERROR;
}
else {
$value = t('Not all updates installed!');
$description = t('Please run update.php to install the latest updates!
You have installed update !installed_update, but the latest update is
!latest_update!', array(
'!installed_update' => $current,
'!latest_update' => end($updates),
));
$severity = REQUIREMENT_ERROR;
}
$requirements['hierarchical_select'] = array(
'title' => t('Hierarchical Select'),
'value' => $value,
'description' => $description,
'severity' => $severity,
);
}
return $requirements;
}