function patterns_check_modules_to_install in Patterns 7.2
Same name and namespace in other branches
- 7 includes/core/modules.inc \patterns_check_modules_to_install()
Checks a list of modules and returns information about their status, whether they are installed, to install or missing.
If
Parameters
$deps is TRUE, also dependencies are checked.:
array $modules Array of module names.:
boolean $deps If TRUE dependecies are also checked.:
Return value
array $result The associative array of information about the modules.
1 call to patterns_check_modules_to_install()
- patterns_install_modules in includes/
core/ modules.inc - Installs required modules for executing the pattern, if they are not already enabled.
File
- includes/
core/ modules.inc, line 85 - Functions to install and uninstall modules during the pattern execution.
Code
function patterns_check_modules_to_install($modules, $deps = TRUE) {
$result = array();
$result['missing'] = array();
$result['to_install'] = array();
$result['installed'] = array();
if (empty($modules)) {
return $result;
}
// Get information about all currently available modules
$modules_info = system_rebuild_module_data();
$active_modules = module_list();
foreach ($modules as $module) {
// Useful check for the XML format
$module = is_array($module) ? $module['value'] : $module;
if (array_key_exists($module, $modules_info)) {
// Is the module to install ?
if (isset($active_modules[$module])) {
array_push($result['installed'], $module);
}
else {
array_push($result['to_install'], $module);
}
// Shall we check the dependecies as well ?
if (!$deps) {
continue;
}
foreach ($modules_info[$module]->info['dependencies'] as $dependency) {
if (!array_key_exists($dependency, $modules_info)) {
array_push($result['missing'], $dependency);
}
else {
if (isset($active_modules[$dependency])) {
array_push($result['installed'], $dependency);
}
else {
array_push($result['to_install'], $dependency);
}
}
}
}
else {
array_push($result['missing'], $module);
}
}
return $result;
}