From ee6d78d6f6c1d6079a17ada31d6dd7bd53024bc1 Mon Sep 17 00:00:00 2001 From: marcus Date: Tue, 15 Jul 2008 10:25:05 +0000 Subject: Entity metadata can now be saved using setMetaData() interface even if guid not specified. git-svn-id: https://code.elgg.org/elgg/trunk@1420 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 7b5383dee..ad78b6f9e 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -192,13 +192,24 @@ remove_metadata($this->getGUID(), $name); $multiple = true; foreach ($value as $v) { - if (!create_metadata($this->getGUID(), $name, $v, $value_type, $this->getOwner(), $this->getAccessID(), $multiple)) return false; + if ((int) $this->guid > 0) { + if (!create_metadata($this->getGUID(), $name, $v, $value_type, $this->getOwner(), $this->getAccessID(), $multiple)) return false; + } else { + $this->temp_metadata[$name] = $value; + } } return true; } else - return create_metadata($this->getGUID(), $name, $value, $value_type, $this->getOwner(), $this->getAccessID()); + { + if ((int) $this->guid > 0) { + return create_metadata($this->getGUID(), $name, $value, $value_type, $this->getOwner(), $this->getAccessID()); + } else { + $this->temp_metadata[$name] = $value; + return true; + } + } } /** -- cgit v1.2.3