delete.php 560 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Delete discussion reply
  4. */
  5. $guid = (int) get_input('guid');
  6. $reply = get_entity($guid);
  7. if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply')) {
  8. register_error(elgg_echo('discussion:reply:error:notdeleted'));
  9. forward(REFERER);
  10. }
  11. if (!$reply->canEdit()) {
  12. register_error(elgg_echo('discussion:error:permissions'));
  13. forward(REFERER);
  14. }
  15. if ($reply->delete()) {
  16. system_message(elgg_echo('discussion:reply:deleted'));
  17. } else {
  18. register_error(elgg_echo('discussion:reply:error:notdeleted'));
  19. }
  20. forward(REFERER);