aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-11 18:00:26 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-11 18:00:26 +0000
commit498986d5e7d269b60d307fba3e79148023d73fb5 (patch)
treea8d052b8d3c6106ed9e7f48e6f06f37a9a20386f /engine/lib/entities.php
parent327010e704cb71fe7b29de48d76975e99a2d355e (diff)
downloadelgg-498986d5e7d269b60d307fba3e79148023d73fb5.tar.gz
elgg-498986d5e7d269b60d307fba3e79148023d73fb5.tar.bz2
Fixes #137: annotate and getAnnotations now functions for unsaved entities. Maths functions non-functional at present.
Refs #135. git-svn-id: https://code.elgg.org/elgg/trunk@1405 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 1ece194aa..278e80a35 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -46,6 +46,11 @@
protected $temp_metadata;
/**
+ * Temporary cache for annotations, permitting meta data access before a guid has obtained.
+ */
+ protected $temp_annotations;
+
+ /**
* Initialise the attributes array.
* This is vital to distinguish between metadata and base parameters.
*
@@ -60,6 +65,7 @@
// Create attributes array if not already created
if (!is_array($this->attributes)) $this->attributes = array();
if (!is_array($this->temp_metadata)) $this->temp_metadata = array();
+ if (!is_array($this->temp_annotations)) $this->temp_annotations = array();
$this->attributes['guid'] = "";
$this->attributes['type'] = "";
@@ -230,7 +236,12 @@
*/
function annotate($name, $value, $access_id = 0, $owner_id = 0, $vartype = "")
{
- return create_annotation($this->getGUID(), $name, $value, $vartype, $owner_id, $access_id);
+ if ((int) $this->guid > 0) {
+ return create_annotation($this->getGUID(), $name, $value, $vartype, $owner_id, $access_id);
+ } else {
+ $this->temp_annotations[$name] = $value;
+ }
+ return true;
}
/**
@@ -243,7 +254,11 @@
*/
function getAnnotations($name, $limit = 50, $offset = 0, $order="asc")
{
- return get_annotations($this->getGUID(), "", "", $name, "", 0, $limit, $offset, $order);
+ if ((int) ($this->guid) > 0) {
+ return get_annotations($this->getGUID(), "", "", $name, "", 0, $limit, $offset, $order);
+ } else {
+ return $this->temp_annotations[$name];
+ }
}
/**