Imrpoved avatar handling when storing them/partly use of "micro"
This commit is contained in:
parent
f8a20a15d3
commit
0b1188b7fe
|
@ -209,21 +209,21 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
||||||
|
|
||||||
// Fetch contact data from the contact table for the given user
|
// Fetch contact data from the contact table for the given user
|
||||||
$r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
|
$r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
|
||||||
`keywords`, `gender`, `photo`, `thumb`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, `self`
|
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, `self`
|
||||||
FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
|
FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
|
||||||
dbesc(normalise_link($url)), intval($uid));
|
dbesc(normalise_link($url)), intval($uid));
|
||||||
|
|
||||||
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
|
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
|
||||||
if (!$r)
|
if (!$r)
|
||||||
$r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
|
$r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
|
||||||
`keywords`, `gender`, `photo`, `thumb`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, 0 AS `self`
|
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, 0 AS `self`
|
||||||
FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
|
FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
|
||||||
dbesc(normalise_link($url)));
|
dbesc(normalise_link($url)));
|
||||||
|
|
||||||
// Fetch the data from the gcontact table
|
// Fetch the data from the gcontact table
|
||||||
if (!$r)
|
if (!$r)
|
||||||
$r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
|
$r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
|
||||||
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `community` AS `forum`, 0 AS `prv`, `community`, `birthday`, 0 AS `self`
|
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `birthday`, 0 AS `self`
|
||||||
FROM `gcontact` WHERE `nurl` = '%s'",
|
FROM `gcontact` WHERE `nurl` = '%s'",
|
||||||
dbesc(normalise_link($url)));
|
dbesc(normalise_link($url)));
|
||||||
|
|
||||||
|
@ -267,9 +267,12 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
||||||
if (($profile["network"] == "") AND isset($default["network"]))
|
if (($profile["network"] == "") AND isset($default["network"]))
|
||||||
$profile["network"] = $default["network"];
|
$profile["network"] = $default["network"];
|
||||||
|
|
||||||
if (!isset($profile["thumb"]) AND isset($profile["photo"]))
|
if (($profile["thumb"] == "") AND isset($profile["photo"]))
|
||||||
$profile["thumb"] = $profile["photo"];
|
$profile["thumb"] = $profile["photo"];
|
||||||
|
|
||||||
|
if (($profile["micro"] == "") AND isset($profile["thumb"]))
|
||||||
|
$profile["micro"] = $profile["thumb"];
|
||||||
|
|
||||||
if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND
|
if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND
|
||||||
in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
|
in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
|
||||||
proc_run('php',"include/update_gcontact.php", $profile["gid"]);
|
proc_run('php',"include/update_gcontact.php", $profile["gid"]);
|
||||||
|
|
|
@ -428,8 +428,8 @@ function bb_ShareAttributes($share, $simplehtml) {
|
||||||
if (isset($data["name"]))
|
if (isset($data["name"]))
|
||||||
$author = $data["name"];
|
$author = $data["name"];
|
||||||
|
|
||||||
if (isset($data["thumb"]))
|
if (isset($data["micro"]))
|
||||||
$avatar = $data["thumb"];
|
$avatar = $data["micro"];
|
||||||
|
|
||||||
$preshare = trim($share[1]);
|
$preshare = trim($share[1]);
|
||||||
|
|
||||||
|
|
|
@ -1809,6 +1809,8 @@ class diaspora {
|
||||||
if(intval($def_gid))
|
if(intval($def_gid))
|
||||||
group_add_member($importer["uid"], "", $contact_record["id"], $def_gid);
|
group_add_member($importer["uid"], "", $contact_record["id"], $def_gid);
|
||||||
|
|
||||||
|
update_contact_avatar($ret["photo"], $importer['uid'], $contact_record["id"], true);
|
||||||
|
|
||||||
if($importer["page-flags"] == PAGE_NORMAL) {
|
if($importer["page-flags"] == PAGE_NORMAL) {
|
||||||
|
|
||||||
$hash = random_string().(string)time(); // Generate a confirm_key
|
$hash = random_string().(string)time(); // Generate a confirm_key
|
||||||
|
|
|
@ -1404,16 +1404,8 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
||||||
dbesc($url)
|
dbesc($url)
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
$contact_record = $r[0];
|
$contact_record = $r[0];
|
||||||
|
update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
|
||||||
$photos = import_profile_photo($photo,$importer["uid"],$contact_record["id"]);
|
|
||||||
|
|
||||||
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
|
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
intval($contact_record["id"])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -388,17 +388,30 @@ function notifier_run(&$argv, &$argc){
|
||||||
// We have not only to look at the parent, since it could be a Friendica thread.
|
// We have not only to look at the parent, since it could be a Friendica thread.
|
||||||
if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
|
if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
|
||||||
|
|
||||||
logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
|
logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent[0]['author-link']." - Owner: ".$thr_parent[0]['owner-link'], LOGGER_DEBUG);
|
||||||
|
|
||||||
// Send a salmon to the parent author
|
// Send a salmon to the parent author
|
||||||
$probed_contact = probe_url($thr_parent[0]['author-link']);
|
$r = q("SELECT `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
|
||||||
|
dbesc(normalise_link($thr_parent[0]['author-link'])),
|
||||||
|
intval($uid));
|
||||||
|
if ($r)
|
||||||
|
$probed_contact = $r[0];
|
||||||
|
else
|
||||||
|
$probed_contact = probe_url($thr_parent[0]['author-link']);
|
||||||
|
|
||||||
if ($probed_contact["notify"] != "") {
|
if ($probed_contact["notify"] != "") {
|
||||||
logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||||
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
|
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a salmon to the parent owner
|
// Send a salmon to the parent owner
|
||||||
$probed_contact = probe_url($thr_parent[0]['owner-link']);
|
$r = q("SELECT `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
|
||||||
|
dbesc(normalise_link($thr_parent[0]['owner-link'])),
|
||||||
|
intval($uid));
|
||||||
|
if ($r)
|
||||||
|
$probed_contact = $r[0];
|
||||||
|
else
|
||||||
|
$probed_contact = probe_url($thr_parent[0]['owner-link']);
|
||||||
if ($probed_contact["notify"] != "") {
|
if ($probed_contact["notify"] != "") {
|
||||||
logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||||
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
|
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
|
||||||
|
|
|
@ -138,6 +138,8 @@ function dfrn_request_post(&$a) {
|
||||||
|
|
||||||
$dfrn_request = $parms['dfrn-request'];
|
$dfrn_request = $parms['dfrn-request'];
|
||||||
|
|
||||||
|
$photo = $parms["photo"];
|
||||||
|
|
||||||
/********* Escape the entire array ********/
|
/********* Escape the entire array ********/
|
||||||
|
|
||||||
dbesc_array($parms);
|
dbesc_array($parms);
|
||||||
|
@ -185,6 +187,9 @@ function dfrn_request_post(&$a) {
|
||||||
if(intval($def_gid))
|
if(intval($def_gid))
|
||||||
group_add_member(local_user(), '', $r[0]['id'], $def_gid);
|
group_add_member(local_user(), '', $r[0]['id'], $def_gid);
|
||||||
|
|
||||||
|
if (isset($photo))
|
||||||
|
update_contact_avatar($photo, local_user(), $r[0]["id"], true);
|
||||||
|
|
||||||
$forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
|
$forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
|
||||||
} else
|
} else
|
||||||
$forwardurl = $a->get_baseurl()."/contacts";
|
$forwardurl = $a->get_baseurl()."/contacts";
|
||||||
|
@ -530,7 +535,7 @@ function dfrn_request_post(&$a) {
|
||||||
|
|
||||||
$parms['url'] = $url;
|
$parms['url'] = $url;
|
||||||
$parms['issued-id'] = $issued_id;
|
$parms['issued-id'] = $issued_id;
|
||||||
|
$photo = $parms["photo"];
|
||||||
|
|
||||||
dbesc_array($parms);
|
dbesc_array($parms);
|
||||||
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
|
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
|
||||||
|
@ -539,7 +544,7 @@ function dfrn_request_post(&$a) {
|
||||||
intval($uid),
|
intval($uid),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
$parms['url'],
|
$parms['url'],
|
||||||
dbesc(normalise_link($parms['url'])),
|
dbesc(normalise_link($url)),
|
||||||
$parms['addr'],
|
$parms['addr'],
|
||||||
$parms['fn'],
|
$parms['fn'],
|
||||||
$parms['nick'],
|
$parms['nick'],
|
||||||
|
@ -562,8 +567,10 @@ function dfrn_request_post(&$a) {
|
||||||
$parms['url'],
|
$parms['url'],
|
||||||
$parms['issued-id']
|
$parms['issued-id']
|
||||||
);
|
);
|
||||||
if(count($r))
|
if(count($r)) {
|
||||||
$contact_record = $r[0];
|
$contact_record = $r[0];
|
||||||
|
update_contact_avatar($photo, $uid, $contact_record["id"], true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,8 @@ function notifications_content(&$a) {
|
||||||
$a->set_pager_itemspage(20);
|
$a->set_pager_itemspage(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact
|
||||||
|
|
||||||
$r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, `fcontact`.`name` AS `fname`,`fcontact`.`url` AS `furl`,`fcontact`.`photo` AS `fphoto`,`fcontact`.`request` AS `frequest`,
|
$r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, `fcontact`.`name` AS `fname`,`fcontact`.`url` AS `furl`,`fcontact`.`photo` AS `fphoto`,`fcontact`.`request` AS `frequest`,
|
||||||
`gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`,
|
`gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`,
|
||||||
`gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`,
|
`gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`,
|
||||||
|
|
|
@ -191,8 +191,8 @@ function ping_init(&$a) {
|
||||||
function xmlize($n){
|
function xmlize($n){
|
||||||
|
|
||||||
$contact = get_contact_details_by_url($n['url']);
|
$contact = get_contact_details_by_url($n['url']);
|
||||||
if (isset($contact["thumb"]))
|
if (isset($contact["micro"]))
|
||||||
$n['photo'] = proxy_url($contact["thumb"], false, PROXY_SIZE_MICRO);
|
$n['photo'] = proxy_url($contact["micro"], false, PROXY_SIZE_MICRO);
|
||||||
else
|
else
|
||||||
$n['photo'] = proxy_url($n['photo'], false, PROXY_SIZE_MICRO);
|
$n['photo'] = proxy_url($n['photo'], false, PROXY_SIZE_MICRO);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue