- $r = q("SELECT COUNT(*) AS `total` FROM `contact`
- WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
- AND NOT `hidden` AND NOT `archive`
- AND `network` IN ('%s', '%s', '%s')",
- intval($a->profile['uid']),
- dbesc(NETWORK_DFRN),
- dbesc(NETWORK_DIASPORA),
- dbesc(NETWORK_OSTATUS)
- );
- if (DBM::is_result($r))
- $a->set_pager_total($r[0]['total']);
-
- $r = q("SELECT * FROM `contact`
- WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
- AND NOT `hidden` AND NOT `archive`
- AND `network` IN ('%s', '%s', '%s')
- ORDER BY `name` ASC LIMIT %d, %d",
- intval($a->profile['uid']),
- dbesc(NETWORK_DFRN),
- dbesc(NETWORK_DIASPORA),
- dbesc(NETWORK_OSTATUS),
- intval($a->pager['start']),
- intval($a->pager['itemspage'])
- );
- if (!DBM::is_result($r)) {
- info(t('No contacts.').EOL);
+ $condition = [
+ 'uid' => $a->profile['uid'],
+ 'blocked' => false,
+ 'pending' => false,
+ 'hidden' => false,
+ 'archive' => false,
+ 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]
+ ];
+
+ $total = DBA::count('count', $condition);
+
+ $pager = new Pager($a->query_string);
+
+ $params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
+
+ $contacts_stmt = DBA::select('contact', [], $condition, $params);
+
+ if (!DBA::isResult($contacts_stmt)) {
+ info(L10n::t('No contacts.') . EOL);