make poco work again
This commit is contained in:
parent
7082d198c2
commit
061a279ed3
65
mod/poco.php
65
mod/poco.php
@ -8,6 +8,9 @@ function poco_init(&$a) {
|
|||||||
http_status_exit(401);
|
http_status_exit(401);
|
||||||
|
|
||||||
|
|
||||||
|
$observer = $a->get_observer();
|
||||||
|
|
||||||
|
|
||||||
if(argc() > 1) {
|
if(argc() > 1) {
|
||||||
$user = notags(trim(argv(1)));
|
$user = notags(trim(argv(1)));
|
||||||
}
|
}
|
||||||
@ -36,35 +39,38 @@ function poco_init(&$a) {
|
|||||||
|
|
||||||
if(! $system_mode) {
|
if(! $system_mode) {
|
||||||
|
|
||||||
$r = q("SELECT `user`.*,`profile`.`hide_friends` from user left join profile on `user`.`uid` = `profile`.`uid`
|
$r = q("SELECT channel.channel_id from channel where channel_address = '%s' limit 1",
|
||||||
where `user`.`nickname` = '%s' and `profile`.`is_default` = 1 limit 1",
|
|
||||||
dbesc($user)
|
dbesc($user)
|
||||||
);
|
);
|
||||||
if(! count($r) || $r[0]['hidewall'] || $r[0]['hide_friends'])
|
if(! $r)
|
||||||
|
http_status_exit(404);
|
||||||
|
|
||||||
|
$channel_id = $r[0]['channel_id'];
|
||||||
|
|
||||||
|
if(! perm_is_allowed($channel_id,$observer,'view_contacts'))
|
||||||
http_status_exit(404);
|
http_status_exit(404);
|
||||||
|
|
||||||
$user = $r[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($justme)
|
if($justme)
|
||||||
$sql_extra = " and `contact`.`self` = 1 ";
|
$sql_extra = " and ( abook_flags & " . ABOOK_FLAG_SELF . " ) ";
|
||||||
else
|
else
|
||||||
$sql_extra = " and `contact`.`self` = 0 ";
|
$sql_extra = " and abook_flags = 0 ";
|
||||||
|
|
||||||
if($cid)
|
if($cid)
|
||||||
$sql_extra = sprintf(" and `contact`.`id` = %d ",intval($cid));
|
$sql_extra = sprintf(" and abook_id = %d ",intval($cid));
|
||||||
|
|
||||||
if($system_mode) {
|
if($system_mode) {
|
||||||
$r = q("SELECT count(*) as `total` from `contact` where self = 1
|
$r = q("SELECT count(*) as `total` from abook where ( abook_flags & " . ABOOK_FLAG_SELF .
|
||||||
and uid in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) ");
|
" ) and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$r = q("SELECT count(*) as `total` from `contact` where `uid` = %d and blocked = 0 and pending = 0 and hidden = 0
|
$r = q("SELECT count(*) as `total` from abook where abook_channel = %d
|
||||||
$sql_extra ",
|
$sql_extra ",
|
||||||
intval($user['uid'])
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(count($r))
|
if($r)
|
||||||
$totalResults = intval($r[0]['total']);
|
$totalResults = intval($r[0]['total']);
|
||||||
else
|
else
|
||||||
$totalResults = 0;
|
$totalResults = 0;
|
||||||
@ -76,21 +82,21 @@ function poco_init(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
if($system_mode) {
|
if($system_mode) {
|
||||||
$r = q("SELECT * from contact where self = 1
|
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where ( abook_flags & " . ABOOK_FLAG_SELF .
|
||||||
and uid in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) limit %d, %d ",
|
" ) and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) limit %d, %d ",
|
||||||
intval($startIndex),
|
intval($startIndex),
|
||||||
intval($itemsPerPage)
|
intval($itemsPerPage)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d
|
||||||
$r = q("SELECT * from `contact` where `uid` = %d and blocked = 0 and pending = 0 and hidden = 0
|
|
||||||
$sql_extra LIMIT %d, %d",
|
$sql_extra LIMIT %d, %d",
|
||||||
intval($user['uid']),
|
intval($channel_id),
|
||||||
intval($startIndex),
|
intval($startIndex),
|
||||||
intval($itemsPerPage)
|
intval($itemsPerPage)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
if(x($_GET,'sorted'))
|
if(x($_GET,'sorted'))
|
||||||
$ret['sorted'] = 'false';
|
$ret['sorted'] = 'false';
|
||||||
@ -107,10 +113,16 @@ function poco_init(&$a) {
|
|||||||
|
|
||||||
$fields_ret = array(
|
$fields_ret = array(
|
||||||
'id' => false,
|
'id' => false,
|
||||||
|
'guid' => false,
|
||||||
|
'guid_sig' => false,
|
||||||
|
'hash' => false,
|
||||||
'displayName' => false,
|
'displayName' => false,
|
||||||
'urls' => false,
|
'urls' => false,
|
||||||
'preferredUsername' => false,
|
'preferredUsername' => false,
|
||||||
'photos' => false
|
'photos' => false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
|
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
|
||||||
@ -127,18 +139,25 @@ function poco_init(&$a) {
|
|||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
$entry = array();
|
$entry = array();
|
||||||
if($fields_ret['id'])
|
if($fields_ret['id'])
|
||||||
$entry['id'] = $rr['id'];
|
$entry['id'] = $rr['abook_id'];
|
||||||
|
if($fields_ret['guid'])
|
||||||
|
$entry['guid'] = $rr['xchan_guid'];
|
||||||
|
if($fields_ret['guid_sig'])
|
||||||
|
$entry['guid_sig'] = $rr['xchan_guid_sig'];
|
||||||
|
if($fields_ret['hash'])
|
||||||
|
$entry['hash'] = $rr['xchan_hash'];
|
||||||
|
|
||||||
if($fields_ret['displayName'])
|
if($fields_ret['displayName'])
|
||||||
$entry['displayName'] = $rr['name'];
|
$entry['displayName'] = $rr['xchan_name'];
|
||||||
if($fields_ret['urls']) {
|
if($fields_ret['urls']) {
|
||||||
$entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile'));
|
$entry['urls'] = array(array('value' => $rr['xchan_url'], 'type' => 'profile'));
|
||||||
if($rr['addr'] && ($rr['network'] !== NETWORK_MAIL))
|
if($rr['addr'] && ($rr['network'] !== NETWORK_MAIL))
|
||||||
$entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger');
|
$entry['urls'][] = array('value' => 'acct:' . $rr['xchan_addr'], 'type' => 'zot');
|
||||||
}
|
}
|
||||||
if($fields_ret['preferredUsername'])
|
if($fields_ret['preferredUsername'])
|
||||||
$entry['preferredUsername'] = $rr['nick'];
|
$entry['preferredUsername'] = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@'));
|
||||||
if($fields_ret['photos'])
|
if($fields_ret['photos'])
|
||||||
$entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile'));
|
$entry['photos'] = array(array('value' => $rr['xchan_photo_l'], 'mimetype' => $rr['xchan_photo_mimetype'], 'type' => 'profile'));
|
||||||
$ret['entry'][] = $entry;
|
$ret['entry'][] = $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user