aboutsummaryrefslogtreecommitdiffstats
path: root/mod/directory.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/directory.php')
-rw-r--r--mod/directory.php72
1 files changed, 52 insertions, 20 deletions
diff --git a/mod/directory.php b/mod/directory.php
index 329e255cf..3e94d6395 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -14,6 +14,31 @@ function directory_init(&$a) {
dbesc($_GET['ignore'])
);
}
+
+ $observer = get_observer_hash();
+ $global_changed = false;
+ $safe_changed = false;
+
+ if(array_key_exists('global',$_REQUEST)) {
+ $globaldir = intval($_REQUEST['global']);
+ $global_changed = true;
+ }
+ if($global_changed) {
+ $_SESSION['globaldir'] = $globaldir;
+ if($observer)
+ set_xconfig($observer,'directory','globaldir',$globaldir);
+ }
+
+ if(array_key_exists('safe',$_REQUEST)) {
+ $safemode = intval($_REQUEST['safe']);
+ $safe_changed = true;
+ }
+ if($safe_changed) {
+ $_SESSION['safemode'] = $safemode;
+ if($observer)
+ set_xconfig($observer,'directory','safe_mode',$safemode);
+ }
+
}
function directory_content(&$a) {
@@ -23,24 +48,20 @@ function directory_content(&$a) {
return;
}
- $safe_mode = 1;
-
$observer = get_observer_hash();
-
- if($observer) {
- $safe_mode = get_xconfig($observer,'directory','safe_mode');
- }
- if($safe_mode === false)
- $safe_mode = 1;
- else
- $safe_mode = intval($safe_mode);
- if(x($_REQUEST,'safe'))
- $safe_mode = (intval($_REQUEST['safe']));
+ $globaldir = get_globaldir_setting($observer);
+ // override your personal global search pref if we're doing a navbar search of the directory
+ if(intval($_REQUEST['navsearch']))
+ $globaldir = 1;
+
+ $safe_mode = get_safemode_setting($observer);
$pubforums = null;
if(array_key_exists('pubforums',$_REQUEST))
$pubforums = intval($_REQUEST['pubforums']);
+ if(! $pubforums)
+ $pubforums = null;
$o = '';
nav_set_selected('directory');
@@ -61,12 +82,15 @@ function directory_content(&$a) {
$suggest = (local_channel() && x($_REQUEST,'suggest')) ? $_REQUEST['suggest'] : '';
if($suggest) {
+
$r = suggestion_query(local_channel(),get_observer_hash());
// Remember in which order the suggestions were
$addresses = array();
+ $common = array();
$index = 0;
foreach($r as $rr) {
+ $common[$rr['xchan_addr']] = $rr['total'];
$addresses[$rr['xchan_addr']] = $index++;
}
@@ -92,6 +116,9 @@ function directory_content(&$a) {
$url = $directory['url'] . '/dirsearch';
}
+ $token = get_config('system','realm_token');
+
+
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
$contacts = array();
@@ -106,16 +133,20 @@ function directory_content(&$a) {
}
}
-
-
if($url) {
// We might want to make the tagadelic count (&kw=) configurable or turn it off completely.
$numtags = get_config('system','directorytags');
- $kw = ((intval($numtags)) ? $numtags : 24);
+ $kw = ((intval($numtags)) ? $numtags : 50);
$query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : '');
+ if($token)
+ $query .= '&t=' . $token;
+
+ if(! $globaldir)
+ $query .= '&hub=' . get_app()->get_hostname();
+
if($search)
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
if(strpos($search,'@'))
@@ -127,15 +158,14 @@ function directory_content(&$a) {
if(! is_null($pubforums))
$query .= '&pubforums=' . intval($pubforums);
- if(! is_null($pubforums))
- $query .= '&pubforums=' . intval($pubforums);
+ $directory_sort_order = get_config('system','directory_sort_order');
+ if(! $directory_sort_order)
+ $directory_sort_order = 'date';
- $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : 'normal');
+ $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : $directory_sort_order);
if($sort_order)
$query .= '&order=' . urlencode($sort_order);
-
-
if($a->pager['page'] != 1)
$query .= '&p=' . $a->pager['page'];
@@ -277,6 +307,8 @@ function directory_content(&$a) {
'keywords' => $out,
'ignlink' => $suggest ? $a->get_baseurl() . '/directory?ignore=' . $rr['hash'] : '',
'ignore_label' => "Don't suggest",
+ 'common_friends' => (($common[$rr['address']]) ? intval($common[$rr['address']]) : ''),
+ 'common_txt' => sprintf( t('Common connections: %s'), intval($common[$rr['address']]) ),
'safe' => $safe_mode
);