Merge pull request #1941 from annando/1510-diaspora-privacy

Reworked contact data fetching on "display" page, bugfix in notifications
This commit is contained in:
Tobias Diekershoff 2015-10-06 19:02:41 +02:00
commit d7d1a09558
4 changed files with 57 additions and 49 deletions

View File

@ -101,39 +101,6 @@ function display_fetchauthor($a, $item) {
$profiledata["url"] = $item["author-link"]; $profiledata["url"] = $item["author-link"];
$profiledata["network"] = $item["network"]; $profiledata["network"] = $item["network"];
// Fetching further contact data from the contact table
$r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `network` = '%s'",
dbesc(normalise_link($profiledata["url"])), intval($item["uid"]), dbesc($item["network"]));
if (!count($r))
$r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
dbesc(normalise_link($profiledata["url"])), intval($item["uid"]));
if (!count($r))
$r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
dbesc(normalise_link($profiledata["url"])));
if (count($r)) {
$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"];
}
// Fetching profile data from unique contacts
$r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", dbesc(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 // Check for a repeated message
$skip = false; $skip = false;
$body = trim($item["body"]); $body = trim($item["body"]);
@ -187,28 +154,49 @@ function display_fetchauthor($a, $item) {
$profiledata["address"] = ""; $profiledata["address"] = "";
$profiledata["about"] = ""; $profiledata["about"] = "";
}
// Fetching profile data from unique contacts // Fetching further contact data from the contact table
if ($profiledata["url"] != "") { $r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `network` = '%s'",
$r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", dbesc(normalise_link($profiledata["url"]))); dbesc(normalise_link($profiledata["url"])), intval($item["uid"]), dbesc($item["network"]));
if (count($r)) {
$profiledata["photo"] = proxy_url($r[0]["avatar"]); if (!count($r))
$profiledata["address"] = bbcode($r[0]["location"]); $r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
$profiledata["about"] = bbcode($r[0]["about"]); dbesc(normalise_link($profiledata["url"])), intval($item["uid"]));
if ($r[0]["nick"] != "")
$profiledata["nickname"] = $r[0]["nick"]; if (!count($r))
} $r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
dbesc(normalise_link($profiledata["url"])));
if (count($r)) {
if ((($r[0]["uid"] != local_user()) OR !local_user()) AND ($profiledata["network"] == NETWORK_DIASPORA)) {
$r[0]["location"] = "";
$r[0]["about"] = "";
} }
$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"];
}
// Fetching profile data from unique contacts
$r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", dbesc(normalise_link($profiledata["url"])));
if (count($r)) {
if ($profiledata["photo"] == "")
$profiledata["photo"] = proxy_url($r[0]["avatar"]);
if (($profiledata["address"] == "") AND ($profiledata["network"] != NETWORK_DIASPORA))
$profiledata["address"] = bbcode($r[0]["location"]);
if (($profiledata["about"] == "") AND ($profiledata["network"] != NETWORK_DIASPORA))
$profiledata["about"] = bbcode($r[0]["about"]);
if (($profiledata["nickname"] == "") AND ($r[0]["nick"] != ""))
$profiledata["nickname"] = $r[0]["nick"];
} }
if (local_user()) { if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
$profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]); $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
//if ($profiledata["network"] == NETWORK_DFRN) {
// $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"])."&addr=".bin2hex($a->get_baseurl()."/profile/".$a->user["nickname"]);
// $profiledata["remoteconnect"] = $connect;
//} elseif ($profiledata["network"] == NETWORK_DIASPORA)
// $profiledata["remoteconnect"] = $a->get_baseurl()."/contacts?add=".GetProfileUsername($profiledata["url"], "", true);
} elseif ($profiledata["network"] == NETWORK_DFRN) { } elseif ($profiledata["network"] == NETWORK_DFRN) {
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]); $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
$profiledata["remoteconnect"] = $connect; $profiledata["remoteconnect"] = $connect;

View File

@ -67,6 +67,11 @@ function follow_content(&$a) {
if (!$r) if (!$r)
$r = array(array("location" => "", "about" => "", "keywords" => "")); $r = array(array("location" => "", "about" => "", "keywords" => ""));
if($ret['network'] === NETWORK_DIASPORA) {
$r[0]["location"] = "";
$r[0]["about"] = "";
}
$header = $ret["name"]; $header = $ret["name"];
if ($ret["addr"] != "") if ($ret["addr"] != "")

View File

@ -222,6 +222,13 @@ function notifications_content(&$a) {
$header .= " (".network_to_name($rr['gnetwork'], $rr['url']).")"; $header .= " (".network_to_name($rr['gnetwork'], $rr['url']).")";
// Don't show these data until you are connected. Diaspora is doing the same.
if($rr['gnetwork'] === NETWORK_DIASPORA) {
$rr['glocation'] = "";
$rr['gabout'] = "";
$rr['ggender'] = "";
}
$notif_content .= replace_macros($tpl, array( $notif_content .= replace_macros($tpl, array(
'$header' => htmlentities($header), '$header' => htmlentities($header),
'$str_notifytype' => t('Notification type: '), '$str_notifytype' => t('Notification type: '),
@ -243,7 +250,8 @@ function notifications_content(&$a) {
'$gender_label' => t('Gender:'), '$gender_label' => t('Gender:'),
'$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''),
'$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')),
'$url' => zrl($rr['url']), '$url' => $rr['url'],
'$zrl' => zrl($rr['url']),
'$url_label' => t('Profile URL'), '$url_label' => t('Profile URL'),
'$knowyou' => $knowyou, '$knowyou' => $knowyou,
'$approve' => t('Approve'), '$approve' => t('Approve'),

View File

@ -226,6 +226,13 @@ function poco_init(&$a) {
Cache::set("about:".$rr['updated'].":".$rr['nurl'],$about); Cache::set("about:".$rr['updated'].":".$rr['nurl'],$about);
} }
// Non connected persons can only see the keywords of a Diaspora account
if ($rr['network'] == NETWORK_DIASPORA) {
$rr['location'] = "";
$about = "";
$rr['gender'] = "";
}
$entry = array(); $entry = array();
if($fields_ret['id']) if($fields_ret['id'])
$entry['id'] = (int)$rr['id']; $entry['id'] = (int)$rr['id'];