delete.php 866 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Action for deleting a wire post
  4. *
  5. */
  6. // Get input data
  7. $guid = (int) get_input('guid');
  8. // Make sure we actually have permission to edit
  9. $thewire = get_entity($guid);
  10. if ($thewire->getSubtype() == "thewire" && $thewire->canEdit()) {
  11. // unset reply metadata on children
  12. $children = elgg_get_entities_from_relationship(array(
  13. 'relationship' => 'parent',
  14. 'relationship_guid' => $post_guid,
  15. 'inverse_relationship' => true,
  16. ));
  17. if ($children) {
  18. foreach ($children as $child) {
  19. $child->reply = false;
  20. }
  21. }
  22. // Get owning user
  23. $owner = get_entity($thewire->getOwnerGUID());
  24. // Delete it
  25. $rowsaffected = $thewire->delete();
  26. if ($rowsaffected > 0) {
  27. // Success message
  28. system_message(elgg_echo("thewire:deleted"));
  29. } else {
  30. register_error(elgg_echo("thewire:notdeleted"));
  31. }
  32. forward("thewire/owner/" . $owner->username);
  33. }