"about" and "location" is now included in global contacts as well.

This commit is contained in:
Michael Vogel 2015-01-25 02:29:46 +01:00
parent 344210bd6d
commit 597ef20b71
5 changed files with 36 additions and 10 deletions

View File

@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Ginger'); define ( 'FRIENDICA_CODENAME', 'Ginger');
define ( 'FRIENDICA_VERSION', '3.3.2' ); define ( 'FRIENDICA_VERSION', '3.3.2' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1177 ); define ( 'DB_UPDATE_VERSION', 1178 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View File

@ -619,6 +619,8 @@ function db_definition() {
"photo" => 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" => ""), "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
"location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"about" => array("type" => "text", "not null" => "1"),
"network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
), ),
"indexes" => array( "indexes" => array(

View File

@ -1380,7 +1380,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
// Contacts from the statusnet connector are also added since you could add them in OStatus as well. // 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"], if (!$arr['private'] AND in_array($arr["network"],
array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_STATUSNET, ""))) { 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"]); poco_check($arr["author-link"], $arr["author-name"], $arr["network"], $arr["author-avatar"], "", "", "", $arr["received"], $arr["contact-id"], $arr["uid"]);
// Maybe its a body with a shared item? Then extract a global contact from it. // Maybe its a body with a shared item? Then extract a global contact from it.
poco_contact_from_body($arr["body"], $arr["received"], $arr["contact-id"], $arr["uid"]); poco_contact_from_body($arr["body"], $arr["received"], $arr["contact-id"], $arr["uid"]);

View File

@ -39,7 +39,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
if(! $url) if(! $url)
return; return;
$url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network' : '?fields=displayName,urls,photos,updated,network') ; $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation') ;
logger('poco_load: ' . $url, LOGGER_DEBUG); logger('poco_load: ' . $url, LOGGER_DEBUG);
@ -69,6 +69,8 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
$name = ''; $name = '';
$network = ''; $network = '';
$updated = '0000-00-00 00:00:00'; $updated = '0000-00-00 00:00:00';
$location = '';
$about = '';
$name = $entry->displayName; $name = $entry->displayName;
@ -99,7 +101,19 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
if(isset($entry->network)) if(isset($entry->network))
$network = $entry->network; $network = $entry->network;
poco_check($profile_url, $name, $network, $profile_photo, $connect_url, $updated, $cid, $uid, $zcid); if(isset($entry->currentLocation))
$location = $entry->currentLocation;
if(isset($entry->aboutMe))
$about = $entry->aboutMe;
poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $connect_url, $updated, $cid, $uid, $zcid);
if (($location != "") OR ($about != ""))
q("UPDATE `contact` SET `location` = '%s', `about` = '%s' WHERE `nurl` = '%s' AND NOT `self`",
dbesc($location),
dbesc($about),
dbesc(normalise_link($profile_url)));
} }
logger("poco_load: loaded $total entries",LOGGER_DEBUG); logger("poco_load: loaded $total entries",LOGGER_DEBUG);
@ -112,7 +126,7 @@ 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) { function poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $connect_url, $updated, $cid = 0, $uid = 0, $zcid = 0) {
$gcid = ""; $gcid = "";
if ($profile_url == "") if ($profile_url == "")
@ -142,8 +156,14 @@ function poco_check($profile_url, $name, $network, $profile_photo, $connect_url,
if(count($x)) { if(count($x)) {
$gcid = $x[0]['id']; $gcid = $x[0]['id'];
if (($location == "") AND ($x[0]['location'] != ""))
$location = $x[0]['location'];
if (($about == "") AND ($x[0]['about'] != ""))
$about = $x[0]['about'];
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) { 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' q("update gcontact set `name` = '%s', `network` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `updated` = '%s', `location` = '%s', `about` = '%s'
where `nurl` = '%s'", where `nurl` = '%s'",
dbesc($name), dbesc($name),
dbesc($network), dbesc($network),
@ -151,11 +171,13 @@ function poco_check($profile_url, $name, $network, $profile_photo, $connect_url,
dbesc($connect_url), dbesc($connect_url),
dbesc($profile_url), dbesc($profile_url),
dbesc($updated), dbesc($updated),
dbesc($location),
dbesc($about),
dbesc(normalise_link($profile_url)) dbesc(normalise_link($profile_url))
); );
} }
} else { } else {
q("insert into `gcontact` (`name`,`network`, `url`,`nurl`,`photo`,`connect`, `updated`) q("insert into `gcontact` (`name`,`network`, `url`,`nurl`,`photo`,`connect`, `updated`, `location`, `about`)
values ('%s', '%s', '%s', '%s', '%s','%s', '%s')", values ('%s', '%s', '%s', '%s', '%s','%s', '%s')",
dbesc($name), dbesc($name),
dbesc($network), dbesc($network),
@ -163,7 +185,9 @@ function poco_check($profile_url, $name, $network, $profile_photo, $connect_url,
dbesc(normalise_link($profile_url)), dbesc(normalise_link($profile_url)),
dbesc($profile_photo), dbesc($profile_photo),
dbesc($connect_url), dbesc($connect_url),
dbesc($updated) dbesc($updated),
dbesc($location),
dbesc($about)
); );
$x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($profile_url)) dbesc(normalise_link($profile_url))
@ -230,7 +254,7 @@ function sub_poco_from_share($share, $created, $cid, $uid) {
return; return;
logger("prepare poco_check for profile ".$profile, LOGGER_DEBUG); logger("prepare poco_check for profile ".$profile, LOGGER_DEBUG);
poco_check($profile, "", "", "", "", $created, $cid, $uid); poco_check($profile, "", "", "", "", "", "", $created, $cid, $uid);
} }
function count_common_friends($uid,$cid) { function count_common_friends($uid,$cid) {

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1177 ); define( 'UPDATE_VERSION' , 1178 );
/** /**
* *