From 82593cd2bc056da73caa1b1e981c5a9ead0f1bf2 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Apr 2011 02:37:16 +0000 Subject: Refs #3362. Plugins don't check deps upon boot. Made package and manifest private properties of ElggPlugin and added ->getPackage() and ->getManifest(). git-svn-id: http://code.elgg.org/elgg/trunk@9030 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggPluginPackage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/classes/ElggPluginPackage.php') diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php index 4daab381e..bad99362f 100644 --- a/engine/classes/ElggPluginPackage.php +++ b/engine/classes/ElggPluginPackage.php @@ -334,13 +334,13 @@ class ElggPluginPackage { // first, check if any active plugin conflicts with us. foreach ($enabled_plugins as $plugin) { - $temp_conflicts = $plugin->manifest->getConflicts(); + $temp_conflicts = $plugin->getManifest()->getConflicts(); foreach ($temp_conflicts as $conflict) { if ($conflict['type'] == 'plugin' && $conflict['name'] == $this_id) { $result = $this->checkDepPlugin($conflict, $enabled_plugins, false); // rewrite the conflict to show the originating plugin - $conflict['name'] = $plugin->manifest->getName(); + $conflict['name'] = $plugin->getManifest()->getName(); if (!$full_report && !$result['status']) { return $result['status']; -- cgit v1.2.3 From f1de8bebee841749c342df0a34591a84d8d5d4e3 Mon Sep 17 00:00:00 2001 From: brettp Date: Mon, 9 May 2011 00:51:17 +0000 Subject: Fixes 3426. Not using a horrible variable name and fixing the bug created by it. git-svn-id: http://code.elgg.org/elgg/trunk@9057 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggPluginPackage.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'engine/classes/ElggPluginPackage.php') diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php index bad99362f..9aa4af8bf 100644 --- a/engine/classes/ElggPluginPackage.php +++ b/engine/classes/ElggPluginPackage.php @@ -455,8 +455,8 @@ class ElggPluginPackage { */ private function checkDepPriority(array $dep, array $plugins, $inverse = false) { // grab the ElggPlugin using this package. - $this_plugin = elgg_get_plugin_from_id($this->getID()); - $this_priority = $this_plugin->getPriority(); + $plugin_package = elgg_get_plugin_from_id($this->getID()); + $plugin_priority = $plugin_package->getPriority(); foreach ($plugins as $test_plugin) { if ($test_plugin->getID() == $dep['plugin']) { @@ -466,8 +466,7 @@ class ElggPluginPackage { // If this isn't a plugin or there are no active plugins, // we can't satisfy this dep. - // Assume everything is ok. See #2946. - if (!$this->plugin || !$plugins) { + if (!$plugin_package || !$plugins) { return array( 'status' => true, 'value' => 'uninstalled' @@ -478,11 +477,11 @@ class ElggPluginPackage { switch ($dep['priority']) { case 'before': - $status = $this_priority < $test_plugin_priority; + $status = $plugin_priority < $test_plugin_priority; break; case 'after': - $status = $this_priority > $test_plugin_priority; + $status = $plugin_priority > $test_plugin_priority; break; default; @@ -490,7 +489,7 @@ class ElggPluginPackage { } // get the current value - if ($this_priority < $test_plugin_priority) { + if ($plugin_priority < $test_plugin_priority) { $value = 'before'; } else { $value = 'after'; -- cgit v1.2.3 From 9a68be3c337ed98475535ab6b0483f53073678e1 Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 24 May 2011 17:59:51 +0000 Subject: Fixes #3467. Fixed bugs in priority deps. Can now disable active plugins with unmet dependencies. git-svn-id: http://code.elgg.org/elgg/trunk@9111 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggPluginPackage.php | 13 +++---- languages/en.php | 1 + views/default/css/admin.php | 9 ++++- views/default/object/plugin/advanced.php | 61 +++++++++++++++++++------------- 4 files changed, 50 insertions(+), 34 deletions(-) (limited to 'engine/classes/ElggPluginPackage.php') diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php index 9aa4af8bf..977b72d76 100644 --- a/engine/classes/ElggPluginPackage.php +++ b/engine/classes/ElggPluginPackage.php @@ -457,16 +457,11 @@ class ElggPluginPackage { // grab the ElggPlugin using this package. $plugin_package = elgg_get_plugin_from_id($this->getID()); $plugin_priority = $plugin_package->getPriority(); + $test_plugin = elgg_get_plugin_from_id($dep['plugin']); - foreach ($plugins as $test_plugin) { - if ($test_plugin->getID() == $dep['plugin']) { - break; - } - } - - // If this isn't a plugin or there are no active plugins, - // we can't satisfy this dep. - if (!$plugin_package || !$plugins) { + // If this isn't a plugin or the plugin isn't installed or active + // priority doesn't matter. Use requires to check if a plugin is active. + if (!$plugin_package || !$test_plugin || !$test_plugin->isActive()) { return array( 'status' => true, 'value' => 'uninstalled' diff --git a/languages/en.php b/languages/en.php index 509de7fb0..83fb66dad 100644 --- a/languages/en.php +++ b/languages/en.php @@ -661,6 +661,7 @@ $english = array( 'admin:plugins:simple_simple_fail' => 'Could not save settings.', 'admin:plugins:simple_simple_success' => 'Settings saved.', 'admin:plugins:simple:cannot_activate' => 'Cannot activate this plugin. Check the advanced plugin admin area for more information.', + 'admin:plugins:warning:unmet_dependencies_active' => 'This plugin is active but has unmet dependencies. You may encounter problems. See "more info" below for details.', 'admin:plugins:dependencies:type' => 'Type', 'admin:plugins:dependencies:name' => 'Name', diff --git a/views/default/css/admin.php b/views/default/css/admin.php index c4dacad91..744211a20 100644 --- a/views/default/css/admin.php +++ b/views/default/css/admin.php @@ -1179,12 +1179,19 @@ ul.admin_plugins { .elgg-plugin.elgg-state-inactive { background: #dedede; } -.elgg-dependency.elgg-state-error { + +.elgg-state-error { background: #fbe3e4; color: #8a1f11; border-color: #fbc2c4; font-weight: bold; } +.elgg-state-warning { + background: #fbedb5; + color: #000000; + border-color: #fbe58b; + font-weight: bold; +} .admin_notices { padding-bottom: 15px; diff --git a/views/default/object/plugin/advanced.php b/views/default/object/plugin/advanced.php index 9aed4163c..56e680ad5 100644 --- a/views/default/object/plugin/advanced.php +++ b/views/default/object/plugin/advanced.php @@ -20,7 +20,6 @@ $actions_base = '/action/admin/plugins/'; $ts = time(); $token = generate_action_token($ts); -$active_class = ($active && $can_activate) ? 'elgg-state-active' : 'elgg-state-inactive'; // build reordering links $links = ''; @@ -80,33 +79,42 @@ if ($priority < $max_priority) { } // activate / deactivate links -if ($can_activate) { - if ($active) { - $action = 'deactivate'; - $class = 'elgg-button-cancel'; - } else { - $action = 'activate'; - $class = 'elgg-button-submit'; + +// always let them deactivate +$options = array( + 'is_action' => true +); +if ($active) { + $active_class = 'elgg-state-active'; + $action = 'deactivate'; + $options['text'] = elgg_echo('deactivate'); + $options['class'] = "elgg-button elgg-button-cancel"; + + if (!$can_activate) { + $active_class = 'elgg-state-active'; + $options['class'] = 'elgg-button elgg-state-warning'; } +} else if ($can_activate) { + $active_class = 'elgg-state-inactive'; + $action = 'activate'; + $options['text'] = elgg_echo('activate'); + $options['class'] = "elgg-button elgg-button-submit"; +} else { + $active_class = 'elgg-state-inactive'; + $action = ''; + $options['text'] = elgg_echo('admin:plugins:cannot_activate'); + $options['class'] = "elgg-button elgg-button-disabled"; + $options['disabled'] = 'disabled'; +} +if ($action) { $url = elgg_http_add_url_query_elements($actions_base . $action, array( - 'plugin_guids[]' => $plugin->guid, - 'is_action' => true + 'plugin_guids[]' => $plugin->guid )); - $action_button = elgg_view('output/url', array( - 'href' => $url, - 'text' => elgg_echo($action), - 'is_action' => true, - 'class' => "elgg-button $class" - )); -} else { - $action_button = elgg_view('output/url', array( - 'text' => elgg_echo('admin:plugins:cannot_activate'), - 'disabled' => 'disabled', - 'class' => "elgg-button elgg-button-action elgg-state-disabled" - )); + $options['href'] = $url; } +$action_button = elgg_view('output/url', $options); // Display categories $categories_html = ''; @@ -202,8 +210,13 @@ if (elgg_view_exists($settings_view_old) || elgg_view_exists($settings_view_new) } if (!$can_activate) { - $message = elgg_echo('admin:plugins:warning:unmet_dependencies'); - echo "

$message

"; + if ($active) { + $message = elgg_echo('admin:plugins:warning:unmet_dependencies_active'); + echo "

$message

"; + } else { + $message = elgg_echo('admin:plugins:warning:unmet_dependencies'); + echo "

$message

"; + } } ?> -- cgit v1.2.3