]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge remote-tracking branch 'upstream/develop' into update-self
[friendica.git] / src / Model / Contact.php
index f8c80579f6d229f5bdd394084488499c288a6912..9330683daf8601a3f793eb0e04f51c34e17300da 100644 (file)
@@ -1582,4 +1582,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;
+       }
 }