aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/annotations.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-17 10:18:03 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-17 10:18:03 +0000
commitddbe1c9698031a8017e073048bc48d5268129c78 (patch)
tree4a11794f657af2226b21d1eeb9e6c06d51975118 /engine/lib/annotations.php
parentd0f3cef69eff311d8eba8b2be0c076399da8ced1 (diff)
downloadelgg-ddbe1c9698031a8017e073048bc48d5268129c78.tar.gz
elgg-ddbe1c9698031a8017e073048bc48d5268129c78.tar.bz2
Fixed get_entities_by_annotation
git-svn-id: https://code.elgg.org/elgg/trunk@1451 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/annotations.php')
-rw-r--r--engine/lib/annotations.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 69110f3dc..f6060755e 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -374,10 +374,10 @@
$limit = (int)$limit;
$offset = (int)$offset;
if($order_by == 'asc')
- $order_by = "a.time_created asc";
+ $order_by = "maxtime asc";
if($order_by == 'desc')
- $order_by = "a.time_created desc";
+ $order_by = "maxtime desc";
$where = array();
@@ -405,11 +405,14 @@
if ($count) {
- $query = "count distinct (e.guid) as total ";
+ $query = "SELECT count(distinct e.guid) as total ";
} else {
- $query = "SELECT distinct e.*, n.string as name, v.string as value ";
+ $query = "SELECT e.*, max(a.time_created) as maxtime ";
}
- $query .= "from {$CONFIG->dbprefix}annotations a JOIN {$CONFIG->dbprefix}entities e on a.entity_guid = e.guid JOIN {$CONFIG->dbprefix}metastrings v on a.value_id=v.id JOIN {$CONFIG->dbprefix}metastrings n on a.name_id = n.id ";
+ $query .= "from {$CONFIG->dbprefix}annotations a JOIN {$CONFIG->dbprefix}entities e on e.guid = a.entity_guid ";
+ if ($value != "")
+ $query .= " JOIN {$CONFIG->dbprefix}metastrings v on a.value_id=v.id";
+
if (($group_guid != 0) && ($entity_type=='object')) $query .= "JOIN {$CONFIG->dbprefix}objects_entity o on o.guid = e.guid";
$query .= " where";
@@ -421,8 +424,8 @@
$row = get_data_row($query);
return $row->total;
} else {
- $query .= " order by $order_by limit $offset,$limit"; // Add order and limit
- return get_data($query, "row_to_elggannotation");
+ $query .= " group by a.entity_guid order by $order_by limit $offset,$limit"; // Add order and limit
+ return get_data($query, "entity_row_to_elggstar");
}
}
@@ -451,8 +454,8 @@
}
$count = get_entities_from_annotations($entity_type, $entity_subtype, $name, $value, $owner_guid, $group_guid, null, null, $asc, true);
$offset = (int) get_input("offset",0);
- $entities = get_entities_from_annotations($entity_type, $entity_subtype, $name, $value, $owner_guid, $group_guid, null, null, $asc);
-
+ $entities = get_entities_from_annotations($entity_type, $entity_subtype, $name, $value, $owner_guid, $group_guid, $limit, $offset, $asc);
+
return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview);
}