]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Profile.php
Merge pull request #5794 from annando/ap1
[friendica.git] / src / Model / Profile.php
index f6e116fa79867b94a9cbb58d5bc0541446898155..cb2754cc80ce6a8ef218421ec7952ccb00327fed 100644 (file)
@@ -28,6 +28,19 @@ require_once 'include/dba.php';
 
 class Profile
 {
+       /**
+        * @brief Returns default profile for a given user id
+        *
+        * @param integer User ID
+        *
+        * @return array Profile data
+        */
+       public static function getByUID($uid)
+       {
+               $profile = DBA::selectFirst('profile', [], ['uid' => $uid, 'is-default' => true]);
+               return $profile;
+       }
+
        /**
         * @brief Returns a formatted location string from the given profile array
         *
@@ -361,7 +374,7 @@ class Profile
                        if ($r) {
                                $remote_url = $r[0]['url'];
                                $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url);
-                               $wallmessage_link = $message_path . base64_encode($profile['addr']);
+                               $wallmessage_link = $message_path . base64_encode(defaults($profile, 'addr', ''));
                        } else if (!empty($profile['nickname'])) {
                                $wallmessage_link = 'wallmessage/' . $profile['nickname'];
                        }
@@ -492,7 +505,7 @@ class Profile
 
                if (isset($p['address'])) {
                        $p['address'] = BBCode::convert($p['address']);
-               } else {
+               } elseif (isset($p['location'])) {
                        $p['address'] = BBCode::convert($p['location']);
                }