aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/metadata.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-02 12:40:38 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-02 12:40:38 +0000
commit4cf87cd1f558593fe7047440806bc6b7d32e83ee (patch)
treeeff1ceef115a0977cfc8988f6ca88ae3afd455e7 /engine/lib/metadata.php
parentdb727a00f06d95da0b6d3a3356b1d60c01feabe3 (diff)
downloadelgg-4cf87cd1f558593fe7047440806bc6b7d32e83ee.tar.gz
elgg-4cf87cd1f558593fe7047440806bc6b7d32e83ee.tar.bz2
The system now uses the site GUID to get and set entity data. Also, installation is a great deal more visual.
git-svn-id: https://code.elgg.org/elgg/trunk@621 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/metadata.php')
-rw-r--r--engine/lib/metadata.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 6bed71eb6..c099d6a9c 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -326,9 +326,10 @@
* @param string $entity_subtype The subtype of the entity.
* @param int $limit
* @param int $offset
- * @param string $order_by Optional ordering.
+ * @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")
+ 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)
{
global $CONFIG;
@@ -339,7 +340,10 @@
$entity_subtype = get_subtype_id($entity_type, $entity_subtype);
$limit = (int)$limit;
$offset = (int)$offset;
- $order_by = sanitise_string($order_by);
+ $order_by = sanitise_string($order_by);
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
$access = get_access_list();
@@ -352,7 +356,9 @@
if ($meta_name!="")
$where[] = "m.name_id='$meta_n'";
if ($meta_value!="")
- $where[] = "m.value_id='$meta_v'";
+ $where[] = "m.value_id='$meta_v'";
+ if ($site_guid > 0)
+ $where[] = "e.site_guid = {$site_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)
@@ -372,9 +378,10 @@
* @param int $limit
* @param int $offset
* @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.
* @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")
+ 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)
{
global $CONFIG;
@@ -402,13 +409,18 @@
$limit = (int)$limit;
$offset = (int)$offset;
$order_by = sanitise_string($order_by);
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
$access = get_access_list();
if ($entity_type!="")
- $where[] = "e.type='$entity_type'";
+ $where[] = "e.type = '{$entity_type}'";
if ($entity_subtype)
- $where[] = "e.subtype=$entity_subtype";
+ $where[] = "e.subtype = {$entity_subtype}";
+ if ($site_guid > 0)
+ $where[] = "e.site_guid = {$site_guid}";
$query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e {$join} where";
foreach ($where as $w)