Merge pull request #1285 from annando/1501-enhanced-poco
"location" and "about" for contacts, improved suggestions, improved contacts exchange
This commit is contained in:
commit
a21fe4059b
7
boot.php
7
boot.php
|
@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
|||
define ( 'FRIENDICA_CODENAME', 'Ginger');
|
||||
define ( 'FRIENDICA_VERSION', '3.3.2' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||
define ( 'DB_UPDATE_VERSION', 1176 );
|
||||
define ( 'DB_UPDATE_VERSION', 1177 );
|
||||
define ( 'EOL', "<br />\r\n" );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||
|
||||
|
@ -1649,8 +1649,10 @@ if(! function_exists('profile_sidebar')) {
|
|||
|
||||
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
|
||||
|
||||
$about = ((x($profile,'about') == 1) ? t('About:') : False);
|
||||
|
||||
if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
|
||||
$location = $pdesc = $gender = $marital = $homepage = False;
|
||||
$location = $pdesc = $gender = $marital = $homepage = $about = False;
|
||||
}
|
||||
|
||||
$firstname = ((strpos($profile['name'],' '))
|
||||
|
@ -1695,6 +1697,7 @@ if(! function_exists('profile_sidebar')) {
|
|||
'$pdesc' => $pdesc,
|
||||
'$marital' => $marital,
|
||||
'$homepage' => $homepage,
|
||||
'$about' => $about,
|
||||
'$network' => t('Network:'),
|
||||
'$diaspora' => $diaspora,
|
||||
'$contact_block' => $contact_block,
|
||||
|
|
|
@ -750,5 +750,14 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
|||
|
||||
logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);
|
||||
|
||||
// Trying if it maybe a diaspora account
|
||||
if ($result['network'] == NETWORK_FEED) {
|
||||
require_once('include/bbcode.php');
|
||||
$address = GetProfileUsername($url, "", true);
|
||||
$result2 = probe_url($address, $mode);
|
||||
if ($result2['network'] != "")
|
||||
$result = $result2;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -413,6 +413,8 @@ function db_definition() {
|
|||
"network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"about" => array("type" => "text", "not null" => "1"),
|
||||
"attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"photo" => array("type" => "text", "not null" => "1"),
|
||||
"thumb" => array("type" => "text", "not null" => "1"),
|
||||
|
@ -616,6 +618,8 @@ function db_definition() {
|
|||
"nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
|
||||
"network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
@ -1248,6 +1252,8 @@ function db_definition() {
|
|||
"nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"about" => array("type" => "text", "not null" => "1"),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
|
|
|
@ -2028,7 +2028,7 @@ function diaspora_retraction($importer,$xml) {
|
|||
dbesc(datetime_convert()),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
delete_thread($r[0]['id']);
|
||||
delete_thread($r[0]['id'], $r[0]['parent-uri']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2101,7 +2101,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
|
|||
dbesc(datetime_convert()),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
delete_thread($r[0]['id']);
|
||||
delete_thread($r[0]['id'], $r[0]['parent-uri']);
|
||||
|
||||
// Now check if the retraction needs to be relayed by us
|
||||
//
|
||||
|
@ -2161,14 +2161,15 @@ function diaspora_profile($importer,$xml,$msg) {
|
|||
$name = unxmlify($xml->first_name) . ((strlen($xml->last_name)) ? ' ' . unxmlify($xml->last_name) : '');
|
||||
$image_url = unxmlify($xml->image_url);
|
||||
$birthday = unxmlify($xml->birthday);
|
||||
$location = diaspora2bb(unxmlify($xml->location));
|
||||
$about = diaspora2bb(unxmlify($xml->bio));
|
||||
|
||||
|
||||
$handle_parts = explode("@", $diaspora_handle);
|
||||
if($name === '') {
|
||||
$name = $handle_parts[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( preg_match("|^https?://|", $image_url) === 0) {
|
||||
$image_url = "http://" . $handle_parts[1] . $image_url;
|
||||
}
|
||||
|
@ -2182,8 +2183,8 @@ function diaspora_profile($importer,$xml,$msg) {
|
|||
require_once('include/Photo.php');
|
||||
|
||||
$images = import_profile_photo($image_url,$importer['uid'],$contact['id']);
|
||||
|
||||
// Generic birthday. We don't know the timezone. The year is irrelevant.
|
||||
|
||||
// Generic birthday. We don't know the timezone. The year is irrelevant.
|
||||
|
||||
$birthday = str_replace('1000','1901',$birthday);
|
||||
|
||||
|
@ -2196,9 +2197,9 @@ function diaspora_profile($importer,$xml,$msg) {
|
|||
$birthday = $contact['bd'];
|
||||
|
||||
// TODO: update name on item['author-name'] if the name changed. See consume_feed()
|
||||
// Not doing this currently because D* protocol is scheduled for revision soon.
|
||||
// Not doing this currently because D* protocol is scheduled for revision soon.
|
||||
|
||||
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s', `location` = '%s', `about` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc($name),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($images[0]),
|
||||
|
@ -2206,9 +2207,26 @@ function diaspora_profile($importer,$xml,$msg) {
|
|||
dbesc($images[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($birthday),
|
||||
dbesc($location),
|
||||
dbesc($about),
|
||||
intval($contact['id']),
|
||||
intval($importer['uid'])
|
||||
);
|
||||
);
|
||||
|
||||
$profileurl = "";
|
||||
$author = q("SELECT * FROM `unique_contacts` WHERE `url`='%s' LIMIT 1",
|
||||
dbesc(normalise_link($contact['url'])));
|
||||
|
||||
if (count($author) == 0) {
|
||||
q("INSERT INTO `unique_contacts` (`url`, `name`, `avatar`, `location`, `about`) VALUES ('%s', '%s', '%s', '%s', '%s')",
|
||||
dbesc(normalise_link($contact['url'])), dbesc($name), dbesc($location), dbesc($about), dbesc($images[0]));
|
||||
|
||||
$author = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
|
||||
dbesc(normalise_link($contact['url'])));
|
||||
} else if (normalise_link($contact['url']).$name.$location.$about != normalise_link($author[0]["url"]).$author[0]["name"].$author[0]["location"].$author[0]["about"]) {
|
||||
q("UPDATE unique_contacts SET name = '%s', avatar = '%s', `location` = '%s', `about` = '%s' WHERE url = '%s'",
|
||||
dbesc($name), dbesc($images[0]), dbesc($location), dbesc($about), dbesc(normalise_link($contact['url'])));
|
||||
}
|
||||
|
||||
/* if($r) {
|
||||
if($oldphotos) {
|
||||
|
|
|
@ -11,6 +11,7 @@ require_once('include/text.php');
|
|||
require_once('include/email.php');
|
||||
require_once('include/ostatus_conversation.php');
|
||||
require_once('include/threads.php');
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
|
||||
|
||||
|
@ -1343,6 +1344,22 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
|||
$current_post = $r[0]['id'];
|
||||
logger('item_store: created item ' . $current_post);
|
||||
|
||||
// Add every contact to the global contact table
|
||||
// Contacts from the statusnet connector are also added since you could add them in OStatus as well.
|
||||
if (!$arr['private'] AND in_array($arr["network"],
|
||||
array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_STATUSNET, "")))
|
||||
poco_check($arr["author-link"], $arr["author-name"], $arr["network"], $arr["author-avatar"], "", $arr["received"], $arr['contact-id'], $arr['uid']);
|
||||
|
||||
// Set "success_update" to the date of the last time we heard from this contact
|
||||
// This can be used to filter for inactive contacts and poco.
|
||||
// Only do this for public postings to avoid privacy problems, since poco data is public.
|
||||
// Don't set this value if it isn't from the owner (could be an author that we don't know)
|
||||
if (!$arr['private'] AND (($arr["author-link"] === $arr["owner-link"]) OR ($arr["parent-uri"] === $arr["uri"])))
|
||||
q("UPDATE `contact` SET `success_update` = '%s' WHERE `id` = %d",
|
||||
dbesc($arr['received']),
|
||||
intval($arr['contact-id'])
|
||||
);
|
||||
|
||||
// Only check for notifications on start posts
|
||||
if ($arr['parent-uri'] === $arr['uri']) {
|
||||
add_thread($r[0]['id']);
|
||||
|
@ -4492,7 +4509,7 @@ function drop_item($id,$interactive = true) {
|
|||
);
|
||||
create_tags_from_item($item['id']);
|
||||
create_files_from_item($item['id']);
|
||||
delete_thread($item['id']);
|
||||
delete_thread($item['id'], $item['parent-uri']);
|
||||
|
||||
// clean up categories and tags so they don't end up as orphans
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ require_once('include/datetime.php');
|
|||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
if(! $url)
|
||||
return;
|
||||
|
||||
$url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos') ;
|
||||
$url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network' : '?fields=displayName,urls,photos,updated,network') ;
|
||||
|
||||
logger('poco_load: ' . $url, LOGGER_DEBUG);
|
||||
|
||||
|
@ -67,6 +67,8 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
$profile_photo = '';
|
||||
$connect_url = '';
|
||||
$name = '';
|
||||
$network = '';
|
||||
$updated = '0000-00-00 00:00:00';
|
||||
|
||||
$name = $entry->displayName;
|
||||
|
||||
|
@ -82,7 +84,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(isset($entry->photos)) {
|
||||
if(isset($entry->photos)) {
|
||||
foreach($entry->photos as $photo) {
|
||||
if($photo->type == 'profile') {
|
||||
$profile_photo = $photo->value;
|
||||
|
@ -91,74 +93,18 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
}
|
||||
}
|
||||
|
||||
if((! $name) || (! $profile_url) || (! $profile_photo))
|
||||
continue;
|
||||
if(isset($entry->updated))
|
||||
$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
|
||||
|
||||
$x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
if(isset($entry->network))
|
||||
$network = $entry->network;
|
||||
|
||||
if(count($x)) {
|
||||
$gcid = $x[0]['id'];
|
||||
|
||||
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) {
|
||||
q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s'
|
||||
where `nurl` = '%s'",
|
||||
dbesc($name),
|
||||
dbesc($profile_photo),
|
||||
dbesc($connect_url),
|
||||
dbesc($profile_url),
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`)
|
||||
values ( '%s', '%s', '%s', '%s','%s') ",
|
||||
dbesc($name),
|
||||
dbesc($profile_url),
|
||||
dbesc(normalise_link($profile_url)),
|
||||
dbesc($profile_photo),
|
||||
dbesc($connect_url)
|
||||
);
|
||||
$x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
if(count($x))
|
||||
$gcid = $x[0]['id'];
|
||||
}
|
||||
if(! $gcid)
|
||||
return;
|
||||
|
||||
$r = q("select * from glink where `cid` = %d and `uid` = %d and `gcid` = %d and `zcid` = %d limit 1",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid),
|
||||
intval($zcid)
|
||||
);
|
||||
if(! count($r)) {
|
||||
q("insert into glink ( `cid`,`uid`,`gcid`,`zcid`, `updated`) values (%d,%d,%d,%d, '%s') ",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid),
|
||||
intval($zcid),
|
||||
dbesc(datetime_convert())
|
||||
);
|
||||
}
|
||||
else {
|
||||
q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d and zcid = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid),
|
||||
intval($zcid)
|
||||
);
|
||||
}
|
||||
poco_check($profile_url, $name, $network, $profile_photo, $connect_url, $updated, $cid, $uid, $zcid);
|
||||
|
||||
}
|
||||
logger("poco_load: loaded $total entries",LOGGER_DEBUG);
|
||||
|
||||
q("delete from glink where `cid` = %d and `uid` = %d and `zcid` = %d and `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY",
|
||||
q("DELETE FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `zcid` = %d AND `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($zcid)
|
||||
|
@ -166,6 +112,87 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
|
||||
}
|
||||
|
||||
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 == ""))
|
||||
return $gcid;
|
||||
|
||||
logger("profile-check URL: ".$profile_url." name: ".$name." avatar: ".$profile_photo, LOGGER_DEBUG);
|
||||
|
||||
$x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
|
||||
if(count($x)) {
|
||||
$gcid = $x[0]['id'];
|
||||
|
||||
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) {
|
||||
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),
|
||||
dbesc($updated),
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
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),
|
||||
dbesc($connect_url),
|
||||
dbesc($updated)
|
||||
);
|
||||
$x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
if(count($x))
|
||||
$gcid = $x[0]['id'];
|
||||
}
|
||||
|
||||
if(! $gcid)
|
||||
return $gcid;
|
||||
|
||||
$r = q("SELECT * FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d LIMIT 1",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid),
|
||||
intval($zcid)
|
||||
);
|
||||
if(! count($r)) {
|
||||
q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid),
|
||||
intval($zcid),
|
||||
dbesc(datetime_convert())
|
||||
);
|
||||
} else {
|
||||
q("UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid),
|
||||
intval($zcid)
|
||||
);
|
||||
}
|
||||
|
||||
// For unknown reasons there are sometimes duplicates
|
||||
q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d AND
|
||||
NOT EXISTS (SELECT `gcid` FROM `glink` WHERE `gcid` = `gcontact`.`id`)",
|
||||
dbesc(normalise_link($profile_url)),
|
||||
intval($gcid)
|
||||
);
|
||||
|
||||
return $gcid;
|
||||
}
|
||||
|
||||
function count_common_friends($uid,$cid) {
|
||||
|
||||
|
@ -192,9 +219,9 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) {
|
|||
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 )
|
||||
|
@ -214,7 +241,7 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) {
|
|||
|
||||
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 ) ",
|
||||
|
@ -233,9 +260,9 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
|
|||
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 )
|
||||
|
@ -269,9 +296,9 @@ function count_all_friends($uid,$cid) {
|
|||
|
||||
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),
|
||||
|
@ -289,16 +316,31 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
|||
if(! $uid)
|
||||
return array();
|
||||
|
||||
$r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
|
||||
INNER JOIN glink on glink.gcid = gcontact.id
|
||||
$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 = "'".$sql_network."', ''";
|
||||
$sql_network = "'".$sql_network."'";
|
||||
|
||||
$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 )
|
||||
group by glink.gcid order by total desc limit %d, %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)
|
||||
);
|
||||
|
@ -306,22 +348,30 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
|||
if(count($r) && count($r) >= ($limit -1))
|
||||
return $r;
|
||||
|
||||
$r2 = q("SELECT gcontact.* from gcontact
|
||||
INNER JOIN glink on glink.gcid = gcontact.id
|
||||
$r2 = q("SELECT gcontact.* from gcontact
|
||||
INNER JOIN glink on glink.gcid = gcontact.id
|
||||
where glink.uid = 0 and glink.cid = 0 and glink.zcid = 0 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)
|
||||
order by rand() limit %d, %d ",
|
||||
intval($uid),
|
||||
intval($uid),
|
||||
intval($uid),
|
||||
$sql_network,
|
||||
intval($start),
|
||||
intval($limit)
|
||||
);
|
||||
|
||||
$list = array();
|
||||
foreach ($r2 AS $suggestion)
|
||||
$list[$suggestion["nurl"]] = $suggestion;
|
||||
|
||||
return array_merge($r,$r2);
|
||||
foreach ($r AS $suggestion)
|
||||
$list[$suggestion["nurl"]] = $suggestion;
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
function update_suggestions() {
|
||||
|
|
|
@ -149,26 +149,26 @@ function delete_thread_uri($itemuri, $uid) {
|
|||
|
||||
if(count($messages))
|
||||
foreach ($messages as $message)
|
||||
delete_thread($message["id"]);
|
||||
delete_thread($message["id"], $itemuri);
|
||||
}
|
||||
|
||||
function delete_thread($itemid) {
|
||||
$item = q("SELECT `uri`, `uid` FROM `thread` WHERE `iid` = %d", intval($itemid));
|
||||
function delete_thread($itemid, $itemuri = "") {
|
||||
$item = q("SELECT `uid` FROM `thread` WHERE `iid` = %d", intval($itemid));
|
||||
|
||||
$result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid));
|
||||
|
||||
logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
|
||||
if (count($item)) {
|
||||
if ($itemuri != "") {
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND NOT (`uid` IN (%d, 0))",
|
||||
dbesc($item["uri"]),
|
||||
dbesc($itemuri),
|
||||
intval($item["uid"])
|
||||
);
|
||||
if (!count($r)) {
|
||||
$r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0)",
|
||||
dbesc($item["uri"])
|
||||
dbesc($itemuri)
|
||||
);
|
||||
logger("delete_thread: Deleted shadow for item ".$item["uri"]." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
logger("delete_thread: Deleted shadow for item ".$itemuri." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ function display_init(&$a) {
|
|||
|
||||
// Does the local user have this item?
|
||||
if (local_user()) {
|
||||
$r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body` FROM `item`
|
||||
$r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `guid` = '%s' AND `uid` = %d", $a->argv[1], local_user());
|
||||
if (count($r)) {
|
||||
|
@ -43,7 +43,7 @@ function display_init(&$a) {
|
|||
}
|
||||
if (count($r)) {
|
||||
if ($r[0]["id"] != $r[0]["parent"])
|
||||
$r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body` FROM `item`
|
||||
$r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `id` = %d", $r[0]["parent"]);
|
||||
|
||||
|
@ -89,23 +89,28 @@ function display_fetchauthor($a, $item) {
|
|||
$profiledata["url"] = $item["author-link"];
|
||||
$profiledata["network"] = $item["network"];
|
||||
|
||||
// Fetching profile data from unique contacts
|
||||
// To-do: Extend "unique contacts" table for further contact data like location, ...
|
||||
$r = q("SELECT `avatar`, `nick` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
|
||||
// Fetching further contact data from the contact table
|
||||
$r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
|
||||
normalise_link($profiledata["url"]), $item["uid"]);
|
||||
if (count($r)) {
|
||||
$profiledata["photo"] = proxy_url($r[0]["avatar"]);
|
||||
$profiledata["photo"] = proxy_url($r[0]["photo"]);
|
||||
$profiledata["address"] = bbcode($r[0]["location"]);
|
||||
$profiledata["about"] = bbcode($r[0]["about"]);
|
||||
if ($r[0]["nick"] != "")
|
||||
$profiledata["nickname"] = $r[0]["nick"];
|
||||
} else {
|
||||
// Is this case possible?
|
||||
// Fetching further contact data from the contact table, when it isn't available in the "unique contacts"
|
||||
$r = q("SELECT `photo`, `nick` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
|
||||
normalise_link($profiledata["url"]), $itemuid);
|
||||
if (count($r)) {
|
||||
$profiledata["photo"] = proxy_url($r[0]["photo"]);
|
||||
if ($r[0]["nick"] != "")
|
||||
$profiledata["nickname"] = $r[0]["nick"];
|
||||
}
|
||||
}
|
||||
|
||||
// Fetching profile data from unique contacts
|
||||
$r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
|
||||
if (count($r)) {
|
||||
if ($profiledata["photo"] == "")
|
||||
$profiledata["photo"] = proxy_url($r[0]["avatar"]);
|
||||
if ($profiledata["address"] == "")
|
||||
$profiledata["address"] = bbcode($r[0]["location"]);
|
||||
if ($profiledata["about"] == "")
|
||||
$profiledata["about"] = bbcode($r[0]["about"]);
|
||||
if (($profiledata["nickname"] == "") AND ($r[0]["nick"] != ""))
|
||||
$profiledata["nickname"] = $r[0]["nick"];
|
||||
}
|
||||
|
||||
// Check for a repeated message
|
||||
|
@ -158,6 +163,21 @@ function display_fetchauthor($a, $item) {
|
|||
|
||||
$profiledata["nickname"] = $profiledata["name"];
|
||||
$profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true);
|
||||
|
||||
$profiledata["address"] = "";
|
||||
$profiledata["about"] = "";
|
||||
|
||||
// Fetching profile data from unique contacts
|
||||
if ($profiledata["url"] != "") {
|
||||
$r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
|
||||
if (count($r)) {
|
||||
$profiledata["photo"] = proxy_url($r[0]["avatar"]);
|
||||
$profiledata["address"] = bbcode($r[0]["location"]);
|
||||
$profiledata["about"] = bbcode($r[0]["about"]);
|
||||
if ($r[0]["nick"] != "")
|
||||
$profiledata["nickname"] = $r[0]["nick"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (local_user()) {
|
||||
|
|
|
@ -93,6 +93,15 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
|
|||
return($siteinfo);
|
||||
}
|
||||
|
||||
if ($do_oembed) {
|
||||
require_once("include/oembed.php");
|
||||
|
||||
$oembed_data = oembed_fetch_url($url);
|
||||
|
||||
if ($oembed_data->type != "error")
|
||||
$siteinfo["type"] = $oembed_data->type;
|
||||
}
|
||||
|
||||
// if the file is too large then exit
|
||||
if ($curl_info["download_content_length"] > 1000000)
|
||||
return($siteinfo);
|
||||
|
@ -115,15 +124,6 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
|
|||
$http_code = $curl_info['http_code'];
|
||||
curl_close($ch);
|
||||
|
||||
if ($do_oembed) {
|
||||
require_once("include/oembed.php");
|
||||
|
||||
$oembed_data = oembed_fetch_url($url);
|
||||
|
||||
if ($oembed_data->type != "error")
|
||||
$siteinfo["type"] = $oembed_data->type;
|
||||
}
|
||||
|
||||
// Fetch the first mentioned charset. Can be in body or header
|
||||
$charset = "";
|
||||
if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches))
|
||||
|
|
73
mod/poco.php
73
mod/poco.php
|
@ -12,7 +12,7 @@ function poco_init(&$a) {
|
|||
$user = notags(trim($a->argv[1]));
|
||||
}
|
||||
if(! x($user)) {
|
||||
$c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = 1");
|
||||
$c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
|
||||
if(! count($c))
|
||||
http_status_exit(401);
|
||||
$system_mode = true;
|
||||
|
@ -30,7 +30,7 @@ function poco_init(&$a) {
|
|||
$justme = true;
|
||||
if($a->argc > 4 && intval($a->argv[4]) && $justme == false)
|
||||
$cid = intval($a->argv[4]);
|
||||
|
||||
|
||||
|
||||
if(! $system_mode) {
|
||||
$r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid`
|
||||
|
@ -44,21 +44,30 @@ function poco_init(&$a) {
|
|||
}
|
||||
|
||||
if($justme)
|
||||
$sql_extra = " and `contact`.`self` = 1 ";
|
||||
$sql_extra = " AND `contact`.`self` = 1 ";
|
||||
else
|
||||
$sql_extra = " and `contact`.`self` = 0 ";
|
||||
$sql_extra = " AND `contact`.`self` = 0 ";
|
||||
|
||||
if($cid)
|
||||
$sql_extra = sprintf(" and `contact`.`id` = %d ",intval($cid));
|
||||
$sql_extra = sprintf(" AND `contact`.`id` = %d ",intval($cid));
|
||||
|
||||
if($system_mode) {
|
||||
$r = q("SELECT count(*) as `total` from `contact` where self = 1
|
||||
and uid in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) ");
|
||||
$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_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
|
||||
$sql_extra ",
|
||||
intval($user['uid'])
|
||||
$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', '%s', '') $sql_extra",
|
||||
intval($user['uid']),
|
||||
dbesc(NETWORK_DFRN),
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
dbesc(NETWORK_OSTATUS),
|
||||
dbesc(NETWORK_STATUSNET)
|
||||
);
|
||||
}
|
||||
if(count($r))
|
||||
|
@ -73,17 +82,24 @@ function poco_init(&$a) {
|
|||
|
||||
|
||||
if($system_mode) {
|
||||
$r = q("SELECT * from contact where self = 1
|
||||
and uid in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) limit %d, %d ",
|
||||
$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
|
||||
$sql_extra LIMIT %d, %d",
|
||||
$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', '%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)
|
||||
);
|
||||
|
@ -106,8 +122,10 @@ function poco_init(&$a) {
|
|||
'id' => false,
|
||||
'displayName' => false,
|
||||
'urls' => false,
|
||||
'updated' => false,
|
||||
'preferredUsername' => false,
|
||||
'photos' => false
|
||||
'photos' => false,
|
||||
'network' => false
|
||||
);
|
||||
|
||||
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
|
||||
|
@ -130,12 +148,31 @@ function poco_init(&$a) {
|
|||
if($fields_ret['urls']) {
|
||||
$entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile'));
|
||||
if($rr['addr'] && ($rr['network'] !== NETWORK_MAIL))
|
||||
$entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger');
|
||||
$entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger');
|
||||
}
|
||||
if($fields_ret['preferredUsername'])
|
||||
$entry['preferredUsername'] = $rr['nick'];
|
||||
if($fields_ret['updated']) {
|
||||
$entry['updated'] = $rr['success_update'];
|
||||
|
||||
if ($rr['name-date'] > $entry['updated'])
|
||||
$entry['updated'] = $rr['name-date'];
|
||||
|
||||
if ($rr['uri-date'] > $entry['updated'])
|
||||
$entry['updated'] = $rr['uri-date'];
|
||||
|
||||
if ($rr['avatar-date'] > $entry['updated'])
|
||||
$entry['updated'] = $rr['avatar-date'];
|
||||
|
||||
$entry['updated'] = date("c", strtotime($entry['updated']));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +190,7 @@ function poco_init(&$a) {
|
|||
if($format === 'json') {
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($ret);
|
||||
killme();
|
||||
killme();
|
||||
}
|
||||
else
|
||||
http_status_exit(500);
|
||||
|
|
|
@ -44,13 +44,15 @@ function suggest_init(&$a) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function suggest_content(&$a) {
|
||||
|
||||
require_once("mod/proxy.php");
|
||||
|
||||
$o = '';
|
||||
if(! local_user()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
|
@ -82,7 +84,7 @@ function suggest_content(&$a) {
|
|||
$o .= replace_macros($tpl,array(
|
||||
'$url' => zrl($rr['url']),
|
||||
'$name' => $rr['name'],
|
||||
'$photo' => $rr['photo'],
|
||||
'$photo' => proxy_url($rr['photo']),
|
||||
'$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'],
|
||||
'$ignid' => $rr['id'],
|
||||
'$conntxt' => t('Connect'),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
define( 'UPDATE_VERSION' , 1176 );
|
||||
define( 'UPDATE_VERSION' , 1177 );
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
{{if $homepage}}<dl class="homepage"><dt class="homepage-label">{{$homepage}}</dt><dd class="homepage-url u-url"><a href="{{$profile.homepage}}" rel="me" target="_blank">{{$profile.homepage}}</a></dd></dl>{{/if}}
|
||||
|
||||
{{if $about}}<dl class="about"><dt class="about-label">{{$about}}</dt><dd class="x-network">{{$profile.about}}</dd></dl>{{/if}}
|
||||
|
||||
{{include file="diaspora_vcard.tpl"}}
|
||||
|
||||
<div id="profile-extra-links">
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
|
||||
{{if $homepage}}<dl class="homepage"><dt class="homepage-label">{{$homepage}}</dt><dd class="homepage-url"><a href="{{$profile.homepage}}" class="u-url" rel="me" target="_blank">{{$profile.homepage}}</a></dd></dl>{{/if}}
|
||||
|
||||
{{if $about}}<dl class="about"><dt class="about-label">{{$about}}</dt><dd class="x-network">{{$profile.about}}</dd></dl>{{/if}}
|
||||
|
||||
{{include file="diaspora_vcard.tpl"}}
|
||||
|
||||
<div id="profile-extra-links">
|
||||
|
|
Loading…
Reference in a new issue