- $r = q("SELECT `id`, `parent`, `parent-uri`, `author-link` FROM `item` WHERE `guid` = '%s' AND `uid` = %d AND NOT `file` LIKE '%%[%%' LIMIT 1",
- dbesc($target_guid),
- intval($importer["uid"])
- );
- if (!$r) {
- logger("Target guid ".$target_guid." was not found for user ".$importer["uid"]);
+ // Fetch items that are about to be deleted
+ $fields = array('uid', 'id', 'parent', 'parent-uri', 'author-link');
+
+ // When we receive a public retraction, we delete every item that we find.
+ if ($importer['uid'] == 0) {
+ $condition = array("`guid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid);
+ } else {
+ $condition = array("`guid` = ? AND `uid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid, $importer['uid']);
+ }
+ $r = dba::select('item', $fields, $condition);
+ if (!dbm::is_result($r)) {
+ logger("Target guid ".$target_guid." was not found on this system for user ".$importer['uid'].".");