diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/directory.php | 4 | ||||
-rw-r--r-- | mod/dirsearch.php | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/mod/directory.php b/mod/directory.php index 46fc34e16..1e5d64a0f 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -59,6 +59,10 @@ function directory_content(&$a) { $query .= '&name=' . urlencode($search); if(strpos($search,'@')) $query .= '&address=' . urlencode($search); + + $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); + if($sort_order) + $query .= '&order=' . urlencode($sort_order); if($a->pager['page'] != 1) $query .= '&p=' . $a->pager['page']; diff --git a/mod/dirsearch.php b/mod/dirsearch.php index b2b28ce8c..993522549 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -35,6 +35,8 @@ function dirsearch_content(&$a) { $agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 ); $agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 ); + $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); + // TODO - a meta search which joins all of these things to one search string $sql_extra = ''; @@ -107,9 +109,16 @@ function dirsearch_content(&$a) { $sql_extra .= " and xchan_hash in ( select ud_hash from updates where ud_date > '" . dbesc($mtime) . "' ) "; } - $order = " ORDER BY `xchan_name` ASC "; + if($sort_order == 'date') + $order = " order by ud_date desc "; + elseif($sort_order == 'reverse') + $order = " order by xchan_name desc "; + else + $order = " order by xchan_name asc "; + + - $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d ) $order $qlimit ", + $r = q("SELECT xchan.*, xprof.*, updates.* from xchan left join xprof on xchan_hash = xprof_hash left join updates on xchan_hash = ud_hash where $logic $sql_extra and not ( xchan_flags & %d ) $order $qlimit ", intval(XCHAN_FLAGS_HIDDEN) ); @@ -125,6 +134,7 @@ function dirsearch_content(&$a) { $entry = array(); $entry['name'] = $rr['xchan_name']; + $entry['updated'] = (($rr['ud_date']) ? $rr['ud_date'] : '0000-00-00 00:00:00'); $entry['url'] = $rr['xchan_url']; $entry['photo'] = $rr['xchan_photo_m']; $entry['address'] = $rr['xchan_addr']; |