aboutsummaryrefslogtreecommitdiff
path: root/actions/widgets/add.php
diff options
context:
space:
mode:
Diffstat (limited to 'actions/widgets/add.php')
-rw-r--r--actions/widgets/add.php46
1 files changed, 28 insertions, 18 deletions
diff --git a/actions/widgets/add.php b/actions/widgets/add.php
index 66d133195..d7b2f291c 100644
--- a/actions/widgets/add.php
+++ b/actions/widgets/add.php
@@ -2,31 +2,41 @@
/**
* Elgg widget add action
*
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
+ * @package Elgg.Core
+ * @subpackage Widgets.Management
*/
-$guid = get_input('user');
+$owner_guid = get_input('owner_guid');
$handler = get_input('handler');
$context = get_input('context');
-$column = get_input('column');
+$show_access = (bool)get_input('show_access', true);
+$column = get_input('column', 1);
+$default_widgets = get_input('default_widgets', 0);
-$result = false;
+elgg_push_context($context);
+if ($default_widgets) {
+ elgg_push_context('default_widgets');
+}
+elgg_push_context('widgets');
+
+if (!empty($owner_guid)) {
+ $owner = get_entity($owner_guid);
+ if ($owner && $owner->canEdit()) {
+ $guid = elgg_create_widget($owner->getGUID(), $handler, $context);
+ if ($guid) {
+ $widget = get_entity($guid);
+
+ // position the widget
+ $widget->move($column, 0);
-if (!empty($guid)) {
- if ($user = get_entity($guid)) {
- if ($user->canEdit()) {
- $result = add_widget($user->getGUID(),$handler,$context,0,$column);
+ // send widget html for insertion
+ echo elgg_view_entity($widget, array('show_access' => $show_access));
+
+ //system_message(elgg_echo('widgets:add:success'));
+ forward(REFERER);
}
}
}
-if ($result) {
- system_message(elgg_echo('widgets:save:success'));
-} else {
- register_error(elgg_echo('widgets:save:failure'));
-}
-
-forward($_SERVER['HTTP_REFERER']); \ No newline at end of file
+register_error(elgg_echo('widgets:add:failure'));
+forward(REFERER);