aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/widgets.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-19 20:43:48 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-19 20:43:48 +0000
commit3b46665b3f4ee10e9d2778033ea7180cca7571eb (patch)
tree6cbea6da55887db7bbd587df9b7e4d8cb209cea2 /engine/lib/widgets.php
parentf42382e0bff1692e2ddcd1c8eb316836e3020f1e (diff)
downloadelgg-3b46665b3f4ee10e9d2778033ea7180cca7571eb.tar.gz
elgg-3b46665b3f4ee10e9d2778033ea7180cca7571eb.tar.bz2
saving widget settings
git-svn-id: http://code.elgg.org/elgg/trunk@7350 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/widgets.php')
-rw-r--r--engine/lib/widgets.php44
1 files changed, 43 insertions, 1 deletions
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 92d022913..1396a9d8f 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -86,6 +86,45 @@ function elgg_create_widget($owner_guid, $handler, $access_id = null) {
}
/**
+ * Saves a widget's settings
+ *
+ * Plugins can override this save function by defining a function of the name
+ * "elgg_save_{$widget->handler}_widget_settings" that takes the widget object
+ * and the parameter array as arguments
+ *
+ * @param int $guid The GUID of the widget
+ * @param array $params An array of name => value parameters
+ * @return bool
+ * @since 1.8.0
+ */
+function elgg_save_widget_settings($guid, $params) {
+ $widget = get_entity($guid);
+ if (!$widget || !$widget->canEdit()) {
+ return false;
+ }
+
+ // check if a plugin is overriding the save function
+ $function = "elgg_save_{$widget->handler}_widget_settings";
+ if (is_callable($function)) {
+ return $function($widget, $params);
+ }
+
+ if (is_array($params) && count($params) > 0) {
+ foreach ($params as $name => $value) {
+ if (is_array($value)) {
+ // private settings cannot handle arrays
+ return false;
+ } else {
+ $widget->$name = $value;
+ }
+ }
+ $widget->save();
+ }
+
+ return true;
+}
+
+/**
* Can the user edit the widgets
*
* @param int $user_guid The GUID of the user or 0 for logged in user
@@ -371,8 +410,10 @@ function get_widget_types() {
* @param array $params An array of name => value parameters
*
* @return bool
+ * @deprecated 1.8
*/
function save_widget_info($widget_guid, $params) {
+ elgg_deprecated_notice("save_widget_info() is deprecated for elgg_save_widget_settings", 1.8);
if ($widget = get_entity($widget_guid)) {
$subtype = $widget->getSubtype();
@@ -428,8 +469,10 @@ function save_widget_info($widget_guid, $params) {
* @param int $owner Owner guid
*
* @return void
+ * @deprecated 1.8
*/
function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) {
+ elgg_deprecated_notice("reorder_widgets_from_panel() is deprecated", 1.8);
$return = true;
$mainwidgets = explode('::', $panelstring1);
@@ -597,7 +640,6 @@ function widget_run_once() {
* @return void
*/
function widgets_init() {
- register_action('widgets/reorder');
register_action('widgets/save');
register_action('widgets/add');
register_action('widgets/move');