Merge pull request #724 from pafcu/suggestionsindir
Show suggestions in directory
This commit is contained in:
commit
934172c2fc
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('include/socgraph.php');
|
||||||
require_once('include/dir_fns.php');
|
require_once('include/dir_fns.php');
|
||||||
require_once('include/widgets.php');
|
require_once('include/widgets.php');
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
@ -7,6 +8,12 @@ require_once('include/bbcode.php');
|
|||||||
function directory_init(&$a) {
|
function directory_init(&$a) {
|
||||||
$a->set_pager_itemspage(60);
|
$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) {
|
function directory_content(&$a) {
|
||||||
@ -43,14 +50,38 @@ function directory_content(&$a) {
|
|||||||
else
|
else
|
||||||
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
|
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
|
||||||
|
|
||||||
|
|
||||||
if(strpos($search,'=') && local_user() && get_pconfig(local_user(),'feature','expert'))
|
if(strpos($search,'=') && local_user() && get_pconfig(local_user(),'feature','expert'))
|
||||||
$advanced = $search;
|
$advanced = $search;
|
||||||
|
|
||||||
|
|
||||||
$keywords = (($_GET['keywords']) ? $_GET['keywords'] : '');
|
$keywords = (($_GET['keywords']) ? $_GET['keywords'] : '');
|
||||||
|
|
||||||
|
// Suggest channels if no search terms or keywords are given
|
||||||
|
$suggest = (local_user() && x($_REQUEST,'suggest')) ? $_REQUEST['suggest'] : '';
|
||||||
|
|
||||||
|
if($suggest) {
|
||||||
|
$r = suggestion_query(local_user(),get_observer_hash());
|
||||||
|
|
||||||
|
// Remember in which order the suggestions were
|
||||||
|
$addresses = array();
|
||||||
|
$index = 0;
|
||||||
|
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\" ";
|
||||||
|
}
|
||||||
|
// Remove last space in the advanced query
|
||||||
|
$advanced = rtrim($advanced);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$tpl = get_markup_template('directory_header.tpl');
|
$tpl = get_markup_template('directory_header.tpl');
|
||||||
|
|
||||||
|
|
||||||
$dirmode = intval(get_config('system','directory_mode'));
|
$dirmode = intval(get_config('system','directory_mode'));
|
||||||
|
|
||||||
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
|
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
|
||||||
@ -236,19 +267,28 @@ function directory_content(&$a) {
|
|||||||
'online' => $online,
|
'online' => $online,
|
||||||
'kw' => (($out) ? t('Keywords: ') : ''),
|
'kw' => (($out) ? t('Keywords: ') : ''),
|
||||||
'keywords' => $out,
|
'keywords' => $out,
|
||||||
|
'ignlink' => $suggest ? $a->get_baseurl() . '/directory?ignore=' . $rr['hash'] : '',
|
||||||
|
'ignore_label' => "Don't suggest",
|
||||||
);
|
);
|
||||||
|
|
||||||
$arr = array('contact' => $rr, 'entry' => $entry);
|
$arr = array('contact' => $rr, 'entry' => $entry);
|
||||||
|
|
||||||
call_hooks('directory_item', $arr);
|
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($profile);
|
||||||
unset($location);
|
unset($location);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ksort($entries); // Sort array by key so that foreach-constructs work as expected
|
||||||
|
|
||||||
if($j['keywords']) {
|
if($j['keywords']) {
|
||||||
$a->data['directory_keywords'] = $j['keywords'];
|
$a->data['directory_keywords'] = $j['keywords'];
|
||||||
}
|
}
|
||||||
@ -277,7 +317,7 @@ function directory_content(&$a) {
|
|||||||
'$finddsc' => t('Finding:'),
|
'$finddsc' => t('Finding:'),
|
||||||
'$safetxt' => htmlspecialchars($search,ENT_QUOTES,'UTF-8'),
|
'$safetxt' => htmlspecialchars($search,ENT_QUOTES,'UTF-8'),
|
||||||
'$entries' => $entries,
|
'$entries' => $entries,
|
||||||
'$dirlbl' => t('Directory'),
|
'$dirlbl' => $suggest ? t('Channel Suggestions') : t('Directory'),
|
||||||
'$submit' => t('Find'),
|
'$submit' => t('Find'),
|
||||||
'$next' => alt_pager($a,$j['records'], t('next page'), t('previous page'))
|
'$next' => alt_pager($a,$j['records'], t('next page'), t('previous page'))
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
{{if $entry.connect}}
|
{{if $entry.connect}}
|
||||||
<div class="directory-connect btn btn-default"><a href="{{$entry.connect}}"><i class="icon-plus connect-icon"></i> {{$entry.conn_label}}</a></div>
|
<div class="directory-connect btn btn-default"><a href="{{$entry.connect}}"><i class="icon-plus connect-icon"></i> {{$entry.conn_label}}</a></div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{if $entry.ignlink}}
|
||||||
|
<div class="directory-ignore btn btn-default"><a href="{{$entry.ignlink}}"> {{$entry.ignore_label}}</a></div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
{{if $similar}}<li><a href="match" >{{$similar}}</a></li>{{/if}}
|
{{if $similar}}<li><a href="match" >{{$similar}}</a></li>{{/if}}
|
||||||
{{if $loggedin}}<li><a href="suggest" >{{$suggest}}</a></li>{{/if}}
|
{{if $loggedin}}<li><a href="directory?suggest=1" >{{$suggest}}</a></li>{{/if}}
|
||||||
<li><a href="randprof" >{{$random}}</a></li>
|
<li><a href="randprof" >{{$random}}</a></li>
|
||||||
{{if $loggedin}}{{if $inv}}<li><a href="invite" >{{$inv}}</a></li>{{/if}}{{/if}}
|
{{if $loggedin}}{{if $inv}}<li><a href="invite" >{{$inv}}</a></li>{{/if}}{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
Reference in New Issue
Block a user