Some more places with owner-view

This commit is contained in:
Michael 2020-04-24 13:41:11 +00:00
parent c4f7f3e26e
commit a5aa43469b
3 changed files with 22 additions and 64 deletions

View File

@ -144,16 +144,7 @@ function poco_init(App $a) {
); );
} elseif ($system_mode) { } elseif ($system_mode) {
Logger::log("Start system mode query", Logger::DEBUG); Logger::log("Start system mode query", Logger::DEBUG);
$contacts = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`, $contacts = DBA::selectToArray('owner-view', [], ['net-publish' => true], ['limit' => [$startIndex, $itemsPerPage]]);
`profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`,
`profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type`
FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `self` = 1 AND `profile`.`net-publish`
LIMIT %d, %d",
intval($startIndex),
intval($itemsPerPage)
);
} else { } else {
Logger::log("Start query for user " . $user['nickname'], Logger::DEBUG); Logger::log("Start query for user " . $user['nickname'], Logger::DEBUG);
$contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
@ -230,28 +221,6 @@ function poco_init(App $a) {
} }
} }
if (($contact['about'] == "") && isset($contact['pabout'])) {
$contact['about'] = $contact['pabout'];
}
if ($contact['location'] == "") {
if (isset($contact['plocation'])) {
$contact['location'] = $contact['plocation'];
}
if (isset($contact['pregion']) && ( $contact['pregion'] != "")) {
if ($contact['location'] != "") {
$contact['location'] .= ", ";
}
$contact['location'] .= $contact['pregion'];
}
if (isset($contact['pcountry']) && ( $contact['pcountry'] != "")) {
if ($contact['location'] != "") {
$contact['location'] .= ", ";
}
$contact['location'] .= $contact['pcountry'];
}
}
if (($contact['keywords'] == "") && isset($contact['pub_keywords'])) { if (($contact['keywords'] == "") && isset($contact['pub_keywords'])) {
$contact['keywords'] = $contact['pub_keywords']; $contact['keywords'] = $contact['pub_keywords'];
} }
@ -343,21 +312,21 @@ function poco_init(App $a) {
$entry['address'] = []; $entry['address'] = [];
// Deactivated. It just reveals too much data. (Although its from the default profile) // Deactivated. It just reveals too much data. (Although its from the default profile)
//if (isset($rr['paddress'])) //if (isset($rr['address']))
// $entry['address']['streetAddress'] = $rr['paddress']; // $entry['address']['streetAddress'] = $rr['address'];
if (isset($contact['plocation'])) { if (isset($contact['locality'])) {
$entry['address']['locality'] = $contact['plocation']; $entry['address']['locality'] = $contact['locality'];
} }
if (isset($contact['pregion'])) { if (isset($contact['region'])) {
$entry['address']['region'] = $contact['pregion']; $entry['address']['region'] = $contact['region'];
} }
// See above // See above
//if (isset($rr['ppostalcode'])) //if (isset($rr['postal-code']))
// $entry['address']['postalCode'] = $rr['ppostalcode']; // $entry['address']['postalCode'] = $rr['postal-code'];
if (isset($contact['pcountry'])) { if (isset($contact['country'])) {
$entry['address']['country'] = $contact['pcountry']; $entry['address']['country'] = $contact['country'];
} }
} }

View File

@ -183,19 +183,12 @@ class DFRN
$sql_extra = sprintf(" AND `item`.`private` != %s ", Item::PRIVATE); $sql_extra = sprintf(" AND `item`.`private` != %s ", Item::PRIVATE);
$r = q( $owner = DBA::selectFirst('owner-view', [], ['nickname' => $owner_nick]);
"SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`, `user`.`account-type` if (!DBA::isResult($owner)) {
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `contact`.`self` AND `user`.`nickname` = '%s' LIMIT 1",
DBA::escape($owner_nick)
);
if (! DBA::isResult($r)) {
Logger::log(sprintf('No contact found for nickname=%d', $owner_nick), Logger::WARNING); Logger::log(sprintf('No contact found for nickname=%d', $owner_nick), Logger::WARNING);
exit(); exit();
} }
$owner = $r[0];
$owner_id = $owner['uid']; $owner_id = $owner['uid'];
$sql_post_table = ""; $sql_post_table = "";
@ -684,18 +677,10 @@ class DFRN
} }
// Only show contact details when we are allowed to // Only show contact details when we are allowed to
$r = q( $profile = DBA::selectFirst('owner-view',
"SELECT `profile`.`about`, `profile`.`name`, `profile`.`homepage`, `user`.`nickname`, ['about', 'name', 'homepage', 'nickname', 'timezone', 'locality', 'region', 'country-name', 'pub_keywords', 'xmpp', 'dob'],
`user`.`timezone`, `profile`.`locality`, `profile`.`region`, `profile`.`country-name`, ['uid' => $owner['uid'], 'hidewall' => false]);
`profile`.`pub_keywords`, `profile`.`xmpp`, `profile`.`dob` if (DBA::isResult($profile)) {
FROM `profile`
INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE NOT `user`.`hidewall` AND `user`.`uid` = %d",
intval($owner['uid'])
);
if (DBA::isResult($r)) {
$profile = $r[0];
XML::addElement($doc, $author, "poco:displayName", $profile["name"]); XML::addElement($doc, $author, "poco:displayName", $profile["name"]);
XML::addElement($doc, $author, "poco:updated", $namdate); XML::addElement($doc, $author, "poco:updated", $namdate);

View File

@ -133,11 +133,15 @@ return [
"notify_new_posts" => ["notify_new_posts"], "notify_new_posts" => ["notify_new_posts"],
"fetch_further_information" => ["fetch_further_information"], "fetch_further_information" => ["fetch_further_information"],
"ffi_keyword_blacklist" => ["ffi_keyword_blacklist"], "ffi_keyword_blacklist" => ["ffi_keyword_blacklist"],
"guid" => ["user", "guid"],
"theme" => ["user", "theme"],
"language" => ["user", "language"],
"email" => ["user", "email"], "email" => ["user", "email"],
"uprvkey" => ["user", "prvkey"], "uprvkey" => ["user", "prvkey"],
"upubkey" => ["user", "pubkey"], "upubkey" => ["user", "pubkey"],
"timezone" => ["user", "timezone"], "timezone" => ["user", "timezone"],
"nickname" => ["user", "nickname"], /// @todo Remove duplicate "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
"username" => ["user", "username"], /// @todo Replaces all uses of "username" with "name"
"sprvkey" => ["user", "sprvkey"], "sprvkey" => ["user", "sprvkey"],
"spubkey" => ["user", "spubkey"], "spubkey" => ["user", "spubkey"],
"page-flags" => ["user", "page-flags"], "page-flags" => ["user", "page-flags"],