]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge branch 'master' into develop
[friendica.git] / src / Model / Contact.php
index f0a1e529293c3de32318d90ffd29a6be925e54ce..b5fef04b3178874d0ecc6da03a91fb9615fb2302 100644 (file)
@@ -1518,4 +1518,29 @@ class Contact extends BaseObject
                        }
                }
        }
+
+       /**
+        * Remove the unavailable contact ids from the provided list
+        *
+        * @param array $contact_ids Contact id list
+        */
+       public static function pruneUnavailable(array &$contact_ids)
+       {
+               if (empty($contact_ids)) {
+                       return;
+               }
+
+               $str = dbesc(implode(',', $contact_ids));
+
+               $stmt = dba::p("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
+
+               $return = [];
+               while($contact = dba::fetch($stmt)) {
+                       $return[] = $contact['id'];
+               }
+
+               dba::close($stmt);
+
+               $contact_ids = $return;
+       }
 }