]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Profile.php
improve Profile model
[friendica.git] / src / Model / Profile.php
index 10bd3a1d7542843aaad239c512c4e892bba45b80..1437068f92c7068002c0012c8f1eaeb292b52487 100644 (file)
@@ -45,6 +45,25 @@ class Profile
                return $profile;
        }
 
+       /**
+        * @brief Returns the profile based on a ID
+        *
+        * @param int $uid The User ID
+        * @param int $id The id of the profile (optional)
+        * @param array $fields The fields to retrieve
+        *
+        * @return array Array of profile data
+        * @throws \Exception
+        */
+       public static function select(int $uid, int $id = null, array $fields = [])
+       {
+               if (empty($id)) {
+                       return DBA::selectToArray('profile', $fields, ['uid' => $uid]);
+               } else {
+                       return DBA::selectFirst('profile', $fields, ['uid' => $uid, 'id' => $id]);
+               }
+       }
+
        /**
         * @brief Returns a formatted location string from the given profile array
         *
@@ -717,7 +736,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');