aboutsummaryrefslogtreecommitdiff
path: root/actions/photos/delete.php
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-11-19 23:13:26 -0500
committercash <cash.costello@gmail.com>2011-11-19 23:13:26 -0500
commitc51b483f24936c8d04a54a6999412937ec21c49a (patch)
treed45e3b9ede0115e3ce3b84ea1622bfc98d7470a0 /actions/photos/delete.php
parent98664daa72a390fe760b69116af8bfa9327826e3 (diff)
downloadelgg-c51b483f24936c8d04a54a6999412937ec21c49a.tar.gz
elgg-c51b483f24936c8d04a54a6999412937ec21c49a.tar.bz2
uploading photos through the basic interface works now
Diffstat (limited to 'actions/photos/delete.php')
-rw-r--r--actions/photos/delete.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/actions/photos/delete.php b/actions/photos/delete.php
new file mode 100644
index 000000000..f8d194e55
--- /dev/null
+++ b/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);