- $r = dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
- 'edited' => datetime_convert(), 'changed' => datetime_convert()),
- array('id' => $item['id']));
-
- create_tags_from_item($item['id']);
- create_files_from_item($item['id']);
- delete_thread($item['id'], $item['parent-uri']);
-
- // clean up categories and tags so they don't end up as orphans
-
- $matches = false;
- $cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
- file_tag_unsave_file($item['uid'], $item['id'], $mtch[1],true);
- }
- }
-
- $matches = false;
-
- $cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
- file_tag_unsave_file($item['uid'], $item['id'], $mtch[1],false);
- }
- }
-
- /*
- * If item is a link to a photo resource, nuke all the associated photos
- * (visitors will not have photo resources)
- * This only applies to photos uploaded from the photos page. Photos inserted into a post do not
- * generate a resource-id and therefore aren't intimately linked to the item.
- */
- if (strlen($item['resource-id'])) {
- dba::delete('photo', array('resource-id' => $item['resource-id'], 'uid' => $item['uid']));
- }
-
- // If item is a link to an event, nuke the event record.
- if (intval($item['event-id'])) {
- dba::delete('event', array('id' => $item['event-id'], 'uid' => $item['uid']));
- }
-
- // If item has attachments, drop them
- foreach (explode(", ", $item['attach']) as $attach) {
- preg_match("|attach/(\d+)|", $attach, $matches);
- dba::delete('attach', array('id' => $matches[1], 'uid' => $item['uid']));
- }
-
- // The new code splits the queries since the mysql optimizer really has bad problems with subqueries