- if ($global) {
- Logger::log("Start global query", Logger::DEBUG);
- $contacts = 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",
- DBA::escape($update_limit),
- DBA::escape(Protocol::DFRN),
- DBA::escape(Protocol::DIASPORA),
- DBA::escape(Protocol::OSTATUS),
- intval($startIndex),
- intval($itemsPerPage)
- );
- } elseif ($system_mode) {
- Logger::log("Start system mode query", Logger::DEBUG);
- $contacts = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`,
- `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`,
- `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type`
- FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
- INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
- WHERE `self` = 1 AND `profile`.`net-publish`
- LIMIT %d, %d",
- intval($startIndex),
- intval($itemsPerPage)
- );
- } else {
- Logger::log("Start query for user " . $user['nickname'], Logger::DEBUG);
- $contacts = 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']),
- DBA::escape(Protocol::DFRN),
- DBA::escape(Protocol::DIASPORA),
- DBA::escape(Protocol::OSTATUS),
- DBA::escape(Protocol::STATUSNET),
- intval($startIndex),
- intval($itemsPerPage)
- );
- }
- Logger::log("Query done", Logger::DEBUG);