- $item = q(
- "SELECT `uid`, `title`, `body`, `guid`, `contact-id`, `private`, `created`, `app`, `location`, `coord`
- FROM `item` WHERE `wall` AND NOT `private` AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
- dbesc($guid),
- NETWORK_DFRN,
- NETWORK_DIASPORA
- );
- if (!$item) {
- $r = q(
- "SELECT `author-link`
- FROM `item` WHERE `uid` = 0 AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
- dbesc($guid),
- NETWORK_DFRN,
- NETWORK_DIASPORA
- );
-
- if ($r) {
- $parts = parse_url($r[0]["author-link"]);
+ $fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network'];
+ $condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
+ $item = Item::selectFirst($fields, $condition);
+ if (!DBM::is_result($item)) {
+ $condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
+ $item = Item::selectFirst(['author-link'], $condition);
+ if (DBM::is_result($item)) {
+ $parts = parse_url($item["author-link"]);