Elgg  Version 2.3
activate.php
Go to the documentation of this file.
1 <?php
14 $plugin_guids = get_input('plugin_guids');
15 
16 if (!is_array($plugin_guids)) {
18 }
19 
20 $activated_guids = array();
21 foreach ($plugin_guids as $guid) {
22  $plugin = get_entity($guid);
23 
24  if (!($plugin instanceof ElggPlugin)) {
25  register_error(elgg_echo('admin:plugins:activate:no', array($guid)));
26  continue;
27  }
28 
29  if ($plugin->activate()) {
31  $ids = array(
32  'cannot_start' . $plugin->getID(),
33  'invalid_and_deactivated_' . $plugin->getID()
34  );
35 
36  foreach ($ids as $id) {
38  }
39 
40  } else {
41  $msg = $plugin->getError();
42  $string = ($msg) ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
43  register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
44  }
45 }
46 
47 // don't regenerate the simplecache because the plugin won't be
48 // loaded until next run. Just invalidate and let it regenerate as needed
50 
51 if (count($activated_guids) === 1) {
52  $url = 'admin/plugins';
53  $query = (string)parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
54  if ($query) {
55  $url .= "?$query";
56  }
58  $id = $css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
59  $url = "$url#id";
60  return elgg_ok_response('', '', $url);
61 } else {
62  // forward to top of page with a failure so remove any #foo
63  $url = $_SERVER['HTTP_REFERER'];
64  if (strpos($url, '#')) {
65  $url = substr(0, strpos($url, '#'));
66  }
68 }
elgg_delete_admin_notice($id)
Remove an admin notice by ID.
Definition: admin.php:92
$plugin
$plugin_guids
Definition: activate.php:14
if(!is_array($plugin_guids)) $activated_guids
Definition: activate.php:20
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_normalize_site_url($unsafe_url)
From untrusted input, get a site URL safe for forwarding.
Definition: output.php:326
$guid
Removes an admin notice.
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:450
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:425
$url
Definition: exceptions.php:24
$string
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
$css_id
Definition: full.php:30
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:399
if(!$collection_name) $id
Definition: add.php:17
elgg_flush_caches()
Flush all the registered caches.
Definition: cache.php:225
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204