aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2013-02-01 10:49:06 -0800
committerCash Costello <cash.costello@gmail.com>2013-02-01 10:49:06 -0800
commit9b8839602051aa1b5c441695ae897c0b049ff889 (patch)
treebaad763aa565ed23d9b9094480975c4d37c7de14 /mod
parent90ba43e54728982a23dd78dbbb07f5a1d88d9d10 (diff)
parentb2724f7300902034398f534e55975b3487e3a235 (diff)
downloadelgg-9b8839602051aa1b5c441695ae897c0b049ff889.tar.gz
elgg-9b8839602051aa1b5c441695ae897c0b049ff889.tar.bz2
Merge pull request #482 from Srokap/ticket_2554
Fixes #2554 - Adds search support for sorting and order
Diffstat (limited to 'mod')
-rw-r--r--mod/search/pages/search/index.php2
-rw-r--r--mod/search/search_hooks.php12
2 files changed, 12 insertions, 2 deletions
diff --git a/mod/search/pages/search/index.php b/mod/search/pages/search/index.php
index fcd95c43e..ede09329b 100644
--- a/mod/search/pages/search/index.php
+++ b/mod/search/pages/search/index.php
@@ -63,7 +63,7 @@ switch ($sort) {
break;
}
-$order = get_input('sort', 'desc');
+$order = get_input('order', 'desc');
if ($order != 'asc' && $order != 'desc') {
$order = 'desc';
}
diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php
index 62058abf1..47351fb8a 100644
--- a/mod/search/search_hooks.php
+++ b/mod/search/search_hooks.php
@@ -35,6 +35,7 @@ function search_objects_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
+ $params['order_by'] = search_get_order_by_sql('e', 'oe', $params['sort'], $params['order']);
$entities = elgg_get_entities($params);
// add the volatile data for why these entities have been returned.
@@ -89,6 +90,7 @@ function search_groups_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
+ $params['order_by'] = search_get_order_by_sql('e', 'ge', $params['sort'], $params['order']);
$entities = elgg_get_entities($params);
// add the volatile data for why these entities have been returned.
@@ -159,6 +161,7 @@ function search_users_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
+ $params['order_by'] = search_get_order_by_sql('e', 'ue', $params['sort'], $params['order']);
$entities = elgg_get_entities($params);
// add the volatile data for why these entities have been returned.
@@ -261,6 +264,7 @@ function search_tags_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
+ $params['order_by'] = search_get_order_by_sql('e', null, $params['sort'], $params['order']);
$entities = elgg_get_entities($params);
// add the volatile data for why these entities have been returned.
@@ -398,6 +402,11 @@ function search_comments_hook($hook, $type, $value, $params) {
return array ('entities' => array(), 'count' => 0);
}
+ $order_by = search_get_order_by_sql('e', null, $params['sort'], $params['order']);
+ if ($order_by) {
+ $order_by = "ORDER BY $order_by";
+ }
+
$q = "SELECT DISTINCT a.*, msv.string as comment FROM {$db_prefix}annotations a
JOIN {$db_prefix}metastrings msn ON a.name_id = msn.id
JOIN {$db_prefix}metastrings msv ON a.value_id = msv.id
@@ -407,7 +416,8 @@ function search_comments_hook($hook, $type, $value, $params) {
AND $e_access
AND $a_access
$container_and
-
+
+ $order_by
LIMIT $offset, $limit
";