1
0
Fork 0

Fetching "location" and "about" from diaspora. Displaying them on the "display" page.

This commit is contained in:
Michael Vogel 2015-01-07 01:46:13 +01:00
commit b36d799044
7 changed files with 40 additions and 31 deletions

View file

@ -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 = 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,11 @@ function diaspora_profile($importer,$xml,$msg) {
dbesc($images[2]),
dbesc(datetime_convert()),
dbesc($birthday),
dbesc($location),
dbesc($about),
intval($contact['id']),
intval($importer['uid'])
);
);
/* if($r) {
if($oldphotos) {

View file

@ -4509,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

View file

@ -149,28 +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) {
// To-Do:
// There is no "uri" in the thread table ...
$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);
}
}
}