diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-19 21:16:49 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-19 21:16:49 +0000 |
commit | bab90941c9faea31651bb8b562ddec6b5a82292c (patch) | |
tree | eaeb02df929678fa1192ad4a22e14c5f733c7ab6 /engine/lib/entities.php | |
parent | f8b8e83d2210d3d6601e61b291df38a078a95093 (diff) | |
download | elgg-bab90941c9faea31651bb8b562ddec6b5a82292c.tar.gz elgg-bab90941c9faea31651bb8b562ddec6b5a82292c.tar.bz2 |
Fixes #568: Exportable code now inclusive not exclusive.
* Added extra function Exportable interface
* OpenDD export modified
* PHP & JSON export views modified
* Default export view will still show all data if you are logged in as admin (since this view is used by the guidtool)
git-svn-id: https://code.elgg.org/elgg/trunk@2467 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r-- | engine/lib/entities.php | 107 |
1 files changed, 56 insertions, 51 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index cd867193d..91314a882 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -709,14 +709,27 @@ $res = delete_entity($this->get('guid')); return $res; } - + // EXPORTABLE INTERFACE //////////////////////////////////////////////////////////// /** - * Export this class into a stdClass containing all necessary fields. + * Return an array of fields which can be exported. + */ + public function getExportableValues() + { + return array( + 'guid', + 'type', + 'subtype', + 'time_created', + 'container_guid', + 'owner_guid', + ); + } + + /** + * Export this class into an array of ODD Elements containing all necessary fields. * Override if you wish to return more information than can be found in $this->attributes (shouldn't happen) - * - * @return stdClass */ public function export() { @@ -734,61 +747,53 @@ $tmp[] = $odd; + $exportable_values = $this->getExportableValues(); + // Now add its attributes foreach ($this->attributes as $k => $v) { $meta = NULL; - switch ($k) - { - case 'guid' : // Dont use guid - case 'subtype' : // The subtype - case 'type' : // Don't use type - case 'access_id' : // Don't use access - if can export then its public for you, then importer decides what access to give this object. - case 'time_updated' : // Don't use date in export - - case 'tables_split' : // We don't want to export the internal counter variables. - case 'tables_loaded' : // Or this one + if (in_array( $k, $exportable_values)) { + switch ($k) + { + case 'guid' : // Dont use guid in OpenDD + case 'type' : // Type and subtype already taken care of + case 'subtype' : + break; - case 'code' : - case 'enabled' : // Useless to an importer + case 'time_created' : // Created = published + $odd->setAttribute('published', date("r", $v)); + break; - case 'email' : - case 'salt' : - case 'password' : // Definitely don't want these three - break; - - case 'time_created' : // Created = published - $odd->setAttribute('published', date("r", $v)); - break; - - case 'site_guid' : // Container - $k = 'site_uuid'; - $v = guid_to_uuid($v); - $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; - - case 'container_guid' : // Container - $k = 'container_uuid'; - $v = guid_to_uuid($v); - $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; - - case 'owner_guid' : // Convert owner guid to uuid, this will be stored in metadata - $k = 'owner_uuid'; - $v = guid_to_uuid($v); - $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; + case 'site_guid' : // Container + $k = 'site_uuid'; + $v = guid_to_uuid($v); + $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); + break; + + case 'container_guid' : // Container + $k = 'container_uuid'; + $v = guid_to_uuid($v); + $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); + break; + + case 'owner_guid' : // Convert owner guid to uuid, this will be stored in metadata + $k = 'owner_uuid'; + $v = guid_to_uuid($v); + $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); + break; + + default : + $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); + } - default : - $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - } - - // set the time of any metadata created - if ($meta) - { - $meta->setAttribute('published', date("r",$this->time_created)); - $tmp[] = $meta; + // set the time of any metadata created + if ($meta) + { + $meta->setAttribute('published', date("r",$this->time_created)); + $tmp[] = $meta; + } } } |