From c5854870424d87372bcc86a7edf75b9bf8841825 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 18 Nov 2010 16:13:34 +0000 Subject: Refs #1793 added ability to add widgets to layout through ajax git-svn-id: http://code.elgg.org/elgg/trunk@7338 36083f99-b078-4883-b0ff-0f9b5a30f544 --- actions/widgets/add.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'actions/widgets') diff --git a/actions/widgets/add.php b/actions/widgets/add.php index 57c331e21..c57e3596a 100644 --- a/actions/widgets/add.php +++ b/actions/widgets/add.php @@ -6,25 +6,28 @@ * @subpackage Widgets.Management */ -$guid = get_input('user'); +$user_guid = get_input('user'); $handler = get_input('handler'); $context = get_input('context'); -$column = get_input('column'); +$column = get_input('column', 1); -$result = false; - -if (!empty($guid)) { - if ($user = get_entity($guid)) { +$guid = false; +if (!empty($user_guid)) { + if ($user = get_entity($user_guid)) { if ($user->canEdit()) { - $result = add_widget($user->getGUID(), $handler, $context, 0, $column); + $guid = add_widget($user->getGUID(), $handler, $context, 0, $column); } } } -if ($result) { - system_message(elgg_echo('widgets:save:success')); +if ($guid) { + system_message(elgg_echo('widgets:add:success')); + + // send widget html for insertion + $widget = get_entity($guid); + echo elgg_view_entity($widget); } else { - register_error(elgg_echo('widgets:save:failure')); + register_error(elgg_echo('widgets:add:failure')); } forward(REFERER); \ No newline at end of file -- cgit v1.2.3