aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/widgets.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-04 13:05:44 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-04 13:05:44 +0000
commita8d7ea23f8868aa70dd6fe87482e3b860e0b615f (patch)
treed05bc4749587fcd8141d70d5c1ca505793150ac2 /engine/lib/widgets.php
parent114bf6e56152d407f660cf5060972f3bfa4fd8ff (diff)
downloadelgg-a8d7ea23f8868aa70dd6fe87482e3b860e0b615f.tar.gz
elgg-a8d7ea23f8868aa70dd6fe87482e3b860e0b615f.tar.bz2
Moves access permissions references over to using the ACCESS_* constants defined in access.php. Refs #687
git-svn-id: https://code.elgg.org/elgg/trunk@2639 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/widgets.php')
-rw-r--r--engine/lib/widgets.php162
1 files changed, 81 insertions, 81 deletions
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 5f9d8969f..2660cc240 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -9,59 +9,59 @@
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @copyright Curverider Ltd 2008-2009
* @link http://elgg.org/
- */
-
- /**
- * Override ElggObject in order to store widget data in ultra-private stores.
- */
- class ElggWidget extends ElggObject
- {
- protected function initialise_attributes()
- {
- parent::initialise_attributes();
-
- $this->attributes['subtype'] = "widget";
- }
-
- public function __construct($guid = null) { parent::__construct($guid); }
-
- /**
- * Override entity get and sets in order to save data to private data store.
- */
- public function get($name)
- {
- // See if its in our base attribute
- if (isset($this->attributes[$name])) {
- return $this->attributes[$name];
- }
-
- // No, so see if its in the private data store.
- $meta = get_private_setting($this->guid, $name);
- if ($meta)
- return $meta;
-
- // Can't find it, so return null
- return null;
- }
-
- /**
- * Override entity get and sets in order to save data to private data store.
- */
- public function set($name, $value)
- {
- if (array_key_exists($name, $this->attributes))
- {
- // Check that we're not trying to change the guid!
- if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))
- return false;
-
- $this->attributes[$name] = $value;
- }
- else
- return set_private_setting($this->guid, $name, $value);
-
- return true;
- }
+ */
+
+ /**
+ * Override ElggObject in order to store widget data in ultra-private stores.
+ */
+ class ElggWidget extends ElggObject
+ {
+ protected function initialise_attributes()
+ {
+ parent::initialise_attributes();
+
+ $this->attributes['subtype'] = "widget";
+ }
+
+ public function __construct($guid = null) { parent::__construct($guid); }
+
+ /**
+ * Override entity get and sets in order to save data to private data store.
+ */
+ public function get($name)
+ {
+ // See if its in our base attribute
+ if (isset($this->attributes[$name])) {
+ return $this->attributes[$name];
+ }
+
+ // No, so see if its in the private data store.
+ $meta = get_private_setting($this->guid, $name);
+ if ($meta)
+ return $meta;
+
+ // Can't find it, so return null
+ return null;
+ }
+
+ /**
+ * Override entity get and sets in order to save data to private data store.
+ */
+ public function set($name, $value)
+ {
+ if (array_key_exists($name, $this->attributes))
+ {
+ // Check that we're not trying to change the guid!
+ if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))
+ return false;
+
+ $this->attributes[$name] = $value;
+ }
+ else
+ return set_private_setting($this->guid, $name, $value);
+
+ return true;
+ }
}
/**
@@ -171,15 +171,15 @@
* @return array|false An array of widget ElggObjects, or false
*/
function get_widgets($user_guid, $context, $column) {
-
- if ($widgets = get_entities_from_private_setting_multi(array(
- 'column' => $column,
+
+ if ($widgets = get_entities_from_private_setting_multi(array(
+ 'column' => $column,
'context' => $context), "object", "widget", $user_guid, "", 10000))
/*if ($widgets = get_user_objects_by_metadata($user_guid, "widget", array(
'column' => $column,
'context' => $context,
), 10000)) {
- */
+ */
{
$widgetorder = array();
@@ -230,11 +230,11 @@
if ($user = get_user($user_guid)) {
- $widget = new ElggWidget;
- $widget->owner_guid = $user_guid;
- $widget->access_id = 1;
- if (!$widget->save())
- return false;
+ $widget = new ElggWidget;
+ $widget->owner_guid = $user_guid;
+ $widget->access_id = ACCESS_LOGGED_IN;
+ if (!$widget->save())
+ return false;
$widget->handler = $handler;
$widget->context = $context;
@@ -355,19 +355,19 @@
$handler = $widget->handler;
if (empty($handler) || !widget_type_exists($handler)) return false;
- if (!$widget->canEdit()) return false;
+ if (!$widget->canEdit()) return false;
// Save the params to the widget
if (is_array($params) && sizeof($params) > 0) {
- foreach($params as $name => $value) {
+ foreach($params as $name => $value) {
if (!empty($name) && !in_array($name,array(
'guid','owner_guid','site_guid'
- ))) {
- if (is_array($value))
- {
- // TODO: Handle arrays securely
- $widget->setMetaData($name, $value, "", true);
+ ))) {
+ if (is_array($value))
+ {
+ // TODO: Handle arrays securely
+ $widget->setMetaData($name, $value, "", true);
}else
$widget->$name = $value;
}
@@ -486,16 +486,16 @@
return $return;
}
-
- /**
- * Run some things once.
- *
- */
- function widget_run_once()
- {
- // Register a class
- add_subtype("object", "widget", "ElggWidget");
- }
+
+ /**
+ * Run some things once.
+ *
+ */
+ function widget_run_once()
+ {
+ // Register a class
+ add_subtype("object", "widget", "ElggWidget");
+ }
/**
* Function to initialise widgets functionality on Elgg init
@@ -506,8 +506,8 @@
register_action('widgets/reorder');
register_action('widgets/save');
register_action('widgets/add');
-
- // Now run this stuff, but only once
+
+ // Now run this stuff, but only once
run_function_once("widget_run_once");
}