Elgg  Version 3.0
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
$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="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:81
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_can_edit_widget_layout($context, $user_guid=0)
Can the user edit the widget layout.
Definition: widgets.php:53
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:842
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_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:65
$page_owner
Definition: add.php:15
if($guid===false) $widget
Definition: add.php:30
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_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:212
if($context) foreach($context_stack as $ctx) $result
Definition: add.php:49
$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:38
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87