Merge pull request #3319 from Hypolite/issue/#3316
Use get_contact_by_url for unknown contacts in acl_lookup
This commit is contained in:
commit
79e827417c
2 changed files with 31 additions and 27 deletions
|
@ -610,12 +610,18 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
$items = array_merge($groups, $contacts);
|
$items = array_merge($groups, $contacts);
|
||||||
|
|
||||||
if ($conv_id) {
|
if ($conv_id) {
|
||||||
/* if $conv_id is set, get unknow contacts in thread */
|
/*
|
||||||
/* but first get know contacts url to filter them out */
|
* if $conv_id is set, get unknown contacts in thread
|
||||||
function _contact_link($i){ return dbesc($i['link']); }
|
* but first get known contacts url to filter them out
|
||||||
$known_contacts = array_map(_contact_link, $contacts);
|
*/
|
||||||
$unknow_contacts=array();
|
$known_contacts = array_map(
|
||||||
$r = q("SELECT `author-avatar`,`author-name`,`author-link`
|
function ($i) {
|
||||||
|
return dbesc($i['link']);
|
||||||
|
}
|
||||||
|
, $contacts);
|
||||||
|
|
||||||
|
$unknown_contacts = array();
|
||||||
|
$r = q("SELECT `author-link`
|
||||||
FROM `item` WHERE `parent` = %d
|
FROM `item` WHERE `parent` = %d
|
||||||
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
|
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
|
||||||
AND `author-link` NOT IN ('%s')
|
AND `author-link` NOT IN ('%s')
|
||||||
|
@ -625,31 +631,29 @@ function acl_lookup(App $a, $out_type = 'json') {
|
||||||
intval($conv_id),
|
intval($conv_id),
|
||||||
dbesc($search),
|
dbesc($search),
|
||||||
dbesc($search),
|
dbesc($search),
|
||||||
implode("','", $known_contacts)
|
implode("', '", $known_contacts)
|
||||||
);
|
);
|
||||||
if (dbm::is_result($r)){
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $row) {
|
foreach ($r as $row) {
|
||||||
// nickname..
|
$contact = get_contact_details_by_url($row['author-link']);
|
||||||
$up = parse_url($row['author-link']);
|
|
||||||
$nick = explode("/",$up['path']);
|
if (count($contact) > 0) {
|
||||||
$nick = $nick[count($nick)-1];
|
$unknown_contacts[] = array(
|
||||||
$nick .= "@".$up['host'];
|
'type' => 'c',
|
||||||
// /nickname
|
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
|
||||||
$unknow_contacts[] = array(
|
'name' => htmlentities($contact['name']),
|
||||||
'type' => 'c',
|
'id' => intval($contact['cid']),
|
||||||
'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
|
'network' => $contact['network'],
|
||||||
'name' => htmlentities($row['author-name']),
|
'link' => $contact['url'],
|
||||||
'id' => '',
|
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
|
||||||
'network' => 'unknown',
|
'forum' => $contact['forum']
|
||||||
'link' => $row['author-link'],
|
);
|
||||||
'nick' => htmlentities($nick),
|
}
|
||||||
'forum' => false
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = array_merge($items, $unknow_contacts);
|
$items = array_merge($items, $unknown_contacts);
|
||||||
$tot += count($unknow_contacts);
|
$tot += count($unknown_contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = array(
|
$results = array(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/* ACL selector json backend */
|
/* ACL selector json backend */
|
||||||
|
|
||||||
require_once("include/acl_selectors.php");
|
require_once 'include/acl_selectors.php';
|
||||||
|
|
||||||
function acl_init(App $a) {
|
function acl_init(App $a) {
|
||||||
acl_lookup($a);
|
acl_lookup($a);
|
||||||
|
|
Loading…
Reference in a new issue