+
+function match_get_contacts($msearch, $entries, $limit)
+{
+ if (empty($msearch->results)) {
+ return $entries;
+ }
+
+ foreach ($msearch->results as $profile) {
+ if (!$profile) {
+ continue;
+ }
+
+ // Already known contact
+ $contact = Contact::getByURL($profile->url, null, ['rel'], local_user());
+ if (!empty($contact) && in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
+ continue;
+ }
+
+ $contact = Contact::getByURLForUser($profile->url, local_user());
+ if (!empty($contact)) {
+ $entries[$contact['id']] = ModuleContact::getContactTemplateVars($contact);
+ }
+
+ if (count($entries) == $limit) {
+ break;
+ }
+ }
+ return $entries;
+}
\ No newline at end of file