aboutsummaryrefslogtreecommitdiffstats
path: root/mod/dirsearch.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/dirsearch.php')
-rw-r--r--mod/dirsearch.php68
1 files changed, 52 insertions, 16 deletions
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index 7e4323da9..524f55cc1 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -22,15 +22,20 @@ function dirsearch_content(&$a) {
json_return_and_die($ret);
}
- $name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : '');
- $address = ((x($_REQUEST,'address')) ? $_REQUEST['address'] : '');
- $locale = ((x($_REQUEST,'locale')) ? $_REQUEST['locale'] : '');
- $region = ((x($_REQUEST,'region')) ? $_REQUEST['region'] : '');
+ $name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : '');
+ $hub = ((x($_REQUEST,'hub')) ? $_REQUEST['hub'] : '');
+ $address = ((x($_REQUEST,'address')) ? $_REQUEST['address'] : '');
+ $locale = ((x($_REQUEST,'locale')) ? $_REQUEST['locale'] : '');
+ $region = ((x($_REQUEST,'region')) ? $_REQUEST['region'] : '');
$postcode = ((x($_REQUEST,'postcode')) ? $_REQUEST['postcode'] : '');
- $country = ((x($_REQUEST,'country')) ? $_REQUEST['country'] : '');
- $gender = ((x($_REQUEST,'gender')) ? $_REQUEST['gender'] : '');
- $marital = ((x($_REQUEST,'marital')) ? $_REQUEST['marital'] : '');
+ $country = ((x($_REQUEST,'country')) ? $_REQUEST['country'] : '');
+ $gender = ((x($_REQUEST,'gender')) ? $_REQUEST['gender'] : '');
+ $marital = ((x($_REQUEST,'marital')) ? $_REQUEST['marital'] : '');
$keywords = ((x($_REQUEST,'keywords')) ? $_REQUEST['keywords'] : '');
+ $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
@@ -38,6 +43,8 @@ function dirsearch_content(&$a) {
if($name)
$sql_extra .= " OR xchan_name like '" . protect_sprintf( '%' . dbesc($name) . '%' ) . "' ";
+ if($hub)
+ $sql_extra .= " OR xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') ";
if($address)
$sql_extra .= " OR xchan_addr like '" . protect_sprintf( '%' . dbesc($address) . '%' ) . "' ";
if($city)
@@ -55,12 +62,23 @@ function dirsearch_content(&$a) {
if($keywords)
$sql_extra .= " OR xprof_keywords like '" . protect_sprintf( '%' . dbesc($keywords) . '%' ) . "' ";
- $perpage = (($_REQUEST['n']) ? $_REQUEST['n'] : 80);
- $page = (($_REQUEST['p']) ? intval($_REQUEST['p'] - 1) : 0);
- $startrec = (($page+1) * $perpage) - $perpage;
- $limit = (($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 0);
+ // we only support an age range currently. You must set both agege
+ // (greater than or equal) and agele (less than or equal)
+
+ if($agele && $agege) {
+ $sql_extra .= " OR ( xprof_age <= " . intval($agele) . " ";
+ $sql_extra .= " AND xprof_age >= " . intval($agege) . ") ";
+ }
+
+ $perpage = (($_REQUEST['n']) ? $_REQUEST['n'] : 80);
+ $page = (($_REQUEST['p']) ? intval($_REQUEST['p'] - 1) : 0);
+ $startrec = (($page+1) * $perpage) - $perpage;
+ $limit = (($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 0);
$return_total = ((x($_REQUEST,'return_total')) ? intval($_REQUEST['return_total']) : 0);
+
+ $mtime = ((x($_REQUEST,'mtime')) ? datetime_convert('UTC','UTC',$_REQUEST['mtime']) : '');
+
// ok a separate tag table won't work.
// merge them into xprof
@@ -77,8 +95,9 @@ function dirsearch_content(&$a) {
else {
$qlimit = " LIMIT " . intval($startrec) . " , " . intval($perpage);
if($return_total) {
- $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d) ",
- intval(XCHAN_FLAGS_HIDDEN)
+ $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d) and not ( xchan_flags & %d ) ",
+ intval(XCHAN_FLAGS_HIDDEN),
+ intval(XCHAN_FLAGS_ORPHAN)
);
if($r) {
$ret['total_items'] = $r[0]['total'];
@@ -86,10 +105,23 @@ function dirsearch_content(&$a) {
}
}
- $order = " ORDER BY `xchan_name` ASC ";
+ if($mtime) {
+ $qlimit = '';
+ $sql_extra .= " and xchan_hash in ( select ud_hash from updates where ud_date > '" . dbesc($mtime) . "' ) ";
+ }
+
+ 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 ",
- intval(XCHAN_FLAGS_HIDDEN)
+
+ $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 ) and not ( xchan_flags & %d ) $order $qlimit ",
+ intval(XCHAN_FLAGS_HIDDEN),
+ intval(XCHAN_FLAGS_ORPHAN)
);
$ret['page'] = $page + 1;
@@ -104,6 +136,9 @@ function dirsearch_content(&$a) {
$entry = array();
$entry['name'] = $rr['xchan_name'];
+ $entry['hash'] = $rr['xchan_hash'];
+
+ $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'];
@@ -113,6 +148,7 @@ function dirsearch_content(&$a) {
$entry['postcode'] = $rr['xprof_postcode'];
$entry['country'] = $rr['xprof_country'];
$entry['birthday'] = $rr['xprof_dob'];
+ $entry['age'] = $rr['xprof_age'];
$entry['gender'] = $rr['xprof_gender'];
$entry['marital'] = $rr['xprof_marital'];
$entry['keywords'] = $rr['xprof_keywords'];