delete_image.php 787 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Deletion of a Tidypics image by GUID provided (if image entry does not get properly displayed on site and delete button can not be reached)
  4. *
  5. * iionly@gmx.de
  6. */
  7. $guid = (int) get_input('guid');
  8. $entity = get_entity($guid);
  9. if (!$entity) {
  10. // unable to get Elgg entity
  11. register_error(elgg_echo('tidypics:delete_image:no_guid'));
  12. forward(REFERER);
  13. }
  14. $subtype = $entity->getSubtype();
  15. switch ($subtype) {
  16. case 'image':
  17. if ($entity->delete()) {
  18. system_message(elgg_echo('tidypics:delete_image:success'));
  19. } else {
  20. register_error(elgg_echo('tidypics:deletefailed'));
  21. }
  22. break;
  23. default:
  24. register_error(elgg_echo('tidypics:delete_image:no_image'));
  25. break;
  26. }
  27. forward(REFERER);