Elgg  Version 4.3
add.php
Go to the documentation of this file.
1 <?php
6 $page_owner_guid = (int) get_input('page_owner_guid');
7 $handler = get_input('handler');
8 $context = get_input('context');
9 $show_access = (bool) get_input('show_access', true);
10 $column = (int) get_input('column', 1);
11 $default_widgets = (int) get_input('default_widgets', 0);
12 
14 
16 if (!$page_owner) {
17  return elgg_error_response(elgg_echo('widgets:add:failure'));
18 }
19 
21  // logged in user must be able to edit the layout to add a widget
22  return elgg_error_response(elgg_echo('widgets:add:failure'));
23 }
24 
26 if ($guid === false) {
27  return elgg_error_response(elgg_echo('widgets:add:failure'));
28 }
29 
31 
32 // position the widget
33 $widget->move($column, 0);
34 
36 
37 if ($default_widgets) {
38  $context_stack[] = 'default_widgets';
39 }
40 $context_stack[] = 'widgets';
41 if ($context) {
43 }
44 
45 foreach ($context_stack as $ctx) {
46  elgg_push_context($ctx);
47 }
48 
50 
$context
Definition: add.php:8
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: context.php:52
$default_widgets
Definition: add.php:11
$column
Definition: add.php:10
$context_stack
Definition: add.php:35
$show_access
Definition: add.php:9
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:34
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_can_edit_widget_layout($context, $user_guid=0)
Can the user edit the widget layout.
Definition: widgets.php:50
if(!$page_owner) if(!elgg_can_edit_widget_layout($context)) $guid
Definition: add.php:25
elgg_view_entity(\ElggEntity $entity, array $vars=[])
Returns a string of a rendered entity.
Definition: views.php:518
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:23
$page_owner
Definition: add.php:15
if($guid===false) $widget
Definition: add.php:30
elgg_error_response($message= '', $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
if($context) foreach($context_stack as $ctx) $result
Definition: add.php:49
elgg_ok_response($content= '', $message= '', $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
$page_owner_guid
Elgg widget add action.
Definition: add.php:6
$handler
Definition: add.php:7
elgg_create_widget($owner_guid, $handler, $context, $access_id=null)
Create a new widget instance.
Definition: widgets.php:35
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69