aboutsummaryrefslogtreecommitdiff
path: root/actions/admin
diff options
context:
space:
mode:
Diffstat (limited to 'actions/admin')
-rw-r--r--actions/admin/plugins/activate.php42
-rw-r--r--actions/admin/plugins/activate_all.php29
-rw-r--r--actions/admin/plugins/deactivate.php42
-rw-r--r--actions/admin/plugins/deactivate_all.php (renamed from actions/admin/plugins/disableall.php)15
-rw-r--r--actions/admin/plugins/disable.php34
-rw-r--r--actions/admin/plugins/enable.php34
-rw-r--r--actions/admin/plugins/enableall.php28
-rw-r--r--actions/admin/plugins/reorder.php51
-rw-r--r--actions/admin/plugins/set_priority.php40
-rw-r--r--actions/admin/plugins/simple_update_states.php38
10 files changed, 178 insertions, 175 deletions
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 @@
+<?php
+/**
+ * Activate a plugin or plugins.
+ *
+ * Plugins to be activated are passed via $_REQUEST['plugin_guids'] as GUIDs.
+ * After activating the plugin(s), the views cache and simplecache are invalidated.
+ *
+ * @uses mixed $_GET['plugin_guids'] The GUIDs of the plugin to activate. Can be an array.
+ *
+ * @package Elgg.Core
+ * @subpackage Administration.Plugins
+ */
+
+$plugin_guids = get_input('plugin_guids');
+
+if (!is_array($plugin_guids)) {
+ $plugin_guids = array($plugin_guids);
+}
+
+foreach ($plugin_guids as $guid) {
+ $plugin = get_entity($guid);
+
+ if (!($plugin instanceof ElggPlugin)) {
+ register_error(elgg_echo('admin:plugins:activate:no', array($guid)));
+ continue;
+ }
+
+ if ($plugin->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 @@
+<?php
+/**
+ * Activates all installed and inactive plugins.
+ *
+ * All plugins in the mod/ directory are that aren't active are activated and the views
+ * cache and simplecache are invalidated.
+ *
+ * @package Elgg.Core
+ * @subpackage Administration.Plugins
+ */
+
+$plugins = elgg_get_plugins('inactive');
+
+foreach ($plugins as $plugin) {
+ if ($plugin->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 @@
+<?php
+/**
+ * Deactivate a plugin or plugins.
+ *
+ * Plugins to be deactivated are passed via $_REQUEST['plugin_guids'] as GUIDs.
+ * After deactivating the plugin(s), the views cache and simplecache are invalidated.
+ *
+ * @uses mixed $_GET['plugin_guids'] The GUIDs of the plugin to deactivate. Can be an array.
+ *
+ * @package Elgg.Core
+ * @subpackage Administration.Plugins
+ */
+
+$plugin_guids = get_input('plugin_guids');
+
+if (!is_array($plugin_guids)) {
+ $plugin_guids = array($plugin_guids);
+}
+
+foreach ($plugin_guids as $guid) {
+ $plugin = get_entity($guid);
+
+ if (!($plugin instanceof ElggPlugin)) {
+ register_error(elgg_echo('admin:plugins:deactivate:no', array($guid)));
+ continue;
+ }
+
+ if ($plugin->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/disableall.php b/actions/admin/plugins/deactivate_all.php
index 351ebf840..bdeda001f 100644
--- a/actions/admin/plugins/disableall.php
+++ b/actions/admin/plugins/deactivate_all.php
@@ -6,20 +6,21 @@
* are reset.
*
* @package Elgg.Core
- * @subpackage Administration.Site
+ * @subpackage Administration.Plugins
*/
-$plugins = get_installed_plugins();
+$plugins = elgg_get_plugins('active');
-foreach ($plugins as $p => $data) {
- if (disable_plugin($p)) {
- elgg_delete_admin_notice('first_installation_plugin_reminder');
- system_message(elgg_echo('admin:plugins:disable:yes', array($p)));
+foreach ($plugins as $plugin) {
+ if ($plugin->deactivate()) {
+ //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->manifest->getName())));
} else {
- register_error(elgg_echo('admin:plugins:disable:no', array($p)));
+ 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();
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 @@
-<?php
-/**
- * Disable a plugin or plugins.
- *
- * Plugins to be disabled are passed via $_REQUEST['plugin'] as plugin ID (directory name).
- * After disabling the plugin(s), the views cache and simplecache are both reset.
- *
- * @uses mixed $_GET['plugin'] The id (directory name) of the plugin to disable. Can be an array.
- *
- * @package Elgg.Core
- * @subpackage Administration.Site
- */
-
-$plugin = get_input('plugin');
-if (!is_array($plugin)) {
- $plugin = array($plugin);
-}
-
-foreach ($plugin as $p) {
- if (disable_plugin($p)) {
- system_message(elgg_echo('admin:plugins:disable:yes', array($p)));
-
- elgg_delete_admin_notice('first_installation_plugin_reminder');
- } 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 @@
-<?php
-/**
- * Enables a plugin or plugins.
- *
- * Plugins to be enabled are passed via $_REQUEST['plugin'] as plugin ID (directory name).
- * After enabling the plugin(s), the views cache and simplecache are reset.
- *
- * @uses mixed $_GET['plugin'] The id (directory name) of the plugin to enable. Can be an array.
- *
- * @package Elgg.Core
- * @subpackage Administration.Site
- */
-
-$plugin = get_input('plugin');
-
-if (!is_array($plugin)) {
- $plugin = array($plugin);
-}
-
-foreach ($plugin as $p) {
- 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/enableall.php b/actions/admin/plugins/enableall.php
deleted file mode 100644
index 04574f067..000000000
--- a/actions/admin/plugins/enableall.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * Enables all installed plugins.
- *
- * All plugins in the mod/ directory are enabled and the views cache and simplecache
- * are reset.
- *
- * @package Elgg.Core
- * @subpackage Administration.Site
- */
-
-$plugins = get_installed_plugins();
-
-foreach ($plugins as $p => $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 @@
-<?php
-/**
- * Changes the load order of a plugin.
- *
- * Plugin order affects priority for view, action, and page handler
- * overriding as well as the order of view extensions. Higher numbers
- * are loaded after lower numbers, and so receive higher priority.
- *
- * NOTE: When viewing the admin page (advanced plugin admin in >= 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 @@
+<?php
+/**
+ * Changes the load priority of a plugin.
+ *
+ * Plugin priority affects view, action, and page handler
+ * overriding as well as the order of view extensions. Plugins with higher
+ * priority are loaded after and override plugins with lower priorities.
+ *
+ * NOTE: When viewing the admin page (advanced plugin admin in >= 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 @@
<?php
/**
- * Bulk enable and disable for plugins appearing in the "simple" interface.
+ * Bulk activate/deactivate for plugins appearing in the "simple" interface.
*
- * Plugins marked as using the "simple" interface can be enabled and disabled
- * en masse by passing the enabled plugins as an array of their plugin ids
- * (directory names) through $_REQUEST['enabled_plugins']. All "simple" plugins
- * not in this array will be disabled.
+ * Plugins marked as using the "simple" interface can be activated/deactivated
+ * en masse by passing the plugins to activate as an array of their plugin guids
+ * in $_REQUEST['enabled_plugins']. All "simple" plugins not in this array will be
+ * deactivated.
*
* Simplecache and views cache are reset.
*
- * @uses array $_REQUEST['enabled_plugins'] An array of plugin ids (directory names) to enable.
+ * @uses array $_REQUEST['activated_plugin_guids'] Array of plugin guids to activate.
*
* @since 1.8
* @package Elgg.Core
- * @subpackage Administration.Site
+ * @subpackage Administration.Plugins
*/
-$installed_plugins = get_installed_plugins();
-$enabled_plugins = get_input('enabled_plugins', array());
-
+$active_plugin_guids = get_input('active_plugin_guids', array());
+$installed_plugins = elgg_get_plugins('any');
$success = TRUE;
-foreach ($installed_plugins as $plugin => $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