aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-18 16:54:02 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-18 16:54:02 +0000
commita24e700999b38185bea3e80dc8461aed271406cb (patch)
treef63cf545c33910e7f83aaf64a7857c0843cc279d /engine/lib
parentc5854870424d87372bcc86a7edf75b9bf8841825 (diff)
downloadelgg-a24e700999b38185bea3e80dc8461aed271406cb.tar.gz
elgg-a24e700999b38185bea3e80dc8461aed271406cb.tar.bz2
Refs #1793 getting sorted widgets from elgg_get_widgets()
git-svn-id: http://code.elgg.org/elgg/trunk@7339 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/widgets.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 79a3b37bf..5d6a7fcc1 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -154,8 +154,31 @@ function get_widgets($user_guid, $context, $column) {
* @return array|false An array of widget ElggObjects, or false
*/
function elgg_get_widgets($user_guid, $context) {
- // @todo implement elgg_get_entities_from_private_settings() first
- return false;
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'widget',
+ 'owner_guid' => $user_guid,
+ 'private_setting_name' => 'context',
+ 'private_setting_value' => $context
+ );
+ $widgets = elgg_get_entities_from_private_settings($options);
+ if (!$widgets) {
+ return false;
+ }
+
+ $sorted_widgets = array();
+ foreach ($widgets as $widget) {
+ if (!isset($sorted_widgets[$widget->column])) {
+ $sorted_widgets[$widget->column] = array();
+ }
+ $sorted_widgets[$widget->column][$widget->order] = $widget;
+ }
+
+ foreach ($sorted_widgets as $col => $widgets) {
+ ksort($sorted_widgets[$col]);
+ }
+
+ return $sorted_widgets;
}
/**
@@ -193,12 +216,15 @@ function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $
$widget->access_id = get_default_access();
}
+ $guid = $widget->save();
+
+ // private settings cannot be set until ElggWidget saved
$widget->handler = $handler;
$widget->context = $context;
$widget->column = $column;
$widget->order = $order;
- return $widget->save();
+ return $guid;
}
return false;