From 9d3a3c457c672567a65600666a44c8de594c729d Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 6 Nov 2008 12:01:31 +0000 Subject: Some tidying of objects and opendd export git-svn-id: https://code.elgg.org/elgg/trunk@2412 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/export.php | 26 ++++++++++++++++++++++++++ engine/lib/extender.php | 6 +----- engine/lib/relationships.php | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) (limited to 'engine') diff --git a/engine/lib/export.php b/engine/lib/export.php index fe9d2b2da..e819264f6 100644 --- a/engine/lib/export.php +++ b/engine/lib/export.php @@ -61,6 +61,32 @@ */ class ImportException extends DataFormatException {} + /** + * Get a UUID from a given object. + * + * @param $object The object either an ElggEntity, ElggRelationship or ElggExtender + * @return the UUID or false + */ + function get_uuid_from_object($object) + { + if ($object instanceof ElggEntity) + return guid_to_uuid($object->guid); + else if ($object instanceof ElggExtender) { + $type = $object->type; + if ($type == 'volatile') + $uuid = guid_to_uuid($object->entity_guid). $type . "/{$object->name}/"; + else + $uuid = guid_to_uuid($object->entity_guid). $type . "/{$object->id}/"; + + return $uuid; + } else if ($object instanceof ElggRelationship) { + return guid_to_uuid($object->guid_one) . "relationship/{$object->id}/"; + } + + + return false; + } + /** * Generate a UUID from a given GUID. * diff --git a/engine/lib/extender.php b/engine/lib/extender.php index f1077b454..988899409 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -129,11 +129,7 @@ */ public function export() { - $type = $this->attributes['type']; - if ($type == 'volatile') - $uuid = guid_to_uuid($this->entity_guid). $type . "/{$this->name}/"; - else - $uuid = guid_to_uuid($this->entity_guid). $type . "/{$this->id}/"; + $uuid = get_uuid_from_object($this); $meta = new ODDMetadata($uuid, guid_to_uuid($this->entity_guid), $this->attributes['name'], $this->attributes['value'], $type, guid_to_uuid($this->owner_guid)); $meta->setAttribute('published', date("r", $this->time_created)); diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index f43a46c54..61234695d 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -127,7 +127,7 @@ */ public function export() { - $uuid = guid_to_uuid($this->guid_one) . "relationship/{$this->id}/"; + $uuid = get_uuid_from_object($this); $relationship = new ODDRelationship( guid_to_uuid($this->guid_one), $this->relationship, -- cgit v1.2.3