aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/metadata.php13
-rw-r--r--engine/lib/users.php17
2 files changed, 27 insertions, 3 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 44474c7d6..94c0b7b2c 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -388,7 +388,7 @@
* @param string $order_by Optional ordering.
* @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
*/
- function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "e.time_created desc", $site_guid = 0)
+ function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "e.time_created desc", $site_guid = 0)
{
global $CONFIG;
@@ -401,6 +401,7 @@
$offset = (int)$offset;
$order_by = sanitise_string($order_by);
$site_guid = (int) $site_guid;
+ $owner_guid = (int) $owner_guid;
if ($site_guid == 0)
$site_guid = $CONFIG->site_guid;
@@ -417,7 +418,9 @@
if ($meta_value!="")
$where[] = "m.value_id='$meta_v'";
if ($site_guid > 0)
- $where[] = "e.site_guid = {$site_guid}";
+ $where[] = "e.site_guid = {$site_guid}";
+ if ($owner_guid > 0)
+ $where[] = "e.owner_guid = {$owner_guid}";
$query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid where";
foreach ($where as $w)
@@ -440,7 +443,7 @@
* @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
* @return array List of ElggEntities
*/
- function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "e.time_created desc", $site_guid = 0)
+ function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "e.time_created desc", $site_guid = 0)
{
global $CONFIG;
@@ -468,6 +471,8 @@
$limit = (int)$limit;
$offset = (int)$offset;
$order_by = sanitise_string($order_by);
+ $owner_guid = (int) $owner_guid;
+
$site_guid = (int) $site_guid;
if ($site_guid == 0)
$site_guid = $CONFIG->site_guid;
@@ -480,6 +485,8 @@
$where[] = "e.subtype = {$entity_subtype}";
if ($site_guid > 0)
$where[] = "e.site_guid = {$site_guid}";
+ if ($owner_guid > 0)
+ $where[] = "e.owner_guid = {$owner_guid}";
$query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e {$join} where";
foreach ($where as $w)
diff --git a/engine/lib/users.php b/engine/lib/users.php
index b4fa795b8..ed73e7405 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -545,6 +545,23 @@
}
return 0;
}
+
+ /**
+ * Get user objects by an array of metadata
+ *
+ * @param int $user_guid The GUID of the owning user
+ * @param string $subtype Optionally, the subtype of objects
+ * @paran array $metadata An array of metadata
+ * @param int $limit The number of results to return (default 10)
+ * @param int $offset Indexing offset, if any
+ * @return false|array An array of ElggObjects or false, depending on success
+ * @return unknown
+ */
+ function get_user_objects_by_metadata($user_guid, $subtype = "", $metadata = array(), $limit = 0, $offset = 0) {
+
+ return get_entities_from_metadata_multi($metadata,"object",$subtype,$user_guid,$limit,$offset);
+
+ }
/**
* Get a user object from a GUID.