diff options
Diffstat (limited to 'actions/widgets')
-rw-r--r-- | actions/widgets/add.php | 14 | ||||
-rw-r--r-- | actions/widgets/delete.php | 9 | ||||
-rw-r--r-- | actions/widgets/move.php | 10 | ||||
-rw-r--r-- | actions/widgets/save.php | 7 |
4 files changed, 25 insertions, 15 deletions
diff --git a/actions/widgets/add.php b/actions/widgets/add.php index 38686b36d..ac8983115 100644 --- a/actions/widgets/add.php +++ b/actions/widgets/add.php @@ -6,18 +6,22 @@ * @subpackage Widgets.Management */ -$user_guid = get_input('user_guid'); +$owner_guid = get_input('owner_guid'); $handler = get_input('handler'); $context = get_input('context'); $column = get_input('column', 1); +$default_widgets = get_input('default_widgets', 0); elgg_push_context($context); +if ($default_widgets) { + elgg_push_context('default_widgets'); +} elgg_push_context('widgets'); -if (!empty($user_guid)) { - $user = get_entity($user_guid); - if ($user && $user->canEdit()) { - $guid = elgg_create_widget($user->getGUID(), $handler, $context); +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); diff --git a/actions/widgets/delete.php b/actions/widgets/delete.php index 5b8aaf75e..47920013d 100644 --- a/actions/widgets/delete.php +++ b/actions/widgets/delete.php @@ -6,12 +6,13 @@ * @subpackage Widgets.Management */ -$guid = get_input('guid'); +$widget_guid = get_input('widget_guid'); +$owner_guid = get_input('owner_guid', elgg_get_logged_in_user_guid()); -$user = elgg_get_logged_in_user_entity(); +$widget = get_entity($widget_guid); +$owner = get_entity($owner_guid); -$widget = get_entity($guid); -if ($widget && $user->canEdit() && $widget->delete()) { +if ($widget && $owner->canEdit() && $widget->delete()) { forward(REFERER); } diff --git a/actions/widgets/move.php b/actions/widgets/move.php index 2edc7912e..eab650c9c 100644 --- a/actions/widgets/move.php +++ b/actions/widgets/move.php @@ -6,14 +6,16 @@ * @subpackage Widgets.Management */ -$guid = get_input('guid'); +$widget_guid = get_input('widget_guid'); $column = get_input('column', 1); $position = get_input('position'); +$owner_guid = get_input('owner_guid', elgg_get_logged_in_user_guid()); -$user = elgg_get_logged_in_user_entity(); +$widget = get_entity($widget_guid); +$owner = get_entity($owner_guid); -$widget = get_entity($guid); -if ($widget && $user->canEdit()) { + +if ($widget && $owner->canEdit()) { $widget->move($column, $position); forward(REFERER); } diff --git a/actions/widgets/save.php b/actions/widgets/save.php index b1649cc17..0a2de0c4d 100644 --- a/actions/widgets/save.php +++ b/actions/widgets/save.php @@ -10,12 +10,15 @@ elgg_set_context('widgets'); $guid = get_input('guid'); $params = get_input('params'); +$default_widgets = get_input('default_widgets', 0); $widget = get_entity($guid); if ($widget && $widget->saveSettings($params)) { elgg_set_page_owner_guid($widget->getContainerGUID()); - $view = "widgets/$widget->handler/content"; - echo elgg_view($view, array('entity' => $widget)); + if (!$default_widgets) { + $view = "widgets/$widget->handler/content"; + echo elgg_view($view, array('entity' => $widget)); + } } else { register_error(elgg_echo('widgets:save:failure')); } |