From 1cd6da51170f2ed79d647fa5391f2bc3b072fc96 Mon Sep 17 00:00:00 2001 From: icewing Date: Tue, 1 Apr 2008 14:04:05 +0000 Subject: Marcus Povey * Moved import to ElggEntity git-svn-id: https://code.elgg.org/elgg/trunk@304 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'engine/lib/entities.php') 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); -- cgit v1.2.3