Elgg  Version master
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
Plugin class containing helper functions for plugin activation/deactivation, dependency checking capa...
Definition: ElggPlugin.php:17
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.
if(!is_array($plugin_guids)) $activated_plugins
Definition: activate.php:17
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
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
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.
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:70
elgg_http_build_url(array $parts, bool $html_encode=true)
Builds a URL from the a parts array like one returned by parse_url().
Definition: elgglib.php:131
elgg_register_error_message(string|array $options)
Registers a error system message.
Definition: elgglib.php:62
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
Definition: deactivate.php:39
$id
Generic annotation delete action.
Definition: delete.php:6
$guid
Reset an ElggUpgrade.
Definition: reset.php:6