+ $unknown_contacts = [];
+
+ $condition = ["`parent` = ?", $conv_id];
+ $params = ['order' => ['author-name' => true]];
+ $authors = Item::selectForUser(local_user(), ['author-link'], $condition, $params);
+ $item_authors = [];
+ while ($author = Item::fetch($authors)) {
+ $item_authors[$author['author-link']] = $author['author-link'];
+ }
+ DBA::close($authors);
+
+ foreach ($item_authors as $author) {
+ if (in_array($author, $known_contacts)) {
+ continue;
+ }
+
+ $contact = Contact::getDetailsByURL($author);
+
+ if (count($contact) > 0) {
+ $unknown_contacts[] = [
+ 'type' => 'c',
+ 'photo' => ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO),
+ 'name' => htmlentities($contact['name']),
+ 'id' => intval($contact['cid']),
+ 'network' => $contact['network'],
+ 'link' => $contact['url'],
+ 'nick' => htmlentities(defaults($contact, 'nick', $contact['addr'])),
+ 'addr' => htmlentities(defaults($contact, 'addr', $contact['url'])),
+ 'forum' => $contact['forum']
+ ];
+ }
+ }
+
+ $items = array_merge($items, $unknown_contacts);
+ $tot += count($unknown_contacts);
+ }
+
+ $results = [
+ 'tot' => $tot,
+ 'start' => $start,
+ 'count' => $count,
+ 'groups' => $groups,
+ 'contacts' => $contacts,
+ 'items' => $items,
+ 'type' => $type,
+ 'search' => $search,
+ ];
+
+ Addon::callHooks('acl_lookup_end', $results);
+
+ $o = [
+ 'tot' => $results['tot'],
+ 'start' => $results['start'],
+ 'count' => $results['count'],
+ 'items' => $results['items'],
+ ];
+
+ echo json_encode($o);
+ exit;
+}