aboutsummaryrefslogtreecommitdiff
path: root/actions/admin/plugins/simple_update_states.php
blob: 216a458f48965c116d47b516cf92ff2cca80451f (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
42
43
44
45
46
47
48
49
<?php
/**
 * Bulk activate/deactivate for plugins appearing in the "simple" interface.
 *
 * 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['activated_plugin_guids'] Array of plugin guids to activate.
 *
 * @since 1.8
 * @package Elgg.Core
 * @subpackage Administration.Plugins
 */

$active_plugin_guids = get_input('active_plugin_guids', array());
$installed_plugins = elgg_get_plugins('any');
$success = TRUE;

foreach ($installed_plugins as $plugin) {
	// this is only for simple plugins.
	if ($plugin->manifest->getAdminInterface() != 'simple') {
		continue;
	}

	// only effect changes to plugins not already in that state.
	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'));
} else {
	register_error(elgg_echo('admin:plugins:simple_simple_fail'));
}

// 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);