diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-01 14:04:05 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-01 14:04:05 +0000 |
commit | 1cd6da51170f2ed79d647fa5391f2bc3b072fc96 (patch) | |
tree | 95e6b7e68b2598f46ec6f075c129e96a1d3b22e7 | |
parent | b640dc452ae9d67c02662997f6c5b6e0d900e4b9 (diff) | |
download | elgg-1cd6da51170f2ed79d647fa5391f2bc3b072fc96.tar.gz elgg-1cd6da51170f2ed79d647fa5391f2bc3b072fc96.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Moved import to ElggEntity
git-svn-id: https://code.elgg.org/elgg/trunk@304 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/entities.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 8784e9af4..9ddb4c9f1 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -763,6 +763,37 @@ return $returnvalue; } + /** + * Import an entity. + * This function checks the passed XML doc (as array) to see if it is a user, if so it constructs a new + * elgg user and returns "true" to inform the importer that it's been handled. + */ + function import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) + { + $name = $params['name']; + $element = $params['element']; + + $tmp = NULL; + + switch ($name) + { + case 'ElggUser' : $tmp = new ElggUser(); break; + case 'ElggSite' : $tmp = new ElggSite(); break; + case 'ElggConnection' : $tmp = new ElggConnection(); break; + case 'ElggObject' : $tmp = new ElggObject(); break; + } + + if ($tmp) + { + $tmp->import($element); + + return $tmp; + } + } + + /** Register the import hook */ + register_plugin_hook("import", "all", "import_user_plugin_hook", 0); + /** Register the hook, ensuring entities are serialised first */ register_plugin_hook("export", "all", "export_entity_plugin_hook", 0); |