aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-12 17:57:25 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-12 17:57:25 +0000
commit683f50786a7aec4a936b7b5d59a8e6338b1c7071 (patch)
treec674bb5a47b3ac98837743d09991013a33232fb1 /engine/lib
parentd423fd2379171706c75c60600442a2dbdc12d87a (diff)
downloadelgg-683f50786a7aec4a936b7b5d59a8e6338b1c7071.tar.gz
elgg-683f50786a7aec4a936b7b5d59a8e6338b1c7071.tar.bz2
Widgets, including a test widget plugin
git-svn-id: https://code.elgg.org/elgg/trunk@900 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/widgets.php23
1 files changed, 18 insertions, 5 deletions
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');
}