diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 21:53:17 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 21:53:17 +0000 |
commit | 2ba91af6ba0de6bfe4b4f9aa29aa1567fca23640 (patch) | |
tree | a18e2c099e16735ada8a88237a8bbf0d307adec6 /engine/lib/metadata.php | |
parent | 555b567e9156dc217f3b28dfe65d6f4d0c24f4ab (diff) | |
download | elgg-2ba91af6ba0de6bfe4b4f9aa29aa1567fca23640.tar.gz elgg-2ba91af6ba0de6bfe4b4f9aa29aa1567fca23640.tar.bz2 |
Deprecated get_metadata() by elgg_get_metadata_by_id() to avoid confusion with elgg_get_metadata(). Not in love with the name...had considered elgg_get_metadatum(). Open to suggestions.
git-svn-id: http://code.elgg.org/elgg/trunk@8175 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/metadata.php')
-rw-r--r-- | engine/lib/metadata.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index a9be5a962..c123a89b0 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -23,26 +23,27 @@ function row_to_elggmetadata($row) { } /** - * Get a specific metadata object. + * Get a specific metadata object by its id. + * If you want multiple metadata objects, use + * {@link elgg_get_metadata()}. * - * @param int $id The id of the metadata being retrieved. + * @param int $id The id of the metadata object being retrieved. * - * @return mixed False on failure or ElggMetadata + * @return false|ElggMetadata */ -function get_metadata($id) { - global $CONFIG; +function elgg_get_metadata_by_id($id) { + $db_prefix = elgg_get_config('dbprefix'); $id = (int)$id; $access = get_access_sql_suffix("e"); $md_access = get_access_sql_suffix("m"); - $query = "SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m" - . " JOIN {$CONFIG->dbprefix}entities e on e.guid = m.entity_guid" - . " JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id" - . " JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id" + $query = "SELECT m.*, n.string as name, v.string as value from {$db_prefix}metadata m" + . " JOIN {$db_prefix}entities e on e.guid = m.entity_guid" + . " JOIN {$db_prefix}metastrings v on m.value_id = v.id" + . " JOIN {$db_prefix}metastrings n on m.name_id = n.id" . " where m.id=$id and $access and $md_access"; - return row_to_elggmetadata(get_data_row($query)); } @@ -850,7 +851,10 @@ function export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params) $guid = (int)$params['guid']; $name = $params['name']; - $result = get_metadata_for_entity($guid); + $result = elgg_get_metadata(array( + 'guid' => $guid, + 'limit' => 0 + )); if ($result) { foreach ($result as $r) { |