*
* Once the global contact is stored add (if necessary) the contact linkage which associates
* the given uid, cid to the global contact entry. There can be many uid/cid combinations
- * pointing to the same global contact id.
+ * pointing to the same global contact id.
*
*/
-
+
if(! $url)
return;
- $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos,updated') ;
+ $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network' : '?fields=displayName,urls,photos,updated,network') ;
logger('poco_load: ' . $url, LOGGER_DEBUG);
$profile_photo = '';
$connect_url = '';
$name = '';
+ $network = '';
$updated = '0000-00-00 00:00:00';
$name = $entry->displayName;
if(isset($entry->updated))
$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
- poco_check($profile_url, $name, $profile_photo, $connect_url, $updated, $cid, $uid, $zcid);
+ if(isset($entry->network))
+ $network = $entry->network;
+
+ poco_check($profile_url, $name, $network, $profile_photo, $connect_url, $updated, $cid, $uid, $zcid);
}
logger("poco_load: loaded $total entries",LOGGER_DEBUG);
}
-function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated, $cid = 0, $uid = 0, $zcid = 0) {
+function poco_check($profile_url, $name, $network, $profile_photo, $connect_url, $updated, $cid = 0, $uid = 0, $zcid = 0) {
$gcid = "";
if (($profile_url == "") OR ($name == "") OR ($profile_photo == ""))
$gcid = $x[0]['id'];
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) {
- q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `updated` = '%s'
+ q("update gcontact set `name` = '%s', `network` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `updated` = '%s'
where `nurl` = '%s'",
dbesc($name),
+ dbesc($network),
dbesc($profile_photo),
dbesc($connect_url),
dbesc($profile_url),
);
}
} else {
- q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`, `updated`)
- values ('%s', '%s', '%s', '%s','%s', '%s')",
+ q("insert into `gcontact` (`name`,`network`, `url`,`nurl`,`photo`,`connect`, `updated`)
+ values ('%s', '%s', '%s', '%s', '%s','%s', '%s')",
dbesc($name),
+ dbesc($network),
dbesc($profile_url),
dbesc(normalise_link($profile_url)),
dbesc($profile_photo),
if($shuffle)
$sql_extra = " order by rand() ";
else
- $sql_extra = " order by `gcontact`.`name` asc ";
+ $sql_extra = " order by `gcontact`.`name` asc ";
- $r = q("SELECT `gcontact`.*
+ $r = q("SELECT `gcontact`.*
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d )
function count_common_friends_zcid($uid,$zcid) {
- $r = q("SELECT count(*) as `total`
+ $r = q("SELECT count(*) as `total`
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`zcid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ",
if($shuffle)
$sql_extra = " order by rand() ";
else
- $sql_extra = " order by `gcontact`.`name` asc ";
+ $sql_extra = " order by `gcontact`.`name` asc ";
- $r = q("SELECT `gcontact`.*
+ $r = q("SELECT `gcontact`.*
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`zcid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
function all_friends($uid,$cid,$start = 0, $limit = 80) {
- $r = q("SELECT `gcontact`.*
+ $r = q("SELECT `gcontact`.*
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
- where `glink`.`cid` = %d and `glink`.`uid` = %d
+ where `glink`.`cid` = %d and `glink`.`uid` = %d
order by `gcontact`.`name` asc LIMIT %d, %d ",
intval($cid),
intval($uid),
if(! $uid)
return array();
+ $network = array("", NETWORK_DFRN);
+
+ if (get_config('system','diaspora_enabled'))
+ $network[] = NETWORK_DIASPORA;
+
+ if (!get_config('system','ostatus_disabled'))
+ $network[] = NETWORK_OSTATUS;
+
+ $sql_network = implode("', '", $network);
+ $sql_network = substr($sql_network, 2)."', ''";
+
$r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
INNER JOIN glink on glink.gcid = gcontact.id
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
and not gcontact.name in ( select name from contact where uid = %d )
and not gcontact.id in ( select gcid from gcign where uid = %d )
AND `gcontact`.`updated` != '0000-00-00 00:00:00'
+ AND `gcontact`.`network` IN (%s)
group by glink.gcid order by gcontact.updated desc,total desc limit %d, %d ",
intval($uid),
intval($uid),
intval($uid),
intval($uid),
+ $sql_network,
intval($start),
intval($limit)
);
and not gcontact.name in ( select name from contact where uid = %d )
and not gcontact.id in ( select gcid from gcign where uid = %d )
AND `gcontact`.`updated` != '0000-00-00 00:00:00'
+ AND `gcontact`.`network` IN (%s)
order by rand() limit %d, %d ",
intval($uid),
intval($uid),
intval($uid),
+ $sql_network,
intval($start),
intval($limit)
);
$sql_extra = sprintf(" AND `contact`.`id` = %d ",intval($cid));
if($system_mode) {
- $r = q("SELECT count(*) AS `total` FROM `contact` WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '')
+ $r = q("SELECT count(*) AS `total` FROM `contact` WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '%s', '')
AND `uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) ",
dbesc(NETWORK_DFRN),
dbesc(NETWORK_DIASPORA),
- dbesc(NETWORK_OSTATUS)
+ dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_STATUSNET)
);
}
else {
$r = q("SELECT count(*) AS `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
- AND `network` IN ('%s', '%s', '%s', '') $sql_extra",
+ AND `network` IN ('%s', '%s', '%s', '%s', '') $sql_extra",
intval($user['uid']),
dbesc(NETWORK_DFRN),
dbesc(NETWORK_DIASPORA),
- dbesc(NETWORK_OSTATUS)
+ dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_STATUSNET)
);
}
if(count($r))
if($system_mode) {
- $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '')
+ $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '%s', '')
AND `uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d",
dbesc(NETWORK_DFRN),
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_STATUSNET),
intval($startIndex),
intval($itemsPerPage)
);
}
else {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
- AND `network` IN ('%s', '%s', '%s', '') $sql_extra LIMIT %d, %d",
+ AND `network` IN ('%s', '%s', '%s', '%s', '') $sql_extra LIMIT %d, %d",
intval($user['uid']),
dbesc(NETWORK_DFRN),
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_STATUSNET),
intval($startIndex),
intval($itemsPerPage)
);
'urls' => false,
'updated' => false,
'preferredUsername' => false,
- 'photos' => false
+ 'photos' => false,
+ 'network' => false
);
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
}
if($fields_ret['photos'])
$entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile'));
+ if($fields_ret['network']) {
+ $entry['network'] = $rr['network'];
+ if ($entry['network'] == NETWORK_STATUSNET)
+ $entry['network'] = NETWORK_OSTATUS;
+ }
$ret['entry'][] = $entry;
}
}