diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-01 18:36:29 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-01 18:36:29 +0000 |
commit | aedefa927ef2d35342b9e2366c77fbccc66308cf (patch) | |
tree | d91c67478ff67956f36f283f28a895f82f8ed788 | |
parent | 853c0c9b82566675b2b0ea98aa283ee3e57e116a (diff) | |
download | elgg-aedefa927ef2d35342b9e2366c77fbccc66308cf.tar.gz elgg-aedefa927ef2d35342b9e2366c77fbccc66308cf.tar.bz2 |
Fixes #1406: get_entity_dates() supports order by.
git-svn-id: http://code.elgg.org/elgg/trunk@3892 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | CHANGES.txt | 1 | ||||
-rw-r--r-- | engine/lib/entities.php | 15 |
2 files changed, 10 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 3119b4703..ca59f83f5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -42,6 +42,7 @@ http://code.elgg.org/elgg/..... * ElggEntity::countEntitiesFromRelationship() supports inverse relationships. #1325 * delete_relationship() triggers the hook delete:relationship and passes the relationship object. #1213 * added ElggEntity::removeRelationship(). #1376. + * get_entity_dates() supports order by. #1406. Services API: * Separated user and api authenticate processing diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 3cabd93ca..b040ab150 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -2285,9 +2285,10 @@ function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = * @param string $subtype The subtype of entity * @param int $container_guid The container GUID that the entinties belong to * @param int $site_guid The site GUID + * @param str order_by SQL order by clause * @return array|false Either an array of timestamps, or false on failure */ -function get_entity_dates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0) { +function get_entity_dates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0, $order_by = 'time_created') { global $CONFIG; $site_guid = (int) $site_guid; @@ -2322,10 +2323,12 @@ function get_entity_dates($type = '', $subtype = '', $container_guid = 0, $site_ $where[] = "({$tempwhere})"; } } else { - if ($subtype AND !$subtype = get_subtype_id($type, $subtype)) { - return false; - } else { - $where[] = "subtype=$subtype"; + if ($subtype) { + if (!$subtype_id = get_subtype_id($type, $subtype)) { + return FALSE; + } else { + $where[] = "subtype=$subtype"; + } } } @@ -2354,7 +2357,7 @@ function get_entity_dates($type = '', $subtype = '', $container_guid = 0, $site_ $sql .= " $w and "; } - $sql .= "1=1"; + $sql .= "1=1 ORDER BY $order_by"; if ($result = get_data($sql)) { $endresult = array(); foreach($result as $res) { |