Elgg  Version 6.1
save.php
Go to the documentation of this file.
1 <?php
13 $params = get_input('params');
14 $plugin_id = get_input('plugin_id');
16 if (empty($plugin_id) || empty($user_guid)) {
17  return elgg_error_response(elgg_echo('error:missing_data'));
18 }
19 
22 if (!$plugin || !$user || !$user->canEdit()) {
23  return elgg_error_response(elgg_echo('plugins:usersettings:save:fail', [$plugin_id]));
24 }
25 
26 $plugin_name = $plugin->getDisplayName();
27 
28 $result = false;
29 
30 foreach ($params as $name => $value) {
31  $result = $user->setPluginSetting($plugin->getID(), $name, $value);
32  if (!$result) {
33  return elgg_error_response(elgg_echo('plugins:usersettings:save:fail', [$plugin_name]));
34  }
35 }
36 
37 return elgg_ok_response('', elgg_echo('plugins:usersettings:save:ok', [$plugin_name]));
$params
Saves global plugin settings.
Definition: save.php:13
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
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
$value
Definition: generic.php:51
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
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
$user
Definition: save.php:21
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
if(!$plugin) $plugin_name
Definition: save.php:25
$user_guid
Definition: save.php:15
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:34