From f2123cdc42c8da21a297158fbb655f72bc92edce Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 5 Jan 2011 04:36:07 +0000 Subject: Fixes #2760. Refs #2759. Updated plugin admin actions to use the new system. Added plugin dependency views in admin. ElggPluginPackage->checkDependencies() now returns the detected value. git-svn-id: http://code.elgg.org/elgg/trunk@7838 36083f99-b078-4883-b0ff-0f9b5a30f544 --- actions/admin/plugins/activate.php | 42 +++++++++++++++++++++ actions/admin/plugins/activate_all.php | 29 +++++++++++++++ actions/admin/plugins/deactivate.php | 42 +++++++++++++++++++++ actions/admin/plugins/deactivate_all.php | 29 +++++++++++++++ actions/admin/plugins/disable.php | 34 ----------------- actions/admin/plugins/disableall.php | 28 -------------- actions/admin/plugins/enable.php | 34 ----------------- actions/admin/plugins/enableall.php | 28 -------------- actions/admin/plugins/reorder.php | 51 -------------------------- actions/admin/plugins/set_priority.php | 40 ++++++++++++++++++++ actions/admin/plugins/simple_update_states.php | 38 +++++++++---------- 11 files changed, 199 insertions(+), 196 deletions(-) create mode 100644 actions/admin/plugins/activate.php create mode 100644 actions/admin/plugins/activate_all.php create mode 100644 actions/admin/plugins/deactivate.php create mode 100644 actions/admin/plugins/deactivate_all.php delete mode 100644 actions/admin/plugins/disable.php delete mode 100644 actions/admin/plugins/disableall.php delete mode 100644 actions/admin/plugins/enable.php delete mode 100644 actions/admin/plugins/enableall.php delete mode 100644 actions/admin/plugins/reorder.php create mode 100644 actions/admin/plugins/set_priority.php (limited to 'actions') diff --git a/actions/admin/plugins/activate.php b/actions/admin/plugins/activate.php new file mode 100644 index 000000000..7a55cb7bb --- /dev/null +++ b/actions/admin/plugins/activate.php @@ -0,0 +1,42 @@ +activate()) { + //system_message(elgg_echo('admin:plugins:activate:yes', array($plugin->manifest->getName()))); + } else { + register_error(elgg_echo('admin:plugins:activate:no', array($plugin->manifest->getName()))); + } +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER); \ No newline at end of file diff --git a/actions/admin/plugins/activate_all.php b/actions/admin/plugins/activate_all.php new file mode 100644 index 000000000..4ba4be270 --- /dev/null +++ b/actions/admin/plugins/activate_all.php @@ -0,0 +1,29 @@ +activate()) { + //system_message(elgg_echo('admin:plugins:activate:yes', array($plugin->manifest->getName()))); + } else { + register_error(elgg_echo('admin:plugins:activate:no', array($plugin->manifest->getName()))); + } +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER); \ No newline at end of file diff --git a/actions/admin/plugins/deactivate.php b/actions/admin/plugins/deactivate.php new file mode 100644 index 000000000..7a9d59287 --- /dev/null +++ b/actions/admin/plugins/deactivate.php @@ -0,0 +1,42 @@ +deactivate()) { + //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->manifest->getName()))); + } else { + register_error(elgg_echo('admin:plugins:deactivate:no', array($plugin->manifest->getName()))); + } +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER); diff --git a/actions/admin/plugins/deactivate_all.php b/actions/admin/plugins/deactivate_all.php new file mode 100644 index 000000000..bdeda001f --- /dev/null +++ b/actions/admin/plugins/deactivate_all.php @@ -0,0 +1,29 @@ +deactivate()) { + //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->manifest->getName()))); + } else { + register_error(elgg_echo('admin:plugins:deactivate:no', array($plugin->manifest->getName()))); + } +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER); diff --git a/actions/admin/plugins/disable.php b/actions/admin/plugins/disable.php deleted file mode 100644 index 64994423f..000000000 --- a/actions/admin/plugins/disable.php +++ /dev/null @@ -1,34 +0,0 @@ - $data) { - if (disable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:disable:yes', array($p))); - } else { - register_error(elgg_echo('admin:plugins:disable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER); diff --git a/actions/admin/plugins/enable.php b/actions/admin/plugins/enable.php deleted file mode 100644 index ebabe7bc8..000000000 --- a/actions/admin/plugins/enable.php +++ /dev/null @@ -1,34 +0,0 @@ - $data) { - if (enable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:enable:yes', array($p))); - } else { - register_error(elgg_echo('admin:plugins:enable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER); \ No newline at end of file diff --git a/actions/admin/plugins/reorder.php b/actions/admin/plugins/reorder.php deleted file mode 100644 index 29c4a7268..000000000 --- a/actions/admin/plugins/reorder.php +++ /dev/null @@ -1,51 +0,0 @@ -= 1.8) plugins - * LOWER on the page have HIGHER priority and will override views, etc - * from plugins above them. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$mod = get_input('plugin'); -$mod = str_replace('.', '', $mod); -$mod = str_replace('/', '', $mod); - -// Get the new order -$order = (int) get_input('order'); - -// Get the current plugin list -$plugins = get_plugin_list(); - -// Inject the plugin order back into the list -if ($key = array_search($mod, $plugins)) { - - unset($plugins[$key]); - while (isset($plugins[$order])) { - $order++; - } - - $plugins[$order] = $mod; -} - -// Disable -if (regenerate_plugin_list($plugins)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:reorder:yes', array($plugin))); -} else { - register_error(elgg_echo('admin:plugins:reorder:no', array($plugin))); -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER); \ No newline at end of file diff --git a/actions/admin/plugins/set_priority.php b/actions/admin/plugins/set_priority.php new file mode 100644 index 000000000..1203e22de --- /dev/null +++ b/actions/admin/plugins/set_priority.php @@ -0,0 +1,40 @@ += 1.8) plugins + * LOWER on the page have HIGHER priority and will override views, etc + * from plugins above them. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugin_guid = get_input('plugin_guid'); +$priority = get_input('priority'); + +$plugin = get_entity($plugin_guid); + +if (!($plugin instanceof ElggPlugin)) { + register_error(elgg_echo('admin:plugins:set_priority:no', array($plugin_guid))); + forward(REFERER); +} + +if ($plugin->setPriority($priority)) { + //system_message(elgg_echo('admin:plugins:set_priority:yes', array($plugin->manifest->getName()))); +} else { + register_error(elgg_echo('admin:plugins:set_priority:no', array($plugin->manifest->getName()))); +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER); \ No newline at end of file diff --git a/actions/admin/plugins/simple_update_states.php b/actions/admin/plugins/simple_update_states.php index 7d01e4a46..216a458f4 100644 --- a/actions/admin/plugins/simple_update_states.php +++ b/actions/admin/plugins/simple_update_states.php @@ -1,48 +1,44 @@ $info) { +foreach ($installed_plugins as $plugin) { // this is only for simple plugins. - $interface_type = elgg_get_array_value('admin_interface', $info['manifest'], NULL); - if (!$interface_type || $interface_type != 'simple') { + if ($plugin->manifest->getAdminInterface() != 'simple') { continue; } - $plugin_enabled = is_plugin_enabled($plugin); - // only effect changes to plugins not already in that state. - if ($plugin_enabled && !in_array($plugin, $enabled_plugins)) { - $success = $success && disable_plugin($plugin); - } elseif (!$plugin_enabled && in_array($plugin, $enabled_plugins)) { - $success = $success && enable_plugin($plugin); + if ($plugin->isActive() && !in_array($plugin->guid, $active_plugin_guids)) { + $success = $success && $plugin->deactivate(); + } elseif (!$plugin->isActive() && in_array($plugin->guid, $active_plugin_guids)) { + $success = $success && $plugin->activate(); } } if ($success) { elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:simple_simple_success')); + //system_message(elgg_echo('admin:plugins:simple_simple_success')); } else { - register_error(elgg_echo('admins:plugins:simple_simple_fail')); + register_error(elgg_echo('admin:plugins:simple_simple_fail')); } // don't regenerate the simplecache because the plugin won't be -- cgit v1.2.3