Elgg  Version 4.3
activate.php
Go to the documentation of this file.
1 <?php
11 $plugin_guids = get_input('plugin_guids');
12 
13 if (!is_array($plugin_guids)) {
15 }
16 
18 foreach ($plugin_guids as $guid) {
19  $plugin = get_entity($guid);
20 
21  if (!($plugin instanceof ElggPlugin)) {
22  elgg_register_error_message(elgg_echo('admin:plugins:activate:no', [$guid]));
23  continue;
24  }
25 
26  try {
27  if (!$plugin->activate()) {
28  elgg_register_error_message(elgg_echo('admin:plugins:activate:no', [$plugin->getDisplayName()]));
29  continue;
30  }
31  } catch (\Elgg\Exceptions\PluginException $e) {
32  elgg_register_error_message(elgg_echo('admin:plugins:activate:no_with_msg', [$plugin->getDisplayName(), $e->getMessage()]));
33  continue;
34  }
35 
36  $ids = [
37  'cannot_start' . $plugin->getID(),
38  'invalid_and_deactivated_' . $plugin->getID()
39  ];
40 
41  foreach ($ids as $id) {
43  }
44 
46 }
47 
48 if (empty($activated_plugins)) {
49  return elgg_error_response();
50 }
51 
52 if (count($activated_plugins) === 1) {
54 
56  'path' => 'admin/plugins',
57  'query' => parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY),
58  'fragment' => preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID()),
59  ]);
60 
61  return elgg_ok_response('', '', $url);
62 }
63 
64 return elgg_ok_response();
$plugin
$plugin_guids
Activate a plugin or plugins.
Definition: activate.php:11
if(!is_array($plugin_guids)) $activated_plugins
Definition: activate.php:17
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:135
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
elgg_delete_admin_notice(string $id)
Remove an admin notice by ID.
Definition: admin.php:63
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_register_error_message($options)
Registers a error system message.
Definition: elgglib.php:62
elgg_http_build_url(array $parts, $html_encode=true)
Builds a URL from the a parts array like one returned by parse_url().
Definition: elgglib.php:431
elgg_error_response($message= '', $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
Definition: deactivate.php:39
elgg_ok_response($content= '', $message= '', $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
$id
Generic annotation delete action.
Definition: delete.php:6
$guid
Reset an ElggUpgrade.
Definition: reset.php:6
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69