aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-08 11:31:34 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-08 11:31:34 +0000
commit1739ce16cfa0933a09496f66b014885c281d114a (patch)
tree225c2bc5c67f752581f6c9998c56b546d10679f7 /engine/lib
parentde352a469c472b981f6949334088679b2d497c3f (diff)
downloadelgg-1739ce16cfa0933a09496f66b014885c281d114a.tar.gz
elgg-1739ce16cfa0933a09496f66b014885c281d114a.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Added get_objects_from_metadatas (untested) git-svn-id: https://code.elgg.org/elgg/trunk@117 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/metadata.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 7718907cf..6fd95f61c 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -284,6 +284,42 @@
return get_data($query, "row_to_elggmetadata");
}
+
+ /**
+ * Similar to get_metadatas, but instead returns the objects associated with a given meta search.
+ *
+ * @param int $object_id
+ * @param string $object_type
+ * @param int $owner_id
+ * @param string $order_by
+ * @param int $limit
+ * @param int $offset
+ * @return mixed Array of objects or false.
+ */
+ function get_objects_from_metadatas($object_id = 0, $object_type = "", $name = "", $value = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0)
+ {
+ $results = get_metadatas($object_id, $object_type, $name, $value, $owner_id, $order_by, $limit, $offset);
+ $objects = false;
+
+ if ($results)
+ {
+ $objects = array();
+
+ foreach ($results as $r)
+ {
+ switch ($r->object_type)
+ {
+ case 'object' : $objects[] = new ElggObject($r->object_id); break;
+ case 'user' : $objects[] = new ElggUser($r->object_id); break;
+ case 'collection' : $objects[] = new ElggCollection($r->object_id); break;
+ case 'site' : $objects[] = new ElggSite($r->object_id); break;
+ default: default : throw new InstallationException("Type {$r->object_type} is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.");
+ }
+ }
+ }
+
+ return $objects;
+ }
/**
* Delete an item of metadata, where the current user has access.