aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/plugins.php
diff options
context:
space:
mode:
authorPaweł Sroka <srokap@gmail.com>2013-10-27 19:27:14 +0100
committerPaweł Sroka <srokap@gmail.com>2013-10-27 19:27:14 +0100
commit33260fd7a88e5e92fbee6ee0719ab4286e9ce221 (patch)
tree3c6a679bd332e99fddf21f424f3456095ddf30b9 /engine/lib/plugins.php
parent9762edd4305ab8e6523d2f8171a32688295f1c88 (diff)
downloadelgg-33260fd7a88e5e92fbee6ee0719ab4286e9ce221.tar.gz
elgg-33260fd7a88e5e92fbee6ee0719ab4286e9ce221.tar.bz2
Refs #6117 - Added docs + changed plugins_deactivate_dependency_check to _plugins_deactivate_dependency_check
Diffstat (limited to 'engine/lib/plugins.php')
-rw-r--r--engine/lib/plugins.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index c296346fc..d5d3db466 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -1104,7 +1104,17 @@ function plugins_test($hook, $type, $value, $params) {
return $value;
}
-function plugins_deactivate_dependency_check($event, $type, $params) {
+/**
+ * Checks on deactivate plugin event if disabling it won't create unmet dependencies and blocks disable in such case.
+ *
+ * @param string $event deactivate
+ * @param string $type plugin
+ * @param array $params Parameters array containing entry with ELggPlugin instance under 'plugin_entity' key
+ * @return bool false to block plugin deactivation action
+ *
+ * @access private
+ */
+function _plugins_deactivate_dependency_check($event, $type, $params) {
$plugin_id = $params['plugin_entity']->getManifest()->getPluginID();
$plugin_name = $params['plugin_entity']->getManifest()->getName();
@@ -1114,7 +1124,7 @@ function plugins_deactivate_dependency_check($event, $type, $params) {
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
@@ -1130,11 +1140,11 @@ function plugins_deactivate_dependency_check($event, $type, $params) {
$list .= '<li>' . $dependent->getManifest()->getName() . '</li>';
}
$list .= '</ul>';
-
+
register_error(elgg_echo('ElggPlugin:Dependencies:ActiveDependent', array($plugin_name, $list)));
-
+
return false;
- }
+ }
}
/**
@@ -1151,7 +1161,7 @@ function plugin_init() {
// note - plugins are booted by the time this handler is registered
// deactivation due to error may have already occurred
- elgg_register_event_handler('deactivate', 'plugin', 'plugins_deactivate_dependency_check');
+ elgg_register_event_handler('deactivate', 'plugin', '_plugins_deactivate_dependency_check');
elgg_register_action("plugins/settings/save", '', 'admin');
elgg_register_action("plugins/usersettings/save");