From e11ff8bde564d0787f612ec9002f041d0634a1e6 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 5 May 2017 11:55:01 +0000 Subject: [PATCH] Issue 3428: Autocompletion now always show user@domain.tld --- include/acl_selectors.php | 10 ++++++---- js/autocomplete.js | 14 +++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index f57af575af..fbe5d1e692 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -543,7 +543,7 @@ function acl_lookup(App $a, $out_type = 'json') { if ($type == '') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' AND NOT (`network` IN ('%s', '%s')) $sql_extra2 @@ -552,7 +552,7 @@ function acl_lookup(App $a, $out_type = 'json') { dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET) ); } elseif ($type == 'c') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' AND NOT (`network` IN ('%s')) $sql_extra2 @@ -562,7 +562,7 @@ function acl_lookup(App $a, $out_type = 'json') { ); } elseif ($type == 'm') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `network` IN ('%s','%s','%s') $sql_extra2 @@ -573,7 +573,7 @@ function acl_lookup(App $a, $out_type = 'json') { dbesc(NETWORK_DIASPORA) ); } elseif ($type == 'a') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra2 ORDER BY `name` ASC ", @@ -617,6 +617,7 @@ function acl_lookup(App $a, $out_type = 'json') { 'network' => $g['network'], 'link' => $g['url'], 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), + 'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']), 'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0), ); } @@ -661,6 +662,7 @@ function acl_lookup(App $a, $out_type = 'json') { 'network' => $contact['network'], 'link' => $contact['url'], 'nick' => htmlentities($contact['nick'] ? : $contact['addr']), + 'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']), 'forum' => $contact['forum'] ); } diff --git a/js/autocomplete.js b/js/autocomplete.js index 3ed9fa30f9..58dde55a6d 100644 --- a/js/autocomplete.js +++ b/js/autocomplete.js @@ -78,22 +78,26 @@ function contact_format(item) { } function editor_replace(item) { - if(typeof item.replace !== 'undefined') { + if (typeof item.replace !== 'undefined') { return '$1$2' + item.replace; } + if (typeof item.addr !== 'undefined') { + return '$1$2' + item.addr + ' '; + } + // $2 ensures that prefix (@,@!) is preserved var id = item.id; // don't add the id if it is empty (the id empty eg. if there are unknow contacts in thread) - if(id.length < 1) + if (id.length < 1) { return '$1$2' + item.nick.replace(' ', '') + ' '; - + } // 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way. // 16 chars is also the minimum length in the backend (otherwise it's interpreted as a local id). - if(id.length > 16) + if (id.length > 16) { id = item.id.substring(0,16); - + } return '$1$2' + item.nick.replace(' ', '') + '+' + id + ' '; }