+ if ($global) {
+ logger("Start global query", LOGGER_DEBUG);
+ $r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND NOT `hide` AND `network` IN ('%s', '%s', '%s') AND `updated` > `last_failure`
+ ORDER BY `updated` DESC LIMIT %d, %d",
+ dbesc($update_limit),
+ dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_DIASPORA),
+ dbesc(NETWORK_OSTATUS),
+ intval($startIndex),
+ intval($itemsPerPage)
+ );
+ } elseif($system_mode) {
+ logger("Start system mode query", LOGGER_DEBUG);
+ $r = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`, `profile`.`gender` AS `pgender`,
+ `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`
+ FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
+ WHERE `self` = 1 AND `profile`.`is-default`
+ AND `contact`.`uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d",
+ intval($startIndex),
+ intval($itemsPerPage)
+ );
+ } else {
+ logger("Start query for user ".$user['nickname'], LOGGER_DEBUG);
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
+ AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`)
+ AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra LIMIT %d, %d",
+ intval($user['uid']),
+ dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_DIASPORA),
+ dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_STATUSNET),
+ intval($startIndex),
+ intval($itemsPerPage)
+ );
+ }
+ logger("Query done", LOGGER_DEBUG);