From 9800d95c50d457440969e5419cb4a7742c57eedd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 Apr 2019 23:19:04 -0700 Subject: fix suggestion ordering in directory module --- Zotlabs/Module/Directory.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 5448a4816..f26040629 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -212,12 +212,17 @@ class Directory extends \Zotlabs\Web\Controller { if($j) { if($j['results']) { - + + $results = $j['results']; + if($suggest) { + $results = self::reorder_results($results,$addresses); + } + $entries = array(); $photo = 'thumb'; - foreach($j['results'] as $rr) { + foreach($results as $rr) { $profile_link = chanlink_url($rr['url']); @@ -438,5 +443,22 @@ class Directory extends \Zotlabs\Web\Controller { return $o; } - + static public function reorder_results($results,$suggests) { + + if(! $suggests) + return $results; + + $out = []; + foreach($suggests as $k => $v) { + foreach($results as $rv) { + if($k == $rv['address']) { + $out[intval($v)] = $rv; + break; + } + } + } + + return $out; + } + } -- cgit v1.2.3 From 9a55df245f4829900a3265fbb1cac56779e2b06e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 Apr 2019 23:38:48 -0700 Subject: disable directory options when using suggestion mode and only return one page (60 items) so that sorting works correctly --- Zotlabs/Module/Directory.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index f26040629..8f5db6635 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -103,8 +103,14 @@ class Directory extends \Zotlabs\Web\Controller { $suggest = (local_channel() && x($_REQUEST,'suggest')) ? $_REQUEST['suggest'] : ''; if($suggest) { - - $r = suggestion_query(local_channel(),get_observer_hash()); + + // the directory options have no effect in suggestion mode + + $globaldir = 1; + $safe_mode = 1; + $type = 0; + + $r = suggestion_query(local_channel(),get_observer_hash(),0,60); if(! $r) { notice( t('No default suggestions were found.') . EOL); -- cgit v1.2.3