+ // check if logged in user is either the author or owner of this item
+
+ if(($_SESSION['visitor_id'] == $item['contact-id']) || ($_SESSION['uid'] == $item['uid'])) {
+
+ // delete the item
+
+ $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc(datetime_convert()),
+ intval($item['id'])
+ );
+
+ // 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'])) {
+ $q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ",
+ dbesc($item['resource-id']),
+ intval($item['uid'])
+ );
+ // ignore the result
+ }
+
+ // If it's the parent of a comment thread, kill all the kids
+
+ if($item['uri'] == $item['parent-uri']) {
+ $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s'
+ WHERE `parent-uri` = '%s' AND `uid` = %d ",
+ dbesc(datetime_convert()),
+ dbesc($item['parent-uri']),
+ intval($item['uid'])
+ );
+ // ignore the result
+ }
+
+ $url = $a->get_baseurl();
+ $drop_id = intval($item['id']);
+
+ // send the notification upstream/downstream as the case may be
+
+ proc_close(proc_open("php include/notifier.php \"$url\" \"drop\" \"$drop_id\" > notify.log &",
+ array(),$foo));
+
+ goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ return; //NOTREACHED
+ }
+ else {
+ notice("Permission denied." . EOL);
+ goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ return; //NOTREACHED
+ }
+ }