Skip to content
Snippets Groups Projects
Commit b860e725 authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Issue #2379407 by twistor, MegaChriz: Make module required if plugins are in use

parent 00a35fe1
No related branches found
No related tags found
No related merge requests found
...@@ -719,6 +719,58 @@ function feeds_field_extra_fields() { ...@@ -719,6 +719,58 @@ function feeds_field_extra_fields() {
return $extras; return $extras;
} }
/**
* Implements hook_system_info_alter().
*
* Goes through a list of all modules that provide Feeds plugins and makes them
* required if there are any importers using those plugins.
*/
function feeds_system_info_alter(array &$info, $file, $type) {
if ($type !== 'module' || !module_hook($file->name, 'feeds_plugins')) {
return;
}
// Don't make Feeds require itself, otherwise you can't disable Feeds until
// all importers are deleted.
if ($file->name === 'feeds' || !function_exists('ctools_include')) {
return;
}
// Get the plugins that belong to the current module.
ctools_include('plugins');
$module_plugins = array();
foreach (ctools_get_plugins('feeds', 'plugins') as $plugin_id => $plugin) {
if ($file->name === $plugin['module']) {
$module_plugins[$plugin_id] = TRUE;
}
}
// Check if any importers are using any plugins from the current module.
foreach (feeds_importer_load_all(TRUE) as $importer) {
$configuration = $importer->getConfig();
foreach (array('fetcher', 'parser', 'processor') as $plugin_type) {
$plugin_key = $configuration[$plugin_type]['plugin_key'];
if (isset($module_plugins[$plugin_key])) {
$info['required'] = TRUE;
break 2;
}
}
}
if (empty($info['required'])) {
return;
}
if (module_exists('feeds_ui') && user_access('administer feeds')) {
$info['explanation'] = t('Feeds is currently using this module for one or more <a href="@link">importers</a>.', array('@link' => url('admin/structure/feeds')));
}
else {
$info['explanation'] = t('Feeds is currently using this module for one or more importers.');
}
}
/** /**
* @} * @}
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment