aboutsummaryrefslogtreecommitdiffstats
path: root/mod/directory.php
diff options
context:
space:
mode:
authorRedMatrix <info@friendica.com>2014-11-19 09:06:36 +1100
committerRedMatrix <info@friendica.com>2014-11-19 09:06:36 +1100
commit39178806736de54cbb0fda20b6bb65779136b9a5 (patch)
treeaba27c55669755957010d69510cc14ed995dc6bc /mod/directory.php
parentf137f50e3b8a17f33b978bd13b72e64af249bab3 (diff)
parente0ab1e24e43e60cec955f82b1d4618050efebeac (diff)
downloadvolse-hubzilla-39178806736de54cbb0fda20b6bb65779136b9a5.tar.gz
volse-hubzilla-39178806736de54cbb0fda20b6bb65779136b9a5.tar.bz2
volse-hubzilla-39178806736de54cbb0fda20b6bb65779136b9a5.zip
Merge pull request #702 from pafcu/master
Directory shows channel suggestions by default
Diffstat (limited to 'mod/directory.php')
-rw-r--r--mod/directory.php42
1 files changed, 40 insertions, 2 deletions
diff --git a/mod/directory.php b/mod/directory.php
index d4a4c383a..ee064e3ed 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -1,5 +1,6 @@
<?php
+require_once('include/socgraph.php');
require_once('include/dir_fns.php');
require_once('include/widgets.php');
require_once('include/bbcode.php');
@@ -7,6 +8,12 @@ require_once('include/bbcode.php');
function directory_init(&$a) {
$a->set_pager_itemspage(60);
+ if(x($_GET,'ignore')) {
+ q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
+ intval(local_user()),
+ dbesc($_GET['ignore'])
+ );
+ }
}
function directory_content(&$a) {
@@ -42,11 +49,33 @@ function directory_content(&$a) {
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
+
if(strpos($search,'=') && local_user() && get_pconfig(local_user(),'feature','expert'))
$advanced = $search;
+
$keywords = (($_GET['keywords']) ? $_GET['keywords'] : '');
+ // Suggest channels if no search terms or keywords are given
+ $suggest = ($search == '' && $keywords == '' && local_user());
+
+ if($suggest) {
+ $r = suggestion_query(local_user(),get_observer_hash());
+
+ // Remember in which order the suggestions were
+ $addresses = array();
+ foreach($r as $rr) {
+ $addresses[$rr['xchan_addr']] = $index++;
+ }
+
+ // Build query to get info about suggested people
+ $advanced = '';
+ foreach(array_keys($addresses) as $address) {
+ $advanced .= "address=\"$address\" ";
+ }
+
+ }
+
$tpl = get_markup_template('directory_header.tpl');
@@ -227,19 +256,28 @@ function directory_content(&$a) {
'online' => $online,
'kw' => (($out) ? t('Keywords: ') : ''),
'keywords' => $out,
+ 'ignlink' => $suggest ? $a->get_baseurl() . '/directory?ignore=' . $rr['hash'] : '',
+ 'ignore_label' => "Don't suggest",
);
$arr = array('contact' => $rr, 'entry' => $entry);
call_hooks('directory_item', $arr);
- $entries[] = $arr['entry'];
+ if($sort_order == '' && $suggest) {
+ $entries[$addresses[$rr['address']]] = $arr['entry']; // Use the same indexes as originally to get the best suggestion first
+ }
+ else {
+ $entries[] = $arr['entry'];
+ }
unset($profile);
unset($location);
}
+ ksort($entries); // Sort array by key so that foreach-constructs work as expected
+
if($j['keywords']) {
$a->data['directory_keywords'] = $j['keywords'];
}
@@ -268,7 +306,7 @@ function directory_content(&$a) {
'$finddsc' => t('Finding:'),
'$safetxt' => htmlspecialchars($search,ENT_QUOTES,'UTF-8'),
'$entries' => $entries,
- '$dirlbl' => t('Directory'),
+ '$dirlbl' => $suggest ? t('Channel Suggestions') : t('Directory'),
'$submit' => t('Find'),
'$next' => alt_pager($a,$j['records'], t('next page'), t('previous page'))