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.php26
1 files changed, 13 insertions, 13 deletions
diff --git a/actions/widgets/add.php b/actions/widgets/add.php
index c57e3596a..78f73e267 100644
--- a/actions/widgets/add.php
+++ b/actions/widgets/add.php
@@ -13,21 +13,21 @@ $column = get_input('column', 1);
$guid = false;
if (!empty($user_guid)) {
- if ($user = get_entity($user_guid)) {
- if ($user->canEdit()) {
- $guid = add_widget($user->getGUID(), $handler, $context, 0, $column);
- }
- }
-}
+ $user = get_entity($user_guid);
+ if ($user && $user->canEdit()) {
+ $guid = elgg_add_widget($user->getGUID(), $handler);
+ if ($guid) {
+ $widget = get_entity($guid);
+ elgg_prepend_widget($widget, $context, $column);
-if ($guid) {
- system_message(elgg_echo('widgets:add:success'));
+ // send widget html for insertion
+ echo elgg_view_entity($widget);
- // send widget html for insertion
- $widget = get_entity($guid);
- echo elgg_view_entity($widget);
-} else {
- register_error(elgg_echo('widgets:add:failure'));
+ system_message(elgg_echo('widgets:add:success'));
+ forward(REFERER);
+ }
+ }
}
+register_error(elgg_echo('widgets:add:failure'));
forward(REFERER); \ No newline at end of file