diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-14 11:50:55 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-14 11:50:55 +0000 |
commit | 0f6addd322fe709f5a889ea5a719113b8deb4b78 (patch) | |
tree | 2555580cbe1110fa81865a39386b62751a345f0c /engine/lib | |
parent | ba96de15a07753e06f02b777d1cfcb0c981d2986 (diff) | |
download | elgg-0f6addd322fe709f5a889ea5a719113b8deb4b78.tar.gz elgg-0f6addd322fe709f5a889ea5a719113b8deb4b78.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* ODD relationship verb -> relationship mapping functions
git-svn-id: https://code.elgg.org/elgg/trunk@442 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/export.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/engine/lib/export.php b/engine/lib/export.php index e9129e3a3..6e9b1c495 100644 --- a/engine/lib/export.php +++ b/engine/lib/export.php @@ -222,6 +222,49 @@ protected function getTagName() { return "relationship"; } } + /** Relationship verb mapping */ + $ODD_RELATIONSHIP_VERBS = array(); + + /** + * This function provides a mapping between entity relationships and ODD relationship verbs. + * @param string $relationship The relationship as stored in the database, eg "friend" or "member of" + * @param string $verb The verb, eg "friends" or "joins" + */ + function register_odd_relationship_mapping($relationship, $verb) + { + global $ODD_RELATIONSHIP_VERBS; + + $ODD_RELATIONSHIP_VERBS[$relationship] = $verb; + } + + /** + * Return a mapping for relationship to a pre-registered ODD verb, or false. + * @param string $relationship The relationship + */ + function get_verb_from_relationship($relationship) + { + global $ODD_RELATIONSHIP_VERBS; + + if (isset($ODD_RELATIONSHIP_VERBS[$relationship])) + return $ODD_RELATIONSHIP_VERBS[$relationship]; + + return false; + } + + /** + * Return the relationship registered with a given verb, or false. + * @param string $verb The verb. + */ + function get_relationship_from_verb($verb) + { + global $ODD_RELATIONSHIP_VERBS; + + foreach ($ODD_RELATIONSHIP_VERBS as $k => $v) + if ($v == $verb) return $k; + + return false; + } + /** * Generate a UUID from a given GUID. * |