]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge pull request #7000 from MrPetovan/task/6999-no-probe-magic-link
[friendica.git] / src / Model / Contact.php
index 24c2bf878c82e326fb288a17dba393cb2a6de4cd..f4c62fea809d554e220e180b292a9e1004f9268f 100644 (file)
@@ -110,6 +110,20 @@ class Contact extends BaseObject
         * @}
         */
 
+       /**
+        * @param array $fields    Array of selected fields, empty for all
+        * @param array $condition Array of fields for condition
+        * @param array $params    Array of several parameters
+        * @return array
+        * @throws \Exception
+        */
+       public static function select(array $fields = [], array $condition = [], array $params = [])
+       {
+               $statement = DBA::select('contact', $fields, $condition, $params);
+
+               return DBA::toArray($statement);
+       }
+
        /**
         * @param  integer       $id
         * @return array|boolean Contact record if it exists, false otherwise
@@ -223,6 +237,28 @@ class Contact extends BaseObject
                return ['public' => $pcid, 'user' => $ucid];
        }
 
+       /**
+        * Returns contact details for a given contact id in combination with a user id
+        *
+        * @param int $cid A contact ID
+        * @param int $uid The User ID
+        * @param array $fields The selected fields for the contact
+        *
+        * @return array The contact details
+        *
+        * @throws \Exception
+        */
+       public static function getContactForUser($cid, $uid, array $fields = [])
+       {
+               $contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => $uid]);
+
+               if (!DBA::isResult($contact)) {
+                       return [];
+               } else {
+                       return $contact;
+               }
+       }
+
        /**
         * @brief Block contact id for user id
         *