diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-05 17:06:35 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-05 17:06:35 +0000 |
commit | 7dbc5cd43f911a381011f4d220a8490f3049c27d (patch) | |
tree | 3c9e6a35be9fd140bcfcaf407e9c953f578b1a1c | |
parent | f98e97d304f47243d367c66a740ad653912ea57d (diff) | |
download | elgg-7dbc5cd43f911a381011f4d220a8490f3049c27d.tar.gz elgg-7dbc5cd43f911a381011f4d220a8490f3049c27d.tar.bz2 |
Fixes for metadata and for the run order.
git-svn-id: https://code.elgg.org/elgg/trunk@817 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/metadata.php | 13 | ||||
-rw-r--r-- | engine/lib/users.php | 17 | ||||
-rw-r--r-- | mod/profile/start.php | 4 |
3 files changed, 31 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.
diff --git a/mod/profile/start.php b/mod/profile/start.php index 86faded71..0c0272bbe 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -116,5 +116,9 @@ register_action("profile/edit",false,$CONFIG->pluginspath . "profile/actions/edit.php");
register_action("profile/iconupload",false,$CONFIG->pluginspath . "profile/actions/iconupload.php");
+ // Define widgets for use in this context
+ if (is_callable('use_widgets')) {
+ use_widgets('profile');
+ }
?>
\ No newline at end of file |