- $config = DI::config();
-
- $diaspora = $config->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::DFRN;
- $ostatus = !$config->get('system', 'ostatus_disabled') ? Protocol::OSTATUS : Protocol::DFRN;
-
- $wildcard = Strings::escapeHtml('%' . $search . '%');
-
- $count = DBA::count('gcontact', [
- 'NOT `hide`
- AND `network` IN (?, ?, ?, ?)
- AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`))
- AND (`url` LIKE ? OR `name` LIKE ? OR `location` LIKE ?
- OR `addr` LIKE ? OR `about` LIKE ? OR `keywords` LIKE ?)
- AND `community` = ?',
- Protocol::ACTIVITYPUB, Protocol::DFRN, $ostatus, $diaspora,
- $wildcard, $wildcard, $wildcard,
- $wildcard, $wildcard, $wildcard,
- ($type === self::TYPE_FORUM),
- ]);
-
- $resultList = new ResultList($start, $itemPage, $count);
-
- if (empty($count)) {
- return $resultList;
- }
-
- $data = DBA::select('gcontact', ['nurl'], [
- 'NOT `hide`
- AND `network` IN (?, ?, ?, ?)
- AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`))
- AND (`url` LIKE ? OR `name` LIKE ? OR `location` LIKE ?
- OR `addr` LIKE ? OR `about` LIKE ? OR `keywords` LIKE ?)
- AND `community` = ?',
- Protocol::ACTIVITYPUB, Protocol::DFRN, $ostatus, $diaspora,
- $wildcard, $wildcard, $wildcard,
- $wildcard, $wildcard, $wildcard,
- ($type === self::TYPE_FORUM),
- ], [
- 'group_by' => ['nurl', 'updated'],
- 'limit' => [$start, $itemPage],
- 'order' => ['updated' => 'DESC']
- ]);
-
- if (!DBA::isResult($data)) {
- return $resultList;
- }