]> git.mxchange.org Git - friendica.git/commitdiff
Some more places with owner-view
authorMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 13:41:11 +0000 (13:41 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 13:41:11 +0000 (13:41 +0000)
mod/poco.php
src/Protocol/DFRN.php
static/dbview.config.php

index edbe73dceaffe825ceb1bc345f425764e71d8c8d..ef77c9c99257181c03c28af696b7a78ba0627333 100644 (file)
@@ -144,16 +144,7 @@ function poco_init(App $a) {
                );
        } elseif ($system_mode) {
                Logger::log("Start system mode query", Logger::DEBUG);
-               $contacts = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`,
-                               `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)
-               );
+               $contacts = DBA::selectToArray('owner-view', [], ['net-publish' => true], ['limit' => [$startIndex, $itemsPerPage]]);
        } else {
                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
@@ -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'])) {
                                        $contact['keywords'] = $contact['pub_keywords'];
                                }
@@ -343,21 +312,21 @@ function poco_init(App $a) {
                                        $entry['address'] = [];
 
                                        // Deactivated. It just reveals too much data. (Although its from the default profile)
-                                       //if (isset($rr['paddress']))
-                                       //       $entry['address']['streetAddress'] = $rr['paddress'];
+                                       //if (isset($rr['address']))
+                                       //       $entry['address']['streetAddress'] = $rr['address'];
 
-                                       if (isset($contact['plocation'])) {
-                                               $entry['address']['locality'] = $contact['plocation'];
+                                       if (isset($contact['locality'])) {
+                                               $entry['address']['locality'] = $contact['locality'];
                                        }
-                                       if (isset($contact['pregion'])) {
-                                               $entry['address']['region'] = $contact['pregion'];
+                                       if (isset($contact['region'])) {
+                                               $entry['address']['region'] = $contact['region'];
                                        }
                                        // See above
-                                       //if (isset($rr['ppostalcode']))
-                                       //       $entry['address']['postalCode'] = $rr['ppostalcode'];
+                                       //if (isset($rr['postal-code']))
+                                       //       $entry['address']['postalCode'] = $rr['postal-code'];
 
-                                       if (isset($contact['pcountry'])) {
-                                               $entry['address']['country'] = $contact['pcountry'];
+                                       if (isset($contact['country'])) {
+                                               $entry['address']['country'] = $contact['country'];
                                        }
                                }
 
index 83010f811e073901851b8ddd8af7c42db7b71cdc..f65a202f4818b8967b226346df7837503d0b1a11 100644 (file)
@@ -183,19 +183,12 @@ class DFRN
 
                $sql_extra = sprintf(" AND `item`.`private` != %s ", Item::PRIVATE);
 
-               $r = q(
-                       "SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`, `user`.`account-type`
-                       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)) {
+               $owner = DBA::selectFirst('owner-view', [], ['nickname' => $owner_nick]);
+               if (!DBA::isResult($owner)) {
                        Logger::log(sprintf('No contact found for nickname=%d', $owner_nick), Logger::WARNING);
                        exit();
                }
 
-               $owner = $r[0];
                $owner_id = $owner['uid'];
 
                $sql_post_table = "";
@@ -684,18 +677,10 @@ class DFRN
                }
 
                // Only show contact details when we are allowed to
-               $r = q(
-                       "SELECT `profile`.`about`, `profile`.`name`, `profile`.`homepage`, `user`.`nickname`,
-                               `user`.`timezone`, `profile`.`locality`, `profile`.`region`, `profile`.`country-name`,
-                               `profile`.`pub_keywords`, `profile`.`xmpp`, `profile`.`dob`
-                       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];
-
+               $profile = DBA::selectFirst('owner-view',
+                       ['about', 'name', 'homepage', 'nickname', 'timezone', 'locality', 'region', 'country-name', 'pub_keywords', 'xmpp', 'dob'],
+                       ['uid' => $owner['uid'], 'hidewall' => false]);
+               if (DBA::isResult($profile)) {
                        XML::addElement($doc, $author, "poco:displayName", $profile["name"]);
                        XML::addElement($doc, $author, "poco:updated", $namdate);
 
index 06f7d3aa95da4d9fa329aa685e5c763efeef8dc1..4363c788666284067d9457f39189d81e9d5a3fef 100755 (executable)
@@ -133,11 +133,15 @@ return [
                        "notify_new_posts" => ["notify_new_posts"],
                        "fetch_further_information" => ["fetch_further_information"],
                        "ffi_keyword_blacklist" => ["ffi_keyword_blacklist"],
+                       "guid" => ["user", "guid"],
+                       "theme" => ["user", "theme"],
+                       "language" => ["user", "language"],
                        "email" => ["user", "email"],
                        "uprvkey" => ["user", "prvkey"],
                        "upubkey" => ["user", "pubkey"],
                        "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"],
                        "spubkey" => ["user", "spubkey"],
                        "page-flags" => ["user", "page-flags"],