- $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND
- (`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR
- `about` REGEXP '%s' OR `keywords` REGEXP '%s')".$extra_sql,
- dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA),
+ if (get_config('system','diaspora_enabled'))
+ $diaspora = NETWORK_DIASPORA;
+ else
+ $diaspora = NETWORK_DFRN;
+
+ if (!get_config('system','ostatus_disabled'))
+ $ostatus = NETWORK_OSTATUS;
+ else
+ $ostatus = NETWORK_DFRN;
+
+ $count = q("SELECT count(*) AS `total` FROM `gcontact`
+ LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
+ AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
+ AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
+ WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
+ ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
+ (`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR
+ `gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') $extra_sql",
+ intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
+ dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),