aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/directory.php74
-rw-r--r--mod/dirsearch.php116
2 files changed, 151 insertions, 39 deletions
diff --git a/mod/directory.php b/mod/directory.php
index 2ab1db108..c9332f447 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -36,14 +36,12 @@ function directory_content(&$a) {
$tpl = get_markup_template('directory_header.tpl');
- $dirmode = get_config('system','directory_mode');
- if($dirmode === false)
- $dirmode = DIRECTORY_MODE_NORMAL;
+ $dirmode = intval(get_config('system','directory_mode'));
- if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
- $localdir = true;
- return;
- }
+// if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
+// $localdir = true;
+// return;
+// }
// FIXME
$localdir = true;
@@ -65,23 +63,22 @@ $localdir = true;
if($localdir) {
if($search)
$search = dbesc($search);
- $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, channel.channel_address, `pdesc`, `locality`,`region`,`country_name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
+ $sql_extra = ((strlen($search)) ? " AND MATCH ( xchan_name, xchan_addr, xprof_desc, xprof_locale, xprof_region, xprof_country, xprof_gender, xprof_marital ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
-
- $r = q("SELECT COUNT(channel_id) AS `total` FROM channel left join profile on channel.channel_id = profile.uid WHERE `is_default` = 1 and not ( channel_pageflags & %d ) $sql_extra ",
- intval(PAGE_HIDDEN)
- );
+ // group_concat(xtag_term separator ', ') as tags
+ $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash $sql_extra");
if($r)
$a->set_pager_total($r[0]['total']);
- $order = " ORDER BY `name` ASC ";
+ $order = " ORDER BY `xchan_name` ASC ";
- $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, channel_name, channel_address, channel_hash, channel_timezone, channel_pageflags FROM `profile` LEFT JOIN channel ON channel_id = `profile`.`uid` WHERE `is_default` = 1 and not ( channel_pageflags & %d ) $sql_extra $order LIMIT %d , %d ",
- intval(PAGE_HIDDEN),
+ $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash $sql_extra $order LIMIT %d , %d ",
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
+
+
if($r) {
$entries = array();
@@ -90,42 +87,41 @@ $localdir = true;
foreach($r as $rr) {
- $profile_link = chanlink_hash($rr['channel_hash']);
+ $profile_link = chanlink_hash($rr['xchan_hash']);
- $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
+ $pdesc = (($rr['xprof_desc']) ? $rr['xprof_desc'] . '<br />' : '');
$details = '';
- if(strlen($rr['locality']))
- $details .= $rr['locality'];
- if(strlen($rr['region'])) {
- if(strlen($rr['locality']))
+ if(strlen($rr['xprof_locale']))
+ $details .= $rr['xprof_locale'];
+ if(strlen($rr['xprof_region'])) {
+ if(strlen($rr['xprof_locale']))
$details .= ', ';
- $details .= $rr['region'];
+ $details .= $rr['xprof_region'];
}
- if(strlen($rr['country_name'])) {
+ if(strlen($rr['xprof_country'])) {
if(strlen($details))
$details .= ', ';
- $details .= $rr['country_name'];
+ $details .= $rr['xprof_country'];
}
- if(strlen($rr['dob'])) {
- if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
+ if(strlen($rr['xprof_dob'])) {
+ if(($years = age($rr['xprof_dob'],'UTC','')) != 0)
$details .= '<br />' . t('Age: ') . $years ;
}
- if(strlen($rr['gender']))
- $details .= '<br />' . t('Gender: ') . $rr['gender'];
+ if(strlen($rr['xprof_gender']))
+ $details .= '<br />' . t('Gender: ') . $rr['xprof_gender'];
$page_type = '';
$profile = $rr;
- if((x($profile,'address') == 1)
- || (x($profile,'locality') == 1)
- || (x($profile,'region') == 1)
- || (x($profile,'postal_code') == 1)
- || (x($profile,'country_name') == 1))
+ if ((x($profile,'xprof_locale') == 1)
+ || (x($profile,'xprof_region') == 1)
+ || (x($profile,'xprof_postcode') == 1)
+ || (x($profile,'xprof_country') == 1))
$location = t('Location:');
- $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
+ $gender = ((x($profile,'xprof_gender') == 1) ? t('Gender:') : False);
$marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
@@ -133,14 +129,14 @@ $localdir = true;
$about = ((x($profile,'about') == 1) ? t('About:') : False);
-
+ $t = 0;
$entry = array(
- 'id' => $rr['id'],
+ 'id' => ++$t,
'profile_link' => $profile_link,
- 'photo' => $rr[$photo],
- 'alttext' => $rr['channel_name'],
- 'name' => $rr['channel_name'],
+ 'photo' => $rr[xchan_photo_m],
+ 'alttext' => $rr['xchan_name'],
+ 'name' => $rr['xchan_name'],
'details' => $pdesc . $details,
'profile' => $profile,
'location' => $location,
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
new file mode 100644
index 000000000..30a1fadae
--- /dev/null
+++ b/mod/dirsearch.php
@@ -0,0 +1,116 @@
+<?php
+
+require_once('include/dir_fns.php');
+
+
+function dirsearch_init(&$a) {
+ $a->set_pager_itemspage(60);
+
+}
+
+function dirsearch_content(&$a) {
+
+ $ret = array('success' => false);
+
+ // If you've got a public directory server, you probably shouldn't block public access
+
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ $ret['message'] = t('Public access denied.');
+ return;
+ }
+
+ $dirmode = intval(get_config('system','directory_mode'));
+
+ if($dirmode == DIRECTORY_MODE_NORMAL) {
+ $ret['message'] = t('This site is not a directory server');
+ return;
+ }
+
+ $name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : '');
+ $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'] : '');
+ $keywords = ((x($_REQUEST,'keywords')) ? $_REQUEST['keywords'] : '');
+
+
+ $sql_extra = '';
+
+ if($name)
+ $sql_extra .= " AND xchan_name like '" . protect_sprintf( '%' . dbesc($name) . '%' ) . "' ";
+ if($addr)
+ $sql_extra .= " AND xchan_addr like '" . protect_sprintf( '%' . dbesc($addr) . '%' ) . "' ";
+ if($city)
+ $sql_extra .= " AND xprof_locale like '" . protect_sprintf( '%' . dbesc($city) . '%' ) . "' ";
+ if($region)
+ $sql_extra .= " AND xprof_region like '" . protect_sprintf( '%' . dbesc($region) . '%' ) . "' ";
+ if($post)
+ $sql_extra .= " AND xprof_postcode like '" . protect_sprintf( '%' . dbesc($post) . '%' ) . "' ";
+ if($country)
+ $sql_extra .= " AND xprof_country like '" . protect_sprintf( '%' . dbesc($country) . '%' ) . "' ";
+ if($gender)
+ $sql_extra .= " AND xprof_gender like '" . protect_sprintf( '%' . dbesc($gender) . '%' ) . "' ";
+ if($marital)
+ $sql_extra .= " AND xprof_marital like '" . protect_sprintf( '%' . dbesc($marital) . '%' ) . "' ";
+ if($keywords)
+ $sql_extra .= " AND 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;
+
+ // ok a separate tag table won't work.
+ // merge them into xprof
+
+ $ret['success'] = true;
+
+ $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where 1 $sql_extra");
+ if($r) {
+ $ret['total_items'] = $r[0]['total'];
+ }
+
+ $order = " ORDER BY `xchan_name` ASC ";
+
+ $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where 1 $sql_extra $order LIMIT %d , %d ",
+ intval($startrec),
+ intval($perpage)
+ );
+
+ $ret['page'] = $page + 1;
+ $ret['records'] = count($r);
+
+ if($r) {
+
+ $entries = array();
+
+
+ foreach($r as $rr) {
+ $entry = array();
+
+ $entry['name'] = $rr['xchan_name'];
+ $entry['url'] = $rr['xchan_url'];
+ $entry['photo'] = $rr['xchan_photo_m'];
+ $entry['address'] = $rr['xchan_addr'];
+ $entry['description'] = $rr['xprof_desc'];
+ $entry['locale'] = $rr['xprof_locale'];
+ $entry['region'] = $rr['xprof_region'];
+ $entry['postcode'] = $rr['xprof_postcode'];
+ $entry['country'] = $rr['xprof_country'];
+ $entry['birthday'] = $rr['xprof_dob'];
+ $entry['gender'] = $rr['xprof_gender'];
+ $entry['marital'] = $rr['xprof_marital'];
+ $entry['keywords'] = $rr['xprof_keywords'];
+
+ $entries[] = $entry;
+
+ }
+
+ $ret['results'] = $entries;
+
+ }
+ json_return_and_die($ret);
+
+}