aboutsummaryrefslogtreecommitdiff
path: root/actions/admin/plugins/simple_update_states.php
blob: 197f183f93855a83c8f4e480ed5c870bb49c5553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
 * Elgg administration simple plugin bulk enable / disable
 *
 * Shows an alphabetical list of "simple" plugins.
 *
 * @package Elgg
 * @subpackage Core
 * @author Curverider Ltd
 * @link http://elgg.org/
 */

$installed_plugins = get_installed_plugins();
$enabled_plugins = get_input('enabled_plugins', array());

$success = TRUE;

foreach ($installed_plugins as $plugin => $info) {
	// this is only for simple plugins.
	if (!isset($info['manifest']['admin_interface']) || $info['manifest']['admin_interface'] != '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 ($success) {
	elgg_delete_admin_notice('first_installation_plugin_reminder');
	system_message(elgg_echo('admin:plugins:simple_simple_success'));
} else {
	register_error(elgg_echo('admins:plugins:simple_simple_fail'));
}

forward($_SERVER['HTTP_REFERER']);