Elgg  Version 3.0
save.php
Go to the documentation of this file.
1 <?php
16 /* @var $request \Elgg\Request */
17 
18 $guid = $request->getParam('guid');
19 if (isset($guid)) {
20  $user = get_user($guid);
21 } else {
23 }
24 
25 if (!$user instanceof ElggUser) {
26  throw new \Elgg\EntityNotFoundException();
27 }
28 
29 if (!$user->canEdit()) {
30  throw new \Elgg\EntityPermissionsException();
31 }
32 
33 elgg_make_sticky_form('usersettings');
34 
36  'user' => $user,
37  'request' => $request,
38 ];
39 
40 // callbacks should return false to indicate that the sticky form should not be cleared
41 if (elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) {
42  elgg_clear_sticky_form('usersettings');
43 }
44 
45 foreach ($request->validation()->all() as $item) {
46  if ($item->isValid()) {
47  if ($message = $item->getMessage()) {
49  }
50  } else {
51  if ($error = $item->getError()) {
53  }
54  }
55 }
56 
57 $data = [
58  'user' => $user,
59  'validation' => $request->validation(),
60 ];
61 
62 return elgg_ok_response($data);
get_user($guid)
Get a user object from a GUID.
Definition: users.php:40
if(!$items) $item
Definition: delete.php:13
$guid
Definition: save.php:48
$request
Page handler for autocomplete endpoint.
Definition: livesearch.php:9
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
Definition: save.php:57
if(!$entity) $user
Definition: save.php:41
$hooks_params
Definition: save.php:35
$error
Bad request error.
Definition: 400.php:6
elgg_make_sticky_form($form_name)
Save form submission data (all GET and POST vars) into a session cache.
Definition: input.php:120
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:720
elgg system_message
Wrapper function for system_messages.
Definition: elgglib.js:382
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:391
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:29
elgg_clear_sticky_form($form_name)
Remove form submission data from the session.
Definition: input.php:136