Elgg  Version master
deactivate_all.php
Go to the documentation of this file.
1 <?php
9 $guids = get_input('guids');
10 
11 if (empty($guids)) {
12  $plugins = elgg_get_plugins('active');
13 } else {
14  $plugins = elgg_get_entities([
15  'type' => 'object',
16  'subtype' => 'plugin',
17  'guids' => explode(',', $guids),
18  'limit' => false,
19  ]);
20 }
21 
22 if (empty($plugins)) {
23  return elgg_ok_response();
24 }
25 
26 $errors = [];
27 foreach ($plugins as $plugin) {
28  if (!$plugin->isActive()) {
29  continue;
30  }
31 
32  try {
33  if (!$plugin->deactivate()) {
34  $errors[] = elgg_echo('admin:plugins:deactivate:no', [$plugin->getDisplayName()]);
35  }
36  } catch (\Elgg\Exceptions\PluginException $e) {
37  $errors[] = elgg_echo('admin:plugins:deactivate:no_with_msg', [$plugin->getDisplayName(), $e->getMessage()]);
38  }
39 }
40 
41 if (empty($errors)) {
42  return elgg_ok_response();
43 }
44 
45 foreach ($errors as $error) {
47 }
48 
49 return elgg_error_response();
elgg_get_plugins(string $status= 'active')
Returns an ordered list of plugins.
Definition: plugins.php:39
$plugin
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(empty($plugins)) $errors
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
$error
Bad request error.
Definition: 400.php:6
elgg_error_response(string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Definition: entities.php:507
elgg_register_error_message(string|array $options)
Registers a error system message.
Definition: elgglib.php:62
$guids
Disable all specified installed plugins.