From 683f50786a7aec4a936b7b5d59a8e6338b1c7071 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 12 Jun 2008 17:57:25 +0000 Subject: Widgets, including a test widget plugin git-svn-id: https://code.elgg.org/elgg/trunk@900 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/widgets.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'engine/lib/widgets.php') diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index bf36cf001..b4ad9bd93 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -82,6 +82,8 @@ return true; + } else { + register_error($widget->subtype); } } @@ -102,13 +104,17 @@ if ($widgets = get_user_objects_by_metadata($user_guid, "widget", array( 'column' => $column, - 'location' => $context, + 'context' => $context, ), 10000)) { $widgetorder = array(); foreach($widgets as $widget) { - $widgetorder[$widget->order] = $widget; + $order = $widget->order; + while(isset($widgetorder[$order])) { + $order++; + } + $widgetorder[$order] = $widget; } return $widgetorder; @@ -148,11 +154,14 @@ if ($user = get_user($user_guid)) { $widget = new ElggObject; + $widget->subtype = "widget"; $widget->handler = $handler; $widget->context = $context; + $widget->column = $column; if (!$widget->save()) return false; - return save_widget_location($widget, $order, $column); + save_widget_location($widget, $order, $column); + return true; } @@ -244,7 +253,9 @@ if ($widget = get_entity($widget_guid)) { - if ($widget->subtype != "widget") return false; + $subtype = $widget->getSubtype(); + + if ($subtype != "widget") return false; $handler = $widget->handler; if (empty($handler) || !widget_type_exists($handler)) return false; @@ -257,6 +268,7 @@ $widget->$name = $value; } } + $widget->save(); } $function = "save_{$handler}_widget"; @@ -276,9 +288,10 @@ * Function to initialise widgets functionality on Elgg init * */ - function widget_init() { + function widgets_init() { register_action('widgets/save'); + register_action('widgets/add'); } -- cgit v1.2.3