From ad5be2901e131ec28356c7bdbb3cd0f748ffaa54 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 3 Feb 2016 00:25:33 +0100 Subject: [PATCH] rework autocomplete: some styling if contact is forum --- include/acl_selectors.php | 11 +++++++---- include/dir_fns.php | 2 +- js/autocomplete.js | 5 +++-- view/theme/vier/style.css | 11 +++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 9e1a2642a..99848aa19 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -509,7 +509,7 @@ function acl_lookup(&$a, $out_type = 'json') { if ($type==''){ - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' AND NOT (`network` IN ('%s', '%s')) $sql_extra2 @@ -520,7 +520,7 @@ function acl_lookup(&$a, $out_type = 'json') { } elseif ($type=='c'){ - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' AND NOT (`network` IN ('%s')) $sql_extra2 @@ -542,7 +542,7 @@ function acl_lookup(&$a, $out_type = 'json') { ); } elseif($type == 'a') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra2 ORDER BY `name` ASC ", @@ -559,6 +559,9 @@ function acl_lookup(&$a, $out_type = 'json') { "photo" => $g['photo'], "name" => $g['name'], "nick" => (x($g['addr']) ? $g['addr'] : $g['url']), + "network" => $g['network'], + "link" => $g['url'], + "forum" => (x($g['community']) ? 1 : 0), ); } } @@ -584,7 +587,7 @@ function acl_lookup(&$a, $out_type = 'json') { "network" => $g['network'], "link" => $g['url'], "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), - "forum" => $g['forum'] + "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), ); } } diff --git a/include/dir_fns.php b/include/dir_fns.php index d25805876..5f018ed8c 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -38,7 +38,7 @@ class dir { $extra_sql = ""; $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`, - `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr` + `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community` FROM `gcontact` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d AND NOT `contact`.`blocked` diff --git a/js/autocomplete.js b/js/autocomplete.js index aa8b6836c..f31161ff8 100644 --- a/js/autocomplete.js +++ b/js/autocomplete.js @@ -24,7 +24,7 @@ function contact_search(term, callback, backend_url, type, mode) { if(lterm.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results // Filter old results locally var matching = contact_search.cache[bt][t].filter(function (x) { return (x.name.toLowerCase().indexOf(lterm) >= 0 || (typeof x.nick !== 'undefined' && x.nick.toLowerCase().indexOf(lterm) >= 0)); }); // Need to check that nick exists because groups don't have one - matching.unshift({taggable:false, text: term, replace: term}); + matching.unshift({forum:false, text: term, replace: term}); setTimeout(function() { callback(matching); } , 1); // Use "pseudo-thread" to avoid some problems return; } @@ -68,9 +68,10 @@ function contact_format(item) { // Show contact information if not explicitly told to show something else if(typeof item.text === 'undefined') { var desc = ((item.label) ? item.nick + ' ' + item.label : item.nick); + var forum = ((item.forum) ? 'forum' : ''); if(typeof desc === 'undefined') desc = ''; if(desc) desc = ' ('+desc+')'; - return "