delete.php 625 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Delete topic action
  4. *
  5. */
  6. $topic_guid = (int) get_input('guid');
  7. $topic = get_entity($topic_guid);
  8. if (!elgg_instanceof($topic, 'object', 'groupforumtopic')) {
  9. register_error(elgg_echo('discussion:error:notdeleted'));
  10. forward(REFERER);
  11. }
  12. if (!$topic->canEdit()) {
  13. register_error(elgg_echo('discussion:error:permissions'));
  14. forward(REFERER);
  15. }
  16. $container = $topic->getContainerEntity();
  17. $result = $topic->delete();
  18. if ($result) {
  19. system_message(elgg_echo('discussion:topic:deleted'));
  20. } else {
  21. register_error(elgg_echo('discussion:error:notdeleted'));
  22. }
  23. forward("discussion/owner/$container->guid");