aboutsummaryrefslogtreecommitdiff
path: root/mod/file/actions/delete.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/file/actions/delete.php')
-rw-r--r--mod/file/actions/delete.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/mod/file/actions/delete.php b/mod/file/actions/delete.php
new file mode 100644
index 000000000..ee6dab91e
--- /dev/null
+++ b/mod/file/actions/delete.php
@@ -0,0 +1,68 @@
+<?php
+
+ /**
+ * Elgg file delete
+ *
+ * @package ElggFile
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
+
+ $guid = (int) get_input('file');
+ if ($file = get_entity($guid)) {
+
+ if ($file->canEdit()) {
+
+ $container = get_entity($file->container_guid);
+
+ $thumbnail = $file->thumbnail;
+ $smallthumb = $file->smallthumb;
+ $largethumb = $file->largethumb;
+ if ($thumbnail) {
+
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $file->owner_guid;
+ $delfile->setFilename($thumbnail);
+ $delfile->delete();
+
+ }
+ if ($smallthumb) {
+
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $file->owner_guid;
+ $delfile->setFilename($smallthumb);
+ $delfile->delete();
+
+ }
+ if ($largethumb) {
+
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $file->owner_guid;
+ $delfile->setFilename($largethumb);
+ $delfile->delete();
+
+ }
+
+ if (!$file->delete()) {
+ register_error(elgg_echo("file:deletefailed"));
+ } else {
+ system_message(elgg_echo("file:deleted"));
+ }
+
+ } else {
+
+ $container = $_SESSION['user'];
+ register_error(elgg_echo("file:deletefailed"));
+
+ }
+
+ } else {
+
+ register_error(elgg_echo("file:deletefailed"));
+
+ }
+
+ forward("pg/file/" . $_SESSION['user']->username);
+
+?> \ No newline at end of file