Elgg  Version master
save.php
Go to the documentation of this file.
1 <?php
13 $params = get_input('params');
14 $flush_cache = get_input('flush_cache');
15 $plugin_id = get_input('plugin_id');
16 if (empty($plugin_id)) {
17  return elgg_error_response(elgg_echo('error:missing_data'));
18 }
19 
21 if (!$plugin) {
22  return elgg_error_response(elgg_echo('plugins:settings:save:fail', [$plugin_id]));
23 }
24 
25 $plugin_name = $plugin->getDisplayName();
26 
27 $result = false;
28 
29 foreach ($params as $k => $v) {
30  $result = $plugin->setSetting($k, $v);
31  if (!$result) {
32  return elgg_error_response(elgg_echo('plugins:settings:save:fail', [$plugin_name]));
33  }
34 }
35 
36 if ($flush_cache) {
38 }
39 
40 return elgg_ok_response('', elgg_echo('plugins:settings:save:ok', [$plugin_name]));
$params
Saves global plugin settings.
Definition: save.php:13
elgg_get_plugin_from_id(string $plugin_id)
Elgg plugins library Contains functions for managing plugins.
Definition: plugins.php:15
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
if(!empty($_SERVER['HTTP_REFERER'])) $result
Definition: save.php:87
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_invalidate_caches()
Invalidate all the registered caches.
Definition: cache.php:88
if(empty($plugin_id)) $plugin
Definition: save.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.
$plugin_id
Definition: save.php:15
if(!$plugin) $plugin_name
Definition: save.php:25
$flush_cache
Definition: save.php:14