Elgg  Version 5.1
activate_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('inactive');
13 } else {
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 
28 do {
29  $additional_plugins_activated = false;
30  foreach ($plugins as $key => $plugin) {
31  if ($plugin->isActive()) {
32  unset($plugins[$key]);
33  continue;
34  }
35 
36  try {
37  if (!$plugin->activate()) {
38  $errors[$plugin->getID()] = elgg_echo('admin:plugins:activate:no', [$plugin->getDisplayName()]);
39  continue;
40  }
41  } catch (\Exception $e) {
42  $errors[$plugin->getID()] = elgg_echo('admin:plugins:activate:no_with_msg', [$plugin->getDisplayName(), $e->getMessage()]);
43  continue;
44  }
45 
46  $ids = [
47  'cannot_start' . $plugin->getID(),
48  'invalid_and_deactivated_' . $plugin->getID()
49  ];
50 
51  foreach ($ids as $id) {
53  }
54 
55  // mark that something has changed in this loop
56  $additional_plugins_activated = true;
57  unset($plugins[$key]);
58 
59  // remove errors set from previous loop
60  unset($errors[$plugin->getDisplayName()]);
61  }
62 
63  if (!$additional_plugins_activated) {
64  // no updates in this pass, break the loop
65  break;
66  }
67 } while (count($plugins) > 0);
68 
69 
70 if (count($errors) < 1) {
71  return elgg_ok_response();
72 }
73 
74 foreach ($errors as $error) {
76 }
77 
78 return elgg_error_response();
elgg_get_plugins(string $status= 'active')
Returns an ordered list of plugins.
Definition: plugins.php:55
$plugin
if(empty($plugins)) $errors
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
$plugins
Definition: categories.php:3
elgg_delete_admin_notice(string $id)
Remove an admin notice by ID.
Definition: admin.php:63
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:504
elgg_register_error_message(string|array $options)
Registers a error system message.
Definition: elgglib.php:62
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
$guids
Activates all specified installed and inactive plugins.
Definition: activate_all.php:9
$id
Generic annotation delete action.
Definition: delete.php:6