diff options
Diffstat (limited to 'mod/lightpics/actions/photos/delete.php')
-rw-r--r-- | mod/lightpics/actions/photos/delete.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mod/lightpics/actions/photos/delete.php b/mod/lightpics/actions/photos/delete.php new file mode 100644 index 000000000..f8d194e55 --- /dev/null +++ b/mod/lightpics/actions/photos/delete.php @@ -0,0 +1,48 @@ +<?php +/** + * Delete album or image + * + * @author Cash Costello + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2 + */ + +$guid = (int) get_input('guid'); +$entity = get_entity($guid); +if (!$entity) { + // unable to get Elgg entity + register_error(elgg_echo("tidypics:deletefailed")); + forward(REFERER); +} + +if (!$entity->canEdit()) { + // user doesn't have permissions + register_error(elgg_echo("tidypics:deletefailed")); + forward(REFERER); +} + +$container = $entity->getContainerEntity(); + +$subtype = $entity->getSubtype(); +switch ($subtype) { + case 'album': + if (elgg_instanceof($container, 'user')) { + $forward_url = "photos/owner/$container->username"; + } else { + $forward_url = "photos/group/$container->guid/all"; + } + break; + case 'image': + $forward_url = $container->getURL(); + break; + default: + forward(REFERER); + break; +} + +if ($entity->delete()) { + system_message(elgg_echo("tidypics:deleted")); +} else { + register_error(elgg_echo("tidypics:deletefailed")); +} + +forward($forward_url); |