delete.php 856 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * delete a site announcement
  4. */
  5. site_announcements_editor_gatekeeper();
  6. $guid = (int) get_input("guid");
  7. if (!empty($guid)) {
  8. $entity = get_entity($guid);
  9. if (!empty($entity) && $entity->canEdit()) {
  10. if (elgg_instanceof($entity, "object", SITE_ANNOUNCEMENT_SUBTYPE)) {
  11. $title = elgg_get_excerpt($entity->description, 50);
  12. if ($entity->delete()) {
  13. system_message(elgg_echo("entity:delete:success", array($title)));
  14. } else {
  15. register_error(elgg_echo("entity:delete:fail", array($title)));
  16. }
  17. } else {
  18. register_error(elgg_echo("ClassException:ClassnameNotClass", array($guid, elgg_echo("item:object:site_announcement"))));
  19. }
  20. } else {
  21. register_error(elgg_echo("InvalidParameterException:NoEntityFound"));
  22. }
  23. } else {
  24. register_error(elgg_echo("InvalidParameterException:MissingParameter"));
  25. }
  26. forward(REFERER);