Elgg  Version 3.0
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  register_error(elgg_echo('admin:plugins:activate:no', [$guid]));
23  continue;
24  }
25 
26  if (!$plugin->activate()) {
27  $msg = $plugin->getError();
28  $string = ($msg) ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
29  register_error(elgg_echo($string, [$plugin->getDisplayName(), $plugin->getError()]));
30  continue;
31  }
32 
33  $ids = [
34  'cannot_start' . $plugin->getID(),
35  'invalid_and_deactivated_' . $plugin->getID()
36  ];
37 
38  foreach ($ids as $id) {
40  }
41 
43 }
44 
45 if (empty($activated_plugins)) {
46  return elgg_error_response();
47 }
48 
49 if (count($activated_plugins) === 1) {
51 
53  'path' => 'admin/plugins',
54  'query' => parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY),
55  'fragment' => preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID()),
56  ]);
57 
58  return elgg_ok_response('', '', $url);
59 }
60 
61 return elgg_ok_response();
elgg_delete_admin_notice($id)
Remove an admin notice by ID.
Definition: admin.php:71
$plugin
$plugin_guids
Activate a plugin or plugins.
Definition: activate.php:11
if(!is_array($plugin_guids)) $activated_plugins
Definition: activate.php:17
$guid
Removes an admin notice.
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:442
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$id
River item delete action.
Definition: delete.php:6
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_error_response($error= '', $forward_url=REFERRER, $status_code=ELGG_HTTP_OK)
Prepare an error response to be returned by a page or an action handler.
$url
Definition: default.php:33
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg register_error
Wrapper function for system_messages.
Definition: elgglib.js:391
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:859
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87