- if ($entrytype == DFRN_TOP_LEVEL) {
- $r = q(
- "UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
- `body` = '', `title` = ''
- WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
- dbesc($when),
- dbesc(datetime_convert()),
- dbesc($uri),
- intval($importer["uid"])
- );
- create_tags_from_itemuri($uri, $importer["uid"]);
- Term::createFromItemURI($uri, $importer["uid"]);
- update_thread_uri($uri, $importer["uid"]);
- } else {
- $r = q(
- "UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
- `body` = '', `title` = ''
- WHERE `uri` = '%s' AND `uid` IN (0, %d)",
- dbesc($when),
- dbesc(datetime_convert()),
- dbesc($uri),
- intval($importer["uid"])
- );
- create_tags_from_itemuri($uri, $importer["uid"]);
- Term::createFromItemURI($uri, $importer["uid"]);
- update_thread_uri($uri, $importer["importer_uid"]);
- if ($item["last-child"]) {
- // ensure that last-child is set in case the comment that had it just got wiped.
- q(
- "UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
- dbesc(datetime_convert()),
- dbesc($item["parent-uri"]),
- intval($item["uid"])
- );
- // who is the last child now?
- $r = q(
- "SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `moderated` = 0 AND `uid` = %d
- ORDER BY `created` DESC LIMIT 1",
- dbesc($item["parent-uri"]),
- intval($importer["uid"])
- );
- if (DBM::is_result($r)) {
- q(
- "UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
- intval($r[0]["id"])
- );
- }
- }
- // if this is a relayed delete, propagate it to other recipients