Elgg  Version master
deactivate.php
Go to the documentation of this file.
1 <?php
11 $plugin_guids = (array) get_input('plugin_guids');
12 
14 foreach ($plugin_guids as $guid) {
15  $plugin = get_entity($guid);
16 
17  if (!$plugin instanceof ElggPlugin) {
18  elgg_register_error_message(elgg_echo('admin:plugins:deactivate:no', [$guid]));
19  continue;
20  }
21 
22  try {
23  if (!$plugin->deactivate()) {
24  elgg_register_error_message(elgg_echo('admin:plugins:deactivate:no', [$plugin->getDisplayName()]));
25  continue;
26  }
27  } catch (\Elgg\Exceptions\PluginException $e) {
28  elgg_register_error_message(elgg_echo('admin:plugins:deactivate:no_with_msg', [$plugin->getDisplayName(), $e->getMessage()]));
29  continue;
30  }
31 
33 }
34 
35 if (empty($deactivated_plugins)) {
36  return elgg_error_response();
37 }
38 
39 $url = null;
40 
41 if (count($deactivated_plugins) === 1) {
43 
45  'path' => 'admin/plugins',
46  'query' => parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY),
47  'fragment' => preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID()),
48  ]);
49 }
50 
51 return elgg_ok_response('', '', $url);
$plugin
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.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
$deactivated_plugins
Definition: deactivate.php:13
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
$plugin_guids
Deactivate a plugin or plugins.
Definition: deactivate.php:11
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
$guid
Reset an ElggUpgrade.
Definition: reset.php:6