aboutsummaryrefslogtreecommitdiff
path: root/actions/widgets
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-18 16:13:34 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-18 16:13:34 +0000
commitc5854870424d87372bcc86a7edf75b9bf8841825 (patch)
tree99dc5d53e82ba6decf27846e574ac9826f5743b2 /actions/widgets
parent522fccf9ed173e3a5a68b3a616a3b7e1961bc22b (diff)
downloadelgg-c5854870424d87372bcc86a7edf75b9bf8841825.tar.gz
elgg-c5854870424d87372bcc86a7edf75b9bf8841825.tar.bz2
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
Diffstat (limited to 'actions/widgets')
-rw-r--r--actions/widgets/add.php23
1 files changed, 13 insertions, 10 deletions
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