aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-12 21:53:17 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-12 21:53:17 +0000
commit2ba91af6ba0de6bfe4b4f9aa29aa1567fca23640 (patch)
treea18e2c099e16735ada8a88237a8bbf0d307adec6
parent555b567e9156dc217f3b28dfe65d6f4d0c24f4ab (diff)
downloadelgg-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
-rw-r--r--engine/lib/deprecated-1.8.php18
-rw-r--r--engine/lib/metadata.php26
2 files changed, 31 insertions, 13 deletions
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index 4e8b02d28..cef705a1b 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -3549,7 +3549,8 @@ function get_metadata_byname($entity_guid, $meta_name) {
$options = array(
'guid' => $entity_guid,
- 'metadata_name' => $meta_name
+ 'metadata_name' => $meta_name,
+ 'limit' => 0
);
$md = elgg_get_metadata($options);
@@ -3573,8 +3574,21 @@ function get_metadata_for_entity($entity_guid) {
elgg_deprecated_notice('get_metadata_for_entity() is deprecated by elgg_get_metadata()', 1.8);
$options = array(
- 'guid' => $entity_guid
+ 'guid' => $entity_guid,
+ 'limit' => 0
);
return elgg_get_metadata($options);
}
+
+/**
+ * Get a specific metadata object.
+ *
+ * @param int $id The id of the metadata being retrieved.
+ *
+ * @return mixed False on failure or ElggMetadata
+ * @deprecated 1.8 Use elgg_get_metadata_by_id()
+ */
+function get_metadata($id) {
+ return elgg_get_metadata_by_id($id);
+}
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) {