aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbeck24 <beck24@gmail.com>2013-10-13 00:03:11 -0700
committerbeck24 <beck24@gmail.com>2013-10-13 00:03:11 -0700
commitb3cf5a302d25b06421a055f280ca4f654bd8e6a7 (patch)
tree3885d83835d283b5879ec1ca5d16a95d67fd0f53 /engine
parent088eb2ce72bfe3852a19f4387e28fee8bdba69c7 (diff)
downloadelgg-b3cf5a302d25b06421a055f280ca4f654bd8e6a7.tar.gz
elgg-b3cf5a302d25b06421a055f280ca4f654bd8e6a7.tar.bz2
Fixes #6177 - refuse to deactive plugins used as dependencies
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/plugins.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index 74bce45fd..f0d89e92d 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -1104,6 +1104,39 @@ function plugins_test($hook, $type, $value, $params) {
return $value;
}
+function plugins_deactivate_dependency_check($event, $type, $params) {
+ $plugin_id = $params['plugin_entity']->getManifest()->getPluginID();
+ $plugin_name = $params['plugin_entity']->getManifest()->getName();
+
+ $active_plugins = elgg_get_plugins();
+
+ $dependents = array();
+ foreach ($active_plugins as $plugin) {
+ $manifest = $plugin->getManifest();
+ $requires = $manifest->getRequires();
+
+ foreach ($requires as $required) {
+ if ($required['type'] == 'plugin' && $required['name'] == $plugin_id) {
+ // there are active dependents
+ $dependents[$manifest->getPluginID()] = $plugin;
+ }
+ }
+ }
+
+ if ($dependents) {
+ $list = '<ul>';
+ // construct error message and prevent disabling
+ foreach ($dependents as $dependent) {
+ $list .= '<li>' . $dependent->getManifest()->getName() . '</li>';
+ }
+ $list .= '</ul>';
+
+ register_error(elgg_echo('ElggPlugin:Dependencies:ActiveDependent', array($plugin_name, $list)));
+
+ return false;
+ }
+}
+
/**
* Initialize the plugin system
* Listens to system init and registers actions
@@ -1115,6 +1148,8 @@ function plugin_init() {
run_function_once("plugin_run_once");
elgg_register_plugin_hook_handler('unit_test', 'system', 'plugins_test');
+
+ elgg_register_event_handler('deactivate', 'plugin', 'plugins_deactivate_dependency_check');
elgg_register_action("plugins/settings/save", '', 'admin');
elgg_register_action("plugins/usersettings/save");