aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/export.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-01 14:27:15 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-01 14:27:15 +0000
commit8a2c85d1650321b1731c21b448a2e3f6e3155e2d (patch)
tree8fd097ba4d0bb3852c8f55ea7acf09627b54b237 /engine/lib/export.php
parent9391179df8ba6ed1595de7de533f633d99d57b35 (diff)
downloadelgg-8a2c85d1650321b1731c21b448a2e3f6e3155e2d.tar.gz
elgg-8a2c85d1650321b1731c21b448a2e3f6e3155e2d.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Some UUID functions git-svn-id: https://code.elgg.org/elgg/trunk@309 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/export.php')
-rw-r--r--engine/lib/export.php35
1 files changed, 31 insertions, 4 deletions
diff --git a/engine/lib/export.php b/engine/lib/export.php
index 33d7946a7..024f25a63 100644
--- a/engine/lib/export.php
+++ b/engine/lib/export.php
@@ -75,8 +75,6 @@
$wrapper->header->date = date("r");
$wrapper->header->timestamp = time();
$wrapper->header->domain = $CONFIG->wwwroot;
- $wrapper->header->guid = $guid;
- $wrapper->header->uuid = guid_to_uuid($guid);
$wrapper->header->exported_by = guid_to_uuid($_SESSION['id']);
// Construct data
@@ -155,8 +153,6 @@
}
}
}
-
-
/**
* Import an XML serialisation of an object.
@@ -172,6 +168,7 @@
$IMPORTED_DATA = array();
$IMPORTED_OBJECT_COUNTER = 0;
+ $IMPORTED_GUID_MAP = array();
$dom = __xml2array($xml);
@@ -212,6 +209,36 @@
return false;
}
+
+ /**
+ * This function attempts to retrieve a previously imported entity via its UUID.
+ *
+ * @param $uuid
+ */
+ function get_entity_from_uuid($uuid)
+ {
+ $uuid = sanitise_string($uuid);
+
+ $entities = get_entities_from_metadata("import_uuid", $uuid);
+ if ((!$entities) || (count($entities)!=1))
+ throw new InvalidParameterException("Unexpected number of entities tagged with $uuid, previous import failed?");
+
+ return $entities[0];
+ }
+
+ /**
+ * Tag a previously created guid with the uuid it was imported on.
+ *
+ * @param int $guid
+ * @param string $uuid
+ */
+ function add_uuid_to_guid($guid, $uuid)
+ {
+ $guid = (int)$guid;
+ $uuid = sanitise_string($uuid);
+
+ return create_metadata($guid, "import_uuid", $uuid);
+ }
/**
* This function serialises an object recursively into an XML representation.