Elgg  Version master
save.php
Go to the documentation of this file.
1 <?php
13 $guid = (int) get_input('guid');
14 $params = (array) get_input('params');
15 $default_widgets = (int) get_input('default_widgets', 0);
16 $context = get_input('context');
17 
19 if (!$widget instanceof \ElggWidget) {
20  return elgg_error_response(elgg_echo('error:missing_data'));
21 }
22 
23 if (!$widget->canEdit()) {
24  return elgg_error_response(elgg_echo('actionunauthorized'));
25 }
26 
27 foreach ($params as $name => $value) {
28  $widget->$name = $value;
29 }
30 
31 // trigger save for cache invalidation
32 $widget->save();
33 
35 
36 if ($default_widgets) {
37  $context_stack[] = 'default_widgets';
38 }
39 
40 $context_stack[] = 'widgets';
41 if ($context) {
43 }
44 
45 foreach ($context_stack as $ctx) {
46  elgg_push_context($ctx);
47 }
48 
49 elgg_set_page_owner_guid($widget->getContainerGUID());
50 
52  'content' => elgg_view('object/widget/elements/content', ['entity' => $widget]),
53  'title' => $widget->getDisplayName(),
54  'href' => $widget->getURL(),
55 ];
56 foreach ($context_stack as $ctx) {
58 }
59 
$default_widgets
Definition: save.php:15
$params
Saves global plugin settings.
Definition: save.php:13
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
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
$context
Definition: save.php:16
$widget
Definition: save.php:18
elgg_set_page_owner_guid(int $guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:34
$guid
Definition: save.php:14
$value
Definition: generic.php:51
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: context.php:62
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
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.
$output
Definition: save.php:51
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:70
$context_stack
Definition: save.php:34
elgg_push_context(string $context)
Push a context onto the top of the stack.
Definition: context.php:52