]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Profile.php
Added post update to remove duplicated contacts
[friendica.git] / src / Model / Profile.php
index 868cc6b70a7f12e9e4a46c6b2a258d431a53b8ed..9ea22a65ee82af4e437d66e41e184a1e90ed803a 100644 (file)
@@ -45,6 +45,35 @@ class Profile
                return $profile;
        }
 
+       /**
+        * @brief Returns default profile for a given user ID and ID
+        *
+        * @param int $uid The contact ID
+        * @param int $id The contact owner ID
+        * @param array $fields The selected fields
+        *
+        * @return array Profile data for the ID
+        * @throws \Exception
+        */
+       public static function getById(int $uid, int $id, array $fields = [])
+       {
+               return DBA::selectFirst('profile', $fields, ['uid' => $uid, 'id' => $id]);
+       }
+
+       /**
+        * @brief Returns profile data for the contact owner
+        *
+        * @param int $uid The User ID
+        * @param array $fields The fields to retrieve
+        *
+        * @return array Array of profile data
+        * @throws \Exception
+        */
+       public static function getListByUser(int $uid, array $fields = [])
+       {
+               return DBA::selectToArray('profile', $fields, ['uid' => $uid]);
+       }
+
        /**
         * @brief Returns a formatted location string from the given profile array
         *
@@ -343,7 +372,7 @@ class Profile
                        || in_array($profile_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
                $visitor_base_path = self::getMyURL() ? preg_replace('=/profile/(.*)=ism', '', self::getMyURL()) : '';
 
-               if (!$local_user_is_self) {
+               if (!$local_user_is_self && $show_connect) {
                        if (!$visitor_is_authenticated) {
                                $follow_link = 'dfrn_request/' . $profile['nickname'];
                        } elseif ($profile_is_native) {
@@ -471,7 +500,7 @@ class Profile
                                        'pending' => false,
                                        'hidden' => false,
                                        'archive' => false,
-                                       'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA],
+                                       'network' => Protocol::FEDERATED,
                                ]);
                        }
                }
@@ -494,6 +523,14 @@ class Profile
                        $p['address'] = BBCode::convert($p['address']);
                }
 
+               if (isset($p['gender'])) {
+                       $p['gender'] = L10n::t($p['gender']);
+               }
+
+               if (isset($p['marital'])) {
+                       $p['marital'] = L10n::t($p['marital']);
+               }
+
                if (isset($p['photo'])) {
                        $p['photo'] = ProxyUtils::proxifyUrl($p['photo'], false, ProxyUtils::SIZE_SMALL);
                }
@@ -717,7 +754,7 @@ class Profile
 
        public static function getAdvanced(App $a)
        {
-               $uid = $a->profile['uid'];
+               $uid = intval($a->profile['uid']);
 
                if ($a->profile['name']) {
                        $tpl = Renderer::getMarkupTemplate('profile_advanced.tpl');
@@ -1195,29 +1232,6 @@ class Profile
                return $uid;
        }
 
-       /**
-       * Strip zrl parameter from a string.
-       *
-       * @param string $s The input string.
-       * @return string The zrl.
-       */
-       public static function stripZrls($s)
-       {
-               return preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is', '', $s);
-       }
-
-       /**
-        * Strip query parameter from a string.
-        *
-        * @param string $s The input string.
-        * @param        $param
-        * @return string The query parameter.
-        */
-       public static function stripQueryParam($s, $param)
-       {
-               return preg_replace('/[\?&]' . $param . '=(.*?)(&|$)/ism', '$2', $s);
-       }
-
        /**
         * search for Profiles
         *