Elgg  Version 3.0
save.php
Go to the documentation of this file.
1 <?php
13 $params = get_input('params');
14 $plugin_id = get_input('plugin_id');
18 
19 if (!$plugin || !$user || !$user->canEdit()) {
20  return elgg_error_response(elgg_echo('plugins:usersettings:save:fail', [$plugin_id]));
21 }
22 
23 $plugin_name = $plugin->getDisplayName();
24 
25 $result = false;
26 
27 foreach ($params as $k => $v) {
28  $result = $plugin->setUserSetting($k, $v, $user->guid);
29  if (!$result) {
30  return elgg_error_response(elgg_echo('plugins:usersettings:save:fail', [$plugin_name]));
31  }
32 }
33 
34 return elgg_ok_response('', elgg_echo('plugins:usersettings:save:ok', [$plugin_name]));
$params
Saves global plugin settings.
Definition: save.php:13
get_user($guid)
Get a user object from a GUID.
Definition: users.php:40
if(!empty($_SERVER['HTTP_REFERER'])) $result
Definition: save.php:77
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
if(!$entity) $user
Definition: save.php:41
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
$plugin_id
Definition: save.php:15
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.
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.
if(!$plugin) $plugin_name
Definition: save.php:22
$plugin
Definition: save.php:16
$user_guid
Definition: save.php:15
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:39
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:28