The "hide" element is included in the feed as well.

This commit is contained in:
Michael Vogel 2016-05-05 06:46:23 +02:00
parent 683cdcc19e
commit 90155da59a
1 changed files with 15 additions and 13 deletions

View File

@ -490,6 +490,13 @@ class dfrn {
if ($birthday) if ($birthday)
xml::add_element($doc, $author, "dfrn:birthday", $birthday); xml::add_element($doc, $author, "dfrn:birthday", $birthday);
// Is the profile hidden or shouldn't be published in the net? Then add the "hide" element
$r = q("SELECT `id` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `hidewall` OR NOT `net-publish` AND `user`.`uid` = %d",
intval($owner['uid']));
if ($r)
xml::add_element($doc, $author, "dfrn:hide", "true");
// The following fields will only be generated if this isn't for a public feed // The following fields will only be generated if this isn't for a public feed
if ($public) if ($public)
return $author; return $author;
@ -561,13 +568,6 @@ class dfrn {
} }
} }
// Is the profile hidden or shouldn't be published in the net? Then add the "hide" element
$r = q("SELECT `id` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `hidewall` OR NOT `net-publish` AND `user`.`uid` = %d",
intval($owner['uid']));
if ($r)
xml::add_element($doc, $author, "dfrn:hide", "true");
return $author; return $author;
} }
@ -1218,11 +1218,13 @@ class dfrn {
/// - poco:country /// - poco:country
// If the "hide" element is present then the profile isn't searchable. // If the "hide" element is present then the profile isn't searchable.
$searchable = !($xpath->evaluate($element."/dfrn:hide/text()", $context)->item(0)->nodeValue == "true"); $hide = intval($xpath->evaluate($element."/dfrn:hide/text()", $context)->item(0)->nodeValue == "true");
logger("Hidden status for contact ".$contact["url"].": ".$hide, LOGGER_DEBUG);
// If the contact isn't searchable then set the contact to "hidden". // If the contact isn't searchable then set the contact to "hidden".
// Problem: This can be manually overridden by the user. // Problem: This can be manually overridden by the user.
if (!$searchable) if ($hide)
$contact["hidden"] = true; $contact["hidden"] = true;
// Save the keywords into the contact table // Save the keywords into the contact table
@ -1277,17 +1279,17 @@ class dfrn {
unset($fields["name-date"]); unset($fields["name-date"]);
unset($fields["uri-date"]); unset($fields["uri-date"]);
// Update check for this field has to be done differently // Update check for this field has to be done differently
$datefields = array("name-date", "uri-date"); $datefields = array("name-date", "uri-date");
foreach ($datefields AS $field) foreach ($datefields AS $field)
if (strtotime($contact[$field]) > strtotime($r[0][$field])) { if (strtotime($contact[$field]) > strtotime($r[0][$field])) {
logger("Difference for contact ".$contact["id"]." in field '".$field."'. Old value: '".$contact[$field]."', new value '".$r[0][$field]."'", LOGGER_DEBUG); logger("Difference for contact ".$contact["id"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$r[0][$field]."'", LOGGER_DEBUG);
$update = true; $update = true;
} }
foreach ($fields AS $field => $data) foreach ($fields AS $field => $data)
if ($contact[$field] != $r[0][$field]) { if ($contact[$field] != $r[0][$field]) {
logger("Difference for contact ".$contact["id"]." in field '".$field."'. Old value: '".$contact[$field]."', new value '".$r[0][$field]."'", LOGGER_DEBUG); logger("Difference for contact ".$contact["id"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$r[0][$field]."'", LOGGER_DEBUG);
$update = true; $update = true;
} }
@ -1314,7 +1316,7 @@ class dfrn {
$poco["generation"] = 2; $poco["generation"] = 2;
$poco["photo"] = $author["avatar"]; $poco["photo"] = $author["avatar"];
$poco["hide"] = !$searchable; $poco["hide"] = $hide;
update_gcontact($poco); update_gcontact($poco);
} }