function og_migrate_get_plugins_dependencies in Organic groups 7
Get a list of plugin names by dependencies.
Parameters
$plugins_name:
Return value
Array with the plugin names sorted, or FALSE if no plugins are accessible.
1 call to og_migrate_get_plugins_dependencies()
- og_migrate_batch in og_migrate/
og_migrate.module - Helper function to create a batch.
File
- og_migrate/
og_migrate.module, line 86 - Migrate and upgrade Organic groups data.
Code
function og_migrate_get_plugins_dependencies($plugins_name) {
// Get all module data so we can find dependencies and sort.
$plugins_data = og_migrate_build_dependencies();
// Create an associative array with weights as values.
$plugins_name = array_flip(array_values($plugins_name));
$plugins_accessible = og_migrate_get_accessible_plugins();
while (list($plugin_name) = each($plugins_name)) {
if (!isset($plugins_data[$plugin_name])) {
// This plugin is not found, abort.
return FALSE;
}
// TODO: Check access.
if (empty($plugins_accessible[$plugin_name])) {
// Skip plugin that has no access.
unset($plugins_name[$plugin_name]);
}
$plugins_name[$plugin_name] = $plugins_data[$plugin_name]['sort'];
// Add dependencies to the list, with a placeholder weight.
// The new modules will be processed as the while loop continues.
foreach (array_keys($plugins_data[$plugin_name]['requires']) as $dependency) {
if (!isset($plugins_name[$dependency])) {
$plugins_name[$dependency] = 0;
}
}
}
if (!$plugins_name) {
// Nothing to do, plugins are not accessible.
return FALSE;
}
// Sort the module list by pre-calculated weights.
arsort($plugins_name);
$plugins_name = array_keys($plugins_name);
return $plugins_name;
}